-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore snippets that only contain text
Closes #624
- Loading branch information
Showing
1 changed file
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,12 +31,24 @@ local function accept(ctx, item, callback) | |
if | ||
ctx.mode == 'default' | ||
and item.insertTextFormat ~= vim.lsp.protocol.InsertTextFormat.Snippet | ||
and item.kind ~= require('blink.cmp.types').CompletionItemKind.Snippet | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
soifou
Contributor
|
||
and require('blink.cmp.config').completion.accept.create_undo_point | ||
then | ||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-g>u', true, true, true), 'n', true) | ||
end | ||
|
||
-- Ignore snippets that only contain text | ||
if item.insertTextFormat == vim.lsp.protocol.InsertTextFormat.Snippet then | ||
local parsed_snippet = require('blink.cmp.sources.snippets.utils').safe_parse(item.textEdit.newText) | ||
if | ||
parsed_snippet ~= nil | ||
and #parsed_snippet.data.children == 1 | ||
and parsed_snippet.data.children[1].type == vim.lsp._snippet_grammar.NodeType.Text | ||
then | ||
vim.notify('Snippet only contains text, ignoring', vim.log.levels.WARN) | ||
item.insertTextFormat = vim.lsp.protocol.InsertTextFormat.PlainText | ||
end | ||
end | ||
|
||
-- Add brackets to the text edit if needed | ||
local brackets_status, text_edit_with_brackets, offset = brackets_lib.add_brackets(ctx, vim.bo.filetype, item) | ||
item.textEdit = text_edit_with_brackets | ||
|
Why the removal of this line? This break luasnip expanding in select mode