Nvim: move to nvim-cmp
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
local nvim_lsp = require('lspconfig')
|
||||
local coq = require('coq')
|
||||
local clangd_extensions = require('clangd_extensions')
|
||||
local lsp_signature = require('lsp_signature')
|
||||
|
||||
@@ -43,40 +42,41 @@ local on_attach = function(client, bufnr)
|
||||
end
|
||||
|
||||
local signs = {
|
||||
{ name = "DiagnosticSignError", text = "" },
|
||||
{ name = "DiagnosticSignWarn", text = "" },
|
||||
{ name = "DiagnosticSignHint", text = "" },
|
||||
{ name = "DiagnosticSignInfo", text = "" },
|
||||
}
|
||||
{ name = "DiagnosticSignError", text = "" },
|
||||
{ name = "DiagnosticSignWarn", text = "" },
|
||||
{ name = "DiagnosticSignHint", text = "" },
|
||||
{ name = "DiagnosticSignInfo", text = "" },
|
||||
}
|
||||
|
||||
for _, sign in ipairs(signs) do
|
||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
||||
end
|
||||
for _, sign in ipairs(signs) do
|
||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
signs = {
|
||||
active = signs,
|
||||
--severity_limit = 'info',
|
||||
},
|
||||
severity_sort = true,
|
||||
underline = false,
|
||||
update_in_insert = false,
|
||||
--virtual_text = {
|
||||
-- spacing = 40,
|
||||
-- severity_limit = 'Warning',
|
||||
--},
|
||||
virtual_text = false,
|
||||
}
|
||||
)
|
||||
--vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
-- vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
-- signs = {
|
||||
-- active = signs,
|
||||
-- --severity_limit = 'info',
|
||||
-- },
|
||||
-- severity_sort = true,
|
||||
-- underline = false,
|
||||
-- update_in_insert = false,
|
||||
-- --virtual_text = {
|
||||
-- -- spacing = 40,
|
||||
-- -- severity_limit = 'Warning',
|
||||
-- --},
|
||||
-- virtual_text = false,
|
||||
-- }
|
||||
--)
|
||||
--
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
nvim_lsp.groovyls.setup (coq.lsp_ensure_capabilities({
|
||||
nvim_lsp.groovyls.setup({
|
||||
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 = vim.lsp.protocol.make_client_capabilities(),
|
||||
})
|
||||
)
|
||||
--on_publish_diagnostics = diagnostic_handler,
|
||||
capabilities = capabilities
|
||||
})
|
||||
|
||||
-- nvim_lsp.ccls.setup(
|
||||
-- coq.lsp_ensure_capabilities({
|
||||
@@ -92,14 +92,13 @@ nvim_lsp.groovyls.setup (coq.lsp_ensure_capabilities({
|
||||
-- root_dir = nvim_lsp.util.root_pattern("compile_commands.json"),
|
||||
-- on_attach = on_attach,
|
||||
-- on_publish_diagnostics = diagnostic_handler,
|
||||
-- capabilities = cmp.update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
-- flags = {
|
||||
-- debounce_text_changes = 150,
|
||||
-- }}
|
||||
-- )
|
||||
-- )
|
||||
|
||||
clangd_extensions.setup(coq.lsp_ensure_capabilities({
|
||||
clangd_extensions.setup({
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
root_pattern = {
|
||||
@@ -109,16 +108,17 @@ clangd_extensions.setup(coq.lsp_ensure_capabilities({
|
||||
'compile_commands.json',
|
||||
'compile_flags.txt',
|
||||
'configure.ac',
|
||||
}
|
||||
},
|
||||
capabilities = capabilities
|
||||
},
|
||||
inlay_hints = {
|
||||
max_len_align = true,
|
||||
max_len_align_padding = 3,
|
||||
right_align = true,
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
nvim_lsp.pylsp.setup(coq.lsp_ensure_capabilities({
|
||||
nvim_lsp.pylsp.setup({
|
||||
settings = {
|
||||
pylint = {
|
||||
enabled = false
|
||||
@@ -127,24 +127,24 @@ nvim_lsp.pylsp.setup(coq.lsp_ensure_capabilities({
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
-- flags = {
|
||||
-- debounce_text_changes = 150,
|
||||
-- },
|
||||
on_attach = on_attach,
|
||||
on_publish_diagnostics = diagnostic_handler,
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
||||
}))
|
||||
capabilities = capabilities
|
||||
--on_publish_diagnostics = diagnostic_handler,
|
||||
})
|
||||
|
||||
-- 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(coq.lsp_ensure_capabilities({
|
||||
nvim_lsp[lsp].setup({
|
||||
on_attach = on_attach,
|
||||
on_publish_diagnostics = diagnostic_handler,
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}))
|
||||
--on_publish_diagnostics = diagnostic_handler,
|
||||
capabilities = capabilities,
|
||||
-- flags = {
|
||||
-- debounce_text_changes = 150,
|
||||
-- }
|
||||
})
|
||||
end
|
||||
|
||||
@@ -1,73 +1,68 @@
|
||||
-- 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)
|
||||
require('snippy').expand_snippet(args.body)
|
||||
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 = false }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'path' },
|
||||
{ name = 'snippy' },
|
||||
{ name = 'calc' },
|
||||
{ name = 'cmp_matlab' },
|
||||
{ name = 'cmp_git' },
|
||||
}, {
|
||||
{ name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
|
||||
}),
|
||||
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({'/', '?'}, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{name = 'cmp_git' },
|
||||
}, {
|
||||
{name = 'buffer' }
|
||||
})
|
||||
})
|
||||
|
||||
require("cmp_git").setup()
|
||||
|
||||
11
.config/nvim/after/available/snippets.rc.lua
Normal file
11
.config/nvim/after/available/snippets.rc.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
require('snippy').setup({
|
||||
mappings = {
|
||||
is = {
|
||||
['<Tab>'] = 'expand_or_advance',
|
||||
['<S-Tab>'] = 'previous',
|
||||
},
|
||||
nx = {
|
||||
['<leader>x'] = 'cut_text',
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -1,8 +0,0 @@
|
||||
" Set completeopt to have a better completion experience
|
||||
"set completeopt=menuone,noinsert,noselect
|
||||
let g:completion_enable_snippet = 'UltiSnips'
|
||||
"iunmap <Tab>
|
||||
"map <c-s> <C-R>=UltiSnips#ExpandSnippet()<CR>
|
||||
"let g:UltiSnipsExpandTrigger="<c-s>"
|
||||
let g:UltiSnipsJumpForwardTrigger="<tab>"
|
||||
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
|
||||
@@ -1,13 +1,30 @@
|
||||
let g:cmake_build_options = [ "-j10" ]
|
||||
"let g:cmake_build_options = [ "-j10" ]
|
||||
"
|
||||
"let g:cmake_root_markers = ['.svn']
|
||||
"
|
||||
"
|
||||
"let g:cmake_jump_on_error = 0 " We do not want to focus the console
|
||||
"augroup vim-cmake-group
|
||||
"autocmd User CMakeBuildFailed :cfirst
|
||||
"augroup END
|
||||
"
|
||||
"augroup vim-cmake-group
|
||||
"autocmd! User CMakeBuildSucceeded CMakeClose
|
||||
"augroup END
|
||||
|
||||
let g:cmake_root_markers = ['.svn']
|
||||
|
||||
|
||||
let g:cmake_jump_on_error = 0 " We do not want to focus the console
|
||||
augroup vim-cmake-group
|
||||
autocmd User CMakeBuildFailed :cfirst
|
||||
augroup END
|
||||
|
||||
augroup vim-cmake-group
|
||||
autocmd! User CMakeBuildSucceeded CMakeClose
|
||||
augroup END
|
||||
lua << EOF
|
||||
require("cmake-tools").setup {
|
||||
cmake_command = "cmake",
|
||||
cmake_build_directory = "build",
|
||||
cmake_generate_options = { "-D", "CMAKE_EXPORT_COMPILE_COMMANDS=1" },
|
||||
cmake_build_options = {},
|
||||
cmake_console_size = 10, -- cmake output window height
|
||||
cmake_show_console = "always", -- "always", "only_on_error"
|
||||
cmake_dap_configuration = { name = "cpp", type = "codelldb", request = "launch" }, -- dap configuration, optional
|
||||
--cmake_dap_open_command = require("dap").repl.open, -- optional
|
||||
cmake_variants_message = {
|
||||
short = { show = true },
|
||||
long = { show = true, max_length = 40 }
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
1
.config/nvim/after/plugin/snippets.rc.lua
Symbolic link
1
.config/nvim/after/plugin/snippets.rc.lua
Symbolic link
@@ -0,0 +1 @@
|
||||
../available/snippets.rc.lua
|
||||
@@ -1 +0,0 @@
|
||||
../available/ultisnips.rc.vim
|
||||
@@ -25,7 +25,7 @@ call plug#begin('~/.config/nvim/plugins')
|
||||
"Plug 'RRethy/vim-illuminate'
|
||||
Plug 'Saecki/crates.nvim' | Plug 'jose-elias-alvarez/null-ls.nvim'
|
||||
Plug 'andrewferrier/debugprint.nvim'
|
||||
Plug 'cdelledonne/vim-cmake'
|
||||
Plug 'Civitasv/cmake-tools.nvim'
|
||||
Plug 'danymat/neogen'
|
||||
Plug 'ftilde/vim-ugdb'
|
||||
Plug 'jubnzv/virtual-types.nvim'
|
||||
@@ -40,14 +40,24 @@ Plug 'romgrk/nvim-treesitter-context'
|
||||
" }}}
|
||||
|
||||
" Completion {{{
|
||||
Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
|
||||
Plug 'ms-jpq/coq_nvim'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/cmp-cmdline'
|
||||
Plug 'petertriho/cmp-git'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'hrsh7th/cmp-path'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
" }}}
|
||||
|
||||
" Snippets {{{
|
||||
"Plug 'fhill2/telescope-ultisnips.nvim'
|
||||
Plug 'dcampos/cmp-snippy'
|
||||
Plug 'dcampos/nvim-snippy'
|
||||
Plug 'honza/vim-snippets'
|
||||
" }}}
|
||||
|
||||
" Files switch, jump and grep-like tools {{{
|
||||
"Plug 'inside/vim-search-pulse'
|
||||
Plug 'MunifTanjim/nui.nvim'
|
||||
Plug 'fhill2/telescope-ultisnips.nvim'
|
||||
Plug 'ggandor/leap.nvim'
|
||||
Plug 'kyazdani42/nvim-tree.lua'
|
||||
Plug 'kyazdani42/nvim-web-devicons'
|
||||
@@ -247,7 +257,7 @@ set shortmess-=F
|
||||
set signcolumn=auto
|
||||
|
||||
set wildmode=longest,list,full
|
||||
set completeopt=menuone,noselect
|
||||
set completeopt=menu,menuone,noselect
|
||||
|
||||
set mouse=
|
||||
|
||||
|
||||
Reference in New Issue
Block a user