Convert from coc to nvim lsp for Rust support
This commit is contained in:
parent
97fbe00d9b
commit
3eec62fae2
4 changed files with 71 additions and 7 deletions
42
nvim/.config/nvim/completion.lua
Normal file
42
nvim/.config/nvim/completion.lua
Normal file
|
@ -0,0 +1,42 @@
|
|||
local cmp = require 'cmp'
|
||||
|
||||
|
||||
cmp.setup {
|
||||
completion = {
|
||||
autocomplete = {
|
||||
},
|
||||
},
|
||||
mapping = {
|
||||
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
['<C-k>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||
['<C-e>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<C-n>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<C-p>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = {
|
||||
-- { name = 'buffer' },
|
||||
-- { name = 'spell' },
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'path' },
|
||||
},
|
||||
}
|
|
@ -4,6 +4,8 @@ source $HOME/.config/nvim/plug/plug.vim
|
|||
source $HOME/.config/nvim/plugs.vim
|
||||
|
||||
source $HOME/.config/nvim/lean.lua
|
||||
source $HOME/.config/nvim/rust.lua
|
||||
source $HOME/.config/nvim/completion.lua
|
||||
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
|
@ -58,8 +60,5 @@ au BufRead,BufNewFile *.tla setf tla
|
|||
" I like pretty things
|
||||
source $HOME/.config/nvim/colors.vim
|
||||
|
||||
" Manually trigger completions
|
||||
inoremap <silent><expr> <C-k> coc#refresh()
|
||||
|
||||
" Conceal markdown syntax
|
||||
set conceallevel=2
|
||||
|
|
|
@ -30,10 +30,12 @@ Plug 'editorconfig/editorconfig-vim'
|
|||
" Make things real pretty
|
||||
Plug 'flazz/vim-colorschemes'
|
||||
|
||||
" Completion and other inline type hints
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
" After installation, run this to setup with Rust:
|
||||
" :CocInstall coc-rust-analyzer
|
||||
" Completions <3
|
||||
Plug 'hrsh7th/nvim-cmp', { 'branch': 'main' }
|
||||
Plug 'hrsh7th/cmp-nvim-lsp', { 'branch': 'main' }
|
||||
|
||||
" Rust support
|
||||
Plug 'simrat39/rust-tools.nvim'
|
||||
|
||||
" Lean theorem prover support
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
|
|
21
nvim/.config/nvim/rust.lua
Normal file
21
nvim/.config/nvim/rust.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
local rt = require("rust-tools")
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
-- " Manually trigger completions
|
||||
-- inoremap <silent><expr> <C-k> coc#refresh()
|
||||
|
||||
rt.setup({
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-k>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
capabilities = capabilities,
|
||||
},
|
||||
})
|
||||
rt.inlay_hints.set()
|
||||
rt.inlay_hints.enable()
|
||||
|
Loading…
Reference in a new issue