about summary refs log tree commit diff
path: root/.config/nvim/lua/plugins/cmp.lua
diff options
context:
space:
mode:
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
+}