-
Hey everyone, Looking for some help troubleshooting snippy as I'm at my wit's end here. return {
{
-- Use snippy instead of LuaSnip.
"L3MON4D3/LuaSnip",
enabled = false,
},
{
-- cmp-snippy configures nvim-cmp to use nvim-snippy.
"dcampos/cmp-snippy",
dependencies = {
"dcampos/nvim-snippy",
"hrsh7th/nvim-cmp",
},
},
{
"dcampos/nvim-snippy",
},
{
"hrsh7th/nvim-cmp",
---@param opts cmp.ConfigSchema
opts = function(_, opts)
opts.enabled = function()
local context = require("cmp.config.context")
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == "c" then
return true
else
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
end
end
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert })
else
fallback()
end
end, { "i", "s" }),
["<Esc>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.abort()
else
fallback()
end
end, { "i", "s" }),
})
end,
},
} This config is working for me right now, I get LSP suggestions as I type: Now I have tried to define some actual snippets for common tasks: 13:16:04 ~ $> cat ~/.config/nvim/snippets/go.snippets
snippet ch "channel"
chan ${0:int}
snippet br "break"
break
snippet cn "continue"
continue However, these snippets do not show up: I believe the It seems to me that I'm missing something very obvious about how to make snippy actually show up my snippets, but I'm not being able to figure that out 😅 Any hint would be extremely appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I've figured this out. I was lacking the following in my opts.snippet.expand = function(args)
require("snippy").expand_snippet(args.body)
end
table.insert(opts.sources, { name = "snippy" }) I thought Full config is now: return {
{
-- Use snippy instead of LuaSnip.
"L3MON4D3/LuaSnip",
enabled = false,
},
{
-- cmp-snippy configures nvim-cmp to use nvim-snippy.
"dcampos/cmp-snippy",
dependencies = {
"dcampos/nvim-snippy",
"hrsh7th/nvim-cmp",
},
},
{
"dcampos/nvim-snippy",
},
{
"hrsh7th/nvim-cmp",
---@param opts cmp.ConfigSchema
opts = function(_, opts)
opts.snippet.expand = function(args)
require("snippy").expand_snippet(args.body)
end
table.insert(opts.sources, { name = "snippy" })
opts.enabled = function()
local context = require("cmp.config.context")
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == "c" then
return true
else
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
end
end
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert })
else
fallback()
end
end, { "i", "s" }),
["<Esc>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.abort()
else
fallback()
end
end, { "i", "s" }),
})
end,
},
} |
Beta Was this translation helpful? Give feedback.
I think I've figured this out. I was lacking the following in my
nvim-cmp
config:I thought
cmp-snippy
would take care of that, but it doesn't seem to be the case. After adding those lines, completion boxes show snippets as well:Full config is now: