Skip to content

Commit dd584df

Browse files
coditvathomasfaingnaert
authored andcommitted
Add g:lsp_virtual_text_prefix option (#521)
This option allows prepending characters or text to the diagnostics which are display as virtual text. It allows virtual text to be differentiated from the code
1 parent 47a883d commit dd584df

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

autoload/lsp/ui/vim/virtual.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function! s:place_virtual(server_name, path, diagnostics) abort
8181

8282
let l:name = get(s:severity_sign_names_mapping, l:item['severity'], 'LspError')
8383
let l:hl_name = l:name . 'Text'
84-
call nvim_buf_set_virtual_text(l:bufnr, l:ns, l:line, [[l:item['message'], l:hl_name]], {})
84+
call nvim_buf_set_virtual_text(l:bufnr, l:ns, l:line,
85+
\ [[g:lsp_virtual_text_prefix . l:item['message'], l:hl_name]], {})
8586
endfor
8687
endif
8788
endfunction

doc/vim-lsp.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,19 @@ g:lsp_virtual_text_enabled *g:lsp_virtual_text_enable
349349
let g:lsp_virtual_text_enabled = 0
350350
<
351351

352+
g:lsp_virtual_text_prefix *g:lsp_virtual_text_prefix*
353+
Type: |String|
354+
Default: `""` for neovim 0.3+
355+
356+
Adds the prefix to the diagnostics to be shown as virtual text. Requires
357+
NeoVim with version 0.3 or newer.
358+
359+
Example:
360+
>
361+
let g:lsp_virtual_text_prefix = "> "
362+
let g:lsp_virtual_text_prefix = " ‣ "
363+
<
364+
352365
g:lsp_highlights_enabled *g:lsp_highlights_enabled*
353366
Type: |Number|
354367
Default: `1` for neovim 0.3+

plugin/lsp.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ let g:lsp_debug_servers = get(g:, 'lsp_debug_servers', [])
1111
let g:lsp_signs_enabled = get(g:, 'lsp_signs_enabled', exists('*sign_define') && (has('nvim') || has('patch-8.1.0772')))
1212
let g:lsp_signs_priority = get(g:, 'lsp_signs_priority', 10)
1313
let g:lsp_virtual_text_enabled = get(g:, 'lsp_virtual_text_enabled', exists('*nvim_buf_set_virtual_text'))
14+
let g:lsp_virtual_text_prefix = get(g:, 'lsp_virtual_text_prefix', '')
1415
let g:lsp_highlights_enabled = get(g:, 'lsp_highlights_enabled', exists('*nvim_buf_add_highlight'))
1516
let g:lsp_textprop_enabled = get(g:, 'lsp_textprop_enabled', exists('*prop_add') && !g:lsp_highlights_enabled)
1617
let g:lsp_signs_error = get(g:, 'lsp_signs_error', {})

0 commit comments

Comments
 (0)