diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | ale_linters/php/phpstan.vim | 7 | ||||
-rw-r--r-- | ale_linters/python/pylint.vim | 9 | ||||
-rw-r--r-- | autoload/ale.vim | 2 | ||||
-rw-r--r-- | autoload/ale/completion.vim | 19 | ||||
-rw-r--r-- | autoload/ale/handlers/eslint.vim | 5 | ||||
-rw-r--r-- | autoload/ale/lsp_linter.vim | 5 | ||||
-rw-r--r-- | doc/ale-php.txt | 8 | ||||
-rw-r--r-- | doc/ale-python.txt | 8 | ||||
-rw-r--r-- | doc/ale.txt | 33 | ||||
-rw-r--r-- | rplugin/python3/deoplete/sources/ale.py | 4 | ||||
-rwxr-xr-x | run-tests | 24 | ||||
-rw-r--r-- | test/command_callback/test_phpstan_command_callbacks.vader | 6 | ||||
-rw-r--r-- | test/completion/test_completion_events.vader | 10 | ||||
-rw-r--r-- | test/completion/test_lsp_completion_parsing.vader | 26 | ||||
-rw-r--r-- | test/completion/test_public_completion_api.vader | 63 | ||||
-rw-r--r-- | test/handler/test_eslint_handler.vader | 42 | ||||
-rw-r--r-- | test/handler/test_pylint_handler.vader | 20 | ||||
-rw-r--r-- | test/lsp/test_did_save_event.vader | 3 | ||||
-rw-r--r-- | test/python/test_deoplete_source.py | 19 | ||||
-rw-r--r-- | test/test_ignoring_linters.vader | 95 | ||||
-rw-r--r-- | test/test_redundant_tsserver_rendering_avoided.vader | 4 |
22 files changed, 401 insertions, 14 deletions
@@ -174,6 +174,9 @@ other plugins, and can be enabled by changing a setting before ALE is loaded. ```vim " Enable completion where available. " This setting must be set before ALE is loaded. +" +" You should not turn this setting on if you wish to use ALE as a completion +" source for other completion plugins, like Deoplete. let g:ale_completion_enabled = 1 ``` diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim index b621f855..78f7dd10 100644 --- a/ale_linters/php/phpstan.vim +++ b/ale_linters/php/phpstan.vim @@ -5,6 +5,7 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan') let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '') let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') +let g:ale_php_phpstan_autoload = get(g:, 'ale_php_phpstan_autoload', '') function! ale_linters#php#phpstan#GetCommand(buffer, version) abort let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration') @@ -12,6 +13,11 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort \ ? ' -c ' . ale#Escape(l:configuration) \ : '' + let l:autoload = ale#Var(a:buffer, 'php_phpstan_autoload') + let l:autoload_option = !empty(l:autoload) + \ ? ' -a ' . ale#Escape(l:autoload) + \ : '' + let l:level = ale#Var(a:buffer, 'php_phpstan_level') let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon') @@ -31,6 +37,7 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort return '%e analyze --no-progress' \ . l:error_format \ . l:configuration_option + \ . l:autoload_option \ . l:level_option \ . ' %s' endfunction diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index 57e82691..b16d5355 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -6,6 +6,7 @@ call ale#Set('python_pylint_options', '') call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pylint_change_directory', 1) call ale#Set('python_pylint_auto_pipenv', 0) +call ale#Set('python_pylint_use_msg_id', 0) function! ale_linters#python#pylint#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylint_auto_pipenv')) @@ -64,11 +65,17 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort continue endif + if ale#Var(a:buffer, 'python_pylint_use_msg_id') is# 1 + let l:code_out = l:code + else + let l:code_out = l:match[4] + endif + call add(l:output, { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 1, \ 'text': l:match[5], - \ 'code': l:match[4], + \ 'code': l:code_out, \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', \}) endfor diff --git a/autoload/ale.vim b/autoload/ale.vim index a887834b..04329dfd 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -97,7 +97,7 @@ function! s:Lint(buffer, should_lint_file, timer_id) 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') - let l:linters = !empty(l:ignore_config) + 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 diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 1d42c489..03cc6471 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -386,6 +386,8 @@ function! ale#completion#ParseLSPCompletions(response) abort if get(l:item, 'insertTextFormat') is s:LSP_INSERT_TEXT_FORMAT_PLAIN \&& type(get(l:item, 'textEdit')) is v:t_dict let l:text = l:item.textEdit.newText + elseif type(get(l:item, 'insertText')) is v:t_string + let l:text = l:item.insertText else let l:text = l:item.label endif @@ -547,6 +549,19 @@ function! s:OnReady(linter, lsp_details) abort endif endfunction +" This function can be called to check if ALE can provide completion data for +" the current buffer. 1 will be returned if there's a potential source of +" completion data ALE can use, and 0 will be returned otherwise. +function! ale#completion#CanProvideCompletions() abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + return 1 + endif + endfor + + return 0 +endfunction + " This function can be used to manually trigger autocomplete, even when " g:ale_completion_enabled is set to false function! ale#completion#GetCompletions(source) abort @@ -582,7 +597,7 @@ function! ale#completion#GetCompletions(source) abort endfunction function! s:TimerHandler(...) abort - if !g:ale_completion_enabled + if !get(b:, 'ale_completion_enabled', g:ale_completion_enabled) return endif @@ -607,7 +622,7 @@ function! ale#completion#StopTimer() abort endfunction function! ale#completion#Queue() abort - if !g:ale_completion_enabled + if !get(b:, 'ale_completion_enabled', g:ale_completion_enabled) return endif diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index bc7c0321..5183f4cd 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -143,6 +143,11 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort " The code can be something like 'Error/foo/bar', or just 'Error' if !empty(get(l:split_code, 1)) let l:obj.code = join(l:split_code[1:], '/') + + if l:obj.code is# 'no-trailing-spaces' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + continue + endif endif for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns) diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim index 3a596d62..f70042dd 100644 --- a/autoload/ale/lsp_linter.vim +++ b/autoload/ale/lsp_linter.vim @@ -10,6 +10,11 @@ endif " Check if diagnostics for a particular linter should be ignored. function! s:ShouldIgnore(buffer, linter_name) abort + " Ignore all diagnostics if LSP integration is disabled. + if ale#Var(a:buffer, 'disable_lsp') + return 1 + endif + let l:config = ale#Var(a:buffer, 'linters_ignore') " Don't load code for ignoring diagnostics if there's nothing to ignore. diff --git a/doc/ale-php.txt b/doc/ale-php.txt index 6f53cead..d41fb50d 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -171,6 +171,14 @@ g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration* This variable sets path to phpstan configuration file. +g:ale_php_phpstan_autoload *g:ale_php_phpstan_autoload* + *b:ale_php_phpstan_autoload* + Type: |String| + Default: `''` + + This variable sets path to phpstan autoload file. + + =============================================================================== psalm *ale-php-psalm* diff --git a/doc/ale-python.txt b/doc/ale-python.txt index dd946ad4..7dd3b65d 100644 --- a/doc/ale-python.txt +++ b/doc/ale-python.txt @@ -580,6 +580,14 @@ g:ale_python_pylint_auto_pipenv *g:ale_python_pylint_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* + *b:ale_python_pylint_use_msg_id* + Type: |Number| + Default: `0` + + Use message for output (e.g. I0011) instead of symbolic name of the message + (e.g. locally-disabled). + =============================================================================== pyls *ale-python-pyls* diff --git a/doc/ale.txt b/doc/ale.txt index b777e575..2a086981 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -142,6 +142,8 @@ ALE offers several options for controlling which linters are run. * Selecting linters to run. - |g:ale_linters| * Aliasing filetypes for linters - |g:ale_linter_aliases| * Only running linters you asked for. - |g:ale_linters_explicit| +* Disabling only a subset of linters. - |g:ale_linters_ignore| +* Disabling LSP linters and `tsserver`. - |g:ale_disable_lsp| ------------------------------------------------------------------------------- @@ -321,6 +323,9 @@ servers. LSP linters can be used in combination with any other linter, and will automatically connect to LSP servers when needed. ALE also supports `tsserver` for TypeScript, which uses a different but very similar protocol. +If you want to use another plugin for LSP features and tsserver, you can use +the |g:ale_disable_lsp| setting to disable ALE's own LSP integrations, or +ignore particular linters with |g:ale_linters_ignore|. ------------------------------------------------------------------------------- 5.1 Completion *ale-completion* @@ -338,9 +343,11 @@ integration should not be combined with ALE's own implementation. ALE also offers its own completion implementation, which does not require any other plugins. Suggestions will be made while you type after completion is -enabled. Completion can be enabled by setting |g:ale_completion_enabled| to -`1`. This setting must be set to `1` before ALE is loaded. The delay for -completion can be configured with |g:ale_completion_delay|. +enabled. ALE's own completion implementation can be enabled by setting +|g:ale_completion_enabled| to `1`. This setting must be set to `1` before ALE +is loaded. The delay for completion can be configured with +|g:ale_completion_delay|. This setting should not be enabled if you wish to +use ALE as a completion source for other plugins. ALE will only suggest so many possible matches for completion. The maximum number of items can be controlled with |g:ale_completion_max_suggestions|. @@ -553,6 +560,7 @@ g:ale_completion_delay *g:ale_completion_delay* g:ale_completion_enabled *g:ale_completion_enabled* +b:ale_completion_enabled *b:ale_completion_enabled* Type: |Number| Default: `0` @@ -562,6 +570,13 @@ g:ale_completion_enabled *g:ale_completion_enabled* This setting must be set to `1` before ALE is loaded for this behavior to be enabled. + This setting should not be enabled if you wish to use ALE as a completion + source for other completion plugins. + + A buffer-local version of this setting `b:ale_completion_enabled` can be set + to `0` to disable ALE's automatic completion support for a single buffer. + ALE's completion support must be enabled globally to be enabled locally. + See |ale-completion| @@ -627,7 +642,9 @@ g:ale_disable_lsp *g:ale_disable_lsp* Type: |Number| Default: `0` - When this option is set to `1`, ALE ignores all linters powered by LSP. + When this option is set to `1`, ALE ignores all linters powered by LSP, + and also `tsserver`. + Please see also |ale-lsp|. @@ -682,7 +699,7 @@ b:ale_echo_msg_format *b:ale_echo_msg_format* `%s` - replaced with the text for the problem `%...code...% `- replaced with the error code `%linter%` - replaced with the name of the linter - `%severity%` - replaced withe severity of the problem + `%severity%` - replaced with the severity of the problem The strings for `%severity%` can be configured with the following options. @@ -699,7 +716,7 @@ b:ale_echo_msg_format *b:ale_echo_msg_format* |g:ale_echo_cursor| needs to be set to 1 for messages to be displayed. The echo message format can also be configured separately for each buffer, - so different formats can be used for differnt languages. (Say in ftplugin + so different formats can be used for different languages. (Say in ftplugin files.) @@ -2459,7 +2476,7 @@ ALELast *ALELast* Flags can be combined to create create custom jumping. Thus you can use ":ALENext -wrap -error -nosyle" to jump to the next error which is not a - style error while going back to the begining of the file if needed. + style error while going back to the beginning of the file if needed. `ALEFirst` goes to the first error or warning in the buffer, while `ALELast` goes to the last one. @@ -3194,7 +3211,7 @@ ale#statusline#Count(buffer) *ale#statusline#Count()* ale#statusline#FirstProblem(buffer, type) *ale#statusline#FirstProblem()* Returns a copy of the first entry in the `loclist` that matches the supplied - buffer number and problem type. If there is no such enty, an empty dictionary + buffer number and problem type. If there is no such entry, an empty dictionary is returned. Problem type should be one of the strings listed below: diff --git a/rplugin/python3/deoplete/sources/ale.py b/rplugin/python3/deoplete/sources/ale.py index 1addfae3..7ed2f6c0 100644 --- a/rplugin/python3/deoplete/sources/ale.py +++ b/rplugin/python3/deoplete/sources/ale.py @@ -30,6 +30,10 @@ class Source(Base): return self.vim.call('ale#completion#GetCompletionPosition') def gather_candidates(self, context): + # Stop early if ALE can't provide completion data for this buffer. + if not self.vim.call('ale#completion#CanProvideCompletions'): + return None + if context.get('is_refresh'): context['is_async'] = False @@ -140,6 +140,30 @@ trap '{ rm -rf "$output_dir"; }' EXIT file_number=0 pid_list='' +# Used for killing tests when you kill the script. +cancel_tests() { + set +e + + if [ -n "$pid_list" ]; then + for pid in $pid_list; do + kill "$pid" + wait "$pid" + done + fi + + # shellcheck disable=SC2046 + docker kill $(docker ps -a -q --filter ancestor="$image" --format='{{.ID}}') &> /dev/null + + if [ -d "$output_dir" ]; then + rm -rf "$output_dir" + fi + + echo + exit 1 +} + +trap cancel_tests INT TERM + for vim in $(docker run --rm "$DOCKER_RUN_IMAGE" ls /vim-build/bin | grep '^neovim\|^vim' ); do if ( [[ $vim =~ ^vim-v8.0 ]] && ((run_vim_80_tests)) ) \ || ( [[ $vim =~ ^vim-v8.1 ]] && ((run_vim_81_tests)) ) \ diff --git a/test/command_callback/test_phpstan_command_callbacks.vader b/test/command_callback/test_phpstan_command_callbacks.vader index 3714fc64..0216b281 100644 --- a/test/command_callback/test_phpstan_command_callbacks.vader +++ b/test/command_callback/test_phpstan_command_callbacks.vader @@ -64,3 +64,9 @@ Execute(Configuration file exists in current directory, but force phpstan config \ ale#Escape('phpstan') . ' --version', \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -c ' . ale#Escape('phpstan.custom.neon') . ' %s' \ ] + +Execute(Autoload parameter is added to the command): + let g:ale_php_phpstan_autoload = 'autoload.php' + + AssertLinter 'phpstan', + \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat raw -a ' . ale#Escape('autoload.php') . ' -l ' . ale#Escape('4') . ' %s' diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index f79773cc..cdd3fea4 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -5,6 +5,7 @@ Before: Save &l:omnifunc Save &l:completeopt + unlet! b:ale_completion_enabled let g:ale_completion_enabled = 1 let g:get_completions_called = 0 let g:feedkeys_calls = [] @@ -49,6 +50,7 @@ Before: After: Restore + unlet! b:ale_completion_enabled unlet! g:output unlet! g:fake_mode unlet! g:get_completions_called @@ -78,6 +80,14 @@ After: Execute(ale#completion#GetCompletions should be called when the cursor position stays the same): call CheckCompletionCalled(1) +Execute(ale#completion#GetCompletions should not be called if the global setting is disabled): + let g:ale_completion_enabled = 0 + call CheckCompletionCalled(0) + +Execute(ale#completion#GetCompletions should not be called if the buffer setting is disabled): + let b:ale_completion_enabled = 0 + call CheckCompletionCalled(0) + Given typescript(): let abc = y. let foo = ab diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader index a8e00260..ef954564 100644 --- a/test/completion/test_lsp_completion_parsing.vader +++ b/test/completion/test_lsp_completion_parsing.vader @@ -486,7 +486,7 @@ Execute(Should handle completion messages with textEdit objects): \ { \ 'detail': 'PlayTimeCallback', \ 'filterText': 'next_callback', - \ 'insertText': 'next_callback', + \ 'insertText': 'ignoreme', \ 'insertTextFormat': 1, \ 'kind': 6, \ 'label': ' next_callback', @@ -502,3 +502,27 @@ Execute(Should handle completion messages with textEdit objects): \ ], \ }, \ }) + +Execute(Should handle completion messages with the deprecated insertText attribute): + AssertEqual + \ [ + \ {'word': 'next_callback', 'menu': 'PlayTimeCallback', 'info': '', 'kind': 'v', 'icase': 1}, + \ ], + \ ale#completion#ParseLSPCompletions({ + \ 'id': 226, + \ 'jsonrpc': '2.0', + \ 'result': { + \ 'isIncomplete': v:false, + \ 'items': [ + \ { + \ 'detail': 'PlayTimeCallback', + \ 'filterText': 'next_callback', + \ 'insertText': 'next_callback', + \ 'insertTextFormat': 1, + \ 'kind': 6, + \ 'label': ' next_callback', + \ 'sortText': '3ee19999next_callback', + \ }, + \ ], + \ }, + \ }) diff --git a/test/completion/test_public_completion_api.vader b/test/completion/test_public_completion_api.vader new file mode 100644 index 00000000..d4db2d6f --- /dev/null +++ b/test/completion/test_public_completion_api.vader @@ -0,0 +1,63 @@ +Before: + call ale#linter#Reset() + + unlet! b:ale_linters + unlet! b:ale_completion_info + unlet! b:ale_completion_response + unlet! b:ale_completion_parser + unlet! b:ale_completion_result + + function! Identity(x) abort + return a:x + endfunction + +After: + delfunction Identity + + call ale#linter#Reset() + + unlet! b:ale_linters + unlet! b:ale_completion_info + unlet! b:ale_completion_response + unlet! b:ale_completion_parser + unlet! b:ale_completion_result + +Execute(ale#completion#GetCompletionResult() should return v:null when there are no results): + AssertEqual v:null, ale#completion#GetCompletionResult() + +Execute(ale#completion#GetCompletionResult() should parse the result when it has yet to be parsed): + let b:ale_completion_response = [1] + let b:ale_completion_parser = 'Identity' + + AssertEqual [1], ale#completion#GetCompletionResult() + Assert !exists('b:ale_completion_response') + Assert !exists('b:ale_completion_parser') + AssertEqual [1], b:ale_completion_result + +Execute(ale#completion#GetCompletionResult() should return a result computed previously): + let b:ale_completion_result = [1] + + Assert !exists('b:ale_completion_response') + Assert !exists('b:ale_completion_parser') + AssertEqual [1], ale#completion#GetCompletionResult() + +Execute(ale#completion#GetCompletionPosition() should return 0 when there is no completion information): + AssertEqual 0, ale#completion#GetCompletionPosition() + +Given python(Some Python file): + foo bar + +Execute(ale#completion#GetCompletionPosition() should return the position in the file when information is available): + let b:ale_completion_info = {'line': 1, 'column': 6} + + " This is the first character of 'bar' + AssertEqual 4, ale#completion#GetCompletionPosition() + +Execute(ale#completion#CanProvideCompletions should return 0 when no completion sources are available): + AssertEqual 0, ale#completion#CanProvideCompletions() + +Execute(ale#completion#CanProvideCompletions should return 1 when at least one completion source is available): + runtime ale_linters/python/pyls.vim + let b:ale_linters = ['pyls'] + + AssertEqual 1, ale#completion#CanProvideCompletions() diff --git a/test/handler/test_eslint_handler.vader b/test/handler/test_eslint_handler.vader index 1bb438a6..01dd2c8f 100644 --- a/test/handler/test_eslint_handler.vader +++ b/test/handler/test_eslint_handler.vader @@ -1,15 +1,23 @@ Before: Save g:ale_javascript_eslint_suppress_eslintignore Save g:ale_javascript_eslint_suppress_missing_config + Save g:ale_warn_about_trailing_whitespace + Save g:ale_warn_about_trailing_blank_lines let g:ale_javascript_eslint_suppress_eslintignore = 0 let g:ale_javascript_eslint_suppress_missing_config = 0 + let g:ale_warn_about_trailing_whitespace = 1 + let g:ale_warn_about_trailing_blank_lines = 1 + unlet! b:ale_warn_about_trailing_whitespace + unlet! b:ale_warn_about_trailing_blank_lines After: Restore unlet! b:ale_javascript_eslint_suppress_eslintignore unlet! b:ale_javascript_eslint_suppress_missing_config + unlet! b:ale_warn_about_trailing_whitespace + unlet! b:ale_warn_about_trailing_blank_lines unlet! g:config_error_lines Execute(The eslint handler should parse lines correctly): @@ -394,3 +402,37 @@ Execute(Failing to connect to eslint_d should be handled correctly): \ ale#handlers#eslint#Handle(bufnr(''), [ \ 'Could not connect', \ ]) + +Execute(Disabling warnings about trailing spaces should work): + silent! noautocmd file foo.ts + + AssertEqual + \ [ + \ { + \ 'lnum': 182, + \ 'col': 22, + \ 'code': 'no-trailing-spaces', + \ 'type': 'E', + \ 'text': 'Trailing spaces not allowed.', + \ }, + \ ], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'foo.js:182:22: Trailing spaces not allowed. [Error/no-trailing-spaces]', + \ ]) + + let g:ale_warn_about_trailing_whitespace = 0 + + AssertEqual + \ [], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'foo.js:182:22: Trailing spaces not allowed. [Error/no-trailing-spaces]', + \ ]) + + let g:ale_warn_about_trailing_whitespace = 1 + let b:ale_warn_about_trailing_whitespace = 0 + + AssertEqual + \ [], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'foo.js:182:22: Trailing spaces not allowed. [Error/no-trailing-spaces]', + \ ]) diff --git a/test/handler/test_pylint_handler.vader b/test/handler/test_pylint_handler.vader index 18f66526..ce7322f3 100644 --- a/test/handler/test_pylint_handler.vader +++ b/test/handler/test_pylint_handler.vader @@ -113,3 +113,23 @@ Execute(The pylint handler should parse Windows filenames): \ '------------------------------------------------------------------', \ 'Your code has been rated at 5.83/10 (previous run: 5.83/10, +0.00)', \ ]) + +Execute(Use msg_id): + let g:ale_python_pylint_use_msg_id = 1 + AssertEqual + \ [ + \ { + \ 'lnum': 13, + \ 'col': 6, + \ 'text': 'Undefined variable ''x''', + \ 'code': 'E0602', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#python#pylint#Handle(bufnr(''), [ + \ '************* Module test', + \ 'D:\acm\github\vim\tools\test.py:13:5: E0602 (undefined-variable) Undefined variable ''x''', + \ '', + \ '------------------------------------------------------------------', + \ 'Your code has been rated at 5.83/10 (previous run: 5.83/10, +0.00)', + \ ]) diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index 423138af..1a60bc9f 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -3,12 +3,15 @@ Before: Save g:ale_enabled Save g:ale_linters Save g:ale_run_synchronously + Save g:ale_disable_lsp call ale#test#SetDirectory('/testplugin/test/completion') call ale#test#SetFilename('dummy.txt') runtime autoload/ale/lsp.vim + let g:ale_disable_lsp = 0 + unlet! b:ale_disable_lsp let g:ale_lint_on_save = 1 let b:ale_enabled = 1 let g:ale_lsp_next_message_id = 1 diff --git a/test/python/test_deoplete_source.py b/test/python/test_deoplete_source.py index 960abe3a..28eec5cd 100644 --- a/test/python/test_deoplete_source.py +++ b/test/python/test_deoplete_source.py @@ -23,7 +23,7 @@ class DeopleteSourceTest(unittest.TestCase): super(DeopleteSourceTest, self).setUp() self.call_list = [] - self.call_results = {} + self.call_results = {'ale#completion#CanProvideCompletions': 1} self.source = ale_module.Source('vim') self.source.vim = VimMock(self.call_list, self.call_results) @@ -62,15 +62,27 @@ class DeopleteSourceTest(unittest.TestCase): self.assertEqual(self.source.gather_candidates(context), []) self.assertEqual(context, {'is_async': True}) self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletions', ('deoplete',)), ]) + def test_request_completion_results_from_buffer_without_providers(self): + self.call_results['ale#completion#CanProvideCompletions'] = 0 + context = {'is_async': False} + + self.assertIsNone(self.source.gather_candidates(context), []) + self.assertEqual(context, {'is_async': False}) + self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), + ]) + def test_refresh_completion_results(self): context = {'is_async': False} self.assertEqual(self.source.gather_candidates(context), []) self.assertEqual(context, {'is_async': True}) self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletions', ('deoplete',)), ]) @@ -79,7 +91,9 @@ class DeopleteSourceTest(unittest.TestCase): self.assertEqual(self.source.gather_candidates(context), []) self.assertEqual(context, {'is_async': True, 'is_refresh': True}) self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletions', ('deoplete',)), + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletions', ('deoplete',)), ]) @@ -90,6 +104,7 @@ class DeopleteSourceTest(unittest.TestCase): self.assertEqual(self.source.gather_candidates(context), []) self.assertEqual(context, {'is_async': True}) self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletionResult', ()), ]) @@ -100,6 +115,7 @@ class DeopleteSourceTest(unittest.TestCase): self.assertEqual(self.source.gather_candidates(context), []) self.assertEqual(context, {'is_async': False}) self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletionResult', ()), ]) @@ -126,5 +142,6 @@ class DeopleteSourceTest(unittest.TestCase): ]) self.assertEqual(context, {'is_async': False}) self.assertEqual(self.call_list, [ + ('ale#completion#CanProvideCompletions', ()), ('ale#completion#GetCompletionResult', ()), ]) diff --git a/test/test_ignoring_linters.vader b/test/test_ignoring_linters.vader index 2d9c67de..f2e9e5c9 100644 --- a/test/test_ignoring_linters.vader +++ b/test/test_ignoring_linters.vader @@ -300,3 +300,98 @@ Execute(Buffer ignore lists should be applied for LSP linters): call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) AssertEqual [], g:loclist + +Execute(ale_disable_lsp should be applied for tsserver): + call ale#test#SetFilename('filename.ts') + call ale#engine#InitBufferInfo(bufnr('')) + + let g:lsp_message = { + \ 'seq': 0, + \ 'type': 'event', + \ 'event': 'syntaxDiag', + \ 'body': { + \ 'file': g:dir . '/filename.ts', + \ 'diagnostics':[ + \ { + \ 'start': { + \ 'line':2, + \ 'offset':14, + \ }, + \ 'end': { + \ 'line':2, + \ 'offset':15, + \ }, + \ 'text': ''','' expected.', + \ "code":1005 + \ }, + \ ], + \ }, + \} + + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual + \ [ + \ { + \ 'lnum': 2, + \ 'col': 14, + \ 'nr': 1005, + \ 'code': '1005', + \ 'type': 'E', + \ 'end_col': 15, + \ 'end_lnum': 2, + \ 'text': ''','' expected.', + \ }, + \ ], + \ g:loclist + + let g:loclist = [] + let b:ale_disable_lsp = 1 + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual [], g:loclist + +Execute(ale_disable_lsp should be applied for LSP linters): + call ale#test#SetFilename('filename.py') + call ale#engine#InitBufferInfo(bufnr('')) + call ale#lsp_linter#SetLSPLinterMap({'347': 'lsplinter'}) + + let g:lsp_message = { + \ 'jsonrpc': '2.0', + \ 'method': 'textDocument/publishDiagnostics', + \ 'params': { + \ 'uri': ale#path#ToURI(expand('%:p')), + \ 'diagnostics': [ + \ { + \ 'severity': 1, + \ 'message': 'x', + \ 'range': { + \ 'start': {'line': 0, 'character': 9}, + \ 'end': {'line': 0, 'character': 9}, + \ }, + \ } + \ ], + \ }, + \} + + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 10, + \ 'type': 'E', + \ 'end_col': 9, + \ 'end_lnum': 1, + \ 'text': 'x', + \ } + \ ], + \ g:loclist + + let b:ale_disable_lsp = 1 + let g:loclist = [] + + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual [], g:loclist diff --git a/test/test_redundant_tsserver_rendering_avoided.vader b/test/test_redundant_tsserver_rendering_avoided.vader index 6e0b2d30..6125ebc2 100644 --- a/test/test_redundant_tsserver_rendering_avoided.vader +++ b/test/test_redundant_tsserver_rendering_avoided.vader @@ -1,5 +1,9 @@ Before: Save g:ale_buffer_info + Save g:ale_disable_lsp + + let g:ale_disable_lsp = 0 + unlet! b:ale_disable_lsp function! CreateError(type, message) abort let l:diagnostics = [] |