Skip to content

Commit 64d514d

Browse files
hrsh7thprabirshrestha
authored andcommitted
Fix completion for clangd (#665)
* Fix completion for clangd * Fix for old vim
1 parent 2f1ce88 commit 64d514d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

autoload/lsp/omni.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@ function! lsp#omni#default_get_vim_completion_item(item, ...) abort
249249
let l:abbr = a:item['label']
250250
endif
251251

252+
if has_key(a:item, 'insertTextFormat') && a:item['insertTextFormat'] == 2
253+
let l:word = substitute(l:word, '\<\$[0-9]\+\|\${[^}]\+}\>', '', 'g')
254+
endif
255+
252256
let l:completion = {
253-
\ 'word': l:word,
257+
\ 'word': lsp#utils#_trim(l:word),
254258
\ 'abbr': l:abbr,
255259
\ 'menu': '',
256260
\ 'info': '',

autoload/lsp/utils.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ function! s:get_base64_alphabet() abort
232232
return l:alphabet
233233
endfunction
234234

235+
if exists('*trim')
236+
function! lsp#utils#_trim(string) abort
237+
return trim(a:string)
238+
endfunction
239+
else
240+
function! lsp#utils#_trim(string) abort
241+
return substitute(a:string, '^\s*\|\s*$', '', 'g')
242+
endfunction
243+
endif
244+
235245
function! lsp#utils#_get_before_line() abort
236246
let l:text = getline('.')
237247
let l:idx = min([strlen(l:text), col('.') - 2])

0 commit comments

Comments
 (0)