Skip to content

Commit 20d1cf3

Browse files
hrsh7thmattn
andauthored
Expand snippets after some textEdit related modifications (#682)
* Expand snippets after some textEdit related modifications * Remove `vim-lsp-snippets` specific codes Co-authored-by: mattn <[email protected]>
1 parent 682a20c commit 20d1cf3

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

autoload/lsp/ui/vim/completion.vim

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function! s:on_complete_done_after() abort
7777

7878
let l:completion_item = s:resolve_completion_item(l:completion_item, l:server_name)
7979

80-
" apply textEdit or insertText(snippet).
80+
" clear completed string if need.
8181
let l:expand_text = s:get_expand_text(l:completed_item, l:completion_item)
8282
if strlen(l:expand_text) > 0
8383
call s:clear_inserted_text(
@@ -86,19 +86,6 @@ function! s:on_complete_done_after() abort
8686
\ l:completed_item,
8787
\ l:completion_item
8888
\ )
89-
90-
if exists('g:lsp_snippets_expand_snippet') && len(g:lsp_snippets_expand_snippet) > 0
91-
" vim-lsp-snippets expects commit characters removed.
92-
call s:simple_expand_text(v:completed_item['word'])
93-
elseif exists('g:lsp_snippet_expand') && len(g:lsp_snippet_expand) > 0
94-
" other snippet integartion point.
95-
call g:lsp_snippet_expand[0]({
96-
\ 'snippet': l:expand_text
97-
\ })
98-
else
99-
" expand text simply.
100-
call s:simple_expand_text(l:expand_text)
101-
endif
10289
endif
10390

10491
" apply additionalTextEdits.
@@ -115,6 +102,20 @@ function! s:on_complete_done_after() abort
115102
call setpos('.', l:pos)
116103
endif
117104

105+
106+
" expand textEdit or insertText.
107+
if strlen(l:expand_text) > 0
108+
if exists('g:lsp_snippet_expand') && len(g:lsp_snippet_expand) > 0
109+
" other snippet integartion point.
110+
call g:lsp_snippet_expand[0]({
111+
\ 'snippet': l:expand_text
112+
\ })
113+
else
114+
" expand text simply.
115+
call s:simple_expand_text(l:expand_text)
116+
endif
117+
endif
118+
118119
doautocmd User lsp_complete_done
119120
return ''
120121
endfunction

0 commit comments

Comments
 (0)