#427 - Output buffer-local variables with :ALEInfo

This commit is contained in:
w0rp 2017-04-27 00:07:41 +01:00
parent b25dbd6ea5
commit 6853d2c304
2 changed files with 50 additions and 0 deletions

View File

@ -51,12 +51,20 @@ endfunction
function! s:EchoLinterVariables(variable_list) abort
for l:key in a:variable_list
echom 'let g:' . l:key . ' = ' . string(g:[l:key])
if has_key(b:, l:key)
echom 'let b:' . l:key . ' = ' . string(b:[l:key])
endif
endfor
endfunction
function! s:EchoGlobalVariables() abort
for l:key in s:global_variable_list
echom 'let g:' . l:key . ' = ' . string(get(g:, l:key, v:null))
if has_key(b:, l:key)
echom 'let b:' . l:key . ' = ' . string(b:[l:key])
endif
endfor
endfunction

View File

@ -37,6 +37,7 @@ Before:
let g:command_header = "\n Command History:\n"
After:
unlet! b:ale_linters
unlet! g:output
unlet! g:globals_string
unlet! g:command_header
@ -45,6 +46,7 @@ After:
unlet! g:ale_testft_testlinter1_foo
unlet! g:ale_testft_testlinter1_bar
unlet! g:ale_testft2_testlinter2_foo
unlet! b:ale_testft2_testlinter2_foo
unlet! g:ale_testft2_testlinter2_bar
Given nolintersft (Empty buffer with no linters):
@ -59,6 +61,26 @@ Execute (ALEInfo with no linters should return the right output):
\ Linter Variables:\n
\" . g:globals_string . g:command_header, g:output
Given (Empty buffer with no filetype):
Execute (ALEInfo should return buffer-local global ALE settings):
let b:ale_linters = {'x': ['y']}
let g:globals_string = substitute(
\ g:globals_string,
\ 'let g:ale_linters = {}',
\ "let g:ale_linters = {}\nlet b:ale_linters = {'x': ['y']}",
\ ''
\)
redir => g:output
silent ALEInfo
redir END
AssertEqual "\n
\ Current Filetype: \n
\Available Linters: []\n
\ Enabled Linters: []\n
\ Linter Variables:\n
\" . g:globals_string . g:command_header, g:output
Given (Empty buffer with no filetype):
Execute (ALEInfo with no filetype should return the right output):
redir => g:output
@ -166,6 +188,26 @@ Execute (ALEInfo should return appropriately named global variables):
\let g:ale_testft_testlinter1_foo = 'abc'"
\ . g:globals_string . g:command_header, g:output
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should buffer-local linter variables):
let g:ale_testft2_testlinter2_foo = 123
let b:ale_testft2_testlinter2_foo = 456
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
redir => g:output
silent ALEInfo
redir END
AssertEqual "\n
\ Current Filetype: testft.testft2\n
\Available Linters: ['testlinter1', 'testlinter2']\n
\ Enabled Linters: ['testlinter1', 'testlinter2']\n
\ Linter Variables:\n
\\n
\let g:ale_testft2_testlinter2_foo = 123\n
\let b:ale_testft2_testlinter2_foo = 456"
\ . g:globals_string . g:command_header, g:output
Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should return command history):
let g:ale_buffer_info[bufnr('%')] = {