Nvim: switch lsp to lua and cmp to coq

This commit is contained in:
2022-09-10 00:17:27 +02:00
parent 253e11a4b3
commit 6d352502a0
3 changed files with 87 additions and 103 deletions

View File

@@ -1,12 +1,6 @@
if !exists('g:lspconfig')
finish
endif
"
" Completion configuration for native neovim + nvim-lspconfig
lua << EOF
local nvim_lsp = require'lspconfig' local nvim_lsp = require'lspconfig'
--local coq = require'coq' local coq = require'coq'
local cmp = require'cmp_nvim_lsp' --local cmp = require'cmp_nvim_lsp'
local clangd_extensions = require("clangd_extensions") local clangd_extensions = require("clangd_extensions")
-- Mappings. -- Mappings.
@@ -70,12 +64,12 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
} }
) )
nvim_lsp.groovyls.setup ({ nvim_lsp.groovyls.setup (coq.lsp_ensure_capabilities({
cmd = { "java", "-jar", "/home/kmcr/tools/groovy-language-server/build/libs/groovy-language-server-all.jar" }, cmd = { "java", "-jar", "/home/kmcr/tools/groovy-language-server/build/libs/groovy-language-server-all.jar" },
on_attach = on_attach, on_attach = on_attach,
on_publish_diagnostics = diagnostic_handler, on_publish_diagnostics = diagnostic_handler,
capabilities = cmp.update_capabilities(vim.lsp.protocol.make_client_capabilities()), capabilities = vim.lsp.protocol.make_client_capabilities(),
} })
) )
-- nvim_lsp.ccls.setup( -- nvim_lsp.ccls.setup(
@@ -99,7 +93,7 @@ nvim_lsp.groovyls.setup ({
-- ) -- )
-- ) -- )
clangd_extensions.setup({ clangd_extensions.setup(coq.lsp_ensure_capabilities({
server = { server = {
on_attach = on_attach, on_attach = on_attach,
root_pattern = { root_pattern = {
@@ -116,7 +110,7 @@ clangd_extensions.setup({
max_len_align_padding = 3, max_len_align_padding = 3,
right_align = true, right_align = true,
} }
}) }))
-- nvim_lsp.clangd.setup( -- nvim_lsp.clangd.setup(
-- coq.lsp_ensure_capabilities({ -- coq.lsp_ensure_capabilities({
-- root_dir = nvim_lsp.util.root_pattern("compile_commands.json"), -- root_dir = nvim_lsp.util.root_pattern("compile_commands.json"),
@@ -128,7 +122,7 @@ clangd_extensions.setup({
-- ) -- )
-- ) -- )
nvim_lsp.pylsp.setup({ nvim_lsp.pylsp.setup(coq.lsp_ensure_capabilities({
settings = { settings = {
pylint = { pylint = {
enabled = false enabled = false
@@ -142,20 +136,19 @@ nvim_lsp.pylsp.setup({
}, },
on_attach = on_attach, on_attach = on_attach,
on_publish_diagnostics = diagnostic_handler, on_publish_diagnostics = diagnostic_handler,
capabilities = cmp.update_capabilities(vim.lsp.protocol.make_client_capabilities()), capabilities = vim.lsp.protocol.make_client_capabilities(),
}) }))
-- Use a loop to conveniently call 'setup' on multiple servers and -- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches -- map buffer local keybindings when the language server attaches
local servers = { "cmake", "rust_analyzer", "bashls" } local servers = { "cmake", "rust_analyzer", "bashls" }
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup({ nvim_lsp[lsp].setup(coq.lsp_ensure_capabilities({
on_attach = on_attach, on_attach = on_attach,
on_publish_diagnostics = diagnostic_handler, on_publish_diagnostics = diagnostic_handler,
capabilities = cmp.update_capabilities(vim.lsp.protocol.make_client_capabilities()), capabilities = vim.lsp.protocol.make_client_capabilities(),
flags = { flags = {
debounce_text_changes = 150, debounce_text_changes = 150,
} }
}) }))
end end
EOF

View File

@@ -1,73 +1,73 @@
-- Setup nvim-cmp. -- Setup nvim-cmp.
local cmp = require'cmp' --local cmp = require'cmp'
--
cmp.setup({ --cmp.setup({
snippet = { -- snippet = {
expand = function(args) -- expand = function(args)
-- For `vsnip` user. -- -- For `vsnip` user.
-- vim.fn["vsnip#anonymous"](args.body) -- -- vim.fn["vsnip#anonymous"](args.body)
--
-- For `luasnip` user. -- -- For `luasnip` user.
-- require('luasnip').lsp_expand(args.body) -- -- require('luasnip').lsp_expand(args.body)
--
-- For `ultisnips` user. -- -- For `ultisnips` user.
vim.fn["UltiSnips#Anon"](args.body) -- vim.fn["UltiSnips#Anon"](args.body)
end, -- end,
}, -- },
mapping = cmp.mapping.preset.insert({ -- mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), -- ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), -- ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), -- ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<tab>'] = cmp.mapping.confirm({ select = true }), -- ['<tab>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping({ -- ['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(), -- i = cmp.mapping.abort(),
c = cmp.mapping.close(), -- c = cmp.mapping.close(),
}), -- }),
}), -- }),
sources = cmp.config.sources({ -- sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- { name = 'nvim_lsp' },
--
{ name = 'path' }, -- { name = 'path' },
--
{ name = 'ultisnips' }, -- { name = 'ultisnips' },
--
{ name = 'calc' }, -- { name = 'calc' },
--
{ name = 'cmp_matlab' }, -- { name = 'cmp_matlab' },
--
{ name = 'cmp_git' }, -- { name = 'cmp_git' },
}, { -- }, {
{ name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 }, -- { name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
}), -- }),
--experimental = { -- --experimental = {
-- native_menu = false -- -- native_menu = false
--} -- --}
--
sorting = { -- sorting = {
comparators = { -- comparators = {
cmp.config.compare.offset, -- cmp.config.compare.offset,
cmp.config.compare.exact, -- cmp.config.compare.exact,
cmp.config.compare.recently_used, -- cmp.config.compare.recently_used,
require("clangd_extensions.cmp_scores"), -- require("clangd_extensions.cmp_scores"),
cmp.config.compare.kind, -- cmp.config.compare.kind,
cmp.config.compare.sort_text, -- cmp.config.compare.sort_text,
cmp.config.compare.length, -- cmp.config.compare.length,
cmp.config.compare.order, -- cmp.config.compare.order,
}, -- },
}, -- },
}) --})
--
cmp.setup.cmdline('/', { --cmp.setup.cmdline('/', {
sources = { -- sources = {
{ name = 'buffer' } -- { name = 'buffer' }
} -- }
}) --})
--
cmp.setup.cmdline(':', { --cmp.setup.cmdline(':', {
sources = { -- sources = {
{ name = 'cmdline' } -- { name = 'cmdline' }
}, -- },
mapping = cmp.mapping.preset.cmdline() -- mapping = cmp.mapping.preset.cmdline()
}) --})
--
require("cmp_git").setup() --require("cmp_git").setup()

View File

@@ -41,17 +41,8 @@ Plug 'danymat/neogen'
" }}} " }}}
" Completion {{{ " Completion {{{
Plug 'hrsh7th/nvim-cmp' Plug 'ms-jpq/coq_nvim'
Plug 'hrsh7th/cmp-nvim-lsp' Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/cmp-calc'
Plug 'joshzcold/cmp-jenkinsfile'
Plug 'petertriho/cmp-git'
Plug 'mstanciu552/cmp-matlab'
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
" }}} " }}}
" Files switch, jump and grep-like tools {{{ " Files switch, jump and grep-like tools {{{