Skip to content

Commit

Permalink
feat(nvim): add base cmp setup
Browse files Browse the repository at this point in the history
  • Loading branch information
workflow committed Dec 17, 2023
1 parent cc9e8fc commit dab768f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions home/neovim/cmp.lua
Original file line number Diff line number Diff line change
@@ -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 {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-u>'] = cmp.mapping.scroll_docs(4),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
},
}
2 changes: 2 additions & 0 deletions home/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ in
}
{
plugin = nvim-cmp; # Autocompletion
config = builtins.readFile ./cmp.lua;
type = "lua";
}
{
plugin = cmp_luasnip; # Autocompletion for luasnip
Expand Down

0 comments on commit dab768f

Please sign in to comment.