switch to nvim-lsp
This commit is contained in:
parent
62b2b87c9f
commit
260e206da0
1 changed files with 142 additions and 26 deletions
168
.vimrc
168
.vimrc
|
|
@ -51,6 +51,8 @@ set splitbelow
|
|||
" bash).
|
||||
"set completeopt=menu,menuone,longest
|
||||
set completeopt=noinsert,menuone,noselect,longest
|
||||
set signcolumn=yes
|
||||
set shortmess+=c
|
||||
|
||||
set diffopt+=vertical
|
||||
" Some stuff for 256-Color consoles that I've forgotten.
|
||||
|
|
@ -195,7 +197,11 @@ Plug 'zchee/vim-goasm'
|
|||
"\ 'do': 'bash install.sh',
|
||||
"\ }
|
||||
"Plug 'ensime/ensime-vim', { 'do': ':UpdateRemotePlugins' }
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'nvim-lua/lsp_extensions.nvim'
|
||||
Plug 'nvim-lua/completion-nvim'
|
||||
Plug 'onsails/lspkind-nvim'
|
||||
|
||||
" Plugins that do specific things
|
||||
Plug 'Shougo/vimproc.vim'
|
||||
|
|
@ -217,42 +223,151 @@ Plug 'barakmich/vim-code-dark'
|
|||
|
||||
call plug#end()
|
||||
|
||||
filetype plugin indent on
|
||||
syntax enable
|
||||
|
||||
" enable ncm2 for all buffers
|
||||
"autocmd BufEnter * call ncm2#enable_for_buffer()
|
||||
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
imap <Leader>, <Plug>(coc-snippets-expand)
|
||||
imap <Leader>ff <Plug>(coc-fix-current)
|
||||
nmap <Leader>ff <Plug>(coc-fix-current)
|
||||
|
||||
" Use K to show documentation in preview window
|
||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
" **** CoC bindings
|
||||
"nmap <silent> gd <Plug>(coc-definition)
|
||||
"nmap <silent> gy <Plug>(coc-type-definition)
|
||||
"nmap <silent> gi <Plug>(coc-implementation)
|
||||
"nmap <silent> gr <Plug>(coc-references)
|
||||
"imap <Leader>l <Plug>(coc-codeaction)
|
||||
"imap <Leader>, <Plug>(coc-snippets-expand)
|
||||
"imap <Leader>ff <Plug>(coc-fix-current)
|
||||
"nmap <Leader>ff <Plug>(coc-fix-current)
|
||||
"" Use `[g` and `]g` to navigate diagnostics
|
||||
"" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
"nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
"nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
function! s:show_documentation()
|
||||
if (index(['vim','help'], &filetype) >= 0)
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
"" Use K to show documentation in preview window
|
||||
"nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
|
||||
"function! s:show_documentation()
|
||||
"if (index(['vim','help'], &filetype) >= 0)
|
||||
"execute 'h '.expand('<cword>')
|
||||
"else
|
||||
"call CocAction('doHover')
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
"NeoBundle 'eclim'
|
||||
"https://git.wincent.com/command-t.git
|
||||
filetype plugin indent on " required
|
||||
syntax enable
|
||||
|
||||
"filetype plugin indent on
|
||||
" If you prefer the Omni-Completion tip window to close when a selection is
|
||||
" made, these lines close it on movement in insert mode or when leaving
|
||||
" insert mode
|
||||
"autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
|
||||
"autocmd InsertLeave * if pumvisible() == 0|pclose|endif
|
||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
|
||||
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
|
||||
|
||||
" Sources
|
||||
" **** End CoC
|
||||
|
||||
" **** Configure LSP
|
||||
lua <<EOF
|
||||
|
||||
-- nvim_lsp object
|
||||
local nvim_lsp = require'lspconfig'
|
||||
|
||||
-- function to attach completion when setting up lsp
|
||||
local on_attach = function(client)
|
||||
require'completion'.on_attach(client)
|
||||
end
|
||||
|
||||
-- Enable rust_analyzer
|
||||
nvim_lsp.rust_analyzer.setup({ on_attach=on_attach })
|
||||
|
||||
-- Enable diagnostics
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
update_in_insert = false,
|
||||
}
|
||||
)
|
||||
|
||||
require('lspkind').init({
|
||||
-- enables text annotations
|
||||
--
|
||||
-- default: true
|
||||
with_text = false,
|
||||
|
||||
-- default symbol map
|
||||
-- can be either 'default' or
|
||||
-- 'codicons' for codicon preset (requires vscode-codicons font installed)
|
||||
--
|
||||
-- default: 'default'
|
||||
preset = 'default',
|
||||
|
||||
-- override preset symbols
|
||||
--
|
||||
-- default: {}
|
||||
symbol_map = {
|
||||
Method = 'm',
|
||||
Function = 'f',
|
||||
Text = 'txt',
|
||||
Constructor = 'new',
|
||||
Variable = 'var',
|
||||
Class = 'cls',
|
||||
Interface = 'iface',
|
||||
Module = 'mod',
|
||||
Property = 'prop',
|
||||
Unit = 'unit',
|
||||
Value = 'val',
|
||||
Enum = 'enum',
|
||||
Keyword = 'kw',
|
||||
Snippet = 'sn',
|
||||
Color = 'color',
|
||||
File = 'file',
|
||||
Folder = 'fold',
|
||||
EnumMember = 'enum',
|
||||
Constant = 'const',
|
||||
Struct = 'struct',
|
||||
},
|
||||
})
|
||||
|
||||
EOF
|
||||
|
||||
" Use <Tab> and <S-Tab> to navigate through popup menu
|
||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
||||
|
||||
" use <Tab> as trigger keys
|
||||
imap <Tab> <Plug>(completion_smart_tab)
|
||||
imap <S-Tab> <Plug>(completion_smart_s_tab)
|
||||
|
||||
" Code navigation shortcuts
|
||||
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
||||
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
|
||||
nnoremap <silent> gy <cmd>lua vim.lsp.buf.type_definition()<CR>
|
||||
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
|
||||
nnoremap <silent> gK <cmd>lua vim.lsp.buf.signature_help()<CR>
|
||||
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
|
||||
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
|
||||
nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
|
||||
"nnoremap <silent> gd <cmd>lua vim.lsp.buf.declaration()<CR>
|
||||
nnoremap <silent> ga <cmd>lua vim.lsp.buf.code_action()<CR>
|
||||
nnoremap <silent> ge <cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>
|
||||
|
||||
" Set updatetime for CursorHold
|
||||
" 300ms of no cursor movement to trigger CursorHold
|
||||
set updatetime=500
|
||||
" Show diagnostic popup on cursor hold
|
||||
autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()
|
||||
|
||||
" Goto previous/next diagnostic warning/error
|
||||
nnoremap <silent> g[ <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
|
||||
nnoremap <silent> g] <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
|
||||
|
||||
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy', 'all']
|
||||
let g:completion_matching_smart_case = 1
|
||||
|
||||
|
||||
" **** End LSP
|
||||
|
||||
"" Sources
|
||||
"source ~/.vim/supertab.vim
|
||||
"source ~/.vim/charm.vim
|
||||
"source ~/.vim/plugin/AppleT.vim
|
||||
|
|
@ -386,11 +501,12 @@ let g:NERDTreeMarkBookmarks = 0
|
|||
let g:NERDTreeMinimalUI = 1
|
||||
|
||||
" * Signify
|
||||
let g:signify_realtime = 0
|
||||
let g:signify_realtime = 1
|
||||
let g:signify_vcs_list = ['git']
|
||||
let g:signify_sign_change = '~'
|
||||
let g:signify_sign_changedelete = g:signify_sign_change
|
||||
let g:signify_sign_show_count = 0
|
||||
let g:signify_priority = 5
|
||||
|
||||
" * VimFiler
|
||||
let g:vimfiler_tree_indentation = 2
|
||||
|
|
@ -745,7 +861,7 @@ nmap gb :TagbarToggle<CR>
|
|||
" gK is similar.
|
||||
nnoremap gc :Kwbd<CR>
|
||||
"nnoremap gc :bdelete<CR>
|
||||
nnoremap gK :bdelete!<CR>
|
||||
"nnoremap gK :bdelete!<CR>
|
||||
|
||||
" I use gn/gp to cycle through open tabs/buffers
|
||||
nnoremap gn :bn<CR>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue