diff --git a/neovim/lua/_bindings.lua b/neovim/lua/_bindings.lua index 5ff405f..04a9e78 100644 --- a/neovim/lua/_bindings.lua +++ b/neovim/lua/_bindings.lua @@ -51,6 +51,8 @@ function _G.complete_space() return utils.t("(completion_trigger)") elseif utils.is_plugin_loaded("nvim-compe") then return vim.fn["compe#complete"]() + elseif utils.is_plugin_loaded("nvim-cmp") then + return utils.t("(cmp_complete)") else return utils.t("") end diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index acd99a4..3629038 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -143,9 +143,20 @@ return require('packer').startup(function() --]] -- Completion + --[[ use { "nvim-lua/completion-nvim", - config = function() require("utils").require_with_local("plugins.completion") end, + config = function() require("plugins.completion").config_complete() end, + } + --]] + use { + "hrsh7th/nvim-cmp", + config = function() require("plugins.completion").config_cmp() end, + requires = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "f3fora/cmp-spell", + } } -- Fuzzy Finder diff --git a/neovim/lua/plugins/completion.lua b/neovim/lua/plugins/completion.lua index 552c1c9..bb389cc 100644 --- a/neovim/lua/plugins/completion.lua +++ b/neovim/lua/plugins/completion.lua @@ -1,24 +1,31 @@ --- TODO: Determine if keeping this ---[[ -local function config_compe() - require("compe").setup{ - enabled = true, - autocomplete = true, - source = { - path = true, - buffer = true, - calc = true, - tags = true, - spell = true, - nvim_lsp = true, - nvim_lua = true, +local M = {} + +function M.config_cmp() + vim.o.completeopt = "menuone,noinsert,noselect" + local cmp = require("cmp") + cmp.setup { + completion = { + completeopt = "menuone,noinsert,noselect", + autocomplete = false, + }, + sources = { + {name = "nvim_lsp"}, + {name = "buffer"}, + {name = "spell"}, }, } + + -- Add a plug mapping to use in C-Space binding + vim.api.nvim_set_keymap( + "i", + "(cmp_complete)", + "lua require('cmp').complete()", + {silent = true, noremap = true} + ) end ---]] -- TODO: Some issue with tags completion maybe compe is better? -local function config_complete() +function M.config_complete() vim.o.completeopt = "menuone,noinsert,noselect" -- shortmess+=c vim.g.completion_enable_auto_popup = 0 @@ -31,4 +38,4 @@ local function config_complete() ]]) end -config_complete() +return M diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index 0edbdd1..b310d6b 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -78,8 +78,16 @@ local function config_lsp() } local lsp_config = require("lspconfig") + -- Maybe update capabilities + local capabilities = vim.lsp.protocol.make_client_capabilities() + if utils.is_plugin_loaded("cmp-nvim-lsp") then + capabilities = require("cmp_nvim_lsp").update_capabilities( + capabilities, {snippetSupport = false}) + end + for _, ls in ipairs(language_servers) do lsp_config[ls].setup{ + capabilities = capabilities, on_attach=default_attach, settings={ pylsp={