Snippet Expansion Removes Closing Parenthesis When Triggered with ;
#1643
-
Contributing guidelines
Module(s)mini.snippets QuestionI'm using (function()
endThe closing I suspect the issue comes from My Code transform_items = function(_, items)
local col = vim.api.nvim_win_get_cursor(0)[2]
local before_cursor = vim.api.nvim_get_current_line():sub(1, col)
local pos = before_cursor:find(";[%w*]*$")
-- if not pos then return items end
if not pos then
return vim.tbl_filter(function(item)
return item.kind ~= require('blink.cmp.types').CompletionItemKind.Snippet
end, items)
end
for _, item in ipairs(items) do
item.textEdit = {
newText = item.insertText or item.label,
range = {
start = {
line = vim.fn.line(".") - 1,
character = pos - 1,
},
["end"] = {
line = vim.fn.line(".") - 1,
character = col,
},
},
}
end
return vim.tbl_filter(function(item)
local kind_snippet = require('blink.cmp.types').CompletionItemKind.Snippet
return pos and item.kind == kind_snippet
end, items)
end,I'm unsure how to fix this for a PR to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
My first thought is that that is a result of how 'Saghen/blink.cmp' (and 'hrsh7th/nvim-cmp', for that matter) handle combination of The second thought is that this might be a consequence of the custom As this is seems to be more of a not 'mini.snippets' question, I am going to close this. If there will be concrete question about how 'mini.snippets' operates, feel free to ask here. I hope to soon update 'mini.snippets' with a way to suggest its entries via an in-process LSP server. Then it can be used with a regular LSP server handling. Not sure if that would help with this custom "; to trigger snippets" approach. |
Beta Was this translation helpful? Give feedback.
My first thought is that that is a result of how 'Saghen/blink.cmp' (and 'hrsh7th/nvim-cmp', for that matter) handle combination of
additionalTextEdits/textEditand snippet expansion. The root cause for this seems to be that 'mini.snippets' always operates in Insert mode which can cause some issues with asynchronous execution (i.e. which text is current at the time of some steps executed). See more information at abeldekat/cmp-mini-snippets#9 and saghen/blink.cmp#1035.The second thought is that this might be a consequence of the custom
transform_itemsconflicting with this part of the 'blink.cmp'.As this is seems to be more of a not 'mini.snippets' question, I am going to close this. …