mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-08 16:34:35 +02:00
* feat(lang) - move to rustacean.nvim, fixes #2113 * update rustacean plugin * PR comment for lsp settings
This commit is contained in:
parent
a8eeb1b75d
commit
66bf7525e3
1 changed files with 56 additions and 85 deletions
|
@ -25,9 +25,8 @@ return {
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
if type(opts.ensure_installed) == "table" then
|
opts.ensure_installed = opts.ensure_installed or {}
|
||||||
vim.list_extend(opts.ensure_installed, { "ron", "rust", "toml" })
|
vim.list_extend(opts.ensure_installed, { "ron", "rust", "toml" })
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -36,66 +35,27 @@ return {
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
optional = true,
|
optional = true,
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
if type(opts.ensure_installed) == "table" then
|
opts.ensure_installed = opts.ensure_installed or {}
|
||||||
vim.list_extend(opts.ensure_installed, { "codelldb" })
|
vim.list_extend(opts.ensure_installed, { "codelldb" })
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"simrat39/rust-tools.nvim",
|
"mrcjkb/rustaceanvim",
|
||||||
lazy = true,
|
version = '^4', -- Recommended
|
||||||
opts = function()
|
ft = { "rust" },
|
||||||
local ok, mason_registry = pcall(require, "mason-registry")
|
|
||||||
local adapter ---@type any
|
|
||||||
if ok then
|
|
||||||
-- rust tools configuration for debugging support
|
|
||||||
local codelldb = mason_registry.get_package("codelldb")
|
|
||||||
local extension_path = codelldb:get_install_path() .. "/extension/"
|
|
||||||
local codelldb_path = extension_path .. "adapter/codelldb"
|
|
||||||
local liblldb_path = ""
|
|
||||||
if vim.loop.os_uname().sysname:find("Windows") then
|
|
||||||
liblldb_path = extension_path .. "lldb\\bin\\liblldb.dll"
|
|
||||||
elseif vim.fn.has("mac") == 1 then
|
|
||||||
liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
|
|
||||||
else
|
|
||||||
liblldb_path = extension_path .. "lldb/lib/liblldb.so"
|
|
||||||
end
|
|
||||||
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path)
|
|
||||||
end
|
|
||||||
return {
|
|
||||||
dap = {
|
|
||||||
adapter = adapter,
|
|
||||||
},
|
|
||||||
tools = {
|
|
||||||
on_initialized = function()
|
|
||||||
vim.cmd([[
|
|
||||||
augroup RustLSP
|
|
||||||
autocmd CursorHold *.rs silent! lua vim.lsp.buf.document_highlight()
|
|
||||||
autocmd CursorMoved,InsertEnter *.rs silent! lua vim.lsp.buf.clear_references()
|
|
||||||
autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh()
|
|
||||||
augroup END
|
|
||||||
]])
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
config = function() end,
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Correctly setup lspconfig for Rust 🚀
|
|
||||||
{
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
opts = {
|
opts = {
|
||||||
servers = {
|
server = {
|
||||||
-- Ensure mason installs the server
|
on_attach = function(client, bufnr)
|
||||||
rust_analyzer = {
|
-- register which-key mappings
|
||||||
keys = {
|
local wk = require("which-key")
|
||||||
{ "K", "<cmd>RustHoverActions<cr>", desc = "Hover Actions (Rust)" },
|
wk.register({
|
||||||
{ "<leader>cR", "<cmd>RustCodeAction<cr>", desc = "Code Action (Rust)" },
|
["<leader>cR"] = { function() vim.cmd.RustLsp("codeAction") end, "Code Action" },
|
||||||
{ "<leader>dr", "<cmd>RustDebuggables<cr>", desc = "Run Debuggables (Rust)" },
|
["<leader>dr"] = { function() vim.cmd.RustLsp("debuggables") end, "Rust debuggables" },
|
||||||
},
|
}, { mode = "n", buffer = bufnr })
|
||||||
settings = {
|
end,
|
||||||
|
default_settings = {
|
||||||
|
-- rust-analyzer language server configuration
|
||||||
["rust-analyzer"] = {
|
["rust-analyzer"] = {
|
||||||
cargo = {
|
cargo = {
|
||||||
allFeatures = true,
|
allFeatures = true,
|
||||||
|
@ -118,7 +78,21 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
vim.g.rustaceanvim = vim.tbl_deep_extend("force",
|
||||||
|
{},
|
||||||
|
opts or {})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Correctly setup lspconfig for Rust 🚀
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
opts = {
|
||||||
|
servers = {
|
||||||
|
rust_analyzer = {},
|
||||||
taplo = {
|
taplo = {
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
|
@ -136,9 +110,7 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup = {
|
setup = {
|
||||||
rust_analyzer = function(_, opts)
|
rust_analyzer = function()
|
||||||
local rust_tools_opts = require("lazyvim.util").opts("rust-tools.nvim")
|
|
||||||
require("rust-tools").setup(vim.tbl_deep_extend("force", rust_tools_opts or {}, { server = opts }))
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
@ -148,13 +120,12 @@ return {
|
||||||
{
|
{
|
||||||
"nvim-neotest/neotest",
|
"nvim-neotest/neotest",
|
||||||
optional = true,
|
optional = true,
|
||||||
dependencies = {
|
opts = function(_, opts)
|
||||||
"rouge8/neotest-rust",
|
opts.adapters = opts.adapters or {}
|
||||||
},
|
vim.list_extend(opts.adapters, {
|
||||||
opts = {
|
require('rustaceanvim.neotest'),
|
||||||
adapters = {
|
})
|
||||||
["neotest-rust"] = {},
|
end
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue