diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | ale_linters/cs/mcsc.vim | 2 | ||||
-rw-r--r-- | ale_linters/perl/perl.vim | 14 | ||||
-rw-r--r-- | autoload/ale/debugging.vim | 1 | ||||
-rw-r--r-- | autoload/ale/engine.vim | 26 | ||||
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/php_cs_fixer.vim | 23 | ||||
-rw-r--r-- | autoload/ale/list.vim | 9 | ||||
-rw-r--r-- | autoload/ale/lsp/response.vim | 8 | ||||
-rw-r--r-- | doc/ale-perl.txt | 3 | ||||
-rw-r--r-- | doc/ale-php.txt | 17 | ||||
-rw-r--r-- | doc/ale.txt | 19 | ||||
-rw-r--r-- | plugin/ale.vim | 3 | ||||
-rw-r--r-- | test/command_callback/php_paths/project-with-php-cs-fixer/test.php | 0 | ||||
-rw-r--r-- | test/command_callback/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer | 0 | ||||
-rw-r--r-- | test/command_callback/php_paths/project-without-php-cs-fixer/test.php | 0 | ||||
-rw-r--r-- | test/fixers/test_php_cs_fixer.vader | 46 | ||||
-rw-r--r-- | test/handler/test_mcsc_handler.vader | 11 | ||||
-rw-r--r-- | test/handler/test_perl_handler.vader | 39 | ||||
-rw-r--r-- | test/lsp/test_read_lsp_diagnostics.vader | 35 | ||||
-rw-r--r-- | test/test_ale_info.vader | 1 | ||||
-rw-r--r-- | test/test_list_opening.vader | 51 |
22 files changed, 293 insertions, 25 deletions
@@ -130,7 +130,7 @@ formatting. | Objective-C++ | [clang](http://clang.llvm.org/) | | OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server) | | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) | -| PHP | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/flow/tree/master/hack/hackfmt), [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) | +| PHP | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/flow/tree/master/hack/hackfmt), [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/) | | PO | [alex](https://github.com/wooorm/alex) !!, [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html), [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | | Pod | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | | Pony | [ponyc](https://github.com/ponylang/ponyc) | @@ -577,6 +577,9 @@ let g:ale_open_list = 1 let g:ale_keep_list_window_open = 1 ``` +You can also set `let g:ale_list_vertical = 1` to open the windows vertically +instead of the default horizontally. + <a name="faq-jsx-stylelint-eslint"></a> ### 5.xii. How can I check JSX files with both stylelint and eslint? diff --git a/ale_linters/cs/mcsc.vim b/ale_linters/cs/mcsc.vim index f16e4b4a..8a78d3b3 100644 --- a/ale_linters/cs/mcsc.vim +++ b/ale_linters/cs/mcsc.vim @@ -10,7 +10,7 @@ function! s:GetWorkingDirectory(buffer) abort return l:working_directory endif - return fnamemodify(bufname(a:buffer), ':p:h') + return expand('#' . a:buffer . ':p:h') endfunction function! ale_linters#cs#mcsc#GetCommand(buffer) abort diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index fcc88f35..1b9aa95e 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -27,12 +27,20 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort let l:output = [] let l:basename = expand('#' . a:buffer . ':t') + let l:type = 'E' + if a:lines[-1] =~# 'syntax OK' + let l:type = 'W' + endif + + let l:seen = {} + for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:line = l:match[3] + let l:file = l:match[2] let l:text = l:match[1] - let l:type = 'E' - if ale#path#IsBufferPath(a:buffer, l:match[2]) + if ale#path#IsBufferPath(a:buffer, l:file) + \ && !has_key(l:seen,l:line) \ && ( \ l:text isnot# 'BEGIN failed--compilation aborted' \ || empty(l:output) @@ -43,6 +51,8 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort \ 'text': l:text, \ 'type': l:type, \}) + + let l:seen[l:line] = 1 endif endfor diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim index 9be1fbf6..cb93ec16 100644 --- a/autoload/ale/debugging.vim +++ b/autoload/ale/debugging.vim @@ -29,6 +29,7 @@ let s:global_variable_list = [ \ 'ale_linters', \ 'ale_linters_explicit', \ 'ale_list_window_size', +\ 'ale_list_vertical', \ 'ale_loclist_msg_format', \ 'ale_max_buffer_history_size', \ 'ale_max_signs', diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index a21eecdd..9ef3ba39 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -145,35 +145,39 @@ function! s:GatherOutput(job_id, line) abort endfunction function! s:HandleLoclist(linter_name, buffer, loclist) abort - let l:buffer_info = get(g:ale_buffer_info, a:buffer, {}) + let l:info = get(g:ale_buffer_info, a:buffer, {}) - if empty(l:buffer_info) + if empty(l:info) return endif " Remove this linter from the list of active linters. " This may have already been done when the job exits. - call filter(l:buffer_info.active_linter_list, 'v:val isnot# a:linter_name') + call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name') " Make some adjustments to the loclists to fix common problems, and also " to set default values for loclist items. let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist) " Remove previous items for this linter. - call filter(g:ale_buffer_info[a:buffer].loclist, 'v:val.linter_name isnot# a:linter_name') - " Add the new items. - call extend(g:ale_buffer_info[a:buffer].loclist, l:linter_loclist) + call filter(l:info.loclist, 'v:val.linter_name isnot# a:linter_name') - " Sort the loclist again. - " We need a sorted list so we can run a binary search against it - " for efficient lookup of the messages in the cursor handler. - call sort(g:ale_buffer_info[a:buffer].loclist, 'ale#util#LocItemCompare') + " We don't need to add items or sort the list when this list is empty. + if !empty(l:linter_loclist) + " Add the new items. + call extend(l:info.loclist, l:linter_loclist) + + " Sort the loclist again. + " We need a sorted list so we can run a binary search against it + " for efficient lookup of the messages in the cursor handler. + call sort(l:info.loclist, 'ale#util#LocItemCompare') + endif if ale#ShouldDoNothing(a:buffer) return endif - call ale#engine#SetResults(a:buffer, g:ale_buffer_info[a:buffer].loclist) + call ale#engine#SetResults(a:buffer, l:info.loclist) endfunction function! s:HandleExit(job_id, exit_code) abort diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 29e263a9..3e407c52 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -104,6 +104,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['php'], \ 'description': 'Fix PHP files with phpcbf.', \ }, +\ 'php_cs_fixer': { +\ 'function': 'ale#fixers#php_cs_fixer#Fix', +\ 'suggested_filetypes': ['php'], +\ 'description': 'Fix PHP files with php-cs-fixer.', +\ }, \ 'clang-format': { \ 'function': 'ale#fixers#clangformat#Fix', \ 'suggested_filetypes': ['c', 'cpp'], diff --git a/autoload/ale/fixers/php_cs_fixer.vim b/autoload/ale/fixers/php_cs_fixer.vim new file mode 100644 index 00000000..56aa9150 --- /dev/null +++ b/autoload/ale/fixers/php_cs_fixer.vim @@ -0,0 +1,23 @@ +" Author: Julien Deniau <julien.deniau@gmail.com> +" Description: Fixing files with php-cs-fixer. + +call ale#Set('php_cs_fixer_executable', 'php-cs-fixer') +call ale#Set('php_cs_fixer_use_global', 0) + +function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [ + \ 'vendor/bin/php-cs-fixer', + \ 'php-cs-fixer' + \]) +endfunction + +function! ale#fixers#php_cs_fixer#Fix(buffer) abort + let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer) + return { + \ 'command': ale#Escape(l:executable) . ' fix %t', + \ 'read_temporary_file': 1, + \} +endfunction + + + diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim index b1a8d4a7..30b8f5cf 100644 --- a/autoload/ale/list.vim +++ b/autoload/ale/list.vim @@ -97,12 +97,17 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort let l:reset_visual_selection = l:mode is? 'v' || l:mode is# "\<c-v>" let l:reset_character_selection = l:mode is? 's' || l:mode is# "\<c-s>" + " open windows vertically instead of default horizontally + let l:open_type = '' + if ale#Var(a:buffer, 'list_vertical') == 1 + let l:open_type = 'vert ' + endif if g:ale_set_quickfix if !ale#list#IsQuickfixOpen() - silent! execute 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) + silent! execute l:open_type . 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) endif elseif g:ale_set_loclist - silent! execute 'lopen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) + silent! execute l:open_type . 'lopen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) endif " If focus changed, restore it (jump to the last window). diff --git a/autoload/ale/lsp/response.vim b/autoload/ale/lsp/response.vim index 13219ef6..5a431287 100644 --- a/autoload/ale/lsp/response.vim +++ b/autoload/ale/lsp/response.vim @@ -59,6 +59,14 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort let l:loclist_item.nr = l:diagnostic.code endif + if get(l:diagnostic, 'category') is# 'warning' + let l:loclist_item.type = 'W' + endif + + if get(l:diagnostic, 'category') is# 'suggestion' + let l:loclist_item.type = 'I' + endif + call add(l:loclist, l:loclist_item) endfor diff --git a/doc/ale-perl.txt b/doc/ale-perl.txt index 414856bd..0a4adfff 100644 --- a/doc/ale-perl.txt +++ b/doc/ale-perl.txt @@ -3,6 +3,9 @@ ALE Perl Integration *ale-perl-options* ALE offers a few ways to check Perl code. Checking code with `perl` is disabled by default, as `perl` code cannot be checked without executing it. +Specifically, we use the `-c` flag to see if `perl` code compiles. This does +not execute all of the code in a file, but it does run `BEGIN` and `CHECK` +blocks. See `perl --help` and https://stackoverflow.com/a/12908487/406224 See |g:ale_linters|. diff --git a/doc/ale-php.txt b/doc/ale-php.txt index 455472f7..7edfe231 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -167,4 +167,21 @@ g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration* =============================================================================== +php-cs-fixer *ale-php-php-cs-fixer* + +g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* + *b:ale_php_cs_fixer_executable* + Type: |String| + Default: `'php-cs-fixer'` + + This variable sets executable used for php-cs-fixer. + +g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* + *b:ale_php_cs_fixer_use_global* + Type: |Boolean| + Default: `0` + + This variable force globally installed fixer. + +=============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 3acd118d..adcdccdf 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -160,6 +160,7 @@ CONTENTS *ale-contents* phpcs...............................|ale-php-phpcs| phpmd...............................|ale-php-phpmd| phpstan.............................|ale-php-phpstan| + php-cs-fixer........................|ale-php-php-cs-fixer| po....................................|ale-po-options| write-good..........................|ale-po-write-good| pod...................................|ale-pod-options| @@ -352,7 +353,7 @@ Notes: * Objective-C++: `clang` * OCaml: `merlin` (see |ale-ocaml-merlin|), `ols` * Perl: `perl -c`, `perl-critic` -* PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf` +* PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer` * PO: `alex`!!, `msgfmt`, `proselint`, `write-good` * Pod: `alex`!!, `proselint`, `write-good` * Pony: `ponyc` @@ -1152,6 +1153,16 @@ g:ale_linters_explicit *g:ale_linters_explicit* as possible, unless otherwise specified. +g:ale_list_vertical *g:ale_list_vertical* + *b:ale_list_vertical* + Type: |Number| + Default: `0` + + When set to `1`, this will cause ALE to open any windows (loclist or + quickfix) vertically instead of horizontally (|vert| |lopen|) or (|vert| + |copen|) + + g:ale_loclist_msg_format *g:ale_loclist_msg_format* b:ale_loclist_msg_format *b:ale_loclist_msg_format* @@ -1223,6 +1234,8 @@ g:ale_open_list *g:ale_open_list* The window size can be configured with |g:ale_list_window_size|. + Windows can be opened vertically with |g:ale_list_vertical|. + If you want to close the loclist window automatically when the buffer is closed, you can set up the following |autocmd| command: > @@ -1252,8 +1265,8 @@ g:ale_pattern_options *g:ale_pattern_options* See |b:ale_linters| and |b:ale_fixers| for information for those options. Filenames are matched with |match()|, and patterns depend on the |magic| - setting, unless prefixed with the special escape sequences like `'\v'`, - etc.The patterns can match any part of a filename. The absolute path of the + setting, unless prefixed with the special escape sequences like `'\v'`, etc. + The patterns can match any part of a filename. The absolute path of the filename will be used for matching, taken from `expand('%:p')`. The options for every match for the filename will be applied, with the diff --git a/plugin/ale.vim b/plugin/ale.vim index d75d33b0..1a473df1 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -118,6 +118,9 @@ let g:ale_open_list = get(g:, 'ale_open_list', 0) " This flag dictates if ale keeps open loclist even if there is no error in loclist let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0) +" This flag dictates that quickfix windows should be opened vertically +let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0) + " The window size to set for the quickfix and loclist windows call ale#Set('list_window_size', 10) diff --git a/test/command_callback/php_paths/project-with-php-cs-fixer/test.php b/test/command_callback/php_paths/project-with-php-cs-fixer/test.php new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/php_paths/project-with-php-cs-fixer/test.php diff --git a/test/command_callback/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer b/test/command_callback/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer diff --git a/test/command_callback/php_paths/project-without-php-cs-fixer/test.php b/test/command_callback/php_paths/project-without-php-cs-fixer/test.php new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/php_paths/project-without-php-cs-fixer/test.php diff --git a/test/fixers/test_php_cs_fixer.vader b/test/fixers/test_php_cs_fixer.vader new file mode 100644 index 00000000..b6579670 --- /dev/null +++ b/test/fixers/test_php_cs_fixer.vader @@ -0,0 +1,46 @@ +Before: + Save g:ale_php_cs_fixer_executable + let g:ale_php_cs_fixer_executable = 'php-cs-fixer' + + call ale#test#SetDirectory('/testplugin/test/fixers') + silent cd .. + silent cd command_callback + let g:dir = getcwd() + +After: + Restore + + call ale#test#RestoreDirectory() + + +Execute(project with php-cs-fixer should use local by default): + call ale#test#SetFilename('php_paths/project-with-php-cs-fixer/test.php') + + AssertEqual + \ ale#path#Simplify(g:dir . '/php_paths/project-with-php-cs-fixer/vendor/bin/php-cs-fixer'), + \ ale#fixers#php_cs_fixer#GetExecutable(bufnr('')) + +Execute(use-global should override local detection): + let g:ale_php_cs_fixer_use_global = 1 + call ale#test#SetFilename('php_paths/project-with-php-cs-fixer/test.php') + + AssertEqual + \ 'php-cs-fixer', + \ ale#fixers#php_cs_fixer#GetExecutable(bufnr('')) + +Execute(project without php-cs-fixer should use global): + call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/test.php') + + AssertEqual + \ 'php-cs-fixer', + \ ale#fixers#php_cs_fixer#GetExecutable(bufnr('')) + + + + +Execute(The php-cs-fixer callback should return the correct default values): + call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/foo/test.php') + + AssertEqual + \ {'read_temporary_file': 1, 'command': ale#Escape('php-cs-fixer') . ' fix %t' }, + \ ale#fixers#php_cs_fixer#Fix(bufnr('')) diff --git a/test/handler/test_mcsc_handler.vader b/test/handler/test_mcsc_handler.vader index ac55ee81..8ae47357 100644 --- a/test/handler/test_mcsc_handler.vader +++ b/test/handler/test_mcsc_handler.vader @@ -3,10 +3,15 @@ Before: unlet! g:ale_cs_mcsc_source + call ale#test#SetDirectory('/testplugin/test/handler') + call ale#test#SetFilename('Test.cs') + runtime ale_linters/cs/mcsc.vim After: unlet! g:ale_cs_mcsc_source + + call ale#test#RestoreDirectory() call ale#linter#Reset() Execute(The mcs handler should work with the default of the buffer's directory): @@ -18,10 +23,10 @@ Execute(The mcs handler should work with the default of the buffer's directory): \ 'text': '; expected', \ 'code': 'CS1001', \ 'type': 'E', - \ 'filename': ale#path#Simplify(expand('%:p:h') . '/Test.cs'), + \ 'filename': ale#path#Simplify(g:dir . '/Test.cs'), \ }, \ ], - \ ale_linters#cs#mcsc#Handle(347, [ + \ ale_linters#cs#mcsc#Handle(bufnr(''), [ \ 'Test.cs(12,29): error CS1001: ; expected', \ 'Compilation failed: 2 error(s), 1 warnings', \ ]) @@ -56,7 +61,7 @@ Execute(The mcs handler should handle cannot find symbol errors): \ 'filename': ale#path#Simplify('/home/foo/project/bar/Test.cs'), \ }, \ ], - \ ale_linters#cs#mcsc#Handle(347, [ + \ ale_linters#cs#mcsc#Handle(bufnr(''), [ \ 'Test.cs(12,29): error CS1001: ; expected', \ 'Test.cs(101,0): error CS1028: Unexpected processor directive (no #if for this #endif)', \ 'Test.cs(10,12): warning CS0123: some warning', diff --git a/test/handler/test_perl_handler.vader b/test/handler/test_perl_handler.vader index 75e8f226..c5791d76 100644 --- a/test/handler/test_perl_handler.vader +++ b/test/handler/test_perl_handler.vader @@ -47,3 +47,42 @@ Execute(The Perl linter should complain about failing to locate modules): \ 'Unable to build `ro` accessor for slot `path` in `App::CPANFileUpdate` because the slot cannot be found. at /extlib/Method/Traits.pm line 189.', \ 'BEGIN failed--compilation aborted at - line 10.', \ ]) + +Execute(The Perl linter should not report warnings as errors): + AssertEqual + \ [ + \ {'lnum': '5', 'type': 'W', 'text': '"my" variable $foo masks earlier declaration in same scope'}, + \ ], + \ ale_linters#perl#perl#Handle(bufnr(''), [ + \ '"my" variable $foo masks earlier declaration in same scope at - line 5.', + \ 't.pl syntax OK', + \ ]) + +Execute(The Perl linter does not default to reporting generic error): + AssertEqual + \ [ + \ {'lnum': '8', 'type': 'E', 'text': 'Missing right curly or square bracket'}, + \ ], + \ ale_linters#perl#perl#Handle(bufnr(''), [ + \ 'Missing right curly or square bracket at - line 8, at end of line', + \ 'syntax error at - line 8, at EOF', + \ 'Execution of t.pl aborted due to compilation errors.', + \ ]) + +" The first "error" is actually a warning, but the current implementation +" doesn't have a good way of teasing out the warnings from amongst the +" errors. If we're able to do this in future, then we'll want to switch +" the first "E" to a "W". + +Execute(The Perl linter reports errors even when mixed with warnings): + AssertEqual + \ [ + \ {'lnum': '5', 'type': 'E', 'text': '"my" variable $foo masks earlier declaration in same scope'}, + \ {'lnum': '8', 'type': 'E', 'text': 'Missing right curly or square bracket'}, + \ ], + \ ale_linters#perl#perl#Handle(bufnr(''), [ + \ '"my" variable $foo masks earlier declaration in same scope at - line 5.', + \ 'Missing right curly or square bracket at - line 8, at end of line', + \ 'syntax error at - line 8, at EOF', + \ 'Execution of t.pl aborted due to compilation errors.', + \ ]) diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index 3e637418..444272aa 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -121,7 +121,8 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages): \ ]}}) Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses): - AssertEqual [ + AssertEqual + \ [ \ { \ 'type': 'E', \ 'nr': 2365, @@ -131,5 +132,35 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver respon \ 'end_lnum': 1, \ 'end_col': 17, \ }, - \], + \ ], \ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/bar/foo.ts","diagnostics":[{"start":{"line":1,"offset":11},"end":{"line":1,"offset":17},"text":"Operator ''+'' cannot be applied to types ''3'' and ''{}''.","code":2365}]}}) + +Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from tsserver): + AssertEqual + \ [ + \ { + \ 'lnum': 27, + \ 'col': 3, + \ 'nr': 2515, + \ 'end_lnum': 27, + \ 'type': 'W', + \ 'end_col': 14, + \ 'text': 'Calls to ''console.log'' are not allowed. (no-console)', + \ } + \ ], + \ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"<removed>","diagnostics":[{"start":{"line":27,"offset":3},"end":{"line":27,"offset":14},"text":"Calls to 'console.log' are not allowed. (no-console)","code":2515,"category":"warning","source":"tslint"}]}}) + +Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions from tsserver): + AssertEqual + \ [ + \ { + \ 'lnum': 27, + \ 'col': 3, + \ 'nr': 2515, + \ 'end_lnum': 27, + \ 'type': 'I', + \ 'end_col': 14, + \ 'text': 'Some info', + \ } + \ ], + \ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"<removed>","diagnostics":[{"start":{"line":27,"offset":3},"end":{"line":27,"offset":14},"text":"Some info","code":2515,"category":"suggestion","source":"tslint"}]}}) diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader index e20125a3..05c045bb 100644 --- a/test/test_ale_info.vader +++ b/test/test_ale_info.vader @@ -66,6 +66,7 @@ Before: \ 'let g:ale_linters = {}', \ 'let g:ale_linters_explicit = 0', \ 'let g:ale_list_window_size = 10', + \ 'let g:ale_list_vertical = 0', \ 'let g:ale_loclist_msg_format = ''%code: %%s''', \ 'let g:ale_max_buffer_history_size = 20', \ 'let g:ale_max_signs = -1', diff --git a/test/test_list_opening.vader b/test/test_list_opening.vader index 63b30ef1..a24e8de9 100644 --- a/test/test_list_opening.vader +++ b/test/test_list_opening.vader @@ -5,6 +5,7 @@ Before: Save g:ale_open_list Save g:ale_keep_list_window_open Save g:ale_list_window_size + Save g:ale_list_vertical Save g:ale_buffer_info Save g:ale_set_lists_synchronously @@ -13,6 +14,7 @@ Before: let g:ale_open_list = 0 let g:ale_keep_list_window_open = 0 let g:ale_list_window_size = 10 + let g:ale_list_vertical = 0 let g:ale_set_lists_synchronously = 1 let g:loclist = [ @@ -33,16 +35,29 @@ Before: return 0 endfunction + " If the window is vertical, window size should match column size/width + function GetQuickfixIsVertical(cols) abort + for l:win in range(1, winnr('$')) + if getwinvar(l:win, '&buftype') is# 'quickfix' + return winwidth(l:win) == a:cols + endif + endfor + + return 0 + endfunction + After: Restore unlet! g:loclist + unlet! b:ale_list_vertical unlet! b:ale_list_window_size unlet! b:ale_open_list unlet! b:ale_keep_list_window_open unlet! b:ale_save_event_fired delfunction GetQuickfixHeight + delfunction GetQuickfixIsVertical " Close quickfix window after every execute block lcl @@ -98,6 +113,24 @@ Execute(The quickfix window height should be correct for the loclist with buffer AssertEqual 8, GetQuickfixHeight() +Execute(The quickfix window should be vertical for the loclist with appropriate variables): + let g:ale_open_list = 1 + let b:ale_list_window_size = 8 + let b:ale_list_vertical = 1 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 1, GetQuickfixIsVertical(b:ale_list_window_size) + +Execute(The quickfix window should be horizontal for the loclist with appropriate variables): + let g:ale_open_list = 1 + let b:ale_list_window_size = 8 + let b:ale_list_vertical = 0 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 0, GetQuickfixIsVertical(b:ale_list_window_size) + Execute(The quickfix window should stay open for just the loclist): let g:ale_open_list = 1 let g:ale_keep_list_window_open = 1 @@ -167,6 +200,24 @@ Execute(The quickfix window height should be correct for the quickfix list with AssertEqual 8, GetQuickfixHeight() +Execute(The quickfix window should be vertical for the quickfix with appropriate variables): + let g:ale_open_list = 1 + let b:ale_list_window_size = 8 + let b:ale_list_vertical = 1 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 1, GetQuickfixIsVertical(b:ale_list_window_size) + +Execute(The quickfix window should be horizontal for the quickfix with appropriate variables): + let g:ale_open_list = 1 + let b:ale_list_window_size = 8 + let b:ale_list_vertical = 0 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 0, GetQuickfixIsVertical(b:ale_list_window_size) + Execute(The buffer ale_open_list option should be respected): let b:ale_open_list = 1 |