nvim/lua/custom/plugins/snippets.lua
Jeremie Fraeys 99a6cba26a
refactor: update development tooling
- Refactor dap.lua debugger configuration
- Update neotest.lua test runner setup
- Simplify linting.lua and formatting.lua configs
- Restructure snippets.lua for better organization
2026-03-23 20:33:16 -04:00

56 lines
1.5 KiB
Lua
Executable file

return {
'L3MON4D3/LuaSnip',
version = 'v2.*',
build = 'make install_jsregexp',
event = 'InsertEnter',
dependencies = {
'saadparwaiz1/cmp_luasnip',
'rafamadriz/friendly-snippets',
},
config = function()
local luasnip = require('luasnip')
local loader = require('luasnip.loaders.from_vscode')
-- load snippets on demand per filetype rather than all at once
loader.lazy_load()
vim.api.nvim_create_autocmd('FileType', {
callback = function(args)
local ft = vim.bo[args.buf].filetype
if ft and ft ~= '' then
loader.lazy_load({ include = { ft } })
end
end,
})
luasnip.config.setup({
history = true,
updateevents = 'TextChanged,TextChangedI',
})
luasnip.filetype_extend('python', { 'google' })
vim.keymap.set('i', '<C-l>e', function()
if luasnip.expand_or_jumpable() then
luasnip.expand()
end
end, { silent = true, desc = 'Snippet: expand' })
vim.keymap.set({ 'i', 's' }, '<C-l>;', function()
if luasnip.jumpable(1) then
luasnip.jump(1)
end
end, { silent = true, desc = 'Snippet: jump forward' })
vim.keymap.set({ 'i', 's' }, '<C-l>,', function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
end
end, { silent = true, desc = 'Snippet: jump backward' })
vim.keymap.set({ 'i', 's' }, '<C-l>c', function()
if luasnip.choice_active() then
luasnip.change_choice(1)
end
end, { silent = true, desc = 'Snippet: cycle choice' })
end,
}