summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ale.txt10
-rw-r--r--plugin/ale.vim6
-rw-r--r--test/test_ale_lint_command.vader61
3 files changed, 75 insertions, 2 deletions
diff --git a/doc/ale.txt b/doc/ale.txt
index 129f0737..3f1c7438 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -1123,6 +1123,14 @@ Some linters may have requirements for some other plugins being installed.
===============================================================================
6. Commands/Keybinds *ale-commands*
+ALELint *ALELint*
+
+ Run ALE once for the current buffer. This command can be used to run ALE
+ manually, instead of automatically, if desired.
+
+ A plug mapping `<Plug>(ale_lint)` is defined for this command.
+
+
ALEPrevious *ALEPrevious*
ALEPreviousWrap *ALEPreviousWrap*
ALENext *ALENext*
@@ -1403,7 +1411,7 @@ ale#statusline#Status() *ale#statusline#Status()*
%{ale#statusline#Status()}
-ALELint *ALELint*
+ALELint *ALELint-autocmd*
This |User| autocommand is triggered by ALE every time it completes a lint
operation. It can be used to update statuslines, send notifications, or
complete any other operation that needs to be done after a lint run.
diff --git a/plugin/ale.vim b/plugin/ale.vim
index fd598d4c..1d7f77a5 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -208,9 +208,12 @@ command! ALEPreviousWrap :call ale#loclist_jumping#Jump('before', 1)
command! ALENext :call ale#loclist_jumping#Jump('after', 0)
command! ALENextWrap :call ale#loclist_jumping#Jump('after', 1)
+" A command for turning ALE on or off.
command! ALEToggle :call s:ALEToggle()
+" A command for linting manually.
+command! ALELint :call ale#Queue(0)
-" Define command to get information about current filetype.
+" Define a command to get information about current filetype.
command! ALEInfo :call ale#debugging#Info()
" The same, but copy output to your clipboard.
command! ALEInfoToClipboard :call ale#debugging#InfoToClipboard()
@@ -221,6 +224,7 @@ nnoremap <silent> <Plug>(ale_previous_wrap) :ALEPreviousWrap<Return>
nnoremap <silent> <Plug>(ale_next) :ALENext<Return>
nnoremap <silent> <Plug>(ale_next_wrap) :ALENextWrap<Return>
nnoremap <silent> <Plug>(ale_toggle) :ALEToggle<Return>
+nnoremap <silent> <Plug>(ale_lint) :ALELint<Return>
" Housekeeping
diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader
new file mode 100644
index 00000000..9e70017c
--- /dev/null
+++ b/test/test_ale_lint_command.vader
@@ -0,0 +1,61 @@
+Before:
+ let g:expected_loclist = [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 2,
+ \ 'vcol': 0,
+ \ 'col': 3,
+ \ 'text': 'foo bar',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}]
+ let g:expected_groups = [
+ \ 'ALECleanupGroup',
+ \ 'ALECursorGroup',
+ \ 'ALEHighlightBufferGroup',
+ \ 'ALERunOnEnterGroup',
+ \ 'ALERunOnTextChangedGroup',
+ \]
+
+ function! ToggleTestCallback(buffer, output)
+ return [{
+ \ 'bufnr': a:buffer,
+ \ 'lnum': 2,
+ \ 'vcol': 0,
+ \ 'col': 3,
+ \ 'text': a:output[0],
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \}]
+ endfunction
+
+ call ale#linter#Define('foobar', {
+ \ 'name': 'testlinter',
+ \ 'callback': 'ToggleTestCallback',
+ \ 'executable': 'echo',
+ \ 'command': 'echo foo bar',
+ \})
+
+After:
+ unlet! g:expected_loclist
+ unlet! g:expected_groups
+
+ let g:ale_buffer_info = {}
+ call ale#linter#Reset()
+
+ delfunction ToggleTestCallback
+
+Given foobar (Some imaginary filetype):
+ foo
+ bar
+ baz
+
+Execute(ALELint should run the linters):
+ AssertEqual 'foobar', &filetype
+
+ ALELint
+ call ale#engine#WaitForJobs(2000)
+
+ " Check the loclist
+ AssertEqual g:expected_loclist, getloclist(0)