mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Diagnostics signs revamp (#994)
This commit is contained in:
15
README.md
15
README.md
@@ -144,21 +144,6 @@ preferred to turn them off and use other plugins instead (like
|
||||
let g:lsp_diagnostics_enabled = 0 " disable diagnostics support
|
||||
```
|
||||
|
||||
#### Signs
|
||||
|
||||
```viml
|
||||
let g:lsp_signs_enabled = 1 " enable signs
|
||||
let g:lsp_diagnostics_echo_cursor = 1 " enable echo under cursor when in normal mode
|
||||
```
|
||||
|
||||
Four groups of signs are defined and used: `LspError`, `LspWarning`, `LspInformation`, `LspHint`. It is possible to set custom text or icon that will be used for each sign (note that icons are only available in GUI). To do this, set some of the following globals: `g:lsp_signs_error`, `g:lsp_signs_warning`, `g:lsp_signs_information`, `g:lsp_signs_hint`. They should be set to a dict, that contains either text that will be used as sign in terminal, or icon that will be used for GUI, or both. For example:
|
||||
|
||||
```viml
|
||||
let g:lsp_signs_error = {'text': '✗'}
|
||||
let g:lsp_signs_warning = {'text': '‼', 'icon': '/path/to/some/icon'} " icons require GUI
|
||||
let g:lsp_signs_hint = {'icon': '/path/to/some/other/icon'} " icons require GUI
|
||||
```
|
||||
|
||||
#### Highlights
|
||||
|
||||
Highlighting diagnostics requires either NeoVim 0.3+ or Vim with patch 8.1.0579.
|
||||
|
||||
@@ -55,7 +55,6 @@ function! lsp#enable() abort
|
||||
endif
|
||||
let s:enabled = 1
|
||||
if g:lsp_diagnostics_enabled
|
||||
if g:lsp_signs_enabled | call lsp#ui#vim#signs#enable() | endif
|
||||
if g:lsp_highlights_enabled | call lsp#ui#vim#highlights#enable() | endif
|
||||
if g:lsp_textprop_enabled | call lsp#ui#vim#diagnostics#textprop#enable() | endif
|
||||
endif
|
||||
@@ -73,7 +72,6 @@ function! lsp#disable() abort
|
||||
if !s:enabled
|
||||
return
|
||||
endif
|
||||
call lsp#ui#vim#signs#disable()
|
||||
call lsp#ui#vim#highlights#disable()
|
||||
call lsp#ui#vim#diagnostics#textprop#disable()
|
||||
call lsp#ui#vim#signature_help#_disable()
|
||||
|
||||
@@ -5,6 +5,7 @@ function! lsp#internal#diagnostics#_enable() abort
|
||||
call lsp#internal#diagnostics#state#_enable() " Needs to be the first one to register
|
||||
call lsp#internal#diagnostics#echo#_enable()
|
||||
call lsp#internal#diagnostics#float#_enable()
|
||||
call lsp#internal#diagnostics#signs#_enable()
|
||||
call lsp#internal#diagnostics#virtual_text#_enable()
|
||||
endfunction
|
||||
|
||||
@@ -12,5 +13,6 @@ function! lsp#internal#diagnostics#_disable() abort
|
||||
call lsp#internal#diagnostics#echo#_disable()
|
||||
call lsp#internal#diagnostics#float#_disable()
|
||||
call lsp#internal#diagnostics#virtual_text#_disable()
|
||||
call lsp#internal#diagnostics#signs#_disable()
|
||||
call lsp#internal#diagnostics#state#_disable() " Needs to be the last one to unregister
|
||||
endfunction
|
||||
|
||||
142
autoload/lsp/internal/diagnostics/signs.vim
Normal file
142
autoload/lsp/internal/diagnostics/signs.vim
Normal file
@@ -0,0 +1,142 @@
|
||||
" internal state for whether it is enabled or not to avoid multiple subscriptions
|
||||
let s:enabled = 0
|
||||
let s:sign_group = 'vim_lsp'
|
||||
|
||||
let s:severity_sign_names_mapping = {
|
||||
\ 1: 'LspError',
|
||||
\ 2: 'LspWarning',
|
||||
\ 3: 'LspInformation',
|
||||
\ 4: 'LspHint',
|
||||
\ }
|
||||
|
||||
if !hlexists('LspErrorText')
|
||||
highlight link LspErrorText Error
|
||||
endif
|
||||
|
||||
if !hlexists('LspWarningText')
|
||||
highlight link LspWarningText Todo
|
||||
endif
|
||||
|
||||
if !hlexists('LspInformationText')
|
||||
highlight link LspInformationText Normal
|
||||
endif
|
||||
|
||||
if !hlexists('LspHintText')
|
||||
highlight link LspHintText Normal
|
||||
endif
|
||||
|
||||
function! lsp#internal#diagnostics#signs#_enable() abort
|
||||
" don't even bother registering if the feature is disabled
|
||||
if !lsp#utils#_has_signs() | return | endif
|
||||
if !g:lsp_diagnostics_signs_enabled | return | endif
|
||||
|
||||
if s:enabled | return | endif
|
||||
let s:enabled = 1
|
||||
|
||||
call s:define_sign('LspError', 'E>', g:lsp_diagnostics_signs_error)
|
||||
call s:define_sign('LspWarning', 'W>', g:lsp_diagnostics_signs_warning)
|
||||
call s:define_sign('LspInformation', 'I>', g:lsp_diagnostics_signs_information)
|
||||
call s:define_sign('LspHint', 'H>', g:lsp_diagnostics_signs_hint)
|
||||
|
||||
let s:Dispose = lsp#callbag#pipe(
|
||||
\ lsp#callbag#merge(
|
||||
\ lsp#callbag#pipe(
|
||||
\ lsp#stream(),
|
||||
\ lsp#callbag#filter({x->has_key(x, 'server') && has_key(x, 'response')
|
||||
\ && has_key(x['response'], 'method') && x['response']['method'] ==# '$/vimlsp/lsp_diagnostics_updated'
|
||||
\ && !lsp#client#is_error(x['response'])}),
|
||||
\ lsp#callbag#map({x->x['response']['params']}),
|
||||
\ ),
|
||||
\ lsp#callbag#pipe(
|
||||
\ lsp#callbag#fromEvent(['InsertEnter', 'InsertLeave']),
|
||||
\ lsp#callbag#filter({_->!g:lsp_diagnostics_signs_insert_mode_enabled}),
|
||||
\ lsp#callbag#map({_->{ 'uri': lsp#utils#get_buffer_uri() }}),
|
||||
\ ),
|
||||
\ ),
|
||||
\ lsp#callbag#filter({_->g:lsp_diagnostics_signs_enabled}),
|
||||
\ lsp#callbag#debounceTime(g:lsp_diagnostics_signs_delay),
|
||||
\ lsp#callbag#tap({x->s:clear_signs(x)}),
|
||||
\ lsp#callbag#tap({x->s:set_signs(x)}),
|
||||
\ lsp#callbag#subscribe(),
|
||||
\ )
|
||||
endfunction
|
||||
|
||||
function! lsp#internal#diagnostics#signs#_disable() abort
|
||||
if !s:enabled | return | endif
|
||||
if exists('s:Dispose')
|
||||
call s:Dispose()
|
||||
unlet s:Dispose
|
||||
endif
|
||||
call s:clear_all_signs()
|
||||
call s:undefine_signs()
|
||||
let s:enabled = 0
|
||||
endfunction
|
||||
|
||||
" Set default sign text to handle case when user provides empty dict
|
||||
function! s:define_sign(sign_name, sign_default_text, sign_options) abort
|
||||
let l:options = {
|
||||
\ 'text': get(a:sign_options, 'text', a:sign_default_text),
|
||||
\ 'texthl': a:sign_name . 'Text',
|
||||
\ 'linehl': a:sign_name . 'Line',
|
||||
\ }
|
||||
let l:sign_icon = get(a:sign_options, 'icon', '')
|
||||
if !empty(l:sign_icon)
|
||||
let l:options['icon'] = l:sign_icon
|
||||
endif
|
||||
call sign_define(a:sign_name, l:options)
|
||||
endfunction
|
||||
|
||||
function! s:undefine_signs() abort
|
||||
call sign_undefine('LspError')
|
||||
call sign_undefine('LspWarning')
|
||||
call sign_undefine('LspInformation')
|
||||
call sign_undefine('LspHint')
|
||||
endfunction
|
||||
|
||||
function! s:clear_all_signs() abort
|
||||
call sign_unplace(s:sign_group)
|
||||
endfunction
|
||||
|
||||
" params => {
|
||||
" server: '' " optional
|
||||
" uri: '' " optional
|
||||
" }
|
||||
function! s:clear_signs(params) abort
|
||||
" TODO: optimize by looking at params
|
||||
call s:clear_all_signs()
|
||||
endfunction
|
||||
|
||||
" params => {
|
||||
" server: '' " optional
|
||||
" uri: '' " optional
|
||||
" }
|
||||
function! s:set_signs(params) abort
|
||||
" TODO: optimize by looking at params
|
||||
if !g:lsp_diagnostics_signs_insert_mode_enabled
|
||||
if mode()[0] ==# 'i' | return | endif
|
||||
endif
|
||||
|
||||
for l:bufnr in range(1, bufnr('$'))
|
||||
if lsp#internal#diagnostics#state#_is_enabled_for_buffer(l:bufnr) && bufexists(l:bufnr) && bufloaded(l:bufnr)
|
||||
let l:uri = lsp#utils#get_buffer_uri(l:bufnr)
|
||||
for [l:server, l:diagnostics_response] in items(lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(l:uri))
|
||||
call s:place_signs(l:server, l:diagnostics_response, l:bufnr)
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:place_signs(server, diagnostics_response, bufnr) abort
|
||||
for l:item in a:diagnostics_response['params']['diagnostics']
|
||||
let l:line = lsp#utils#position#lsp_line_to_vim(a:bufnr, l:item['range']['start'])
|
||||
if has_key(l:item, 'severity') && !empty(l:item['severity'])
|
||||
let l:sign_name = get(s:severity_sign_names_mapping, l:item['severity'], 'LspError')
|
||||
let l:sign_priority = get(g:lsp_diagnostics_signs_priority_map, l:sign_name, g:lsp_diagnostics_signs_priority)
|
||||
let l:sign_priority = get(g:lsp_diagnostics_signs_priority_map,
|
||||
\ a:server . '_' . l:sign_name, l:sign_priority)
|
||||
" pass 0 and let vim generate sign id
|
||||
let l:sign_id = sign_place(0, s:sign_group, l:sign_name, a:bufnr,
|
||||
\{ 'lnum': l:line, 'priority': l:sign_priority })
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
@@ -113,8 +113,8 @@ function! s:set_virtual_text(params) abort
|
||||
endif
|
||||
|
||||
for l:bufnr in nvim_list_bufs()
|
||||
let l:uri = lsp#utils#get_buffer_uri(l:bufnr)
|
||||
if lsp#internal#diagnostics#state#_is_enabled_for_buffer(l:uri) && bufexists(l:bufnr) && bufloaded(l:bufnr)
|
||||
if lsp#internal#diagnostics#state#_is_enabled_for_buffer(l:bufnr) && bufexists(l:bufnr) && bufloaded(l:bufnr)
|
||||
let l:uri = lsp#utils#get_buffer_uri(l:bufnr)
|
||||
for [l:server, l:diagnostics_response] in items(lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(l:uri))
|
||||
call s:place_virtual_text(l:server, l:diagnostics_response, l:bufnr)
|
||||
endfor
|
||||
@@ -124,6 +124,7 @@ endfunction
|
||||
|
||||
function! s:place_virtual_text(server, diagnostics_response, bufnr) abort
|
||||
for l:item in a:diagnostics_response['params']['diagnostics']
|
||||
" need to do -1 for virtual text
|
||||
let l:line = lsp#utils#position#lsp_line_to_vim(a:bufnr, l:item['range']['start']) - 1
|
||||
let l:name = get(s:severity_sign_names_mapping, get(l:item, 'severity', 3), 'LspError')
|
||||
let l:hl_name = l:name . 'VirtualText'
|
||||
|
||||
@@ -14,7 +14,6 @@ function! lsp#ui#vim#diagnostics#handle_text_document_publish_diagnostics(server
|
||||
|
||||
call lsp#ui#vim#highlights#set(a:server_name, a:data)
|
||||
call lsp#ui#vim#diagnostics#textprop#set(a:server_name, a:data)
|
||||
call lsp#ui#vim#signs#set(a:server_name, a:data)
|
||||
|
||||
doautocmd <nomodeline> User lsp_diagnostics_updated
|
||||
endfunction
|
||||
@@ -25,7 +24,6 @@ function! lsp#ui#vim#diagnostics#force_refresh(bufnr) abort
|
||||
for [l:server_name, l:response] in items(l:data)
|
||||
call lsp#ui#vim#highlights#set(l:server_name, l:response)
|
||||
call lsp#ui#vim#diagnostics#textprop#set(l:server_name, l:response)
|
||||
call lsp#ui#vim#signs#set(l:server_name, l:response)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
" TODO: handle !has('signs')
|
||||
" TODO: handle signs clearing when server exits
|
||||
" https://github.com/vim/vim/pull/3652
|
||||
let s:supports_signs = exists('*sign_define') && (has('nvim') || has('patch-8.1.0772'))
|
||||
let s:enabled = 0
|
||||
let s:signs = {} " { server_name: { path: {} } }
|
||||
let s:severity_sign_names_mapping = {
|
||||
\ 1: 'LspError',
|
||||
\ 2: 'LspWarning',
|
||||
\ 3: 'LspInformation',
|
||||
\ 4: 'LspHint',
|
||||
\ }
|
||||
|
||||
if !hlexists('LspErrorText')
|
||||
highlight link LspErrorText Error
|
||||
endif
|
||||
|
||||
if !hlexists('LspWarningText')
|
||||
highlight link LspWarningText Todo
|
||||
endif
|
||||
|
||||
if !hlexists('LspInformationText')
|
||||
highlight link LspInformationText Normal
|
||||
endif
|
||||
|
||||
if !hlexists('LspHintText')
|
||||
highlight link LspHintText Normal
|
||||
endif
|
||||
|
||||
function! lsp#ui#vim#signs#enable() abort
|
||||
if !s:supports_signs
|
||||
call lsp#log('vim-lsp signs requires patch-8.1.0772')
|
||||
return
|
||||
endif
|
||||
if !s:enabled
|
||||
call s:define_signs()
|
||||
let s:enabled = 1
|
||||
call lsp#log('vim-lsp signs enabled')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Set default sign text to handle case when user provides empty dict
|
||||
function! s:add_sign(sign_name, sign_default_text, sign_options) abort
|
||||
if !s:supports_signs | return | endif
|
||||
let l:options = {
|
||||
\ 'text': get(a:sign_options, 'text', a:sign_default_text),
|
||||
\ 'texthl': a:sign_name . 'Text',
|
||||
\ 'linehl': a:sign_name . 'Line',
|
||||
\ }
|
||||
let l:sign_icon = get(a:sign_options, 'icon', '')
|
||||
if !empty(l:sign_icon)
|
||||
let l:options['icon'] = l:sign_icon
|
||||
endif
|
||||
call sign_define(a:sign_name, l:options)
|
||||
endfunction
|
||||
|
||||
function! s:define_signs() abort
|
||||
if !s:supports_signs | return | endif
|
||||
" let vim handle errors/duplicate instead of us maintaining the state
|
||||
call s:add_sign('LspError', 'E>', g:lsp_signs_error)
|
||||
call s:add_sign('LspWarning', 'W>', g:lsp_signs_warning)
|
||||
call s:add_sign('LspInformation', 'I>', g:lsp_signs_information)
|
||||
call s:add_sign('LspHint', 'H>', g:lsp_signs_hint)
|
||||
endfunction
|
||||
|
||||
function! lsp#ui#vim#signs#disable() abort
|
||||
if s:enabled
|
||||
call s:clear_all_signs()
|
||||
call s:undefine_signs()
|
||||
let s:enabled = 0
|
||||
call lsp#log('vim-lsp signs disabled')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:clear_all_signs() abort
|
||||
if !s:supports_signs | return | endif
|
||||
for l:server_name in lsp#get_server_names()
|
||||
let l:sign_group = s:get_sign_group(l:server_name)
|
||||
call sign_unplace(l:sign_group)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:undefine_signs() abort
|
||||
if !s:supports_signs | return | endif
|
||||
call sign_undefine('LspError')
|
||||
call sign_undefine('LspWarning')
|
||||
call sign_undefine('LspInformation')
|
||||
call sign_undefine('LspHint')
|
||||
endfunction
|
||||
|
||||
function! lsp#ui#vim#signs#set(server_name, data) abort
|
||||
if !s:supports_signs | return | endif
|
||||
if !s:enabled | return | endif
|
||||
|
||||
if lsp#client#is_error(a:data['response'])
|
||||
return
|
||||
endif
|
||||
|
||||
let l:uri = a:data['response']['params']['uri']
|
||||
let l:diagnostics = a:data['response']['params']['diagnostics']
|
||||
|
||||
let l:path = lsp#utils#uri_to_path(l:uri)
|
||||
|
||||
" will always replace existing set
|
||||
call s:clear_signs(a:server_name, l:path)
|
||||
call s:place_signs(a:server_name, l:path, l:diagnostics)
|
||||
endfunction
|
||||
|
||||
function! s:clear_signs(server_name, path) abort
|
||||
if !s:supports_signs || !bufloaded(a:path) | return | endif
|
||||
let l:sign_group = s:get_sign_group(a:server_name)
|
||||
call sign_unplace(l:sign_group, { 'buffer': a:path })
|
||||
endfunction
|
||||
|
||||
function! s:get_sign_group(server_name) abort
|
||||
return 'vim_lsp_' . a:server_name
|
||||
endfunction
|
||||
|
||||
function! s:place_signs(server_name, path, diagnostics) abort
|
||||
if !s:supports_signs | return | endif
|
||||
|
||||
let l:sign_group = s:get_sign_group(a:server_name)
|
||||
|
||||
if !empty(a:diagnostics) && bufnr(a:path) >= 0
|
||||
for l:item in a:diagnostics
|
||||
let l:line = l:item['range']['start']['line'] + 1
|
||||
|
||||
if has_key(l:item, 'severity') && !empty(l:item['severity'])
|
||||
let l:sign_name = get(s:severity_sign_names_mapping, l:item['severity'], 'LspError')
|
||||
let l:sign_priority = get(g:lsp_signs_priority_map, l:sign_name, g:lsp_signs_priority)
|
||||
let l:sign_priority = get(g:lsp_signs_priority_map,
|
||||
\a:server_name . '_' . l:sign_name, l:sign_priority)
|
||||
" pass 0 and let vim generate sign id
|
||||
let l:sign_id = sign_place(0, l:sign_group, l:sign_name, a:path,
|
||||
\{ 'lnum': l:line, 'priority': l:sign_priority })
|
||||
call lsp#log('add signs', l:sign_id)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
" vim sw=4 ts=4 et
|
||||
@@ -3,6 +3,11 @@ function! lsp#utils#_has_virtual_text() abort
|
||||
return s:has_virtual_text
|
||||
endfunction
|
||||
|
||||
let s:has_signs = exists('*sign_define') && (has('nvim') || has('patch-8.1.0772'))
|
||||
function! lsp#utils#_has_signs() abort
|
||||
return s:has_signs
|
||||
endfunction
|
||||
|
||||
function! lsp#utils#is_file_uri(uri) abort
|
||||
return stridx(a:uri, 'file:///') == 0
|
||||
endfunction
|
||||
|
||||
113
doc/vim-lsp.txt
113
doc/vim-lsp.txt
@@ -12,7 +12,6 @@ CONTENTS *vim-lsp-contents*
|
||||
vim-lsp-settings |vim-lsp-settings_plugin|
|
||||
Wiki |vim-lsp-configure-wiki|
|
||||
Options |vim-lsp-options|
|
||||
g:lsp_diagnostics_enabled |g:lsp_diagnostics_enabled|
|
||||
g:lsp_auto_enable |g:lsp_auto_enable|
|
||||
g:lsp_preview_keep_focus |g:lsp_preview_keep_focus|
|
||||
g:lsp_preview_float |g:lsp_preview_float|
|
||||
@@ -25,10 +24,18 @@ CONTENTS *vim-lsp-contents*
|
||||
g:lsp_documentation_float_docked |g:lsp_documentation_float_docked|
|
||||
g:lsp_documentation_float_docked_maxheight
|
||||
|g:lsp_documentation_float_docked_maxheight|
|
||||
g:lsp_diagnostics_enabled |g:lsp_diagnostics_enabled|
|
||||
g:lsp_diagnostics_echo_cursor |g:lsp_diagnostics_echo_cursor|
|
||||
g:lsp_diagnostics_echo_delay |g:lsp_diagnostics_echo_delay|
|
||||
g:lsp_diagnostics_float_cursor |g:lsp_diagnostics_float_cursor|
|
||||
g:lsp_diagnostics_float_delay |g:lsp_diagnostics_float_delay|
|
||||
g:lsp_diagnostics_signs_enabled |g:lsp_diagnostics_signs_enabled|
|
||||
g:lsp_diagnostics_signs_insert_mode_enabled
|
||||
|g:lsp_diagnostics_signs_insert_mode_enabled|
|
||||
g:lsp_diagnostics_signs_delay |g:lsp_diagnostics_signs_delay|
|
||||
g:lsp_diagnostics_signs_priority |g:lsp_diagnostics_signs_priority|
|
||||
g:lsp_diagnostics_signs_priority_map
|
||||
|g:lsp_diagnostics_signs_priority_map|
|
||||
g:lsp_diagnostics_virtual_text_enabled
|
||||
|g:lsp_diagnostics_virtual_text_enabled|
|
||||
g:lsp_diagnostics_virtual_text_insert_mode_enabled
|
||||
@@ -38,9 +45,6 @@ CONTENTS *vim-lsp-contents*
|
||||
g:lsp_diagnostics_virtual_text_prefix
|
||||
|g:lsp_diagnostics_virtual_text_prefix|
|
||||
g:lsp_format_sync_timeout |g:lsp_format_sync_timeout|
|
||||
g:lsp_signs_enabled |g:lsp_signs_enabled|
|
||||
g:lsp_signs_priority |g:lsp_signs_priority|
|
||||
g:lsp_signs_priority_map |g:lsp_signs_priority_map|
|
||||
g:lsp_highlights_enabled |g:lsp_highlights_enabled|
|
||||
g:lsp_textprop_enabled |g:lsp_textprop_enabled|
|
||||
g:lsp_use_event_queue |g:lsp_use_event_queue|
|
||||
@@ -242,18 +246,6 @@ to https://github.com/prabirshrestha/vim-lsp/wiki/Servers
|
||||
==============================================================================
|
||||
Options *vim-lsp-options*
|
||||
|
||||
g:lsp_diagnostics_enabled *g:lsp_diagnostics_enabled*
|
||||
Type: |Number|
|
||||
Default: `1`
|
||||
|
||||
Enable support for document diagnostics like warnings and error messages.
|
||||
enabling vim-lsp during startup. Refer to |g:lsp_signs_enabled| to enable
|
||||
signs column.
|
||||
|
||||
Example: >
|
||||
let g:lsp_diagnostics_enabled = 1
|
||||
let g:lsp_diagnostics_enabled = 0
|
||||
|
||||
g:lsp_auto_enable *g:lsp_auto_enable*
|
||||
Type: |Number|
|
||||
Default: `1`
|
||||
@@ -427,7 +419,8 @@ g:lsp_documentation_float_docked *g:lsp_documentation_float_docked
|
||||
let g:lsp_documentation_float_docked = 1
|
||||
let g:lsp_documentation_float_docked = 0
|
||||
|
||||
g:lsp_documentation_float_docked_maxheight *g:lsp_documentation_float_docked_maxheight*
|
||||
g:lsp_documentation_float_docked_maxheight
|
||||
*g:lsp_documentation_float_docked_maxheight*
|
||||
Type: |Number|
|
||||
Default: `&previewheight`
|
||||
|
||||
@@ -437,6 +430,19 @@ g:lsp_documentation_float_docked_maxheight *g:lsp_documentation_float_docked
|
||||
let g:lsp_documentation_float_docked_maxheight = 1
|
||||
let g:lsp_documentation_float_docked_maxheight = 0
|
||||
|
||||
g:lsp_diagnostics_enabled *g:lsp_diagnostics_enabled*
|
||||
Type: |Number|
|
||||
Default: `1`
|
||||
|
||||
Enable support for document diagnostics like warnings and error messages.
|
||||
enabling vim-lsp during startup.
|
||||
Refer to |g:lsp_diagnostics_signs_enabled| to enable signs column.
|
||||
Refer to |g:lsp_diagnostics_virtual_text_enabled| to enable virtual text.
|
||||
|
||||
Example: >
|
||||
let g:lsp_diagnostics_enabled = 1
|
||||
let g:lsp_diagnostics_enabled = 0
|
||||
<
|
||||
g:lsp_diagnostics_echo_cursor *g:lsp_diagnostics_echo_cursor*
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
@@ -497,38 +503,79 @@ g:lsp_format_sync_timeout *g:lsp_format_sync_timeout*
|
||||
let g:lsp_format_sync_timeout = -1
|
||||
let g:lsp_format_sync_timeout = 1000
|
||||
|
||||
g:lsp_signs_enabled *g:lsp_signs_enabled*
|
||||
g:lsp_diagnostics_signs_enabled
|
||||
*g:lsp_diagnostics_signs_enabled*
|
||||
Type: |Number|
|
||||
Default: `1` for vim/neovim with patch 8.1.0772
|
||||
|
||||
Enables signs for diagnostics. Requires patch 8.1.0772 and
|
||||
|g:lsp_diagnostics_enabled| set to 1.
|
||||
Enables signs for diagnostics. Requires NeoVim with |sign_define| or Vim
|
||||
with |sign_define| and patch 8.1.0772 or newer and
|
||||
|g:lsp_diagnostics_enabled| set to `1`.
|
||||
|
||||
Example: >
|
||||
let g:lsp_signs_enabled = 1
|
||||
let g:lsp_signs_enabled = 0
|
||||
let g:lsp_diagnostics_signs_enabled = 1
|
||||
let g:lsp_diagnostics_signs_enabled = 0
|
||||
<
|
||||
Four groups of signs are defined and used:
|
||||
`LspError`, `LspWarning`, `LspInformation`, `LspHint`.
|
||||
|
||||
g:lsp_signs_priority *g:lsp_signs_priority*
|
||||
It is possible to set custom text or icon that will be used for each sign
|
||||
(note that icons are only available in GUI). To do this, set some of the
|
||||
following globals:
|
||||
`g:lsp_diagnostics_signs_error`, `g:lsp_diagnostics_signs_warning`,
|
||||
`g:lsp_diagnostics_signs_information`, `g:lsp_diagnostics_signs_hint`.
|
||||
They should be set to a dict, that contains either text that will be used
|
||||
as sign in terminal, or icon that will be used for GUI, or both.
|
||||
|
||||
Example: >
|
||||
let g:lsp_diagnostics_signs_error = {'text': '✗'}
|
||||
let g:lsp_diagnostics_signs_warning = {'text': '‼', 'icon': '/path/to/some/icon'} " icons require GUI
|
||||
let g:lsp_diagnostics_signs_hint = {'icon': '/path/to/some/other/icon'} " icons require GUI
|
||||
|
||||
g:lsp_diagnostics_signs_insert_mode_enabled
|
||||
*g:lsp_diagnostics_signs_insert_mode_enabled*
|
||||
Type: |Number|
|
||||
Default: `10` for vim/neovim with patch 8.1.0772
|
||||
Default: `1`
|
||||
|
||||
Indicates whether to enable diagnostics signs column when in |insertmode|.
|
||||
Requires |g:lsp_diagnostics_signs_enabled|.
|
||||
|
||||
Example: >
|
||||
let g:lsp_diagnostics_signs_insert_mode_enabled = 1
|
||||
let g:lsp_diagnostics_signs_insert_mode_enabled = 0
|
||||
|
||||
g:lsp_diagnostics_signs_delay *g:lsp_diagnostics_signs_delay*
|
||||
Type: |Number|
|
||||
Default: `500`
|
||||
|
||||
Delay milliseconds to update diagnostics signs column. Requires
|
||||
|g:lsp_diagnostics_signs_enabled|.
|
||||
|
||||
Example: >
|
||||
let g:lsp_diagnostics_signs_delay = 200
|
||||
let g:lsp_diagnostics_signs_delay = 1000
|
||||
|
||||
g:lsp_diagnostics_signs_priority *g:lsp_diagnostics_signs_priority*
|
||||
Type: |Number|
|
||||
Default: `10`
|
||||
|
||||
Configures the |sign-priority| for placed signs. Signs placed by other
|
||||
plugins have a priority of 10 by default. Requires |g:lsp_signs_enabled|
|
||||
set to 1.
|
||||
plugins have a priority of 10 by default. Requires
|
||||
|g:lsp_diagnostics_signs_enabled| set to 1.
|
||||
|
||||
Example: >
|
||||
let g:lsp_signs_priority = 11
|
||||
let g:lsp_signs_priority = 9
|
||||
let g:lsp_diagnostics_signs_priority = 11
|
||||
let g:lsp_diagnostics_signs_priority = 9
|
||||
|
||||
g:lsp_signs_priority_map *g:lsp_signs_priority_map*
|
||||
g:lsp_diagnostics_signs_priority_map *g:lsp_diagnostics_signs_priority_map*
|
||||
Type: |Dict|
|
||||
Default: `{}` for vim/neovim with patch 8.1.0772
|
||||
Default: `{}`
|
||||
|
||||
Overrides |g:lsp_signs_priority| per severity level or per server name
|
||||
and severity level. Requires |g:lsp_signs_enabled| set to 1.
|
||||
Overrides |g:lsp_diagnostics_signs_priority| per severity level or per server
|
||||
name and severity level. Requires |g:lsp_diagnostics_signs_enabled| set to 1.
|
||||
|
||||
Example: >
|
||||
let g:lsp_signs_priority_map = {
|
||||
let g:lsp_diagnostics_signs_priority_map = {
|
||||
\'LspError': 11,
|
||||
\'LspWarning': 7,
|
||||
\'clangd_LspWarning': 11,
|
||||
|
||||
@@ -10,15 +10,8 @@ let g:lsp_log_file = get(g:, 'lsp_log_file', '')
|
||||
let g:lsp_log_verbose = get(g:, 'lsp_log_verbose', 1)
|
||||
let g:lsp_debug_servers = get(g:, 'lsp_debug_servers', [])
|
||||
let g:lsp_format_sync_timeout = get(g:, 'lsp_format_sync_timeout', -1)
|
||||
let g:lsp_signs_enabled = get(g:, 'lsp_signs_enabled', exists('*sign_define') && (has('nvim') || has('patch-8.1.0772')))
|
||||
let g:lsp_highlights_enabled = get(g:, 'lsp_highlights_enabled', exists('*nvim_buf_add_highlight'))
|
||||
let g:lsp_textprop_enabled = get(g:, 'lsp_textprop_enabled', exists('*prop_add') && !g:lsp_highlights_enabled)
|
||||
let g:lsp_signs_error = get(g:, 'lsp_signs_error', {})
|
||||
let g:lsp_signs_warning = get(g:, 'lsp_signs_warning', {})
|
||||
let g:lsp_signs_information = get(g:, 'lsp_signs_information', {})
|
||||
let g:lsp_signs_hint = get(g:, 'lsp_signs_hint', {})
|
||||
let g:lsp_signs_priority = get(g:, 'lsp_signs_priority', 10)
|
||||
let g:lsp_signs_priority_map = get(g:, 'lsp_signs_priority_map', {})
|
||||
let g:lsp_documentation_debounce = get(g:, 'lsp_documentation_debounce', 80)
|
||||
let g:lsp_documentation_float = get(g:, 'lsp_documentation_float', 1)
|
||||
let g:lsp_documentation_float_docked = get(g:, 'lsp_documentation_float_docked', 0)
|
||||
@@ -29,12 +22,20 @@ let g:lsp_diagnostics_echo_cursor = get(g:, 'lsp_diagnostics_echo_cursor', 0)
|
||||
let g:lsp_diagnostics_echo_delay = get(g:, 'lsp_diagnostics_echo_delay', 500)
|
||||
let g:lsp_diagnostics_float_cursor = get(g:, 'lsp_diagnostics_float_cursor', 0)
|
||||
let g:lsp_diagnostics_float_delay = get(g:, 'lsp_diagnostics_float_delay', 500)
|
||||
let g:lsp_diagnostics_signs_enabled = get(g:, 'lsp_diagnostics_signs_enabled', lsp#utils#_has_signs())
|
||||
let g:lsp_diagnostics_signs_insert_mode_enabled = get(g:, 'lsp_diagnostics_signs_insert_mode_enabled', 1)
|
||||
let g:lsp_diagnostics_signs_delay = get(g:, 'lsp_diagnostics_signs_delay', 500)
|
||||
let g:lsp_diagnostics_signs_error = get(g:, 'lsp_diagnostics_signs_error', {})
|
||||
let g:lsp_diagnostics_signs_warning = get(g:, 'lsp_diagnostics_signs_warning', {})
|
||||
let g:lsp_diagnostics_signs_information = get(g:, 'lsp_diagnostics_signs_information', {})
|
||||
let g:lsp_diagnostics_signs_hint = get(g:, 'lsp_diagnostics_signs_hint', {})
|
||||
let g:lsp_diagnostics_signs_priority = get(g:, 'lsp_diagnostics_signs_priority', 10)
|
||||
let g:lsp_diagnostics_signs_priority_map = get(g:, 'lsp_diagnostics_signs_priority_map', {})
|
||||
let g:lsp_diagnostics_virtual_text_enabled = get(g:, 'lsp_diagnostics_virtual_text_enabled', lsp#utils#_has_virtual_text())
|
||||
let g:lsp_diagnostics_virtual_text_insert_mode_enabled = get(g:, 'lsp_diagnostics_virtual_text_insert_mode_enabled', 0)
|
||||
let g:lsp_diagnostics_virtual_text_delay = get(g:, 'lsp_diagnostics_virtual_text_delay', 500)
|
||||
let g:lsp_diagnostics_virtual_text_prefix = get(g:, 'lsp_diagnostics_virtual_text_prefix', '')
|
||||
|
||||
let g:lsp_next_sign_id = get(g:, 'lsp_next_sign_id', 6999)
|
||||
let g:lsp_preview_keep_focus = get(g:, 'lsp_preview_keep_focus', 1)
|
||||
let g:lsp_use_event_queue = get(g:, 'lsp_use_event_queue', has('nvim') || has('patch-8.1.0889'))
|
||||
let g:lsp_insert_text_enabled= get(g:, 'lsp_insert_text_enabled', 1)
|
||||
|
||||
Reference in New Issue
Block a user