Beginner luasnip configuration for terraform
This commit is contained in:
parent
8937b9f566
commit
ac168d66d7
@ -34,7 +34,8 @@ ls.config.set_config {
|
|||||||
|
|
||||||
-- Expand if expandable, or jump forward if jumpable
|
-- Expand if expandable, or jump forward if jumpable
|
||||||
-- If neither, do nothing queitly
|
-- If neither, do nothing queitly
|
||||||
vim.keymap.set({ "i", "s" }, "<C-K>", function()
|
-- vim.keymap.set({ "i", "s" }, "<C-K>", function()
|
||||||
|
vim.keymap.set({ "i", "s" }, "<Tab>", function()
|
||||||
if ls.expand_or_jumpable() then
|
if ls.expand_or_jumpable() then
|
||||||
ls.expand_or_jump()
|
ls.expand_or_jump()
|
||||||
end
|
end
|
||||||
@ -42,23 +43,37 @@ end, { silent = true })
|
|||||||
-- end, { silent = true })
|
-- end, { silent = true })
|
||||||
|
|
||||||
-- Jump backwards to the previous jumpable point
|
-- Jump backwards to the previous jumpable point
|
||||||
vim.keymap.set({ "i", "s" }, "<C-J>", function()
|
-- vim.keymap.set({ "i", "s" }, "<C-J>", function()
|
||||||
|
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
|
||||||
if ls.jumpable(-1) then
|
if ls.jumpable(-1) then
|
||||||
ls.jump(-1)
|
ls.jump(-1)
|
||||||
end
|
end
|
||||||
end, { silent = true })
|
end, { silent = true })
|
||||||
|
|
||||||
-- Selecting from a list of options in a choice node
|
-- Selecting from a list of options in a choice node
|
||||||
vim.keymap.set({ "i" }, "<C-L>", function()
|
-- vim.keymap.set({ "i" }, "<C-L>", function()
|
||||||
|
vim.keymap.set({ "i" }, "<A-Tab>", function()
|
||||||
if ls.choice_active() then
|
if ls.choice_active() then
|
||||||
ls.change_choice(1)
|
ls.change_choice(1)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Allow us to hot reload snippets
|
-- Allow us to hot reload snippets by unloading snippets then resourcing file
|
||||||
vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/lua/user/luasnip.lua<CR>")
|
local ls_cleanup = function()
|
||||||
|
ls.cleanup()
|
||||||
|
vim.cmd("source ~/.config/nvim/lua/user/luasnip.lua")
|
||||||
|
end
|
||||||
|
vim.keymap.set("n", "<leader><leader>s", ls_cleanup)
|
||||||
|
|
||||||
ls.add_snippets('lua', {
|
ls.add_snippets(nil, {
|
||||||
|
terraform = {
|
||||||
|
ls.parser.parse_snippet("res", "resource \"$1\" \"$2\" {\n $3\n}"),
|
||||||
|
ls.parser.parse_snippet("dat", "data \"$1\" \"$2\" {\n $3\n}"),
|
||||||
|
ls.parser.parse_snippet("var", "variable \"$1\" {\n type = $2\n description = $3\n}"),
|
||||||
|
ls.parser.parse_snippet("loc", "locals {\n $1\n}"),
|
||||||
|
ls.parser.parse_snippet("mod", "module {\n source = $1\n}"),
|
||||||
|
},
|
||||||
|
lua = {
|
||||||
ls.parser.parse_snippet("expand", "-- this is what was expanded!"),
|
ls.parser.parse_snippet("expand", "-- this is what was expanded!"),
|
||||||
ls.parser.parse_snippet("lf", "local $1 = function($2)\n $0\nend"),
|
ls.parser.parse_snippet("lf", "local $1 = function($2)\n $0\nend"),
|
||||||
ls.parser.parse_snippet("mf", "$1.$2 = function($3)\n $0\nend"),
|
ls.parser.parse_snippet("mf", "$1.$2 = function($3)\n $0\nend"),
|
||||||
@ -79,4 +94,5 @@ ls.add_snippets('lua', {
|
|||||||
rep(1)
|
rep(1)
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user