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.lua99
1 files changed, 99 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..69a2396
--- /dev/null
+++ b/config/nvim/lua/plugins/cmp.lua
@@ -0,0 +1,99 @@
+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({
+      -- preselect = cmp.PreselectMode.None,
+      completion = {
+        completeopt = "menu,menuone,noinsert",
+        callSnippet = "Replace",
+        keywordSnippet = "Replace",
+      },
+      window = {
+        completion = cmp.config.window.bordered({}),
+        documentation = cmp.config.window.bordered({}),
+      },
+      snippet = {
+        expand = function(arg)
+          vim.snippet.expand(arg.body)
+        end
+      },
+      mapping = cmp.mapping.preset.insert({
+        ['<Tab>'] = cmp.mapping.confirm({ select = true }),
+        ['<C-n>'] = cmp.mapping.select_next_item(),
+        ['<C-p>'] = cmp.mapping.select_prev_item(),
+        ['<C-g>'] = cmp.mapping.abort(),
+      }),
+      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()
+    vim.lsp.config('lua_ls', {
+      -- cmd = { '/home/venomade/.local/share/lua-language-server/bin/lua-language-server' },
+      capabilities = capabilities,
+      root_markers = {
+        ".luarc.json",
+        ".luarc.jsonc",
+        ".git",
+      },
+      settings = {
+        Lua = {
+          runtime = {
+            version = 'Lua 5.4',
+            path = vim.list_extend(
+              vim.split(package.path, ';'),
+              {
+                '?.lua',
+                '?/init.lua',
+                './stubs/?.lua',
+                './stubs/?/init.lua'
+              }),
+          },
+          workspace = {
+            library = {
+              vim.env.HOME .. '/.luarocks/share/lua/5.4',
+              './stubs'
+            },
+          },
+          diagnostics = {
+            enable = true,
+          },
+        },
+      },
+    })
+
+    vim.lsp.enable('lua_ls')
+    vim.lsp.config('clangd', {
+      capabilities = capabilities
+    })
+    vim.lsp.enable('clangd')
+  end
+}