Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ghost_text): Added custom multi-line snippets ghost_text support #2001

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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