2022-10-16 23:50:45 +00:00
|
|
|
local present, luasnip = pcall(require, "luasnip")
|
|
|
|
|
|
|
|
if not present then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2023-01-30 21:13:34 +00:00
|
|
|
local M = {}
|
2022-10-16 23:50:45 +00:00
|
|
|
local types = require("luasnip.util.types")
|
|
|
|
|
|
|
|
local options = {
|
|
|
|
history = true,
|
|
|
|
updateevents = "TextChanged,TextChangedI",
|
2022-10-19 13:40:39 +00:00
|
|
|
enable_autosnippets = true,
|
2022-10-16 23:50:45 +00:00
|
|
|
ext_opts = {
|
|
|
|
[types.choiceNode] = {
|
|
|
|
passive = {
|
2022-10-19 13:40:39 +00:00
|
|
|
virt_text = { { " ", "LuaSnipChoice" } },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[types.insertNode] = {
|
|
|
|
passive = {
|
|
|
|
virt_text = { { " ", "LuaSnipInsert" } },
|
2022-10-16 23:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
M.setup = function()
|
|
|
|
luasnip.config.set_config(options)
|
|
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
|
|
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("InsertLeave", {
|
|
|
|
callback = function()
|
|
|
|
if require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
|
|
|
|
and not require("luasnip").session.jump_active
|
|
|
|
then
|
|
|
|
require("luasnip").unlink_current()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|