-
Notifications
You must be signed in to change notification settings - Fork 120
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
Postfix snippets from Luasnip are not expanded correctly #533
Comments
I've found the solution for postfix snippets defined with Luasnip: keymap = {
["<C-f>"] = {
function(cmp)
vim.schedule(function()
local ls = require "luasnip"
if ls.expandable() then
ls.expand()
else
cmp.select_and_accept()
end
end)
end
}
|
I would like to select elements without any additional keymaps. |
I'm not sure what you mean. Do you mind giving an example? |
Sorry I though you suggested new keymap just for it. I tried your solution and it seems working partially. |
Can you please dump your entire blink.cmp config? |
return {
'saghen/blink.cmp',
lazy = false, -- lazy loading handled internally
version = 'v0.*',
opts = {
keymap = {
preset = 'super-tab',
['<CR>'] = { 'accept', 'fallback' },
-- fix attempt
['<C-g>'] = { function(cmp)
vim.schedule(function()
local ls = require "luasnip"
if ls.expandable() then
ls.expand()
else
cmp.select_and_accept()
end
end)
end },
['<S-Tab>'] = { 'select_prev', 'fallback' },
['<Tab>'] = { 'select_next', 'fallback' },
['<C-n>'] = {
function(cmp)
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
'snippet_forward',
'fallback'
},
['<C-p>'] = { 'snippet_backward', 'fallback' },
},
completion = {
trigger = {
show_in_snippet = false
},
list = {
selection = "auto_insert"
}
},
documentation = {
auto_show = false,
},
appearance = {
use_nvim_cmp_as_default = true,
nerd_font_variant = 'mono'
},
sources = {
completion = {
enabled_providers = function(ctx)
-- providers func body
end
},
providers = {
-- non related providers
},
snippets = {
expand = function(snippet)
require('luasnip').lsp_expand(snippet)
end,
active = function(filter)
if filter and filter.direction then
return require('luasnip').jumpable(filter.direction)
end
return require('luasnip').in_snippet()
end,
jump = function(direction) require('luasnip').jump(direction) end,
},
},
opts_extend = { "sources.completion.enabled_providers" }
} |
I would recommend updating to the latest version first. Here's the updated config: --- @type LazySpec
return {
"saghen/blink.cmp",
dependencies = "L3MON4D3/LuaSnip",
lazy = false, -- lazy loading handled internally
-- version = 'v0.*',
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = {
preset = "super-tab",
["<CR>"] = { "accept", "fallback" },
-- fix attempt
["<C-g>"] = {
function(cmp)
vim.schedule(function()
local ls = require "luasnip"
if ls.expandable() then
ls.expand()
else
cmp.select_and_accept()
end
end)
end,
},
["<S-Tab>"] = { "select_prev", "fallback" },
["<Tab>"] = { "select_next", "fallback" },
["<C-n>"] = {
function(cmp)
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
"snippet_forward",
"fallback",
},
["<C-p>"] = { "snippet_backward", "fallback" },
},
completion = {
trigger = {
show_in_snippet = false,
},
list = {
selection = "auto_insert",
},
},
documentation = {
auto_show = false,
},
appearance = {
use_nvim_cmp_as_default = true,
nerd_font_variant = "mono",
},
sources = {
completion = {
default = { "lsp", "buffer", "path", "luasnip" },
},
providers = {
-- non related providers
},
snippets = {
expand = function(snippet)
require("luasnip").lsp_expand(snippet)
end,
active = function(filter)
if filter and filter.direction then
return require("luasnip").jumpable(filter.direction)
end
return require("luasnip").in_snippet()
end,
jump = function(direction)
require("luasnip").jump(direction)
end,
},
},
opts_extend = { "sources.default" },
},
} I made blink.cmp depend on luasnip and commented out the explicitly specified version plus added the new After updating the config, I would recommend that you delete blink through Lazy by running |
Hey, I followed your steps, adjusted the configuration and dived deep into testing.
|
For ["<cr>"] = {
function(cmp)
if cmp.is_visible() then return cmp.accept() end
end,
"fallback",
},
I'm not experiencing those issues at all, so unfortunately I'm unable to provide hints there. |
Make sure you have done the following
blink.cmp
Bug Description
When selecting postfix snippet it appears after TS "context".
Relevant configuration
neovim version
NVIM v0.10.2 Build type: Release LuaJIT 2.1.1727870382 Run "nvim -V1 -v" for more info
blink.cmp
version: branch, tag, or commitv0.7.6
The text was updated successfully, but these errors were encountered: