Fix #288 - Add a command for running ALE

This commit is contained in:
w0rp 2017-02-28 09:10:58 +00:00
parent 31d328b272
commit ceeff6c723
3 changed files with 75 additions and 2 deletions

View File

@ -1123,6 +1123,14 @@ Some linters may have requirements for some other plugins being installed.
=============================================================================== ===============================================================================
6. Commands/Keybinds *ale-commands* 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* ALEPrevious *ALEPrevious*
ALEPreviousWrap *ALEPreviousWrap* ALEPreviousWrap *ALEPreviousWrap*
ALENext *ALENext* ALENext *ALENext*
@ -1403,7 +1411,7 @@ ale#statusline#Status() *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 This |User| autocommand is triggered by ALE every time it completes a lint
operation. It can be used to update statuslines, send notifications, or operation. It can be used to update statuslines, send notifications, or
complete any other operation that needs to be done after a lint run. complete any other operation that needs to be done after a lint run.

View File

@ -208,9 +208,12 @@ command! ALEPreviousWrap :call ale#loclist_jumping#Jump('before', 1)
command! ALENext :call ale#loclist_jumping#Jump('after', 0) command! ALENext :call ale#loclist_jumping#Jump('after', 0)
command! ALENextWrap :call ale#loclist_jumping#Jump('after', 1) command! ALENextWrap :call ale#loclist_jumping#Jump('after', 1)
" A command for turning ALE on or off.
command! ALEToggle :call s:ALEToggle() 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() command! ALEInfo :call ale#debugging#Info()
" The same, but copy output to your clipboard. " The same, but copy output to your clipboard.
command! ALEInfoToClipboard :call ale#debugging#InfoToClipboard() 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) :ALENext<Return>
nnoremap <silent> <Plug>(ale_next_wrap) :ALENextWrap<Return> nnoremap <silent> <Plug>(ale_next_wrap) :ALENextWrap<Return>
nnoremap <silent> <Plug>(ale_toggle) :ALEToggle<Return> nnoremap <silent> <Plug>(ale_toggle) :ALEToggle<Return>
nnoremap <silent> <Plug>(ale_lint) :ALELint<Return>
" Housekeeping " Housekeeping

View File

@ -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)