46 lines
1.3 KiB
Lua
46 lines
1.3 KiB
Lua
local ls = require('luasnip')
|
|
local ll = require('luasnip.loaders.from_lua')
|
|
local types = require('luasnip.util.types')
|
|
|
|
ls.config.set_config({
|
|
enable_autosnippets = true,
|
|
store_selection_keys = '<C-s>',
|
|
history = true,
|
|
updateevents = 'TextChanged,TextChangedI',
|
|
delete_check_events = 'TextChanged',
|
|
ext_opts = {
|
|
[types.insertNode] = {
|
|
active = {},
|
|
unvisited = {
|
|
virt_text = { { '<- insert', 'DiagnosticVirtualTextHint' } }
|
|
},
|
|
visited = {},
|
|
passive = {},
|
|
snippet_passive = {},
|
|
},
|
|
[types.choiceNode] = {
|
|
active = {
|
|
virt_text = { { '<- insert', 'DiagnosticVirtualTextError' } },
|
|
},
|
|
}
|
|
},
|
|
})
|
|
|
|
ll.load({ paths = { vim.fn.stdpath('config') .. '/snippets' } })
|
|
|
|
vim.keymap.set({ 'i', 's' }, '<C-j>', function()
|
|
if ls.expand_or_jumpable() then
|
|
ls.expand_or_jump()
|
|
end
|
|
end, { silent = true })
|
|
|
|
vim.keymap.set({ 'i', 's' }, '<C-k>', function()
|
|
if ls.jumpable(-1) then
|
|
ls.jump(-1)
|
|
end
|
|
end, { silent = true })
|
|
|
|
vim.keymap.set('n', '<leader><leader>s', function()
|
|
vim.cmd('source ' .. vim.fn.stdpath('config') .. '/after/plugin/luasnip.lua')
|
|
vim.notify('Sourced snippets', 'info', { title = 'LuaSnip' })
|
|
end)
|