summaryrefslogtreecommitdiff
path: root/nvim/.config
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/.config')
-rw-r--r--nvim/.config/nvim/lua/cmp_config.lua51
-rw-r--r--nvim/.config/nvim/lua/lsp_config.lua5
-rw-r--r--nvim/.config/nvim/lua/plugins.lua13
3 files changed, 69 insertions, 0 deletions
diff --git a/nvim/.config/nvim/lua/cmp_config.lua b/nvim/.config/nvim/lua/cmp_config.lua
new file mode 100644
index 0000000..fa1610f
--- /dev/null
+++ b/nvim/.config/nvim/lua/cmp_config.lua
@@ -0,0 +1,51 @@
+local cmp = require('cmp')
+
+cmp.setup({
+ snippet = {
+ -- REQUIRED - you must specify a snippet engine
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
+ -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
+ -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
+ -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
+ end,
+ },
+ window = {
+ -- completion = cmp.config.window.bordered(),
+ -- documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'vsnip' }, -- For vsnip users.
+ -- { name = 'luasnip' }, -- For luasnip users.
+ -- { name = 'ultisnips' }, -- For ultisnips users.
+ -- { name = 'snippy' }, -- For snippy users.
+ { name = 'path' },
+ })
+})
+
+-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
+cmp.setup.cmdline('/', {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = {
+ { name = 'buffer' }
+ }
+})
+
+-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
+cmp.setup.cmdline(':', {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = cmp.config.sources({
+ { name = 'path' }
+ }, {
+ { name = 'cmdline' }
+ })
+})
+
diff --git a/nvim/.config/nvim/lua/lsp_config.lua b/nvim/.config/nvim/lua/lsp_config.lua
index 4bb64bf..55f4d6d 100644
--- a/nvim/.config/nvim/lua/lsp_config.lua
+++ b/nvim/.config/nvim/lua/lsp_config.lua
@@ -50,12 +50,17 @@ local on_attach = function(client, bufnr)
end
end
+-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
+local capabilities = vim.lsp.protocol.make_client_capabilities()
+capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
+
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'tsserver', 'zls' }
for _, lsp in pairs(servers) do
lspconfig[lsp].setup({
on_attach = on_attach,
+ capabilities = capabilities,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua
index ae53f90..18d0fd0 100644
--- a/nvim/.config/nvim/lua/plugins.lua
+++ b/nvim/.config/nvim/lua/plugins.lua
@@ -39,11 +39,24 @@ return require('packer').startup(function()
requires = {
"jose-elias-alvarez/null-ls.nvim",
"jose-elias-alvarez/nvim-lsp-ts-utils",
+ "hrsh7th/cmp-nvim-lsp'",
},
config = function() require('lsp_config') end
}
use {
+ 'hrsh7th/nvim-cmp',
+ requires = {
+ 'hrsh7th/cmp-nvim-lsp',
+ 'hrsh7th/cmp-buffer',
+ 'hrsh7th/cmp-path',
+ 'hrsh7th/cmp-cmdline',
+ 'hrsh7th/vim-vsnip',
+ },
+ config = function() require('cmp_config') end
+ }
+
+ use {
'nvim-neo-tree/neo-tree.nvim',
requires = {
'nvim-lua/plenary.nvim',