Skip to content

Commit ae23813

Browse files
L0stLinkautozimu
L0stLink
authored andcommitted
Added customizable virtual text prefix
1 parent d08b657 commit ae23813

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

autoload/LanguageClient.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,19 @@ endfunction
148148
function! s:set_virtual_texts(buf_id, ns_id, line_start, line_end, virtual_texts) abort
149149
" VirtualText: map with keys line, text and hl_group.
150150

151+
let l:prefix = s:GetVar('LanguageClient_virtualTextPrefix')
152+
if l:prefix is v:null
153+
let l:prefix = ''
154+
endif
155+
151156
if !exists('*nvim_buf_set_virtual_text')
152157
return
153158
endif
154159

155160
call nvim_buf_clear_namespace(a:buf_id, a:ns_id, a:line_start, a:line_end)
156161

157162
for vt in a:virtual_texts
158-
call nvim_buf_set_virtual_text(a:buf_id, a:ns_id, vt['line'], [[vt['text'], vt['hl_group']]], {})
163+
call nvim_buf_set_virtual_text(a:buf_id, a:ns_id, vt['line'], [[l:prefix . vt['text'], vt['hl_group']]], {})
159164
endfor
160165
endfunction
161166

doc/LanguageClient.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,16 @@ supported.
357357
Default: 1 when a floating window is supported, otherwise 0
358358
Valid Options: 1 | 0
359359

360+
2.27 g:LanguageClient_virtualTextPrefix *g:LanguageClient_virtualTextPrefix*
361+
362+
When the value is set to a valid string and |g:LanguageClient_useVirtualText| is
363+
enabled, all virtual text lines are prefixed with the defined string.
364+
This variable is effective only when the virtual text feature is
365+
supported.
366+
367+
Default: Empty string ('')
368+
Valid Options: string
369+
360370
==============================================================================
361371
3. Commands *LanguageClientCommands*
362372

min-vimrc.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ let g:LanguageClient_serverCommands = {
2020
\ }
2121
let $RUST_BACKTRACE = 1
2222
let g:LanguageClient_loggingLevel = 'INFO'
23+
let g:LanguageClient_virtualTextPrefix = ''
2324
let g:LanguageClient_loggingFile = expand('~/.local/share/nvim/LanguageClient.log')
2425
let g:LanguageClient_serverStderr = expand('~/.local/share/nvim/LanguageServer.log')

0 commit comments

Comments
 (0)