Skip to content

Commit ce16de5

Browse files
committed
support snippet item in ghost_text
1 parent 7240362 commit ce16de5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lua/cmp/view/ghost_text_view.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local misc = require('cmp.utils.misc')
33
local snippet = require('cmp.utils.snippet')
44
local str = require('cmp.utils.str')
55
local api = require('cmp.utils.api')
6+
local types = require('cmp.types')
67

78
---@class cmp.GhostTextView
89
---@field win number|nil
@@ -77,7 +78,10 @@ end
7778
--- This function calculates the bytes of the entry to display calculating the number
7879
--- of character differences instead of just byte difference.
7980
ghost_text_view.text_gen = function(self, line, cursor_col)
80-
local word = tostring(snippet.parse(self.entry:get_insert_text()))
81+
local word = self.entry:get_insert_text()
82+
if self.entry:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then
83+
word = tostring(snippet.parse(word))
84+
end
8185
word = str.oneline(word)
8286
local word_clen = vim.str_utfindex(word)
8387
local cword = string.sub(line, self.entry:get_offset(), cursor_col)

0 commit comments

Comments
 (0)