feat(lsp): switch to rustaceanvim and add document highlighting

This commit is contained in:
Matej Janezic 2024-02-19 15:56:47 +01:00
parent b087eaa1ef
commit b2fe474605
Signed by: janezicmatej
GPG Key ID: 4298E230ED37B2C0
1 changed files with 11 additions and 4 deletions

View File

@ -37,6 +37,9 @@ local on_attach = function(_, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format() vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' }) end, { desc = 'Format current buffer with LSP' })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { command = 'lua pcall(vim.lsp.buf.document_highlight)', buffer = bufnr })
vim.api.nvim_create_autocmd({ 'CursorMoved' }, { command = 'lua pcall(vim.lsp.buf.clear_references)', buffer = bufnr })
end end
return { return {
@ -49,7 +52,11 @@ return {
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
-- adds extra functionality over rust_analyzer -- adds extra functionality over rust_analyzer
'simrat39/rust-tools.nvim', {
'mrcjkb/rustaceanvim',
version = '^4',
ft = { 'rust' },
},
-- Useful status updates for LSP -- Useful status updates for LSP
{ 'j-hui/fidget.nvim', opts = {} }, { 'j-hui/fidget.nvim', opts = {} },
@ -99,7 +106,7 @@ return {
end, end,
} }
local rust_tools_opts = { vim.g.rustaceanvim = {
tools = { tools = {
inlay_hints = { inlay_hints = {
auto = false, auto = false,
@ -117,12 +124,12 @@ return {
checkOnSave = { checkOnSave = {
command = 'clippy', command = 'clippy',
}, },
-- leave rainbow higlightifg to plugin
rainbowHighlightOn = false,
}, },
}, },
}, },
} }
require('rust-tools').setup(rust_tools_opts)
end, end,
}, },
} }