summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/c/clangd.vim7
-rw-r--r--ale_linters/cpp/clangd.vim7
-rw-r--r--ale_linters/nim/nimlsp.vim33
-rw-r--r--autoload/ale.vim9
-rw-r--r--autoload/ale/completion.vim15
-rw-r--r--autoload/ale/lsp_linter.vim6
-rw-r--r--autoload/ale/lsp_window.vim58
-rw-r--r--autoload/ale/sign.vim10
-rw-r--r--doc/ale-nim.txt25
-rw-r--r--doc/ale-php.txt4
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt55
-rw-r--r--supported-tools.md5
-rw-r--r--test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json (renamed from test/command_callback/clangd_paths/compile_commands.json)0
-rw-r--r--test/command_callback/clangd_paths/with_compile_commands/compile_commands.json0
-rw-r--r--test/command_callback/test_c_clangd_command_callbacks.vader31
-rw-r--r--test/command_callback/test_nimlsp_command_callback.vader12
-rw-r--r--test/completion/test_completion_events.vader6
-rw-r--r--test/completion/test_lsp_completion_messages.vader2
-rw-r--r--test/lsp/test_handling_window_requests.vader94
-rw-r--r--test/nim-test-files/with-git/src/source.nim0
-rw-r--r--test/sign/test_linting_sets_signs.vader2
-rw-r--r--test/sign/test_sign_parsing.vader14
-rw-r--r--test/sign/test_sign_placement.vader6
-rw-r--r--test/test_ale_has.vader1
-rw-r--r--test/test_nimlsp_project_root.vader19
26 files changed, 388 insertions, 34 deletions
diff --git a/ale_linters/c/clangd.vim b/ale_linters/c/clangd.vim
index 79b600fa..ab8a0259 100644
--- a/ale_linters/c/clangd.vim
+++ b/ale_linters/c/clangd.vim
@@ -3,9 +3,14 @@
call ale#Set('c_clangd_executable', 'clangd')
call ale#Set('c_clangd_options', '')
+call ale#Set('c_build_dir', '')
function! ale_linters#c#clangd#GetCommand(buffer) abort
- return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
+
+ return '%e -x c'
+ \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
+ \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('c', {
diff --git a/ale_linters/cpp/clangd.vim b/ale_linters/cpp/clangd.vim
index fab605f4..14f3fe55 100644
--- a/ale_linters/cpp/clangd.vim
+++ b/ale_linters/cpp/clangd.vim
@@ -3,9 +3,14 @@
call ale#Set('cpp_clangd_executable', 'clangd')
call ale#Set('cpp_clangd_options', '')
+call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangd#GetCommand(buffer) abort
- return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
+
+ return '%e'
+ \ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
+ \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('cpp', {
diff --git a/ale_linters/nim/nimlsp.vim b/ale_linters/nim/nimlsp.vim
new file mode 100644
index 00000000..5d041043
--- /dev/null
+++ b/ale_linters/nim/nimlsp.vim
@@ -0,0 +1,33 @@
+" Author: jeremija <https://github.com/jeremija>
+" Description: Support for nimlsp (language server for nim)
+
+call ale#Set('nim_nimlsp_nim_sources', '')
+
+function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort
+ let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
+
+ if !empty(l:project_root)
+ return fnamemodify(l:project_root, ':h:h')
+ endif
+
+ return ''
+endfunction
+
+function! ale_linters#nim#nimlsp#GetCommand(buffer) abort
+ let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources')
+
+ if !empty(l:nim_sources)
+ let l:nim_sources = ale#Escape(l:nim_sources)
+ endif
+
+ return '%e' . ale#Pad(l:nim_sources)
+endfunction
+
+call ale#linter#Define('nim', {
+\ 'name': 'nimlsp',
+\ 'lsp': 'stdio',
+\ 'executable': 'nimlsp',
+\ 'command': function('ale_linters#nim#nimlsp#GetCommand'),
+\ 'language': 'nim',
+\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'),
+\})
diff --git a/autoload/ale.vim b/autoload/ale.vim
index 3a4e79c8..ee1a0d54 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -5,11 +5,18 @@
" Strings used for severity in the echoed message
let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error')
let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info')
+let g:ale_echo_msg_log_str = get(g:, 'ale_echo_msg_log_str', 'Log')
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
" Ignoring linters, for disabling some, or ignoring LSP diagnostics.
let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {})
let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0)
+" LSP window/showMessage format
+let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s')
+" Valid values mimic LSP definitions (error, warning and information; log is
+" never shown)
+let g:ale_lsp_show_message_severity = get(g:, 'ale_lsp_show_message_severity', 'error')
+
let s:lint_timer = -1
let s:getcmdwintype_exists = exists('*getcmdwintype')
@@ -156,7 +163,7 @@ function! ale#Queue(delay, ...) abort
endif
endfunction
-let s:current_ale_version = [2, 5, 0]
+let s:current_ale_version = [2, 6, 0]
" A function used to check for ALE features in files outside of the project.
function! ale#Has(feature) abort
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index 896a3745..005caf17 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -492,10 +492,17 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort
let l:identifiers = []
for l:name in l:names
- call add(l:identifiers, {
+ let l:identifier = {
\ 'name': l:name.word,
- \ 'source': get(l:name, 'source', ''),
- \})
+ \}
+ let l:source = get(l:name, 'source', '')
+
+ " Empty source results in no details for the completed item
+ if !empty(l:source)
+ call extend(l:identifier, { 'source': l:source })
+ endif
+
+ call add(l:identifiers, l:identifier)
endfor
let b:ale_completion_info.request_id = ale#lsp#Send(
@@ -722,7 +729,7 @@ endfunction
function! ale#completion#HandleUserData(completed_item) abort
let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '')
- if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual'
+ if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual' && l:source isnot# 'ale-callback'
return
endif
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index 190a16b4..e4148ceb 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -130,6 +130,12 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
call s:HandleLSPErrorMessage(l:linter_name, a:response)
elseif l:method is# 'textDocument/publishDiagnostics'
call s:HandleLSPDiagnostics(a:conn_id, a:response)
+ elseif l:method is# 'window/showMessage'
+ call ale#lsp_window#HandleShowMessage(
+ \ s:lsp_linter_map[a:conn_id],
+ \ g:ale_lsp_show_message_format,
+ \ a:response.params
+ \)
elseif get(a:response, 'type', '') is# 'event'
\&& get(a:response, 'event', '') is# 'semanticDiag'
call s:HandleTSServerDiagnostics(a:response, 'semantic')
diff --git a/autoload/ale/lsp_window.vim b/autoload/ale/lsp_window.vim
new file mode 100644
index 00000000..9a27f2f1
--- /dev/null
+++ b/autoload/ale/lsp_window.vim
@@ -0,0 +1,58 @@
+" Author: suoto <andre820@gmail.com>
+" Description: Handling of window/* LSP methods, although right now only
+" handles window/showMessage
+
+" Constants for message type codes
+let s:LSP_MESSAGE_TYPE_DISABLED = 0
+let s:LSP_MESSAGE_TYPE_ERROR = 1
+let s:LSP_MESSAGE_TYPE_WARNING = 2
+let s:LSP_MESSAGE_TYPE_INFORMATION = 3
+let s:LSP_MESSAGE_TYPE_LOG = 4
+
+" Translate strings from the user config to a number so we can check
+" severities
+let s:CFG_TO_LSP_SEVERITY = {
+\ 'disabled': s:LSP_MESSAGE_TYPE_DISABLED,
+\ 'error': s:LSP_MESSAGE_TYPE_ERROR,
+\ 'warning': s:LSP_MESSAGE_TYPE_WARNING,
+\ 'information': s:LSP_MESSAGE_TYPE_INFORMATION,
+\ 'info': s:LSP_MESSAGE_TYPE_INFORMATION,
+\ 'log': s:LSP_MESSAGE_TYPE_LOG
+\}
+
+" Handle window/showMessage response.
+" - details: dict containing linter name and format (g:ale_lsp_show_message_format)
+" - params: dict with the params for the call in the form of {type: number, message: string}
+function! ale#lsp_window#HandleShowMessage(linter_name, format, params) abort
+ let l:message = a:params.message
+ let l:type = a:params.type
+
+ " Get the configured severity level threshold and check if the message
+ " should be displayed or not
+ let l:configured_severity = tolower(get(g:, 'ale_lsp_show_message_severity', 'error'))
+ " If the user has configured with a value we can't find on the conversion
+ " dict, fall back to warning
+ let l:cfg_severity_threshold = get(s:CFG_TO_LSP_SEVERITY, l:configured_severity, s:LSP_MESSAGE_TYPE_WARNING)
+
+ if l:type > l:cfg_severity_threshold
+ return
+ endif
+
+ " Severity will depend on the message type
+ if l:type is# s:LSP_MESSAGE_TYPE_ERROR
+ let l:severity = g:ale_echo_msg_error_str
+ elseif l:type is# s:LSP_MESSAGE_TYPE_INFORMATION
+ let l:severity = g:ale_echo_msg_info_str
+ elseif l:type is# s:LSP_MESSAGE_TYPE_LOG
+ let l:severity = g:ale_echo_msg_log_str
+ else
+ " Default to warning just in case
+ let l:severity = g:ale_echo_msg_warning_str
+ endif
+
+ let l:string = substitute(a:format, '\V%severity%', l:severity, 'g')
+ let l:string = substitute(l:string, '\V%linter%', a:linter_name, 'g')
+ let l:string = substitute(l:string, '\V%s\>', l:message, 'g')
+
+ call ale#util#ShowMessage(l:string)
+endfunction
diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim
index 7430c7f2..db0e1ab6 100644
--- a/autoload/ale/sign.vim
+++ b/autoload/ale/sign.vim
@@ -23,6 +23,8 @@ let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000)
let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0)
let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0)
+let s:supports_sign_groups = has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
+
if !hlexists('ALEErrorSign')
highlight link ALEErrorSign error
endif
@@ -149,7 +151,7 @@ function! ale#sign#GetSignName(sublist) abort
endfunction
function! s:PriorityCmd() abort
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if s:supports_sign_groups
return ' priority=' . g:ale_sign_priority . ' '
else
return ''
@@ -157,7 +159,7 @@ function! s:PriorityCmd() abort
endfunction
function! s:GroupCmd() abort
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if s:supports_sign_groups
return ' group=ale '
else
return ' '
@@ -175,7 +177,7 @@ function! ale#sign#ReadSigns(buffer) abort
endfunction
function! ale#sign#ParsePattern() abort
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if s:supports_sign_groups
" Matches output like :
" line=4 id=1 group=ale name=ALEErrorSign
" строка=1 id=1000001 группа=ale имя=ALEErrorSign
@@ -460,7 +462,7 @@ endfunction
" Remove all signs.
function! ale#sign#Clear() abort
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if s:supports_sign_groups
sign unplace group=ale *
else
sign unplace *
diff --git a/doc/ale-nim.txt b/doc/ale-nim.txt
new file mode 100644
index 00000000..ad7aa686
--- /dev/null
+++ b/doc/ale-nim.txt
@@ -0,0 +1,25 @@
+===============================================================================
+ALE Nim Integration *ale-nim-options*
+
+
+===============================================================================
+nimcheck *ale-nim-nimcheck*
+
+ ALE does not provide additional configuration options for `nimcheck` at this
+ point.
+
+
+===============================================================================
+nimlsp *ale-nim-nimlsp*
+
+g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources*
+
+ Type: |String|
+ Default: `''`
+
+ Sets the path to Nim source repository as the first argument to `nimlsp`
+ command.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-php.txt b/doc/ale-php.txt
index d41fb50d..e17e1023 100644
--- a/doc/ale-php.txt
+++ b/doc/ale-php.txt
@@ -157,9 +157,9 @@ g:ale_php_phpstan_level *g:ale_php_phpstan_level*
Type: |String|
Default: `''`
- This variable controls the rule levels. 0 is the loosest and 4 is the
+ This variable controls the rule levels. 0 is the loosest and 7 is the
strictest. If this option isn't set, the rule level will be controlled by
- the configuration file. If no configuration file can be detected, `'4'` will
+ the configuration file. If no configuration file can be detected, `'7'` will
be used instead.
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index a5b7c35e..e2379b70 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -282,6 +282,7 @@ Notes:
* `nasm`!!
* Nim
* `nim check`!!
+ * `nimlsp`
* nix
* `nix-instantiate`
* `nixpkgs-fmt`
diff --git a/doc/ale.txt b/doc/ale.txt
index c6e48043..291e90fb 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -172,7 +172,7 @@ address to connect to instead. >
call ale#linter#Define('filetype_here', {
\ 'name': 'any_name_you_want',
- \ 'lsp': 'stdio',
+ \ 'lsp': 'socket',
\ 'address': 'servername:1234',
\ 'project_root': '/path/to/root_of_project',
\})
@@ -801,6 +801,15 @@ g:ale_echo_msg_info_str *g:ale_echo_msg_info_str*
The string used for `%severity%` for info. See |g:ale_echo_msg_format|
+g:ale_echo_msg_log_str *g:ale_echo_msg_log_str*
+
+ Type: |String|
+ Default: `'Log'`
+
+ The string used for `%severity%` for log, used only for handling LSP show
+ message requests. See |g:ale_lsp_show_message_format|
+
+
g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str*
Type: |String|
@@ -1251,6 +1260,47 @@ b:ale_loclist_msg_format *b:ale_loclist_msg_format*
The strings for configuring `%severity%` are also used for this option.
+
+g:ale_lsp_show_message_format *g:ale_lsp_show_message_format*
+
+ Type: |String|
+ Default: `'%severity%:%linter%: %s'`
+
+ This variable defines the format that messages received from an LSP will
+ have when echoed. The following sequences of characters will be replaced.
+
+ `%s` - replaced with the message text
+ `%linter%` - replaced with the name of the linter
+ `%severity%` - replaced with the severity of the message
+
+ The strings for `%severity%` levels "error", "info" and "warning" are shared
+ with |g:ale_echo_msg_format|. Severity "log" is unique to
+ |g:ale_lsp_show_message_format| and it can be configured via
+
+ |g:ale_echo_msg_log_str| - Defaults to `'Log'`
+
+ Please note that |g:ale_lsp_show_message_format| *can not* be configured
+ separately for each buffer like |g:ale_echo_msg_format| can.
+
+
+g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity*
+
+ Type: |String|
+ Default: `'error'`
+
+ This variable defines the minimum severity level an LSP message needs to be
+ displayed. Messages below this level are discarded; please note that
+ messages with `Log` severity level are always discarded.
+
+ Possible values follow the LSP spec `MessageType` definition:
+
+ `'error'` - Displays only errors.
+ `'warning'` - Displays errors and warnings.
+ `'information'` - Displays errors, warnings and infos
+ `'log'` - Same as `'information'`
+ `'disabled'` - Doesn't display any information at all.
+
+
g:ale_lsp_root *g:ale_lsp_root*
b:ale_lsp_root *b:ale_lsp_root*
@@ -2307,6 +2357,9 @@ documented in additional help files.
mmc...................................|ale-mercury-mmc|
nasm....................................|ale-nasm-options|
nasm..................................|ale-nasm-nasm|
+ nim.....................................|ale-nim-options|
+ nimcheck..............................|ale-nim-nimcheck|
+ nimlsp................................|ale-nim-nimlsp|
nix.....................................|ale-nix-options|
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
nroff...................................|ale-nroff-options|
diff --git a/supported-tools.md b/supported-tools.md
index e392f282..c302d38c 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -291,6 +291,7 @@ formatting.
* [nasm](https://www.nasm.us/) :floppy_disk:
* Nim
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
+ * [nimlsp](https://github.com/PMunch/nimlsp)
* nix
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
@@ -342,8 +343,8 @@ formatting.
* Pony
* [ponyc](https://github.com/ponylang/ponyc)
* PowerShell
- * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk
- * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk
+ * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk:
+ * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk:
* Prolog
* [swipl](https://github.com/SWI-Prolog/swipl-devel)
* proto
diff --git a/test/command_callback/clangd_paths/compile_commands.json b/test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json
index e69de29b..e69de29b 100644
--- a/test/command_callback/clangd_paths/compile_commands.json
+++ b/test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json
diff --git a/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json b/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json
diff --git a/test/command_callback/test_c_clangd_command_callbacks.vader b/test/command_callback/test_c_clangd_command_callbacks.vader
index dc52097d..555122f6 100644
--- a/test/command_callback/test_c_clangd_command_callbacks.vader
+++ b/test/command_callback/test_c_clangd_command_callbacks.vader
@@ -4,31 +4,52 @@ Before:
Save &filetype
let &filetype = 'c'
+ Save b:ale_c_clangd_options
+ Save b:ale_c_build_dir
+ Save b:ale_c_build_dir_names
+ Save b:ale_c_parse_compile_commands
+
+ let b:command_tail = ' -x c'
+
After:
+ unlet! b:command_tail
+
call ale#assert#TearDownLinterTest()
Execute(The language string should be correct):
AssertLSPLanguage 'c'
Execute(The default executable should be correct):
- AssertLinter 'clangd', ale#Escape('clangd')
+ AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail
Execute(The project root should be detected correctly):
call ale#test#SetFilename(tempname() . '/dummy.c')
AssertLSPProject ''
- call ale#test#SetFilename('clangd_paths/dummy.c')
+ call ale#test#SetFilename('clangd_paths/with_compile_commands/dummy.c')
- AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths')
+ AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths/with_compile_commands')
Execute(The executable should be configurable):
let g:ale_c_clangd_executable = 'foobar'
- AssertLinter 'foobar', ale#Escape('foobar')
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(The options should be configurable):
let b:ale_c_clangd_options = '-compile-commands-dir=foo'
- AssertLinter 'clangd', ale#Escape('clangd') . ' ' . b:ale_c_clangd_options
+ AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail . ' ' . b:ale_c_clangd_options
+
+Execute(The compile command database should be detected correctly):
+ call ale#test#SetFilename('clangd_paths/with_build_dir/dummy_src/dummy.c')
+
+ let b:ale_c_clangd_options = ''
+ let b:ale_c_build_dir = ''
+ let b:ale_c_build_dir_names = ['unusual_build_dir_name']
+ let b:ale_c_parse_compile_commands = 1
+
+ AssertLinter 'clangd', ale#Escape('clangd') . b:command_tail
+ \ . ' -compile-commands-dir='
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/clangd_paths/with_build_dir/unusual_build_dir_name'))
diff --git a/test/command_callback/test_nimlsp_command_callback.vader b/test/command_callback/test_nimlsp_command_callback.vader
new file mode 100644
index 00000000..c109deef
--- /dev/null
+++ b/test/command_callback/test_nimlsp_command_callback.vader
@@ -0,0 +1,12 @@
+Before:
+ call ale#assert#SetUpLinterTest('nim', 'nimlsp')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(It does not set nim sources by default):
+ AssertLinter 'nimlsp', ale#Escape('nimlsp')
+
+Execute(Sets nimlsp and escapes sources from g:ale_nim_nimlsp_nim_sources):
+ let g:ale_nim_nimlsp_nim_sources = '/path/to /Nim'
+ AssertLinter 'nimlsp', ale#Escape('nimlsp') . ' ' . ale#Escape('/path/to /Nim')
diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader
index a6dcdac4..90a2e3a2 100644
--- a/test/completion/test_completion_events.vader
+++ b/test/completion/test_completion_events.vader
@@ -432,6 +432,12 @@ Execute(HandleUserData should call ale#code_action#HandleCodeAction):
\})
AssertEqual g:handle_code_action_called, 2
+ let b:ale_completion_info = {'source': 'ale-callback'}
+ call ale#completion#HandleUserData({
+ \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}'
+ \})
+ AssertEqual g:handle_code_action_called, 3
+
Execute(ale#code_action#HandleCodeAction should not be called when when source is not ALE):
call MockHandleCodeAction()
let b:ale_completion_info = {'source': 'syntastic'}
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index b997ac86..4b7392f5 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -190,10 +190,8 @@ Execute(The right message sent to the tsserver LSP when the first completion mes
\ 'source': '/path/to/foo.ts',
\ }, {
\ 'name': 'FooBar',
- \ 'source': '',
\ }, {
\ 'name': 'frazzle',
- \ 'source': '',
\ }],
\ 'offset': 1,
\ 'line': 1,
diff --git a/test/lsp/test_handling_window_requests.vader b/test/lsp/test_handling_window_requests.vader
new file mode 100644
index 00000000..551d5975
--- /dev/null
+++ b/test/lsp/test_handling_window_requests.vader
@@ -0,0 +1,94 @@
+Before:
+ let g:expr_list = []
+ let g:linter_name = 'some_linter'
+ let g:format = '%severity%:%linter%: %s'
+ " Get the default value to restore it
+ let g:default_severity = g:ale_lsp_show_message_severity
+ let g:ale_lsp_show_message_severity = 'information'
+
+ function! ale#util#ShowMessage(expr) abort
+ call add(g:expr_list, a:expr)
+ endfunction
+
+After:
+ unlet! g:expr_list
+ unlet! g:linter_name
+ unlet! g:format
+ let g:ale_lsp_show_message_severity = g:default_severity
+ unlet! g:default_severity
+
+Execute(ale#lsp_window#HandleShowMessage() should only show errors when severity is set to "error"):
+ let g:ale_lsp_show_message_severity = 'error'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual ['Error:some_linter: an error'], g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should only show errors and warnings when severity is set to "warning"):
+ let g:ale_lsp_show_message_severity = 'warning'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual ['Error:some_linter: an error', 'Warning:some_linter: a warning'], g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should only show errors, warnings and infos when severity is set to "information"):
+ let g:ale_lsp_show_message_severity = 'information'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual [
+ \ 'Error:some_linter: an error',
+ \ 'Warning:some_linter: a warning',
+ \ 'Info:some_linter: an info'],
+ \ g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should only show errors, warnings and infos when severity is set to "info"):
+ let g:ale_lsp_show_message_severity = 'info'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual [
+ \ 'Error:some_linter: an error',
+ \ 'Warning:some_linter: a warning',
+ \ 'Info:some_linter: an info'],
+ \ g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should show all messages is severity is set to "log"):
+ let g:ale_lsp_show_message_severity = 'log'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual [
+ \ 'Error:some_linter: an error',
+ \ 'Warning:some_linter: a warning',
+ \ 'Info:some_linter: an info',
+ \ 'Log:some_linter: a log'],
+ \ g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should not show anything if severity is configured as disabled):
+ let g:ale_lsp_show_message_severity = 'disabled'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual [], g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should use "warning" when severity is set to an invalid value):
+ let g:ale_lsp_show_message_severity = 'foo'
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'})
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'})
+ AssertEqual [
+ \ 'Error:some_linter: an error',
+ \ 'Warning:some_linter: a warning'],
+ \ g:expr_list
+
+Execute(ale#lsp_window#HandleShowMessage() should escape quotes on messages):
+ call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':"this is an 'info'"})
+ AssertEqual ['Info:some_linter: this is an ''info'''], g:expr_list
diff --git a/test/nim-test-files/with-git/src/source.nim b/test/nim-test-files/with-git/src/source.nim
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/nim-test-files/with-git/src/source.nim
diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader
index bb042679..60ae0a83 100644
--- a/test/sign/test_linting_sets_signs.vader
+++ b/test/sign/test_linting_sets_signs.vader
@@ -32,7 +32,7 @@ Before:
function! CollectSigns()
redir => l:output
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
silent exec 'sign place group=ale'
else
silent exec 'sign place'
diff --git a/test/sign/test_sign_parsing.vader b/test/sign/test_sign_parsing.vader
index 8fb7f8e0..157ff2f4 100644
--- a/test/sign/test_sign_parsing.vader
+++ b/test/sign/test_sign_parsing.vader
@@ -1,5 +1,5 @@
Execute (Parsing English signs should work):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[9, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([
@@ -16,7 +16,7 @@ Execute (Parsing English signs should work):
endif
Execute (Parsing Russian signs should work):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[1, 1000001, 'ALEErrorSign']]],
\ ale#sign#ParseSigns([' строка=1 id=1000001 группа=ale имя=ALEErrorSign'])
@@ -27,7 +27,7 @@ Execute (Parsing Russian signs should work):
endif
Execute (Parsing Japanese signs should work):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[1, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([' 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign'])
@@ -38,7 +38,7 @@ Execute (Parsing Japanese signs should work):
endif
Execute (Parsing Spanish signs should work):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[12, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([' línea=12 id=1000001 grupo=ale nombre=ALEWarningSign'])
@@ -49,7 +49,7 @@ Execute (Parsing Spanish signs should work):
endif
Execute (Parsing Italian signs should work):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[1, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([' riga=1 id=1000001, gruppo=ale nome=ALEWarningSign'])
@@ -60,7 +60,7 @@ Execute (Parsing Italian signs should work):
endif
Execute (Parsing German signs should work):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[235, 1000001, 'ALEErrorSign']]],
\ ale#sign#ParseSigns([' Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign'])
@@ -71,7 +71,7 @@ Execute (Parsing German signs should work):
endif
Execute (The sign parser should indicate if the dummy sign is set):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [1, [[1, 1000001, 'ALEErrorSign']]],
\ ale#sign#ParseSigns([
diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader
index 97bd9302..80153b22 100644
--- a/test/sign/test_sign_placement.vader
+++ b/test/sign/test_sign_placement.vader
@@ -68,7 +68,7 @@ Before:
function! ParseSigns()
redir => l:output
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
silent sign place group=ale
else
silent sign place
@@ -152,7 +152,7 @@ Execute(The current signs should be set for running a job):
\ ParseSigns()
Execute(Loclist items with sign_id values should be kept):
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('')
exec 'sign place 1000348 group=ale line=15 name=ALEErrorSign buffer=' . bufnr('')
exec 'sign place 1000349 group=ale line=16 name=ALEWarningSign buffer=' . bufnr('')
@@ -297,7 +297,7 @@ Execute(No exceptions should be thrown when setting signs for invalid buffers):
Execute(Signs should be removed when lines have multiple sign IDs on them):
" We can fail to remove signs if there are multiple signs on one line,
" say after deleting lines in Vim, etc.
- if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
+ if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('')
exec 'sign place 1000348 group=ale line=3 name=ALEWarningSign buffer=' . bufnr('')
exec 'sign place 1000349 group=ale line=10 name=ALEErrorSign buffer=' . bufnr('')
diff --git a/test/test_ale_has.vader b/test/test_ale_has.vader
index b2df01fe..b8a99103 100644
--- a/test/test_ale_has.vader
+++ b/test/test_ale_has.vader
@@ -1,4 +1,5 @@
Execute(Checks for versions below the current version should succeed):
+ AssertEqual 1, ale#Has('ale-2.6.0')
AssertEqual 1, ale#Has('ale-2.5.0')
AssertEqual 1, ale#Has('ale-2.4.0')
AssertEqual 1, ale#Has('ALE-2.2.1')
diff --git a/test/test_nimlsp_project_root.vader b/test/test_nimlsp_project_root.vader
new file mode 100644
index 00000000..e7027575
--- /dev/null
+++ b/test/test_nimlsp_project_root.vader
@@ -0,0 +1,19 @@
+Before:
+ runtime ale_linters/nim/nimlsp.vim
+ call ale#test#SetDirectory('/testplugin/test')
+
+After:
+ if isdirectory(g:dir . '/.git')
+ call delete(g:dir . '/.git', 'd')
+ endif
+
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+
+Execute(Detect root of nim project with .git/ correctly):
+ call ale#test#SetFilename('nim-test-files/with-git/src/source.nim')
+ call mkdir(g:dir . '/.git')
+ AssertEqual
+ \ ale#path#Simplify(g:dir),
+ \ ale_linters#nim#nimlsp#GetProjectRoot(bufnr(''))