Skip to content

Commit

Permalink
feat(ghost_text): Added multi-line ghost_text support for custom snip…
Browse files Browse the repository at this point in the history
…pets of luasnip
  • Loading branch information
ldfwbebp committed Jul 27, 2024
1 parent d818fd0 commit 5f8e04f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lua/cmp/view/ghost_text_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ end
--- This function calculates the bytes of the entry to display calculating the number
--- of character differences instead of just byte difference.
ghost_text_view.text_gen = function(self, line, cursor_col)
local word = self.entry:get_insert_text()
local word
local completion_kind = self.entry:get_kind()
local completion_item = self.entry:get_completion_item()
-- Check if completion_kind indicates a snippet
-- Handle custom snippet
if completion_kind == 15 and completion_item and completion_item.documentation and completion_item.documentation.value then
local doc_value = completion_item.documentation.value
local pattern = '```(.-)\n(.-)\n```'
_, word = doc_value:match(pattern)
else
-- Handle built-in snippet and non-snippet completion
word = self.entry:get_insert_text()
end
if self.entry:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = tostring(snippet.parse(word))
end
Expand Down

0 comments on commit 5f8e04f

Please sign in to comment.