Merge pull request #3362 from daliusd/tsserver_hints
Show tsserver hints/suggestions in Ale.
This commit is contained in:
commit
783cf4ab82
3 changed files with 50 additions and 2 deletions
|
@ -85,12 +85,18 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
|||
endif
|
||||
|
||||
let l:info.syntax_loclist = l:thislist
|
||||
else
|
||||
elseif a:error_type is# 'semantic'
|
||||
if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0
|
||||
let l:no_changes = 1
|
||||
endif
|
||||
|
||||
let l:info.semantic_loclist = l:thislist
|
||||
else
|
||||
if len(l:thislist) is 0 && len(get(l:info, 'suggestion_loclist', [])) is 0
|
||||
let l:no_changes = 1
|
||||
endif
|
||||
|
||||
let l:info.suggestion_loclist = l:thislist
|
||||
endif
|
||||
|
||||
if l:no_changes
|
||||
|
@ -98,6 +104,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
|||
endif
|
||||
|
||||
let l:loclist = get(l:info, 'semantic_loclist', [])
|
||||
\ + get(l:info, 'suggestion_loclist', [])
|
||||
\ + get(l:info, 'syntax_loclist', [])
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
|
||||
|
@ -150,6 +157,10 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
|
|||
elseif get(a:response, 'type', '') is# 'event'
|
||||
\&& get(a:response, 'event', '') is# 'syntaxDiag'
|
||||
call s:HandleTSServerDiagnostics(a:response, 'syntax')
|
||||
elseif get(a:response, 'type', '') is# 'event'
|
||||
\&& get(a:response, 'event', '') is# 'suggestionDiag'
|
||||
\&& get(g:, 'ale_lsp_suggestions', '1') == 1
|
||||
call s:HandleTSServerDiagnostics(a:response, 'suggestion')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -1708,6 +1708,15 @@ g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity*
|
|||
`'disabled'` - Doesn't display any information at all.
|
||||
|
||||
|
||||
g:ale_lsp_suggestions *g:ale_lsp_suggestions*
|
||||
|
||||
Type: |Number|
|
||||
Default: 1
|
||||
|
||||
This variable defines if suggestions must be collected from LSP or tsserver
|
||||
and shown.
|
||||
|
||||
|
||||
g:ale_lsp_root *g:ale_lsp_root*
|
||||
*b:ale_lsp_root*
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ Execute(An initial list of semantic errors should be handled):
|
|||
|
||||
Assert g:ale_handle_loclist_called
|
||||
|
||||
Execute(Subsequent empty lists should be ignored):
|
||||
Execute(Subsequent empty lists should be ignored - semantic):
|
||||
let g:ale_buffer_info[bufnr('')].semantic_loclist = []
|
||||
|
||||
call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', ''))
|
||||
|
@ -138,3 +138,31 @@ Execute(Non-empty then non-empty semantic errors should be handled):
|
|||
call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', 'x'))
|
||||
|
||||
Assert g:ale_handle_loclist_called
|
||||
|
||||
Execute(Subsequent empty lists should be ignored - suggestion):
|
||||
let g:ale_buffer_info[bufnr('')].suggestion_loclist = []
|
||||
|
||||
call ale#lsp_linter#HandleLSPResponse(1, CreateError('suggestionDiag', ''))
|
||||
|
||||
Assert !g:ale_handle_loclist_called
|
||||
|
||||
Execute(Empty then non-empty suggestion messages should be handled):
|
||||
let g:ale_buffer_info[bufnr('')].suggestion_loclist = []
|
||||
|
||||
call ale#lsp_linter#HandleLSPResponse(1, CreateError('suggestionDiag', 'x'))
|
||||
|
||||
Assert g:ale_handle_loclist_called
|
||||
|
||||
Execute(Non-empty then empt suggestion messages should be handled):
|
||||
let g:ale_buffer_info[bufnr('')].suggestion_loclist = CreateLoclist('x')
|
||||
|
||||
call ale#lsp_linter#HandleLSPResponse(1, CreateError('suggestionDiag', ''))
|
||||
|
||||
Assert g:ale_handle_loclist_called
|
||||
|
||||
Execute(Non-empty then non-empty suggestion messages should be handled):
|
||||
let g:ale_buffer_info[bufnr('')].suggestion_loclist = CreateLoclist('x')
|
||||
|
||||
call ale#lsp_linter#HandleLSPResponse(1, CreateError('suggestionDiag', 'x'))
|
||||
|
||||
Assert g:ale_handle_loclist_called
|
||||
|
|
Reference in a new issue