add lua snippet
This commit is contained in:
parent
9efae9f0f4
commit
2fe153a57a
@ -2,10 +2,11 @@ local ls = require("luasnip")
|
||||
local capture = require("utils.capture")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local choice = ls.choice_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
|
||||
local function getCurrentYear()
|
||||
@ -20,6 +21,18 @@ local function getGitUsername()
|
||||
return stdout
|
||||
end
|
||||
|
||||
ls.config.set_config {
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
enable_autosnippets = true
|
||||
}
|
||||
|
||||
vim.keymap.set({"i"}, "<c-l>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
end
|
||||
end)
|
||||
|
||||
ls.add_snippets("all", {
|
||||
s("MIT", {
|
||||
t({"The MIT License (MIT)", "Copyright © "}),
|
||||
@ -53,3 +66,15 @@ ls.add_snippets("all", {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
ls.add_snippets("lua", {
|
||||
s("req",
|
||||
fmt([[local {} = require("{}")]], {
|
||||
f(function(module_name)
|
||||
local parts = vim.split(module_name[1][1], ".", true)
|
||||
return (parts[#parts] or ""):gsub("-", "_")
|
||||
end, { 1 }),
|
||||
i(1)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user