summaryrefslogtreecommitdiff
path: root/plugins/cmp.lua
diff options
context:
space:
mode:
authorseth <[email protected]>2023-09-17 04:54:00 -0400
committerseth <[email protected]>2023-10-07 12:55:41 -0400
commit9d0051e6b4170851ebcc09e7ff44097818c8e1dc (patch)
tree067e1d6b745fc61aeb9b885439482f946bbdf2fe /plugins/cmp.lua
parente910460767dd835c7fb8aa7a59082e645c207cbd (diff)
start using willruggiano/neovim.nix
Diffstat (limited to 'plugins/cmp.lua')
-rw-r--r--plugins/cmp.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/cmp.lua b/plugins/cmp.lua
new file mode 100644
index 0000000..a61dc4a
--- /dev/null
+++ b/plugins/cmp.lua
@@ -0,0 +1,38 @@
+return function()
+ local cmp = require("cmp")
+ local luasnip = require("luasnip")
+ local mapping = cmp.mapping
+
+ return {
+ completion = {
+ completeopt = "menu,menuone,noinsert",
+ },
+
+ snippet = {
+ expand = function(args)
+ luasnip.lsp_expand(args.body)
+ end,
+ },
+
+ mapping = mapping.preset.insert({
+ ["<C-n>"] = mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-p>"] = mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-b>"] = mapping.scroll_docs(-4),
+ ["<C-f>"] = mapping.scroll_docs(4),
+ ["<C-Space>"] = mapping.complete(),
+ ["<C-e>"] = mapping.abort(),
+ ["<CR>"] = mapping.confirm({ select = true }),
+ ["<S-CR>"] = mapping.confirm({
+ behavior = cmp.ConfirmBehavior.Replace,
+ select = true,
+ }),
+ }),
+
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ { name = "async_path" },
+ { name = "buffer" },
+ }),
+ }
+end