diff options
-rw-r--r-- | after/plugin/luasnip.lua | 24 | ||||
-rw-r--r-- | lua/config/lsp.lua | 2 |
2 files changed, 18 insertions, 8 deletions
diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua index e882168..9943ba3 100644 --- a/after/plugin/luasnip.lua +++ b/after/plugin/luasnip.lua @@ -5,15 +5,17 @@ local t = ls.text_node local map = vim.keymap.set -map("i", "<C-k>", function() +map("i", "<C-h>", function() if ls.expand_or_locally_jumpable() then ls.expand_or_jump() end end, { silent = true }) -map({ "i", "s" }, "<C-J>", function() - ls.locally_jumpable(-1) -end, { silent = true }) map({ "i", "s" }, "<C-l>", function() + if ls.locally_jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) +map({ "i", "s" }, "<C-c>", function() if ls.choice_active() then ls.change_choice(1) end @@ -26,6 +28,14 @@ ls.config.set_config({ history = true, }) --- ls.add_snippets("all", { --- ls.parser.parse_snippet("expand", "-- this is $1 expanded $2 $3!"), --- }) +ls.add_snippets("all", { + ls.parser.parse_snippet("test", "$1->$2->$3->$0\n"), +}) +ls.add_snippets("go", { + ls.parser.parse_snippet("main", "package main\n\nfunc main() {\n\t$0\n}"), + ls.parser.parse_snippet("e", "if err != nil {\n\t$1\n}\n$0"), + ls.parser.parse_snippet("ep", "if err != nil {\n\tpanic(err)\n}\n$0"), + ls.parser.parse_snippet("eif", "if err := $1; err != nil {\n\tpanic(err)\n}\n$0"), + ls.parser.parse_snippet("pf", "fmt.Printf($0)"), + ls.parser.parse_snippet("pl", "fmt.Println($0)"), +}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 346f791..d5645af 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -96,7 +96,7 @@ cmp.setup({ name = "nvim_lsp", keyword_length = 3, }, - { name = "luasnip" }, + -- { name = "luasnip" }, }, { -- { name = "buffer", max_item_count = 5 }, { name = "path", max_item_count = 5 }, |