about summary refs log tree commit diff
path: root/.config/nvim/lua/plugins/cmp.lua
diff options
context:
space:
mode:
authorvenomade <venomade@venomade.com>2025-05-22 20:25:43 +0100
committervenomade <venomade@venomade.com>2025-05-22 20:25:43 +0100
commitedc74a464606b98378e24e27dcd3041b0f7f9162 (patch)
treef8f9acfcb332360906eb2d0ac7f1115d543768e4 /.config/nvim/lua/plugins/cmp.lua
parentedcf5dd381c26274a939f4e703539b15c0058e99 (diff)
MacOS & Neovim HEAD master
Diffstat (limited to '.config/nvim/lua/plugins/cmp.lua')
-rw-r--r--.config/nvim/lua/plugins/cmp.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua
new file mode 100644
index 0000000..e61b901
--- /dev/null
+++ b/.config/nvim/lua/plugins/cmp.lua
@@ -0,0 +1,51 @@
+return {
+  'hrsh7th/nvim-cmp',
+  dependencies = {
+    'neovim/nvim-lspconfig',
+    'hrsh7th/cmp-nvim-lsp',
+    'hrsh7th/cmp-buffer',
+    'hrsh7th/cmp-path',
+    'lukas-reineke/cmp-rg',
+    'onsails/lspkind.nvim'
+  },
+  config = function()
+    local cmp = require('cmp')
+    local lspkind = require('lspkind')
+    cmp.setup({
+      snippet = {
+        expand = function(arg)
+          vim.snippet.expand(arg.body)
+        end
+      },
+      mapping = cmp.mapping.preset.insert({
+        -- ['<CR>'] = cmp.mapping.confirm({ select = true }),
+        ['<CR>'] = cmp.mapping.confirm(),
+        ['<Tab>'] = cmp.mapping.select_next_item(),
+        ['<S-Tab>'] = cmp.mapping.select_prev_item(),
+      }),
+      sources = cmp.config.sources(
+        {
+          { name = 'nvim_lsp' },
+        },
+        {
+          { name = 'path' },
+        },
+        {
+          { name = 'buffer' },
+          { name = 'rg', keyword_length = 3 }
+        }
+      ),
+      formatting = {
+        format = lspkind.cmp_format({
+          mode = 'symbol'
+        })
+      },
+      view = {
+        entries = 'native'
+      }
+    })
+
+    local capabilities = require('cmp_nvim_lsp').default_capabilities()
+    require("lspconfig").lua_ls.setup({capabilities = capabilities})
+  end
+}