Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bartek thindil Jasicki
2019-10-18 18:15:05 +02:00
22 changed files with 371 additions and 19 deletions

View File

@@ -3,9 +3,14 @@
call ale#Set('c_clangd_executable', 'clangd') call ale#Set('c_clangd_executable', 'clangd')
call ale#Set('c_clangd_options', '') call ale#Set('c_clangd_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#c#clangd#GetCommand(buffer) abort 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 endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {

View File

@@ -3,9 +3,14 @@
call ale#Set('cpp_clangd_executable', 'clangd') call ale#Set('cpp_clangd_executable', 'clangd')
call ale#Set('cpp_clangd_options', '') call ale#Set('cpp_clangd_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangd#GetCommand(buffer) abort 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 endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {

View File

@@ -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'),
\})

View File

@@ -5,11 +5,18 @@
" Strings used for severity in the echoed message " 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_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_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') let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
" Ignoring linters, for disabling some, or ignoring LSP diagnostics. " Ignoring linters, for disabling some, or ignoring LSP diagnostics.
let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {}) let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {})
let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0) 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:lint_timer = -1
let s:getcmdwintype_exists = exists('*getcmdwintype') let s:getcmdwintype_exists = exists('*getcmdwintype')
@@ -156,7 +163,7 @@ function! ale#Queue(delay, ...) abort
endif endif
endfunction 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. " A function used to check for ALE features in files outside of the project.
function! ale#Has(feature) abort function! ale#Has(feature) abort

View File

@@ -492,10 +492,17 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort
let l:identifiers = [] let l:identifiers = []
for l:name in l:names for l:name in l:names
call add(l:identifiers, { let l:identifier = {
\ 'name': l:name.word, \ '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 endfor
let b:ale_completion_info.request_id = ale#lsp#Send( let b:ale_completion_info.request_id = ale#lsp#Send(
@@ -722,7 +729,7 @@ endfunction
function! ale#completion#HandleUserData(completed_item) abort function! ale#completion#HandleUserData(completed_item) abort
let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') 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 return
endif endif

View File

@@ -130,6 +130,12 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
call s:HandleLSPErrorMessage(l:linter_name, a:response) call s:HandleLSPErrorMessage(l:linter_name, a:response)
elseif l:method is# 'textDocument/publishDiagnostics' elseif l:method is# 'textDocument/publishDiagnostics'
call s:HandleLSPDiagnostics(a:conn_id, a:response) 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' elseif get(a:response, 'type', '') is# 'event'
\&& get(a:response, 'event', '') is# 'semanticDiag' \&& get(a:response, 'event', '') is# 'semanticDiag'
call s:HandleTSServerDiagnostics(a:response, 'semantic') call s:HandleTSServerDiagnostics(a:response, 'semantic')

View File

@@ -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

25
doc/ale-nim.txt Normal file
View File

@@ -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:

View File

@@ -157,9 +157,9 @@ g:ale_php_phpstan_level *g:ale_php_phpstan_level*
Type: |String| Type: |String|
Default: `''` 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 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. be used instead.

View File

@@ -283,6 +283,7 @@ Notes:
* `nasm`!! * `nasm`!!
* Nim * Nim
* `nim check`!! * `nim check`!!
* `nimlsp`
* nix * nix
* `nix-instantiate` * `nix-instantiate`
* `nixpkgs-fmt` * `nixpkgs-fmt`

View File

@@ -172,7 +172,7 @@ address to connect to instead. >
call ale#linter#Define('filetype_here', { call ale#linter#Define('filetype_here', {
\ 'name': 'any_name_you_want', \ 'name': 'any_name_you_want',
\ 'lsp': 'stdio', \ 'lsp': 'socket',
\ 'address': 'servername:1234', \ 'address': 'servername:1234',
\ 'project_root': '/path/to/root_of_project', \ '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| 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* g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str*
Type: |String| 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. 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* g:ale_lsp_root *g:ale_lsp_root*
b:ale_lsp_root *b:ale_lsp_root* b:ale_lsp_root *b:ale_lsp_root*
@@ -2308,6 +2358,9 @@ documented in additional help files.
mmc...................................|ale-mercury-mmc| mmc...................................|ale-mercury-mmc|
nasm....................................|ale-nasm-options| nasm....................................|ale-nasm-options|
nasm..................................|ale-nasm-nasm| nasm..................................|ale-nasm-nasm|
nim.....................................|ale-nim-options|
nimcheck..............................|ale-nim-nimcheck|
nimlsp................................|ale-nim-nimlsp|
nix.....................................|ale-nix-options| nix.....................................|ale-nix-options|
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
nroff...................................|ale-nroff-options| nroff...................................|ale-nroff-options|

View File

@@ -292,6 +292,7 @@ formatting.
* [nasm](https://www.nasm.us/) :floppy_disk: * [nasm](https://www.nasm.us/) :floppy_disk:
* Nim * Nim
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk: * [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
* [nimlsp](https://github.com/PMunch/nimlsp)
* nix * nix
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
@@ -343,8 +344,8 @@ formatting.
* Pony * Pony
* [ponyc](https://github.com/ponylang/ponyc) * [ponyc](https://github.com/ponylang/ponyc)
* PowerShell * PowerShell
* [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk:
* [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk:
* Prolog * Prolog
* [swipl](https://github.com/SWI-Prolog/swipl-devel) * [swipl](https://github.com/SWI-Prolog/swipl-devel)
* proto * proto

View File

@@ -4,31 +4,52 @@ Before:
Save &filetype Save &filetype
let &filetype = 'c' 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: After:
unlet! b:command_tail
call ale#assert#TearDownLinterTest() call ale#assert#TearDownLinterTest()
Execute(The language string should be correct): Execute(The language string should be correct):
AssertLSPLanguage 'c' AssertLSPLanguage 'c'
Execute(The default executable should be correct): 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): Execute(The project root should be detected correctly):
call ale#test#SetFilename(tempname() . '/dummy.c') call ale#test#SetFilename(tempname() . '/dummy.c')
AssertLSPProject '' 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): Execute(The executable should be configurable):
let g:ale_c_clangd_executable = 'foobar' 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): Execute(The options should be configurable):
let b:ale_c_clangd_options = '-compile-commands-dir=foo' 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'))

View File

@@ -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')

View File

@@ -431,6 +431,12 @@ Execute(HandleUserData should call ale#code_action#HandleCodeAction):
\}) \})
AssertEqual g:handle_code_action_called, 2 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): Execute(ale#code_action#HandleCodeAction should not be called when when source is not ALE):
call MockHandleCodeAction() call MockHandleCodeAction()
let b:ale_completion_info = {'source': 'syntastic'} let b:ale_completion_info = {'source': 'syntastic'}

View File

@@ -190,10 +190,8 @@ Execute(The right message sent to the tsserver LSP when the first completion mes
\ 'source': '/path/to/foo.ts', \ 'source': '/path/to/foo.ts',
\ }, { \ }, {
\ 'name': 'FooBar', \ 'name': 'FooBar',
\ 'source': '',
\ }, { \ }, {
\ 'name': 'frazzle', \ 'name': 'frazzle',
\ 'source': '',
\ }], \ }],
\ 'offset': 1, \ 'offset': 1,
\ 'line': 1, \ 'line': 1,

View File

@@ -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

View File

@@ -1,4 +1,5 @@
Execute(Checks for versions below the current version should succeed): 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.5.0')
AssertEqual 1, ale#Has('ale-2.4.0') AssertEqual 1, ale#Has('ale-2.4.0')
AssertEqual 1, ale#Has('ALE-2.2.1') AssertEqual 1, ale#Has('ALE-2.2.1')

View File

@@ -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(''))