Migrate to nvim-cmp over nvim-compe
parent
60d4643cbd
commit
fbfd4800f9
|
@ -78,7 +78,9 @@ return require('packer').startup {
|
||||||
-- LSP --
|
-- LSP --
|
||||||
use 'neovim/nvim-lspconfig' -- Easy LSP Config
|
use 'neovim/nvim-lspconfig' -- Easy LSP Config
|
||||||
use 'alexaandru/nvim-lspupdate' -- Easy install and update for many LSP servers
|
use 'alexaandru/nvim-lspupdate' -- Easy install and update for many LSP servers
|
||||||
use 'hrsh7th/nvim-compe' -- LSP completion integration
|
use 'hrsh7th/cmp-nvim-lsp' -- LSP source for cmp
|
||||||
|
use 'hrsh7th/cmp-buffer' -- Buffer source for nvim-cmp
|
||||||
|
use 'hrsh7th/nvim-cmp' -- completion integration
|
||||||
use 'nvim-lua/lsp_extensions.nvim' -- LSP extensions (like closing labels for Dart)
|
use 'nvim-lua/lsp_extensions.nvim' -- LSP extensions (like closing labels for Dart)
|
||||||
|
|
||||||
-- LSP language specific
|
-- LSP language specific
|
||||||
|
|
|
@ -3,38 +3,25 @@
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Set completeopt to have a better completion experience
|
-- Set completeopt to have a better completion experience
|
||||||
vim.o.completeopt = "menuone,noselect"
|
vim.o.completeopt = "menu,menuone,noselect"
|
||||||
|
|
||||||
require'compe'.setup {
|
local cmp = require'cmp'
|
||||||
enabled = true;
|
cmp.setup {
|
||||||
autocomplete = true;
|
snippet = {
|
||||||
debug = false;
|
expand = function(args)
|
||||||
min_length = 1;
|
vim.fn["UltiSnips#Anon"](args.body)
|
||||||
preselect = 'enable';
|
end,
|
||||||
throttle_time = 80;
|
},
|
||||||
source_timeout = 200;
|
mapping = {
|
||||||
incomplete_delay = 400;
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
max_abbr_width = 100;
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
max_kind_width = 100;
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
max_menu_width = 100;
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
documentation = true;
|
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
},
|
||||||
source = {
|
sources = {
|
||||||
path = true;
|
{ name = 'nvim_lsp' },
|
||||||
buffer = true;
|
{ name = 'ultisnips' },
|
||||||
calc = true;
|
{ name = 'buffer' },
|
||||||
nvim_lsp = true;
|
}
|
||||||
nvim_lua = true;
|
|
||||||
ultisnips = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
|
||||||
|
|
||||||
local default_opts = {noremap = true, silent = true, expr = true}
|
|
||||||
|
|
||||||
set_keymap('i', '<C-Space>', 'compe#complete()', default_opts)
|
|
||||||
set_keymap('i', '<C-y>', "compe#confirm('<C-y>')", default_opts)
|
|
||||||
set_keymap('i', '<C-e>', "compe#close('<C-e>')", default_opts)
|
|
||||||
set_keymap('i', '<C-f>', "compe#scroll({ 'delta': +4 })", default_opts)
|
|
||||||
set_keymap('i', '<C-d>', "compe#scroll({ 'delta': -4 })", default_opts)
|
|
||||||
|
|
|
@ -5,15 +5,21 @@
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
local common_config = require("lsp.server_config")
|
local common_config = require("lsp.server_config")
|
||||||
|
|
||||||
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
-- Lsp default language servers
|
-- Lsp default language servers
|
||||||
local servers = { "bashls", "clangd", "cucumber_language_server", "crystalline", "dockerls", "jsonls", "pyright", "rust_analyzer", "kotlin_language_server", "mint", "vimls", "clojure_lsp", "gopls", "gdscript", "terraformls", "tsserver" }
|
local servers = { "bashls", "clangd", "cucumber_language_server", "crystalline", "dockerls", "jsonls", "pyright", "rust_analyzer", "kotlin_language_server", "mint", "vimls", "clojure_lsp", "gopls", "gdscript", "terraformls", "tsserver" }
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
lspconfig[lsp].setup { on_attach = common_config.on_attach }
|
lspconfig[lsp].setup {
|
||||||
|
on_attach = common_config.on_attach,
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Lua bultin lsp
|
-- Lua bultin lsp
|
||||||
require('nlua.lsp.nvim').setup(lspconfig, {
|
require('nlua.lsp.nvim').setup(lspconfig, {
|
||||||
on_attach = common_config.on_attach,
|
on_attach = common_config.on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
|
||||||
-- Include globals you want to tell the LSP are real :)
|
-- Include globals you want to tell the LSP are real :)
|
||||||
globals = {}
|
globals = {}
|
||||||
|
@ -22,7 +28,8 @@ require('nlua.lsp.nvim').setup(lspconfig, {
|
||||||
-- Flutter tools
|
-- Flutter tools
|
||||||
require('flutter-tools').setup {
|
require('flutter-tools').setup {
|
||||||
lsp = {
|
lsp = {
|
||||||
on_attach = common_config.on_attach
|
on_attach = common_config.on_attach,
|
||||||
|
capabilities = capabilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +39,12 @@ local omnisharp_bin = vim.fn.glob('$HOME') .. "/lsp/dotnet/omnisharp/run"
|
||||||
lspconfig.omnisharp.setup {
|
lspconfig.omnisharp.setup {
|
||||||
cmd = { omnisharp_bin, "--languageserver" , "--hostPID", tostring(pid) };
|
cmd = { omnisharp_bin, "--languageserver" , "--hostPID", tostring(pid) };
|
||||||
on_attach = common_config.on_attach;
|
on_attach = common_config.on_attach;
|
||||||
|
capabilities = capabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Leminx (XML Language server)
|
-- Leminx (XML Language server)
|
||||||
lspconfig.lemminx.setup {
|
lspconfig.lemminx.setup {
|
||||||
cmd = { "lemminx" };
|
cmd = { "lemminx" };
|
||||||
on_attach = common_config.on_attach;
|
on_attach = common_config.on_attach;
|
||||||
|
capabilities = capabilities
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue