diff --git a/doc/ale.txt b/doc/ale.txt index 129f073..3f1c743 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 `(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 fd598d4..1d7f77a 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 (ale_previous_wrap) :ALEPreviousWrap nnoremap (ale_next) :ALENext nnoremap (ale_next_wrap) :ALENextWrap nnoremap (ale_toggle) :ALEToggle +nnoremap (ale_lint) :ALELint " Housekeeping diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader new file mode 100644 index 0000000..9e70017 --- /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)