@@ -42,7 +42,6 @@ local function get_context_aware_snippets(item, completion_item, line_to_cursor)
4242 end
4343 local line = vim .api .nvim_get_current_line ()
4444 local nextWord = line :sub (# line_to_cursor + 1 , # line_to_cursor + 1 )
45- print (nextWord == " " or # nextWord == 0 )
4645 if nextWord == " " or # nextWord == 0 then
4746 return
4847 else
@@ -53,6 +52,7 @@ local function get_context_aware_snippets(item, completion_item, line_to_cursor)
5352 end
5453 if matches ~= 0 then
5554 item .word = word
55+ item .user_data = {}
5656 end
5757 end
5858end
@@ -83,14 +83,6 @@ local function text_document_completion_list_to_complete_items(result, opt)
8383 item .info = info
8484
8585 item .word = get_completion_word (completion_item , opt .prefix , opt .suffix )
86- if opt .suffix ~= nil and # opt .suffix ~= 0 then
87- local index = item .word :find (opt .suffix )
88- if index ~= nil then
89- local newWord = item .word
90- newWord = newWord :sub (1 , index - 1 )
91- item .word = newWord
92- end
93- end
9486 item .user_data = {
9587 lsp = {
9688 completion_item = completion_item ,
@@ -99,6 +91,15 @@ local function text_document_completion_list_to_complete_items(result, opt)
9991 local kind = protocol .CompletionItemKind [completion_item .kind ]
10092 item .kind = customize_label [kind ] or kind
10193 item .abbr = completion_item .label
94+ if opt .suffix ~= nil and # opt .suffix ~= 0 then
95+ local index = item .word :find (opt .suffix )
96+ if index ~= nil then
97+ local newWord = item .word
98+ newWord = newWord :sub (1 , index - 1 )
99+ item .word = newWord
100+ item .user_data = {}
101+ end
102+ end
102103 get_context_aware_snippets (item , completion_item , opt .line_to_cursor )
103104 item .priority = vim .g .completion_items_priority [item .kind ]
104105 item .menu = completion_item .detail or ' '
0 commit comments