Skip to content

Commit

Permalink
Close #3003 - Show ignored linters in :ALEInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Sep 8, 2020
1 parent 7d90ff5 commit 6a367e4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
8 changes: 1 addition & 7 deletions autoload/ale.vim
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,7 @@ function! s:Lint(buffer, should_lint_file, timer_id) abort
" Use the filetype from the buffer
let l:filetype = getbufvar(a:buffer, '&filetype')
let l:linters = ale#linter#Get(l:filetype)

" Apply ignore lists for linters only if needed.
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
let l:linters = !empty(l:ignore_config) || l:disable_lsp
\ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config, l:disable_lsp)
\ : l:linters
let l:linters = ale#linter#RemoveIgnored(a:buffer, l:filetype, l:linters)

" Tell other sources that they can start checking the buffer now.
let g:ale_want_results_buffer = a:buffer
Expand Down
13 changes: 13 additions & 0 deletions autoload/ale/debugging.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let s:global_variable_list = [
\ 'ale_completion_delay',
\ 'ale_completion_enabled',
\ 'ale_completion_max_suggestions',
\ 'ale_disable_lsp',
\ 'ale_echo_cursor',
\ 'ale_echo_msg_error_str',
\ 'ale_echo_msg_format',
Expand All @@ -28,6 +29,7 @@ let s:global_variable_list = [
\ 'ale_linter_aliases',
\ 'ale_linters',
\ 'ale_linters_explicit',
\ 'ale_linters_ignore',
\ 'ale_list_vertical',
\ 'ale_list_window_size',
\ 'ale_loclist_msg_format',
Expand Down Expand Up @@ -196,6 +198,7 @@ function! s:EchoLSPErrorMessages(all_linter_names) abort
endfunction

function! ale#debugging#Info() abort
let l:buffer = bufnr('')
let l:filetype = &filetype

" We get the list of enabled linters for free by the above function.
Expand All @@ -222,10 +225,20 @@ function! ale#debugging#Info() abort
let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1]))
let l:fixers_string = join(map(copy(l:fixers), '"\n " . v:val'), '')

let l:non_ignored_names = map(
\ copy(ale#linter#RemoveIgnored(l:buffer, l:filetype, l:enabled_linters)),
\ 'v:val[''name'']',
\)
let l:ignored_names = filter(
\ copy(l:enabled_names),
\ 'index(l:non_ignored_names, v:val) < 0'
\)

call s:Echo(' Current Filetype: ' . l:filetype)
call s:Echo('Available Linters: ' . string(l:all_names))
call s:EchoLinterAliases(l:all_linters)
call s:Echo(' Enabled Linters: ' . string(l:enabled_names))
call s:Echo(' Ignored Linters: ' . string(l:ignored_names))
call s:Echo(' Suggested Fixers: ' . l:fixers_string)
call s:Echo(' Linter Variables:')
call s:Echo('')
Expand Down
10 changes: 10 additions & 0 deletions autoload/ale/linter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ function! ale#linter#Get(original_filetypes) abort
return reverse(l:combined_linters)
endfunction

function! ale#linter#RemoveIgnored(buffer, filetype, linters) abort
" Apply ignore lists for linters only if needed.
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')

return !empty(l:ignore_config) || l:disable_lsp
\ ? ale#engine#ignore#Exclude(a:filetype, a:linters, l:ignore_config, l:disable_lsp)
\ : a:linters
endfunction

" Given a buffer and linter, get the executable String for the linter.
function! ale#linter#GetExecutable(buffer, linter) abort
let l:Executable = a:linter.executable
Expand Down
27 changes: 27 additions & 0 deletions test/test_ale_info.vader
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Before:
Save g:ale_completion_delay
Save g:ale_completion_enabled
Save g:ale_completion_max_suggestions
Save g:ale_disable_lsp
Save g:ale_echo_cursor
Save g:ale_echo_msg_error_str
Save g:ale_echo_msg_format
Expand All @@ -24,6 +25,7 @@ Before:
Save g:ale_lint_on_text_changed
Save g:ale_linters
Save g:ale_linters_explicit
Save g:ale_linters_ignore
Save g:ale_list_vertical
Save g:ale_list_window_size
Save g:ale_loclist_msg_format
Expand Down Expand Up @@ -64,6 +66,7 @@ Before:
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = 50
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
Expand All @@ -80,6 +83,7 @@ Before:
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {'python': ['pyright']}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
Expand Down Expand Up @@ -138,6 +142,7 @@ Before:
\ 'let g:ale_completion_delay = 100',
\ 'let g:ale_completion_enabled = 0',
\ 'let g:ale_completion_max_suggestions = 50',
\ 'let g:ale_disable_lsp = 0',
\ 'let g:ale_echo_cursor = 1',
\ 'let g:ale_echo_msg_error_str = ''Error''',
\ 'let g:ale_echo_msg_format = ''%code: %%s''',
Expand All @@ -158,6 +163,7 @@ Before:
\ 'let g:ale_linter_aliases = {}',
\ 'let g:ale_linters = {}',
\ 'let g:ale_linters_explicit = 0',
\ 'let g:ale_linters_ignore = {''python'': [''pyright'']}',
\ 'let g:ale_list_vertical = 0',
\ 'let g:ale_list_window_size = 10',
\ 'let g:ale_loclist_msg_format = ''%code: %%s''',
Expand Down Expand Up @@ -243,6 +249,7 @@ Execute (ALEInfo with no linters should return the right output):
\ ' Current Filetype: nolintersft',
\ 'Available Linters: []',
\ ' Enabled Linters: []',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -265,6 +272,7 @@ Execute (ALEInfo should return buffer-local global ALE settings):
\ ' Current Filetype: ',
\ 'Available Linters: []',
\ ' Enabled Linters: []',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -279,6 +287,7 @@ Execute (ALEInfo with no filetype should return the right output):
\ ' Current Filetype: ',
\ 'Available Linters: []',
\ ' Enabled Linters: []',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -295,6 +304,7 @@ Execute (ALEInfo with a single linter should return the right output):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -312,6 +322,7 @@ Execute (ALEInfo with two linters should return the right output):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -333,6 +344,7 @@ Execute (ALEInfo should calculate enabled linters correctly):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -350,6 +362,7 @@ Execute (ALEInfo should only return linters for current filetype):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -367,6 +380,7 @@ Execute (ALEInfo with compound filetypes should return linters for both of them)
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -389,6 +403,7 @@ Execute (ALEInfo should return appropriately named global variables):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + [
Expand Down Expand Up @@ -420,6 +435,7 @@ Execute (ALEInfoToFile should write to a file correctly):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + [
Expand Down Expand Up @@ -447,6 +463,7 @@ Execute (ALEInfo should buffer-local linter variables):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + [
Expand Down Expand Up @@ -478,6 +495,7 @@ Execute (ALEInfo should output linter aliases):
\ '''testlinter1'' -> [''testftalias1'', ''testftalias2'']',
\ '''testlinter2'' -> [''testftalias3'', ''testftalias4'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + [
Expand Down Expand Up @@ -505,6 +523,7 @@ Execute (ALEInfo should return command history):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand Down Expand Up @@ -532,6 +551,7 @@ Execute (ALEInfo command history should print exit codes correctly):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand Down Expand Up @@ -580,6 +600,7 @@ Execute (ALEInfo command history should print command output if logging is on):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand Down Expand Up @@ -618,6 +639,7 @@ Execute (ALEInfo should include executable checks in the history):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand Down Expand Up @@ -647,6 +669,7 @@ Execute (The option for caching failing executable checks should work):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -669,6 +692,7 @@ Execute (LSP errors for a linter should be outputted):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -693,6 +717,7 @@ Execute (LSP errors for other linters shouldn't appear):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -715,6 +740,7 @@ Execute (ALEInfo should include linter global options):
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand All @@ -740,6 +766,7 @@ Execute (ALEInfo should include linter global options for enabled linters):
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ' Ignored Linters: []',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
Expand Down

0 comments on commit 6a367e4

Please sign in to comment.