mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-22 02:52:14 +08:00
Merge branch 'master' into do-not-save-on-autoimport
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
58
autoload/ale/lsp_window.vim
Normal file
58
autoload/ale/lsp_window.vim
Normal 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
|
||||
@@ -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 *
|
||||
|
||||
Reference in New Issue
Block a user