From 849f08267eeaba47544c1afb9d59d9f404bda9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Wed, 3 Jan 2024 11:08:50 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(nvim):=20change?= =?UTF-8?q?=20rust-tools=20for=20rustaceanvim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lazy-lock.json | 2 +- .../lua/plugins/extras/lang/rust-extended.lua | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 52b2e3e1..bb6696b7 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -106,7 +106,7 @@ "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "4a90ac83c7c8e0ba8a1b6af38bed6d5ee1b04e08" }, "refactoring.nvim": { "branch": "master", "commit": "156532476deb10b1b2a32cb38e1078b3f9951c42" }, - "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, + "rustaceanvim": { "branch": "master", "commit": "3a439b5c76f0e54bd8bf3b498a849079015fc20f" }, "satellite.nvim": { "branch": "main", "commit": "1a20861227eba8bf2d8282ab4ec5fc071e8b20e2" }, "search-replace.nvim": { "branch": "main", "commit": "d92290a02d97f4e9b8cd60d28b56b403432158d5" }, "semshi": { "branch": "master", "commit": "0182447e2ff4dfa04cd2dfe5f189e012c581ca45" }, diff --git a/.config/nvim/lua/plugins/extras/lang/rust-extended.lua b/.config/nvim/lua/plugins/extras/lang/rust-extended.lua index 60aef896..47af05ec 100644 --- a/.config/nvim/lua/plugins/extras/lang/rust-extended.lua +++ b/.config/nvim/lua/plugins/extras/lang/rust-extended.lua @@ -1,5 +1,67 @@ return { { import = "lazyvim.plugins.extras.lang.rust" }, + { + "simrat39/rust-tools.nvim", + enabled = false, + }, + { + "mrcjkb/rustaceanvim", + version = "^3", -- Recommended + ft = { "rust" }, + opts = { + server = { + on_attach = function(client, bufnr) + -- register which-key mappings + local wk = require("which-key") + -- stylua: ignore + wk.register({ + ["cR"] = { function() vim.cmd.RustLsp("codeAction") end, "Code Action" }, + ["dr"] = { function() vim.cmd.RustLsp("debuggables") end, "Rust debuggables" }, + }, { mode = "n", buffer = bufnr }) + end, + settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + -- Add clippy lints for Rust. + checkOnSave = { + allFeatures = true, + command = "clippy", + extraArgs = { "--no-deps" }, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, + }, + }, + config = function(_, opts) + vim.g.rustaceanvim = vim.tbl_deep_extend("force", {}, opts or {}) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + rust_analyzer = {}, + }, + setup = { + rust_analyzer = function() + return true + end, + }, + }, + }, { "luckasRanarison/nvim-devdocs", optional = true,