From dab768faa85b60f7985eb7a8cdb3c0ddc7431161 Mon Sep 17 00:00:00 2001 From: workflow <4farlion@gmail.com> Date: Sun, 17 Dec 2023 21:30:22 +0000 Subject: [PATCH] feat(nvim): add base cmp setup --- home/neovim/cmp.lua | 28 ++++++++++++++++++++++++++++ home/neovim/default.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 home/neovim/cmp.lua diff --git a/home/neovim/cmp.lua b/home/neovim/cmp.lua new file mode 100644 index 00000000..acbc2f9e --- /dev/null +++ b/home/neovim/cmp.lua @@ -0,0 +1,28 @@ +local cmp = require 'cmp' +local luasnip = require 'luasnip' +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, +} diff --git a/home/neovim/default.nix b/home/neovim/default.nix index 3b5577ba..a0671494 100644 --- a/home/neovim/default.nix +++ b/home/neovim/default.nix @@ -490,6 +490,8 @@ in } { plugin = nvim-cmp; # Autocompletion + config = builtins.readFile ./cmp.lua; + type = "lua"; } { plugin = cmp_luasnip; # Autocompletion for luasnip