Nvim: switch lsp to lua and cmp to coq
This commit is contained in:
@@ -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 coq = require'coq'
|
||||
local cmp = require'cmp_nvim_lsp'
|
||||
local coq = require'coq'
|
||||
--local cmp = require'cmp_nvim_lsp'
|
||||
local clangd_extensions = require("clangd_extensions")
|
||||
|
||||
-- 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" },
|
||||
on_attach = on_attach,
|
||||
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(
|
||||
@@ -99,7 +93,7 @@ nvim_lsp.groovyls.setup ({
|
||||
-- )
|
||||
-- )
|
||||
|
||||
clangd_extensions.setup({
|
||||
clangd_extensions.setup(coq.lsp_ensure_capabilities({
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
root_pattern = {
|
||||
@@ -116,7 +110,7 @@ clangd_extensions.setup({
|
||||
max_len_align_padding = 3,
|
||||
right_align = true,
|
||||
}
|
||||
})
|
||||
}))
|
||||
-- nvim_lsp.clangd.setup(
|
||||
-- coq.lsp_ensure_capabilities({
|
||||
-- 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 = {
|
||||
pylint = {
|
||||
enabled = false
|
||||
@@ -142,20 +136,19 @@ nvim_lsp.pylsp.setup({
|
||||
},
|
||||
on_attach = on_attach,
|
||||
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
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = { "cmake", "rust_analyzer", "bashls" }
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup({
|
||||
nvim_lsp[lsp].setup(coq.lsp_ensure_capabilities({
|
||||
on_attach = on_attach,
|
||||
on_publish_diagnostics = diagnostic_handler,
|
||||
capabilities = cmp.update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
})
|
||||
}))
|
||||
end
|
||||
EOF
|
||||
@@ -1,73 +1,73 @@
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- For `vsnip` user.
|
||||
-- vim.fn["vsnip#anonymous"](args.body)
|
||||
|
||||
-- For `luasnip` user.
|
||||
-- require('luasnip').lsp_expand(args.body)
|
||||
|
||||
-- For `ultisnips` user.
|
||||
vim.fn["UltiSnips#Anon"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = 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' }),
|
||||
['<tab>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-e>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
|
||||
{ name = 'path' },
|
||||
|
||||
{ name = 'ultisnips' },
|
||||
|
||||
{ name = 'calc' },
|
||||
|
||||
{ name = 'cmp_matlab' },
|
||||
|
||||
{ name = 'cmp_git' },
|
||||
}, {
|
||||
{ name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
|
||||
}),
|
||||
--experimental = {
|
||||
-- native_menu = false
|
||||
--}
|
||||
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.recently_used,
|
||||
require("clangd_extensions.cmp_scores"),
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = {
|
||||
{ name = 'cmdline' }
|
||||
},
|
||||
mapping = cmp.mapping.preset.cmdline()
|
||||
})
|
||||
|
||||
require("cmp_git").setup()
|
||||
--local cmp = require'cmp'
|
||||
--
|
||||
--cmp.setup({
|
||||
-- snippet = {
|
||||
-- expand = function(args)
|
||||
-- -- For `vsnip` user.
|
||||
-- -- vim.fn["vsnip#anonymous"](args.body)
|
||||
--
|
||||
-- -- For `luasnip` user.
|
||||
-- -- require('luasnip').lsp_expand(args.body)
|
||||
--
|
||||
-- -- For `ultisnips` user.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body)
|
||||
-- end,
|
||||
-- },
|
||||
-- mapping = cmp.mapping.preset.insert({
|
||||
-- ['<C-b>'] = 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' }),
|
||||
-- ['<tab>'] = cmp.mapping.confirm({ select = true }),
|
||||
-- ['<C-e>'] = cmp.mapping({
|
||||
-- i = cmp.mapping.abort(),
|
||||
-- c = cmp.mapping.close(),
|
||||
-- }),
|
||||
-- }),
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'nvim_lsp' },
|
||||
--
|
||||
-- { name = 'path' },
|
||||
--
|
||||
-- { name = 'ultisnips' },
|
||||
--
|
||||
-- { name = 'calc' },
|
||||
--
|
||||
-- { name = 'cmp_matlab' },
|
||||
--
|
||||
-- { name = 'cmp_git' },
|
||||
-- }, {
|
||||
-- { name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
|
||||
-- }),
|
||||
-- --experimental = {
|
||||
-- -- native_menu = false
|
||||
-- --}
|
||||
--
|
||||
-- sorting = {
|
||||
-- comparators = {
|
||||
-- cmp.config.compare.offset,
|
||||
-- cmp.config.compare.exact,
|
||||
-- cmp.config.compare.recently_used,
|
||||
-- require("clangd_extensions.cmp_scores"),
|
||||
-- cmp.config.compare.kind,
|
||||
-- cmp.config.compare.sort_text,
|
||||
-- cmp.config.compare.length,
|
||||
-- cmp.config.compare.order,
|
||||
-- },
|
||||
-- },
|
||||
--})
|
||||
--
|
||||
--cmp.setup.cmdline('/', {
|
||||
-- sources = {
|
||||
-- { name = 'buffer' }
|
||||
-- }
|
||||
--})
|
||||
--
|
||||
--cmp.setup.cmdline(':', {
|
||||
-- sources = {
|
||||
-- { name = 'cmdline' }
|
||||
-- },
|
||||
-- mapping = cmp.mapping.preset.cmdline()
|
||||
--})
|
||||
--
|
||||
--require("cmp_git").setup()
|
||||
|
||||
@@ -41,17 +41,8 @@ Plug 'danymat/neogen'
|
||||
" }}}
|
||||
|
||||
" Completion {{{
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
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'
|
||||
Plug 'ms-jpq/coq_nvim'
|
||||
Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
|
||||
" }}}
|
||||
|
||||
" Files switch, jump and grep-like tools {{{
|
||||
|
||||
Reference in New Issue
Block a user