Fix #288 - Add a command for running ALE
This commit is contained in:
parent
31d328b272
commit
ceeff6c723
10
doc/ale.txt
10
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.
|
||||
|
@ -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
|
||||
|
||||
|
61
test/test_ale_lint_command.vader
Normal file
61
test/test_ale_lint_command.vader
Normal 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)
|
Loading…
Reference in New Issue
Block a user