From 0c196909a3f3ef9388344ef88e1f0002aa445fd6 Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Tue, 30 Jan 2024 11:23:49 -0500 Subject: NOT WORKING: Add custom snippets --- after/plugin/lsp.lua | 9 +++++++-- after/plugin/luasnip.lua | 0 my_snippets/package.json | 25 +++++++++++++++++++++++++ my_snippets/python.json | 8 ++++++++ my_snippets/snippets/all.json | 16 ++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 after/plugin/luasnip.lua create mode 100644 my_snippets/package.json create mode 100644 my_snippets/python.json create mode 100644 my_snippets/snippets/all.json diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index a923813..a438d00 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -21,6 +21,9 @@ lsp.configure('lua-language-server', { } }) +-- require("luasnip.loaders.from_vscode").lazy_load({ paths = { "./my-cool-snippets" } }) +require("luasnip.loaders.from_vscode").lazy_load({paths = {"~/snippets"}}) + -- Autocomplettion engine setup -- This is the drop downs that come up local cmp = require('cmp') @@ -48,8 +51,10 @@ lsp.setup_nvim_cmp({ -- I feel like what I'm writing is, more often than not, something I've already written so I don't mind scrolling down in the list if I have to make a function or actually use one of the snippets. sources = { {name = 'buffer'}, -- words found in your buffer (cmp-buffer) - {name = 'nvim_lsp'}, -- everything the language server finds (neovim/nvim-lspconfig) + -- {name = 'nvim_lsp'}, -- everything the language server finds (neovim/nvim-lspconfig) + { name = 'nvim_lsp', max_item_count = 10, keyword_length = 4 }, {name = 'luasnip'}, -- custom/popular snippets for languages (L3MON4D3/LuaSnip and rafamadriz/friendly-snippets) + {name = 'cmd_luasnip'}, -- custom/popular snippets for languages (L3MON4D3/LuaSnip and rafamadriz/friendly-snippets) } }) @@ -81,6 +86,6 @@ end) lsp.setup() vim.diagnostic.config({ - virtual_text = true + virtual_text = true }) diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua new file mode 100644 index 0000000..e69de29 diff --git a/my_snippets/package.json b/my_snippets/package.json new file mode 100644 index 0000000..0059209 --- /dev/null +++ b/my_snippets/package.json @@ -0,0 +1,25 @@ +{ + "name": "example-snippets", + "contributes": { + "snippets": [ + { + "language": [ + "all" + ], + "path": "./snippets/all.json" + }, + { + "language": [ + "lua" + ], + "path": "./lua.json" + } + { + "language": [ + "python" + ], + "path": "./python.json" + } + ] + } +} diff --git a/my_snippets/python.json b/my_snippets/python.json new file mode 100644 index 0000000..1ebe30a --- /dev/null +++ b/my_snippets/python.json @@ -0,0 +1,8 @@ +{ + "snip1": { + "prefix": "python", + "body": [ + "pythonpythonpython" + ] + } +} diff --git a/my_snippets/snippets/all.json b/my_snippets/snippets/all.json new file mode 100644 index 0000000..29df278 --- /dev/null +++ b/my_snippets/snippets/all.json @@ -0,0 +1,16 @@ +{ + "snip1": { + "prefix": "all1", + "body": [ + "expands? jumps? $1 $2 !" + ] + }, + "snip2": { + "prefix": "all2", + "body": [ + "multi $1", + "line $2", + "snippet$0" + ] + } +} -- cgit v1.2.3