diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d5f385371..7c64a6ae8 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -34,6 +34,11 @@ Release notes for release 0.7 longer filtered and thus should be used instead. - Add dap-go for better dap configurations - Make noice.nvim customizable +- Switch from [rust-tools.nvim](https://github.com/simrat39/rust-tools.nvim) + to the more feature-packed [rustacean.nvim](https://github.com/mrcjkb/rustaceanvim. + This switch entails a whole bunch of new features and options, so you are + recommended to go through rustacean.nvim's README to take a closer look at + its features and usage. [jacekpoz](https://github.com/jacekpoz): diff --git a/flake.lock b/flake.lock index f6bb3995b..4601bc1b4 100644 --- a/flake.lock +++ b/flake.lock @@ -129,11 +129,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1720571246, - "narHash": "sha256-nkUXwunTck+hNMt2wZuYRN+jf2ySRjKTzI0fo5TDH78=", + "lastModified": 1721016451, + "narHash": "sha256-Cypl9ORr5UjtBsbjXMTJRepTe362yNVrPrntUvHiTaw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "16e401f01842c5bb2499e78c1fe227f939c0c474", + "rev": "a14c5d651cee9ed70f9cd9e83f323f1e531002db", "type": "github" }, "original": { @@ -1484,19 +1484,19 @@ "type": "github" } }, - "plugin-rust-tools": { + "plugin-rustaceanvim": { "flake": false, "locked": { - "lastModified": 1704259376, - "narHash": "sha256-kFane5ze7VDiOzF7jdmXkr50XQsNvdb+a9HQtybEVE0=", - "owner": "simrat39", - "repo": "rust-tools.nvim", - "rev": "676187908a1ce35ffcd727c654ed68d851299d3e", + "lastModified": 1720595685, + "narHash": "sha256-Mx8pB9ECjFpbfmZPuXfpwoE5pUZ363M53f27ht7MBmA=", + "owner": "mrcjkb", + "repo": "rustaceanvim", + "rev": "047f9c9d8cd2861745eb9de6c1570ee0875aa795", "type": "github" }, "original": { - "owner": "simrat39", - "repo": "rust-tools.nvim", + "owner": "mrcjkb", + "repo": "rustaceanvim", "type": "github" } }, @@ -1896,7 +1896,7 @@ "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", "plugin-rose-pine": "plugin-rose-pine", - "plugin-rust-tools": "plugin-rust-tools", + "plugin-rustaceanvim": "plugin-rustaceanvim", "plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-smartcolumn": "plugin-smartcolumn", "plugin-sqls-nvim": "plugin-sqls-nvim", diff --git a/flake.nix b/flake.nix index 67ed93e30..7c3c38ff3 100644 --- a/flake.nix +++ b/flake.nix @@ -164,8 +164,8 @@ flake = false; }; - plugin-rust-tools = { - url = "github:simrat39/rust-tools.nvim"; + plugin-rustaceanvim = { + url = "github:mrcjkb/rustaceanvim"; flake = false; }; diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index 0753ab440..aaed6c554 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -125,72 +125,61 @@ in { (mkIf (cfg.lsp.enable || cfg.dap.enable) { vim = { - startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package]; - - lsp.lspconfig = { - enable = true; - sources.rust-lsp = '' - local rt = require('rust-tools') - rust_on_attach = function(client, bufnr) - default_on_attach(client, bufnr) - local opts = { noremap=true, silent=true, buffer = bufnr } - vim.keymap.set("n", "ris", rt.inlay_hints.set, opts) - vim.keymap.set("n", "riu", rt.inlay_hints.unset, opts) - vim.keymap.set("n", "rr", rt.runnables.runnables, opts) - vim.keymap.set("n", "rp", rt.parent_module.parent_module, opts) - vim.keymap.set("n", "rm", rt.expand_macro.expand_macro, opts) - vim.keymap.set("n", "rc", rt.open_cargo_toml.open_cargo_toml, opts) - vim.keymap.set("n", "rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts) - ${optionalString cfg.dap.enable '' - vim.keymap.set("n", "rd", ":RustDebuggables", opts) - vim.keymap.set( - "n", "${config.vim.debugger.nvim-dap.mappings.continue}", - function() - local dap = require("dap") - if dap.status() == "" then - vim.cmd "RustDebuggables" - else - dap.continue() - end - end, - opts - ) - ''} - end - local rustopts = { - tools = { - autoSetHints = true, - hover_with_actions = false, - inlay_hints = { - only_current_line = false, - } + startPlugins = ["rustaceanvim"]; + + luaConfigRC.rustaceanvim = entryAnywhere '' + vim.g.rustaceanvim = { + ${optionalString cfg.lsp.enable '' + -- LSP + tools = { + hover_actions = { + replace_builtin_hover = false }, - server = { - capabilities = capabilities, - on_attach = rust_on_attach, - cmd = ${ + }, + server = { + cmd = ${ if isList cfg.lsp.package then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/rust-analyzer"}'' }, - settings = { - ${cfg.lsp.opts} - } - }, - - ${optionalString cfg.dap.enable '' - dap = { - adapter = { - type = "executable", - command = "${cfg.dap.package}/bin/lldb-vscode", - name = "rt_lldb", - }, - }, + on_attach = function(client, bufnr) + default_on_attach(client, bufnr) + local opts = { noremap=true, silent=true, buffer = bufnr } + vim.keymap.set("n", "rr", ":RustLsp runnables", opts) + vim.keymap.set("n", "rp", ":RustLsp parentModule", opts) + vim.keymap.set("n", "rm", ":RustLsp expandMacro", opts) + vim.keymap.set("n", "rc", ":RustLsp openCargo", opts) + vim.keymap.set("n", "rg", ":RustLsp crateGraph x11", opts) + ${optionalString cfg.dap.enable '' + vim.keymap.set("n", "rd", ":RustLsp debuggables", opts) + vim.keymap.set( + "n", "${config.vim.debugger.nvim-dap.mappings.continue}", + function() + local dap = require("dap") + if dap.status() == "" then + vim.cmd "RustLsp debuggables" + else + dap.continue() + end + end, + opts + ) ''} - } - rt.setup(rustopts) - ''; - }; + end + }, + ''} + + ${optionalString cfg.dap.enable '' + dap = { + adapter = { + type = "executable", + command = "${cfg.dap.package}/bin/lldb-vscode", + name = "rustacean_lldb", + }, + }, + ''} + } + ''; }; }) ]);