aleinfo global options (#2686)

* added omitted global variables which was breaking this test when run standalone
* invert logic for s:GetLinterVariables excluding disabled linters, so that linter global options can appear in output
* additional tests for s:GetLinterVariables for linter global options
This commit is contained in:
richyfish 2019-08-12 16:29:28 +01:00 committed by w0rp
parent dd1e1025b8
commit 28c93ab185
2 changed files with 117 additions and 3 deletions

View File

@ -62,7 +62,7 @@ function! s:Echo(message) abort
execute 'echo a:message'
endfunction
function! s:GetLinterVariables(filetype, linter_names) abort
function! s:GetLinterVariables(filetype, exclude_linter_names) abort
let l:variable_list = []
let l:filetype_parts = split(a:filetype, '\.')
@ -73,7 +73,7 @@ function! s:GetLinterVariables(filetype, linter_names) abort
" Include matching variables.
if !empty(l:match)
\&& index(l:filetype_parts, l:match[1]) >= 0
\&& index(a:linter_names, l:match[2]) >= 0
\&& index(a:exclude_linter_names, l:match[2]) == -1
call add(l:variable_list, l:key)
endif
endfor
@ -211,10 +211,11 @@ function! ale#debugging#Info() abort
let l:all_names = map(copy(l:all_linters), 'v:val[''name'']')
let l:enabled_names = map(copy(l:enabled_linters), 'v:val[''name'']')
let l:exclude_names = filter(copy(l:all_names), 'index(l:enabled_names, v:val) == -1')
" Load linter variables to display
" This must be done after linters are loaded.
let l:variable_list = s:GetLinterVariables(l:filetype, l:enabled_names)
let l:variable_list = s:GetLinterVariables(l:filetype, l:exclude_names)
let l:fixers = ale#fix#registry#SuggestedFixers(l:filetype)
let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1]))

View File

@ -1,50 +1,112 @@
Before:
Save g:ale_buffer_info
Save g:ale_cache_executable_check_failures
Save g:ale_change_sign_column_color
Save g:ale_command_wrapper
Save g:ale_completion_delay
Save g:ale_completion_enabled
Save g:ale_completion_max_suggestions
Save g:ale_echo_cursor
Save g:ale_echo_msg_error_str
Save g:ale_echo_msg_format
Save g:ale_echo_msg_info_str
Save g:ale_echo_msg_warning_str
Save g:ale_fix_on_save
Save g:ale_fixers
Save g:ale_history_enabled
Save g:ale_history_log_output
Save g:ale_keep_list_window_open
Save g:ale_lint_delay
Save g:ale_lint_on_enter
Save g:ale_lint_on_filetype_changed
Save g:ale_lint_on_insert_leave
Save g:ale_lint_on_save
Save g:ale_lint_on_text_changed
Save g:ale_linters
Save g:ale_linters_explicit
Save g:ale_list_vertical
Save g:ale_list_window_size
Save g:ale_loclist_msg_format
Save g:ale_lsp_error_messages
Save g:ale_lsp_root
Save g:ale_max_buffer_history_size
Save g:ale_max_signs
Save g:ale_maximum_file_size
Save g:ale_open_list
Save g:ale_pattern_options
Save g:ale_pattern_options_enabled
Save g:ale_set_balloons
Save g:ale_set_highlights
Save g:ale_set_loclist
Save g:ale_set_quickfix
Save g:ale_set_signs
Save g:ale_sign_column_always
Save g:ale_sign_error
Save g:ale_sign_info
Save g:ale_sign_offset
Save g:ale_sign_style_error
Save g:ale_sign_style_warning
Save g:ale_sign_warning
Save g:ale_statusline_format
Save g:ale_type_map
Save g:ale_use_global_executables
Save g:ale_virtualtext_cursor
Save g:ale_warn_about_trailing_blank_lines
Save g:ale_warn_about_trailing_whitespace
unlet! b:ale_history
let g:ale_buffer_info = {}
let g:ale_cache_executable_check_failures = 0
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = 50
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_fix_on_save = 0
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_error_messages = {}
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = 0
let g:ale_open_list = 0
let g:ale_pattern_options = {}
let g:ale_pattern_options_enabled = 0
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
@ -164,6 +226,8 @@ After:
unlet! b:ale_testft2_testlinter2_foo
unlet! g:ale_testft2_testlinter2_bar
unlet! g:info_test_file
unlet! g:ale_testft_build_dir_names
unlet! g:ale_testft_testlinter2_option
delfunction CheckInfo
call ale#test#RestoreDirectory()
@ -632,3 +696,52 @@ Execute (LSP errors for other linters shouldn't appear):
\ + g:globals_lines
\ + g:command_header
\)
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should include linter global options):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
" eg: like g:c_build_dir_names
let g:ale_testft_build_dir_names = ['build', 'bin']
call add(g:variables_lines, 'let g:ale_testft_build_dir_names = [''build'', ''bin'']')
call CheckInfo(
\ [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
\ + g:globals_lines
\ + g:command_header
\)
Given testft (Empty buffer with two filetypes):
Execute (ALEInfo should include linter global options for enabled linters):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft', g:testlinter2)
let g:ale_linters = {'testft': ['testlinter1']}
" should not appear, since not enabled
let g:ale_testft_testlinter2_option = 'test'
let g:globals_lines[index(g:globals_lines, 'let g:ale_linters = {}')]
\ = 'let g:ale_linters = {''testft'': [''testlinter1'']}'
call CheckInfo(
\ [
\ ' Current Filetype: testft',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'']',
\ ]
\ + g:fixer_lines
\ + g:variables_lines
\ + g:globals_lines
\ + g:command_header
\)