nvim: Enable native autocompletion plugin
This commit is contained in:
@@ -18,6 +18,7 @@ Plug 'wellle/context.vim'
|
|||||||
Plug 'dbeniamine/cheat.sh-vim'
|
Plug 'dbeniamine/cheat.sh-vim'
|
||||||
Plug 'puremourning/vimspector'
|
Plug 'puremourning/vimspector'
|
||||||
Plug 'derekwyatt/vim-fswitch'
|
Plug 'derekwyatt/vim-fswitch'
|
||||||
|
Plug 'nvim-lua/completion-nvim'
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Files switch, jump and grep-like tools {{{
|
" Files switch, jump and grep-like tools {{{
|
||||||
@@ -150,6 +151,7 @@ set updatetime=300
|
|||||||
|
|
||||||
" Don't pass messages to |ins-completion-menu|.
|
" Don't pass messages to |ins-completion-menu|.
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
|
set shortmess-=F
|
||||||
|
|
||||||
" Always show the signcolumn, otherwise it would shift the text each time
|
" Always show the signcolumn, otherwise it would shift the text each time
|
||||||
" diagnostics appear/become resolved.
|
" diagnostics appear/become resolved.
|
||||||
@@ -255,9 +257,9 @@ local on_attach = function(client, bufnr)
|
|||||||
local opts = { noremap=true, silent=true }
|
local opts = { noremap=true, silent=true }
|
||||||
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
@@ -272,7 +274,7 @@ local on_attach = function(client, bufnr)
|
|||||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||||
|
require'completion'.on_attach()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||||
@@ -282,3 +284,12 @@ for _, lsp in ipairs(servers) do
|
|||||||
nvim_lsp[lsp].setup { on_attach = on_attach }
|
nvim_lsp[lsp].setup { on_attach = on_attach }
|
||||||
end
|
end
|
||||||
EOF
|
EOF
|
||||||
|
"
|
||||||
|
" lua require'lspconfig'.pyls.setup{on_attach=require'completion'.on_attach}
|
||||||
|
" lua require'lspconfig'.ccls.setup{on_attach=require'completion'.on_attach}
|
||||||
|
" lua require'lspconfig'.cmake.setup{on_attach=require'completion'.on_attach}
|
||||||
|
" lua require'lspconfig'.rls.setup{on_attach=require'completion'.on_attach}
|
||||||
|
"
|
||||||
|
" Set completeopt to have a better completion experience
|
||||||
|
set completeopt=menuone,noinsert,noselect
|
||||||
|
let g:completion_enable_snippet = 'UltiSnips'
|
||||||
|
|||||||
Reference in New Issue
Block a user