neovim: move to vim.pack from lazy

This commit is contained in:
2026-03-13 19:18:43 +03:00
parent 8883f27fb9
commit 33c988cfb1
17 changed files with 224 additions and 320 deletions

View File

@@ -10,6 +10,9 @@ cmp.setup({
end,
},
mapping = {
["<CR>"] = cmp.mapping(function(fallback)
fallback()
end),
["<C-u>"] = cmp.mapping(function(fallback)
if ls.jumpable(1) then
ls.jump(1)
@@ -121,92 +124,3 @@ cmp.setup.filetype("gitcommit", {
})
require("luasnip.loaders.from_vscode").lazy_load()
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node
local d = ls.dynamic_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local ts_utils = require("nvim-treesitter.ts_utils")
ls.add_snippets("go", {
s(
"iferr",
fmt(
[[
if err != nil {
<>
}
]],
{
d(1, function()
local current_node = ts_utils.get_node_at_cursor(0, true)
if not current_node then
return ""
end
local func = current_node
while func do
if func:type() == "function_declaration" then
break
end
func = func:parent()
end
if not func then
return ""
end
local return_type_node = func:child(3)
if not return_type_node then
return ""
end
local params = {}
for index = 0, return_type_node:child_count(), 1 do
local param = return_type_node:child(index)
if param and param:type() == "parameter_declaration" then
local text = ts_utils.get_node_text(param)
table.insert(params, text[1])
end
end
local rec = {
["string"] = '""',
["int"] = "0",
["uint"] = "0",
["error"] = "err",
["bool"] = "false",
}
local size = vim.tbl_count(params)
if size == 0 then
return sn(nil, { i(1) })
end
local x = { t("return ") }
for index, param in ipairs(params) do
local replace = rec[param]
if replace ~= nil then
table.insert(x, i(index, replace))
else
table.insert(x, i(index, param))
end
if index < size then
table.insert(x, t(", "))
end
end
return sn(nil, x)
end, {}),
},
{
delimiters = "<>",
}
)
),
})