mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-22 19:37:34 +00:00
Use rustaceanvim rather than defunct rust-tools
This commit is contained in:
parent
29e936904d
commit
54da69cd40
@ -155,9 +155,9 @@
|
|||||||
"branch": "master",
|
"branch": "master",
|
||||||
"commit": "2d9b06177a975543726ce5c73fca176cedbffe9d"
|
"commit": "2d9b06177a975543726ce5c73fca176cedbffe9d"
|
||||||
},
|
},
|
||||||
"rust-tools.nvim": {
|
"rustaceanvim": {
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"commit": "676187908a1ce35ffcd727c654ed68d851299d3e"
|
"commit": "e1f9464d9e1addeccb170eb7968471966965f5a3"
|
||||||
},
|
},
|
||||||
"sg.nvim": {
|
"sg.nvim": {
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
|
@ -340,8 +340,21 @@ return {
|
|||||||
|
|
||||||
-- Rust analyzer
|
-- Rust analyzer
|
||||||
{
|
{
|
||||||
"https://github.com/simrat39/rust-tools.nvim",
|
"https://github.com/mrcjkb/rustaceanvim",
|
||||||
|
version = "^5",
|
||||||
|
-- Already loads on ft
|
||||||
|
lazy = false,
|
||||||
ft = { "rust" },
|
ft = { "rust" },
|
||||||
|
init = function()
|
||||||
|
local lsp = require("plugins.lsp")
|
||||||
|
vim.g.rustaceanvim = {
|
||||||
|
server = {
|
||||||
|
capabilities = lsp.merged_capabilities(),
|
||||||
|
on_attach = lsp.get_default_attach(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
enabled = vim.fn.has("nvim-0.10") == 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Better display of lsp diagnostics
|
-- Better display of lsp diagnostics
|
||||||
|
@ -36,7 +36,7 @@ function M.config_lsp_ui()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_default_attach(override_capabilities)
|
function M.get_default_attach(override_capabilities)
|
||||||
return function(client, bufnr)
|
return function(client, bufnr)
|
||||||
-- Allow overriding capabilities to avoid duplicate lsps with capabilities
|
-- Allow overriding capabilities to avoid duplicate lsps with capabilities
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ local function get_default_attach(override_capabilities)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function merged_capabilities()
|
function M.merged_capabilities()
|
||||||
-- Maybe update capabilities
|
-- Maybe update capabilities
|
||||||
local capabilities = nil
|
local capabilities = nil
|
||||||
utils.try_require("cmp-nvim-lsp", function(cmp_nvim_lsp)
|
utils.try_require("cmp-nvim-lsp", function(cmp_nvim_lsp)
|
||||||
@ -174,8 +174,8 @@ end
|
|||||||
|
|
||||||
function M.config_lsp()
|
function M.config_lsp()
|
||||||
utils.try_require("lspconfig", function(lsp_config)
|
utils.try_require("lspconfig", function(lsp_config)
|
||||||
local capabilities = merged_capabilities()
|
local capabilities = M.merged_capabilities()
|
||||||
local default_attach = get_default_attach()
|
local default_attach = M.get_default_attach()
|
||||||
local default_setup = { capabilities = capabilities, on_attach = default_attach }
|
local default_setup = { capabilities = capabilities, on_attach = default_attach }
|
||||||
|
|
||||||
local maybe_setup = function(config, options)
|
local maybe_setup = function(config, options)
|
||||||
@ -205,22 +205,10 @@ function M.config_lsp()
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Set up rust analyzer (preferred) or rls
|
-- Set up rust analyzer (preferred) or rls
|
||||||
-- TODO: Remove rls and all configuration for it when all machines are up to date
|
-- NOTE: For version 0.10 or higher, rustaceanvim is initialized in ftconfig
|
||||||
if vim.fn.executable("rust-analyzer") == 1 then
|
-- Maybe all lsp configs should be set up as part of their ftconfig
|
||||||
-- Prefer rust-tools, if present
|
if vim.fn.has("nvim-0.10") == 1 then
|
||||||
utils.try_require("rust-tools", function(rust_tools)
|
maybe_setup(lsp_config.rust_analyzer, {
|
||||||
rust_tools.setup({
|
|
||||||
server = {
|
|
||||||
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,
|
capabilities = capabilities,
|
||||||
on_attach = default_attach,
|
on_attach = default_attach,
|
||||||
settings = {
|
settings = {
|
||||||
@ -231,8 +219,6 @@ function M.config_lsp()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end)
|
|
||||||
else
|
|
||||||
maybe_setup(lsp_config.rls, default_setup)
|
maybe_setup(lsp_config.rls, default_setup)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user