neovim: Replace CoC with nvim-lspconfig for Rust
This commit is contained in:
parent
1fe1ba9edf
commit
a4637654a3
8 changed files with 39 additions and 45 deletions
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"coc.preferences.formatOnSaveFiletypes": ["rust"],
|
||||
"rust-analyzer.enable": false,
|
||||
"rust-analyzer.diagnostics.enableExperimental": false,
|
||||
"rust-analyzer.inlayHints.enable": false,
|
||||
"rust-analyzer.procMacro.enable": true,
|
||||
"rust-analyzer.updates.channel": "nightly"
|
||||
}
|
||||
3
neovim/coc/.gitignore
vendored
3
neovim/coc/.gitignore
vendored
|
|
@ -1,3 +0,0 @@
|
|||
/list-extensions-history.json
|
||||
/list-location-history.json
|
||||
/commands
|
||||
2
neovim/coc/extensions/.gitignore
vendored
2
neovim/coc/extensions/.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
|||
/coc-rust-analyzer-data
|
||||
/package-lock.json
|
||||
|
|
@ -1 +0,0 @@
|
|||
{}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"coc-json": ">=1.3.4",
|
||||
"coc-rls": ">=1.1.6",
|
||||
"coc-rust-analyzer": ">=0.46.0",
|
||||
"coc-tsserver": ">=1.8.1"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"coc-rust-analyzer|global": {
|
||||
"release": "nightly 2021-06-05"
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ Plug 'ledger/vim-ledger'
|
|||
Plug 'LnL7/vim-nix'
|
||||
Plug 'MarcWeber/vim-addon-local-vimrc'
|
||||
Plug 'mxw/vim-jsx'
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'ntpeters/vim-better-whitespace'
|
||||
Plug 'pangloss/vim-javascript'
|
||||
Plug 'plasticboy/vim-markdown'
|
||||
|
|
@ -328,5 +328,41 @@ endfun
|
|||
command ResetScreen call s:ResetScreen()
|
||||
nnoremap <C-l> :ResetScreen<CR>
|
||||
|
||||
nmap <silent> <Leader>j <Plug>(coc-diagnostic-next)
|
||||
nmap <silent> <Leader>k <Plug>(coc-diagnostic-prev)
|
||||
lua <<LSPCONFIG
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
local on_attach = function(client, bufno)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufno, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufno, ...) end
|
||||
|
||||
-- Enable completion through omnifunc, triggered by <C-x><C-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<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', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>R', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>d', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>j', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>k', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<Leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
|
||||
end
|
||||
|
||||
local servers = { 'rust_analyzer' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
}
|
||||
end
|
||||
LSPCONFIG
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
snippet sigp
|
||||
abbr sig { params(...).returns(...) }
|
||||
sig { params(${1}).returns(${2}) }${0}
|
||||
|
||||
snippet sigdo
|
||||
abbr sig do params(...).returns(...) end
|
||||
sig do
|
||||
params(
|
||||
${1}
|
||||
).returns(${2})
|
||||
end${0}
|
||||
|
||||
snippet sigv
|
||||
abbr sig { params(...).void}
|
||||
sig { params(${1}).void }${0}
|
||||
Loading…
Add table
Add a link
Reference in a new issue