From: Lukas Hägele Date: Sat, 28 Oct 2023 15:35:40 +0000 (+0200) Subject: add: snippet engine to lsp config X-Git-Url: https://git.lhaegele.de/?a=commitdiff_plain;h=d45f4289f0a05dc6bc99312a739370825b0bd4d8;p=dotfiles_nvim.git add: snippet engine to lsp config --- diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 9b6e7a0..c2493b6 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -58,12 +58,19 @@ local cmp_mappings = cmp.mapping.preset.insert({ [''] = cmp.mapping.select_next_item(cmp_select), }) +local cmp_snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end +} + local cmp_sources = cmp.config.sources({ - { name = 'nvim_lsp' } + { name = 'nvim_lsp' }, + { name = 'luasnip' } }) cmp.setup { mapping = cmp_mappings, - --TODO snippet = ..., + snippet = cmp_snippet, sources = cmp_sources } diff --git a/lua/lukas/packer.lua b/lua/lukas/packer.lua index 45e9c21..c9d857f 100644 --- a/lua/lukas/packer.lua +++ b/lua/lukas/packer.lua @@ -34,6 +34,9 @@ return require('packer').startup(function(use) use('hrsh7th/nvim-cmp') -- additional capabilities use('hrsh7th/cmp-nvim-lsp') + -- snippet engine + use({"L3MON4D3/LuaSnip", tag = "v2.*"}) + use{'saadparwaiz1/cmp_luasnip'} -- syntax highlighting use { @@ -41,7 +44,7 @@ return require('packer').startup(function(use) run = function() local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) ts_update() - end, + end, } -- diagnostics @@ -56,7 +59,7 @@ return require('packer').startup(function(use) -- wiki use { - 'serenevoid/kiwi.nvim', + 'serenevoid/kiwi.nvim', requires = { {'nvim-lua/plenary.nvim'} } } end) diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua index 2048e5a..268f210 100644 --- a/plugin/packer_compiled.lua +++ b/plugin/packer_compiled.lua @@ -74,11 +74,21 @@ end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { + LuaSnip = { + loaded = true, + path = "/home/lukas/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, ["cmp-nvim-lsp"] = { loaded = true, path = "/home/lukas/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + cmp_luasnip = { + loaded = true, + path = "/home/lukas/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, harpoon = { loaded = true, path = "/home/lukas/.local/share/nvim/site/pack/packer/start/harpoon",