From 6853d2c304e5eae22393208f91b0d072d2f22d74 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 27 Apr 2017 00:07:41 +0100 Subject: [PATCH] #427 - Output buffer-local variables with :ALEInfo --- autoload/ale/debugging.vim | 8 ++++++++ test/test_ale_info.vader | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim index 60c1b37..f42c9e8 100644 --- a/autoload/ale/debugging.vim +++ b/autoload/ale/debugging.vim @@ -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 diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader index d5a8ed6..83d32cb 100644 --- a/test/test_ale_info.vader +++ b/test/test_ale_info.vader @@ -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('%')] = {