Revamp diagnostics highlights (#995)

This commit is contained in:
Prabir Shrestha
2020-12-31 23:13:19 -08:00
committed by GitHub
parent b4f710f143
commit efd07d859e
13 changed files with 266 additions and 340 deletions

View File

@@ -144,19 +144,6 @@ preferred to turn them off and use other plugins instead (like
let g:lsp_diagnostics_enabled = 0 " disable diagnostics support
```
#### Highlights
Highlighting diagnostics requires either NeoVim 0.3+ or Vim with patch 8.1.0579.
They are enabled by default when supported, but can be turned off respectively by
```viml
let g:lsp_highlights_enabled = 0
let g:lsp_textprop_enabled = 0
```
Can be customized by setting or linking `LspErrorHighlight`, `LspWarningHighlight`,
`LspInformationHighlight` and `LspHintHighlight` highlight groups.
### Highlight references
Highlight references to the symbol under the cursor (enabled by default).

View File

@@ -55,10 +55,6 @@ function! lsp#enable() abort
let s:already_setup = 1
endif
let s:enabled = 1
if g:lsp_diagnostics_enabled
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
if g:lsp_signature_help_enabled
call lsp#ui#vim#signature_help#setup()
endif
@@ -74,8 +70,6 @@ function! lsp#disable() abort
if !s:enabled
return
endif
call lsp#ui#vim#highlights#disable()
call lsp#ui#vim#diagnostics#textprop#disable()
call lsp#ui#vim#signature_help#_disable()
call lsp#ui#vim#completion#_disable()
call lsp#internal#document_highlight#_disable()
@@ -237,7 +231,6 @@ function! s:on_text_document_did_open(...) abort
" Some language server notify diagnostics to the buffer that has not been loaded yet.
" This diagnostics was stored `autoload/lsp/ui/vim/diagnostics.vim` but not highlighted.
" So we should refresh highlights when buffer opened.
call lsp#ui#vim#diagnostics#force_refresh(l:buf)
call lsp#internal#diagnostics#state#_force_notify_buffer(l:buf)
for l:server_name in lsp#get_allowed_servers(l:buf)

View File

@@ -4,6 +4,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#highlights#_enable()
call lsp#internal#diagnostics#float#_enable()
call lsp#internal#diagnostics#signs#_enable()
call lsp#internal#diagnostics#virtual_text#_enable()
@@ -12,6 +13,7 @@ endfunction
function! lsp#internal#diagnostics#_disable() abort
call lsp#internal#diagnostics#echo#_disable()
call lsp#internal#diagnostics#float#_disable()
call lsp#internal#diagnostics#highlights#_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

View File

@@ -3,7 +3,7 @@
" }
function! lsp#internal#diagnostics#document_diagnostics_command#do(options) abort
if !g:lsp_diagnostics_enabled
call lsp#utils#error(':LspDocumentDiagnostics', 'g:lsp_diagnostics_enabled must be enabled')
call lsp#utils#error(':LspDocumentDiagnostics g:lsp_diagnostics_enabled must be enabled')
return
endif

View File

@@ -0,0 +1,180 @@
" internal state for whether it is enabled or not to avoid multiple subscriptions
let s:enabled = 0
let s:namespace_id = '' " will be set when enabled
let s:severity_sign_names_mapping = {
\ 1: 'LspError',
\ 2: 'LspWarning',
\ 3: 'LspInformation',
\ 4: 'LspHint',
\ }
if !hlexists('LspErrorHighlight')
highlight link LspErrorHighlight Error
endif
if !hlexists('LspWarningHighlight')
highlight link LspWarningHighlight Todo
endif
if !hlexists('LspInformationHighlight')
highlight link LspInformationHighlight Normal
endif
if !hlexists('LspHintHighlight')
highlight link LspHintHighlight Normal
endif
function! lsp#internal#diagnostics#highlights#_enable() abort
" don't even bother registering if the feature is disabled
if !lsp#utils#_has_highlights() | return | endif
if !g:lsp_diagnostics_highlights_enabled | return | endif
if s:enabled | return | endif
let s:enabled = 1
if empty(s:namespace_id)
if has('nvim')
let s:namespace_id = nvim_create_namespace('vim_lsp_diagnostics_highlights')
else
let s:namespace_id = 'vim_lsp_diagnostics_highlights'
for l:severity in keys(s:severity_sign_names_mapping)
let l:hl_group = s:severity_sign_names_mapping[l:severity] . 'Highlight'
call prop_type_add(s:get_prop_type_name(l:severity),
\ {'highlight': l:hl_group, 'combine': v:true })
endfor
endif
endif
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_highlights_insert_mode_enabled}),
\ lsp#callbag#map({_->{ 'uri': lsp#utils#get_buffer_uri() }}),
\ ),
\ ),
\ lsp#callbag#filter({_->g:lsp_diagnostics_highlights_enabled}),
\ lsp#callbag#debounceTime(g:lsp_diagnostics_highlights_delay),
\ lsp#callbag#tap({x->s:clear_highlights(x)}),
\ lsp#callbag#tap({x->s:set_highlights(x)}),
\ lsp#callbag#subscribe(),
\ )
endfunction
function! lsp#internal#diagnostics#highlights#_disable() abort
if !s:enabled | return | endif
if exists('s:Dispose')
call s:Dispose()
unlet s:Dispose
endif
call s:clear_all_highlights()
let s:enabled = 0
endfunction
function! s:get_prop_type_name(severity) abort
return s:namespace_id . '_' . get(s:severity_sign_names_mapping, a:severity, 'LspError')
endfunction
function! s:clear_all_highlights() abort
for l:bufnr in range(1, bufnr('$'))
if bufexists(l:bufnr) && bufloaded(l:bufnr)
if has('nvim')
call nvim_buf_clear_namespace(l:bufnr, s:namespace_id, 0, -1)
else
for l:severity in keys(s:severity_sign_names_mapping)
try
" TODO: need to check for valid range before calling prop_add
" See https://github.com/prabirshrestha/vim-lsp/pull/721
silent! call prop_remove({
\ 'type': s:get_prop_type_name(l:severity),
\ 'bufnr': l:bufnr,
\ 'all': v:true })
catch
call lsp#log('diagnostics', 'clear_all_highlights', 'prop_remove', v:exception, v:throwpoint)
endtry
endfor
endif
endif
endfor
endfunction
function! s:clear_highlights(params) abort
" TODO: optimize by looking at params
call s:clear_all_highlights()
endfunction
function! s:set_highlights(params) abort
" TODO: optimize by looking at params
if !g:lsp_diagnostics_highlights_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_highlights(l:server, l:diagnostics_response, l:bufnr)
endfor
endif
endfor
endfunction
function! s:place_highlights(server, diagnostics_response, bufnr) abort
" TODO: make diagnostics highlights same across vim and neovim
for l:item in a:diagnostics_response['params']['diagnostics']
let [l:start_line, l:start_col] = lsp#utils#position#lsp_to_vim(a:bufnr, l:item['range']['start'])
let [l:end_line, l:end_col] = lsp#utils#position#lsp_to_vim(a:bufnr, l:item['range']['end'])
let l:severity = get(l:item, 'severity', 3)
let l:hl_group = get(s:severity_sign_names_mapping, l:severity, 'LspError') . 'Highlight'
if has('nvim')
for l:line in range(l:start_line, l:end_line)
if l:line == l:start_line
let l:highlight_start_col = l:start_col
else
let l:highlight_start_col = 1
endif
if l:line == l:end_line
let l:highlight_end_col = l:end_col
else
" neovim treats -1 as end of line, special handle it later
" when calling nvim_buf_add_higlight
let l:highlight_end_col = -1
endif
if l:start_line == l:end_line && l:highlight_start_col == l:highlight_end_col
" higlighting same start col and end col on same line
" doesn't work so use -1 for start col
let l:highlight_start_col -= 1
if l:highlight_start_col <= 0
let l:highlight_start_col = 1
endif
endif
call nvim_buf_add_highlight(a:bufnr, s:namespace_id, l:hl_group,
\ l:line - 1, l:highlight_start_col - 1, l:highlight_end_col == -1 ? -1 : l:highlight_end_col)
endfor
else
try
" TODO: need to check for valid range before calling prop_add
" See https://github.com/prabirshrestha/vim-lsp/pull/721
silent! call prop_add(l:start_line, l:start_col, {
\ 'end_lnum': l:end_line,
\ 'end_col': l:end_col,
\ 'bufnr': a:bufnr,
\ 'type': s:get_prop_type_name(l:severity),
\ })
catch
call lsp#log('diagnostics', 'place_highlights', 'prop_add', v:exception, v:throwpoint)
endtry
endif
endfor
endfunction

View File

@@ -1,4 +1,4 @@
let s:use_vim_textprops = has('textprop') && !has('nvim')
let s:use_vim_textprops = lsp#utils#_has_textprops() && !has('nvim')
let s:prop_id = 11
function! lsp#internal#document_highlight#_enable() abort
@@ -108,12 +108,18 @@ function! s:set_highlights(data) abort
call s:init_reference_highlight(l:bufnr)
if s:use_vim_textprops
for l:position in l:position_list
call prop_add(l:position[0], l:position[1],
\ {'id': s:prop_id,
\ 'bufnr': l:bufnr,
\ 'length': l:position[2],
\ 'type': 'vim-lsp-reference-highlight'})
call add(b:lsp_reference_matches, l:position[0])
try
" TODO: need to check for valid range before calling prop_add
" See https://github.com/prabirshrestha/vim-lsp/pull/721
silent! call prop_add(l:position[0], l:position[1], {
\ 'id': s:prop_id,
\ 'bufnr': l:bufnr,
\ 'length': l:position[2],
\ 'type': 'vim-lsp-reference-highlight'})
call add(b:lsp_reference_matches, l:position[0])
catch
call lsp#log('document_highlight', 'set_highlights', v:exception, v:throwpoint)
endtry
endfor
else
for l:position in l:position_list

View File

@@ -12,22 +12,9 @@ function! lsp#ui#vim#diagnostics#handle_text_document_publish_diagnostics(server
endif
let s:diagnostics[l:uri][a:server_name] = a:data
call lsp#ui#vim#highlights#set(a:server_name, a:data)
call lsp#ui#vim#diagnostics#textprop#set(a:server_name, a:data)
doautocmd <nomodeline> User lsp_diagnostics_updated
endfunction
function! lsp#ui#vim#diagnostics#force_refresh(bufnr) abort
let l:data = lsp#ui#vim#diagnostics#get_document_diagnostics(a:bufnr)
if !empty(l:data)
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)
endfor
endif
endfunction
function! lsp#ui#vim#diagnostics#get_document_diagnostics(bufnr) abort
return get(s:diagnostics, lsp#utils#get_buffer_uri(a:bufnr), {})
endfunction

View File

@@ -1,144 +0,0 @@
let s:supports_hl = exists('*prop_add')
let s:enabled = 0
let s:prop_type_prefix = 'vim_lsp_hl_'
let s:severity_sign_names_mapping = {
\ 1: 'LspError',
\ 2: 'LspWarning',
\ 3: 'LspInformation',
\ 4: 'LspHint',
\ }
if !hlexists('LspErrorHighlight')
highlight link LspErrorHighlight Error
endif
if !hlexists('LspWarningHighlight')
highlight link LspWarningHighlight Todo
endif
if !hlexists('LspInformationHighlight')
highlight link LspInformationHighlight Normal
endif
if !hlexists('LspHintHighlight')
highlight link LspHintHighlight Normal
endif
function! lsp#ui#vim#diagnostics#textprop#enable() abort
if !s:supports_hl
call lsp#log('vim-lsp highlighting requires vim with +textprop')
return
endif
if !s:enabled
let s:enabled = 1
call lsp#log('vim-lsp highlighting enabled (textprop)')
endif
endfunction
function! lsp#ui#vim#diagnostics#textprop#disable() abort
if s:enabled
call s:clear_all_highlights()
let s:enabled = 0
call lsp#log('vim-lsp highlighting disabled')
endif
endfunction
function! lsp#ui#vim#diagnostics#textprop#set(server_name, data) abort
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)
call s:clear_highlights(a:server_name, l:path)
call s:place_highlights(a:server_name, l:path, l:diagnostics)
endfunction
function! s:get_prop_type(server_name, severity) abort
let l:severity = has_key(s:severity_sign_names_mapping, a:severity) ? a:severity : 0
let l:name = s:prop_type_prefix . l:severity . '_' . a:server_name
if empty(prop_type_get(l:name))
call prop_type_add(l:name, {
\ 'highlight': s:severity_sign_names_mapping[l:severity] . 'Highlight',
\ 'combine': v:true,
\ })
endif
return l:name
endfunction
function! s:clear_all_highlights() abort
for l:prop_type in prop_type_list()
if l:prop_type !~# '^' . s:prop_type_prefix
continue
endif
for l:bufnr in range(1, bufnr('$'))
if bufexists(l:bufnr) && bufloaded(l:bufnr)
try
call prop_remove({
\ 'type': l:prop_type,
\ 'bufnr': l:bufnr,
\ 'all': v:true,
\ }, 1, len(getbufline(l:bufnr, 1, '$')))
catch
call lsp#log('clear_all_highlights', v:exception)
endtry
endif
endfor
call prop_type_delete(l:prop_type)
endfor
endfunction
function! s:clear_highlights(server_name, path) abort
if !s:enabled | return | endif
let l:bufnr = bufnr(a:path)
if l:bufnr == -1
call lsp#log('Skipping clear_highlights for ' . a:path . ': buffer is not loaded')
return
endif
for l:severity in keys(s:severity_sign_names_mapping)
let l:prop_type = s:get_prop_type(a:server_name, l:severity)
try
call prop_remove({
\ 'type': l:prop_type,
\ 'bufnr': l:bufnr,
\ 'all': v:true,
\ }, 1, len(getbufline(l:bufnr, 1, '$')))
catch
call lsp#log('clear_highlights', v:exception)
endtry
endfor
endfunction
function! s:place_highlights(server_name, path, diagnostics) abort
if !s:enabled | return | endif
let l:bufnr = bufnr(a:path)
if !empty(a:diagnostics) && l:bufnr >= 0
for l:item in a:diagnostics
let [l:start_line, l:start_col] = lsp#utils#position#lsp_to_vim(l:bufnr, l:item['range']['start'])
let [l:end_line, l:end_col] = lsp#utils#position#lsp_to_vim(l:bufnr, l:item['range']['end'])
let l:prop_type = s:get_prop_type(a:server_name, get(l:item, 'severity', 1))
try
call prop_add(l:start_line, l:start_col, {
\ 'end_lnum': l:end_line,
\ 'end_col': l:end_col,
\ 'bufnr': l:bufnr,
\ 'type': l:prop_type,
\ })
catch
call lsp#log('place_highlights', v:exception)
endtry
endfor
endif
endfunction

View File

@@ -1,108 +0,0 @@
let s:supports_hl = exists('*nvim_buf_add_highlight')
let s:enabled = 0
let s:ns_key = 'vim_lsp_hl_'
let s:severity_sign_names_mapping = {
\ 1: 'LspError',
\ 2: 'LspWarning',
\ 3: 'LspInformation',
\ 4: 'LspHint',
\ }
if !hlexists('LspErrorHighlight')
highlight link LspErrorHighlight Error
endif
if !hlexists('LspWarningHighlight')
highlight link LspWarningHighlight Todo
endif
if !hlexists('LspInformationHighlight')
highlight link LspInformationHighlight Normal
endif
if !hlexists('LspHintHighlight')
highlight link LspHintHighlight Normal
endif
function! lsp#ui#vim#highlights#enable() abort
if !s:supports_hl
call lsp#log('vim-lsp highlighting requires neovim')
return
endif
if !s:enabled
let s:enabled = 1
call lsp#log('vim-lsp highlighting enabled')
endif
endfunction
function! lsp#ui#vim#highlights#disable() abort
if s:enabled
for l:ns in keys(nvim_get_namespaces())
call s:clear_all_highlights(l:ns)
endfor
let s:enabled = 0
call lsp#log('vim-lsp highlighting disabled')
endif
endfunction
function! lsp#ui#vim#highlights#set(server_name, data) abort
if !s:supports_hl | 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)
call s:clear_highlights(a:server_name, l:path)
call s:place_highlights(a:server_name, l:path, l:diagnostics)
endfunction
function! s:get_highlight_group(name) abort
return nvim_create_namespace(s:ns_key . a:name)
endfunction
function! s:clear_all_highlights(namespace) abort
if a:namespace =~# '^' . s:ns_key
let l:ns = nvim_create_namespace(a:namespace)
for l:bufnr in nvim_list_bufs()
call nvim_buf_clear_namespace(l:bufnr, l:ns, 0, -1)
endfor
endif
endfunction
function! s:clear_highlights(server_name, path) abort
if !s:supports_hl | return | endif
if !s:enabled | return | endif
let l:ns = s:get_highlight_group(a:server_name)
let l:bufnr = bufnr(a:path)
if l:bufnr != -1
call nvim_buf_clear_namespace(l:bufnr, l:ns, 0, -1)
endif
endfunction
function! s:place_highlights(server_name, path, diagnostics) abort
if !s:supports_hl | return | endif
if !s:enabled | return | endif
let l:ns = s:get_highlight_group(a:server_name)
let l:bufnr = bufnr(a:path)
if !empty(a:diagnostics) && l:bufnr >= 0
for l:item in a:diagnostics
let [l:line, l:start_col] = lsp#utils#position#lsp_to_vim(l:bufnr, l:item['range']['start'])
let [l:_, l:end_col] = lsp#utils#position#lsp_to_vim(l:bufnr, l:item['range']['end'])
let l:name = get(s:severity_sign_names_mapping, get(l:item, 'severity', 3), 'LspError')
let l:hl_name = l:name . 'Highlight'
call nvim_buf_add_highlight(l:bufnr, l:ns, l:hl_name, l:line - 1, l:start_col - 1, l:end_col - 1)
endfor
endif
endfunction

View File

@@ -1,4 +1,4 @@
let s:use_vim_textprops = has('textprop') && !has('nvim')
let s:use_vim_textprops = lsp#utils#_has_textprops() && !has('nvim')
let s:use_nvim_highlight = exists('*nvim_buf_add_highlight') && has('nvim')
let s:textprop_cache = 'vim-lsp-semantic-cache'

View File

@@ -8,6 +8,22 @@ function! lsp#utils#_has_signs() abort
return s:has_signs
endfunction
let s:has_nvim_buf_highlight = exists('*nvim_buf_add_highlight')
function! lsp#utils#_has_nvim_buf_highlight() abort
return s:has_nvim_buf_highlight
endfunction
" https://github.com/prabirshrestha/vim-lsp/issues/399#issuecomment-500585549
let s:has_textprops = exists('*prop_add') && has('patch-8.1.1035')
function! lsp#utils#_has_textprops() abort
return s:has_textprops
endfunction
let s:has_higlights = has('nvim') ? lsp#utils#_has_nvim_buf_highlight() : lsp#utils#_has_textprops()
function! lsp#utils#_has_highlights() abort
return s:has_higlights
endfunction
function! lsp#utils#is_file_uri(uri) abort
return stridx(a:uri, 'file:///') == 0
endfunction

View File

@@ -29,6 +29,12 @@ CONTENTS *vim-lsp-contents*
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_highlights_enabled
|g:lsp_diagnostics_highlights_enabled|
g:lsp_diagnostics_highlights_insert_mode_enabled
|g:lsp_diagnostics_highlights_insert_mode_enabled|
g:lsp_diagnostics_highlights_delay
|g:lsp_diagnostics_highlights_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|
@@ -45,8 +51,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_highlights_enabled |g:lsp_highlights_enabled|
g:lsp_textprop_enabled |g:lsp_textprop_enabled|
g:lsp_use_event_queue |g:lsp_use_event_queue|
g:lsp_document_highlight_enabled |g:lsp_document_highlight_enabled|
g:lsp_document_highlight_delay |g:lsp_document_highlight_delay|
@@ -504,6 +508,47 @@ 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_diagnostics_highlights_enabled *g:lsp_diagnostics_highlights_enabled*
Type: |Number|
Default: `1` for neovim 0.3+ and vim with patch-8.1.1035
Enables highlighting of diagnostics. Requires NeoVim with version 0.3 or
Vim 8.1.1035 or newer.
Example: >
let g:lsp_diagnostics_highlights_enabled = 1
let g:lsp_diagnostics_highlights_enabled = 0
<
To change the style of the highlighting, you can set or link
`LspErrorHighlight`, `LspWarningHighlight`, `LspInformationHighlight` and
`LspHintHighlight` highlight groups.
Example: >
highlight link LspErrorHighlight Error
g:lsp_diagnostics_highlights_insert_mode_enabled
*g:lsp_diagnostics_highlights_insert_mode_enabled*
Type: |Number|
Default: `1`
Indicates whether to enable diagnostics highlighting when in |insertmode|.
Requires |g:lsp_diagnostics_highlights_enabled|.
Example: >
let g:lsp_diagnostics_highlights_insert_mode_enabled = 1
let g:lsp_diagnostics_highlights_insert_mode_enabled = 0
g:lsp_diagnostics_highlights_delay *g:lsp_diagnostics_highlights_delay*
Type: |Number|
Default: `500`
Delay milliseconds to update diagnostics highlights. Requires
|g:lsp_diagnostics_highlights_enabled|.
Example: >
let g:lsp_diagnostics_highlights_delay = 200
let g:lsp_diagnostics_highlights_delay = 1000
g:lsp_diagnostics_signs_enabled
*g:lsp_diagnostics_signs_enabled*
Type: |Number|
@@ -634,46 +679,6 @@ g:lsp_diagnostics_virtual_text_prefix *g:lsp_diagnostics_virtual_text_prefix*
let g:lsp_diagnostics_virtual_text_prefix = "> "
let g:lsp_diagnostics_virtual_text_prefix = " ‣ "
g:lsp_highlights_enabled *g:lsp_highlights_enabled*
Type: |Number|
Default: `1` for neovim 0.3+
Enables highlighting of diagnostics. Requires NeoVim with version 0.3 or
newer.
Example: >
let g:lsp_highlights_enabled = 1
let g:lsp_highlights_enabled = 0
<
To change the style of the highlighting, you can set or link
`LspErrorHighlight`, `LspWarningHighlight`, `LspInformationHighlight` and
`LspHintHighlight` highlight groups.
Example: >
highlight link LspErrorHighlight Error
g:lsp_textprop_enabled *g:lsp_textprop_enabled*
Type: |Number|
Default: `1` for vim with +textprop
Enables highlighting of diagnostics. Requires vim with +textprop
(patch 8.1.0579).
Example: >
let g:lsp_textprop_enabled = 1
let g:lsp_textprop_enabled = 0
<
To change the style of the highlighting, you can set or link
`LspErrorHighlight`, `LspWarningHighlight`, `LspInformationHighlight` and
`LspHintHighlight` highlight groups.
Example: >
highlight LspErrorHighlight term=underline cterm=underline gui=underline
g:lsp_use_event_queue *g:lsp_use_event_queue*
Type: |Number|
Default: `1` for neovim or vim with patch-8.1.0889
@@ -687,9 +692,10 @@ g:lsp_use_event_queue *g:lsp_use_event_queue*
g:lsp_document_highlight_enabled *g:lsp_document_highlight_enabled*
Type: |Number|
Default: `1`
Default: `1` for neovim or vim with patch-8.1.1035
Enable highlighting of the references to the symbol under the cursor.
Enables highlighting of the references to the symbol under the cursor.
Requires NeoVim with version 0.3 or Vim 8.1.1035 or newer.
Example: >
let g:lsp_document_highlight_enabled = 1

View File

@@ -10,8 +10,6 @@ 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_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_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)
@@ -22,6 +20,9 @@ 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_highlights_enabled = get(g:, 'lsp_diagnostics_highlights_enabled', lsp#utils#_has_highlights())
let g:lsp_diagnostics_highlights_insert_mode_enabled = get(g:, 'lsp_diagnostics_highlights_insert_mode_enabled', 1)
let g:lsp_diagnostics_highlights_delay = get(g:, 'lsp_diagnostics_highlights_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)