From 8aecc1b1a2b11065099060f6695682420ffaac1e Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Fri, 9 Feb 2024 01:40:58 +0300 Subject: nvim: switch to vim-snippets luasnip fork https://www.reddit.com/r/neovim/comments/18w0ule/luasnip_snippet_collection_from_vimsnippets/ --- .config/nvim/lua/plugins/cmp.lua | 39 ++++++++++++++++++++++++++------------- .config/nvim/lua/plugins/lsp.lua | 3 --- 2 files changed, 26 insertions(+), 16 deletions(-) (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 6a93009..2e8fade 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -10,7 +10,6 @@ return { "hrsh7th/cmp-nvim-lsp-signature-help", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", - "honza/vim-snippets", }, config = function() local cmp = require("cmp") @@ -141,28 +140,42 @@ return { }) end, }, + { + 'mireq/luasnip-snippets', + dependencies = {'L3MON4D3/LuaSnip'}, + init = function() + require('luasnip_snippets.common.snip_utils').setup() + end + + }, { "L3MON4D3/LuaSnip", version = "v2.*", dependencies = { - "honza/vim-snippets", + 'nvim-treesitter/nvim-treesitter', }, build = "make install_jsregexp", - keys = { - { - "", - function() require("luasnip").expand_or_jump() end, - mode = { "i", "s" }, - }, - }, opts = { history = false, region_check_events = 'InsertEnter', delete_check_events = 'InsertLeave', }, - config = function(_, opts) - require("luasnip").setup(opts) - require("luasnip.loaders.from_snipmate").lazy_load() - end, + init = function() + local ls = require('luasnip') + ls.setup({ + -- Required to automatically include base snippets, like "c" snippets for "cpp" + load_ft_func = require('luasnip_snippets.common.snip_utils').load_ft_func, + ft_func = require('luasnip_snippets.common.snip_utils').ft_func, + -- To enable auto expansin + enable_autosnippets = true, + -- Uncomment to enable visual snippets triggered using + -- store_selection_keys = '', + }) + -- LuaSnip key bindings + vim.keymap.set({"i", "s"}, "", function() if ls.expand_or_jumpable() then ls.expand_or_jump() else vim.api.nvim_input('') end end, {silent = true}) + vim.keymap.set({"i", "s"}, "", function() ls.jump(-1) end, {silent = true}) + vim.keymap.set({"i", "s"}, "", function() if ls.choice_active() then ls.change_choice(1) end end, {silent = true}) + end + }, } diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 95f09f1..029a0f1 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -72,9 +72,6 @@ return { local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) - -- pkgbuild - require("lspconfig").pkgbuild_language_server.setup({}) - -- lua require("lspconfig")["lua_ls"].setup({ on_attach = on_attach, -- cgit v1.2.3-70-g09d2