Switch from rls to rust-analyzer and from rust.vim to rust-tools.nvim

This includes some transition support for both rls and rust-analyzer
that should eventually be removed.
This commit is contained in:
ViViDboarder 2023-06-13 14:59:37 -07:00
parent b0e8fe7743
commit 21de929b35
3 changed files with 40 additions and 13 deletions

View File

@ -75,7 +75,7 @@ function install_language_servers() {
# Rust
if want_lang rust ;then
maybe_run rustup component add rls rustfmt rust-analysis rust-src clippy rustfmt
maybe_run rustup component add rustfmt rust-analysis rust-src clippy rust-analyzer
fi
# Go

View File

@ -269,6 +269,12 @@ use({
requires = "neovim/nvim-lspconfig",
})
-- Rust analyzer
use({
"simrat39/rust-tools.nvim",
disable = vim.fn.has("nvim-0.7.0") ~= 1,
})
-- Better display of lsp diagnostics
-- TODO: Pin < 0.7 version
use({
@ -441,7 +447,6 @@ use({
-- Filetypes
use("ViViDboarder/vim-forcedotcom")
use("rust-lang/rust.vim")
use("hsanson/vim-android")
use({
"sheerun/vim-polyglot",

View File

@ -254,17 +254,39 @@ function M.config_lsp()
lsp_config.bashls.setup(default_setup)
lsp_config.gopls.setup(default_setup)
lsp_config.pyright.setup(default_setup)
lsp_config.rls.setup({
capabilities = capabilities,
on_attach = default_attach,
settings = {
rust = {
build_on_save = false,
all_features = true,
unstable_features = true,
},
},
})
-- Set up rust analyzer (preferred) or rls
-- TODO: Remove rls and all configuration for it when all machines are up to date
if vim.fn.executable("rust-analyzer") == 1 then
-- Prefer rust-tools, if present
utils.try_require("rust-tools", function(rust_tools)
rust_tools.setup({
capabilities = capabilities,
on_attach = function(client, bufnr)
default_attach(client, bufnr)
-- TODO: override some bindings from rust-tools
-- Eg. rust_tools.hover_actions.hover_actions or rt.code_action_group.code_action_group
end,
})
end, function()
lsp_config.rust_analyzer.setup({
capabilities = capabilities,
on_attach = default_attach,
settings = {
["rust-analyzer"] = {
cargo = {
features = "all",
},
},
},
})
end)
else
lsp_config.rls.setup({
capabilities = capabilities,
on_attach = default_attach,
})
end
-- Configure neovim dev for when sumneko_lua is installed
utils.try_require("neodev", function(neodev)