From 8f2d37e78594f634db989a76a4dcc2b98c7157c1 Mon Sep 17 00:00:00 2001 From: Marvin Drescher Date: Mon, 19 Feb 2024 09:56:17 +0100 Subject: [PATCH] feat(nvim/rustacean): runnables config --- default.nix | 1 + init.lua | 8 +++++++- rust.lua | 43 +++++++++++++++++++++++++++++++------------ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/default.nix b/default.nix index 73b854b..c031e7f 100644 --- a/default.nix +++ b/default.nix @@ -82,6 +82,7 @@ in ) # https://github.com/mrcjkb/rustaceanvim/discussions/46#discussioncomment-7620822 plenary-nvim crates-nvim + neotest nvim-lspconfig telescope-nvim telescope-undo-nvim diff --git a/init.lua b/init.lua index 294d59b..f4b74f4 100644 --- a/init.lua +++ b/init.lua @@ -236,7 +236,13 @@ lspconfig.nil_ls.setup { autoEvalInputs = true, }, } - +require('neotest').setup { + -- ..., + adapters = { + -- ..., + require('rustaceanvim.neotest') + }, +} require("lsp-inlayhints").setup() require("completion") require("rust") diff --git a/rust.lua b/rust.lua index b2fa401..14397f5 100644 --- a/rust.lua +++ b/rust.lua @@ -6,7 +6,11 @@ vim.g.rustaceanvim = { tools = { -- rust-tools options -- how to execute terminal commands -- options right now: termopen / quickfix / toggleterm / vimux - executor = require("rust-tools.executors").termopen, + executor = require('rustaceanvim.executors').termopen, + + test_executor = require('rustaceanvim.executors').neotest; + + crate_test_executor = require('rustaceanvim.executors').background; -- callback to execute once rust-analyzer is done initializing the workspace -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" @@ -52,8 +56,7 @@ vim.g.rustaceanvim = { highlight = "Comment" }, - -- options same as lsp hover / vim.lsp.util.open_floating_preview() - hover_actions = { + float_win_config = { -- the border that is used for the hover window -- see vim.api.nvim_open_win() @@ -72,7 +75,7 @@ vim.g.rustaceanvim = { -- whether the hover action window gets automatically focused -- default: false - auto_focus = false + auto_focus = false, }, -- settings for showing the crate graph based on graphviz and the dot @@ -133,20 +136,36 @@ vim.g.rustaceanvim = { function() vim.cmd.RustLsp('openCargo') end, keymap_opts) vim.keymap.set('n', 'cr', function() + vim.cmd.RustLsp {'runnables', } + end, keymap_opts) + + vim.keymap.set('n', 'cR', function() vim.cmd.RustLsp {'runnables', 'last' --[[ optional ]] } end, keymap_opts) vim.keymap.set('n', 'cd', function() + vim.cmd.RustLsp {'debuggables', } + end, keymap_opts) + + vim.keymap.set('n', 'cD', function() vim.cmd.RustLsp {'debuggables', 'last' --[[ optional ]] } + end, keymap_opts) + + vim.keymap.set('n', 'ct', function() + vim.cmd.RustLsp {'testables', } + end, keymap_opts) + + vim.keymap.set('n', 'cT', function() + vim.cmd.RustLsp {'testables', 'last' } + end, keymap_opts) + + vim.keymap.set('n', 'cm', function() + vim.cmd.RustLsp {'expandMacro'} + end, keymap_opts) + + vim.keymap.set('n', 'cE', function() + vim.cmd.RustLsp {'explainError'} end, keymap_opts) -- vim.keymap.set("n", "g0", vim.lsp.buf.document_symbol, keymap_opts) - local diag_float_grp = vim.api.nvim_create_augroup( - "DiagnosticFloat", {clear = true}) - vim.api.nvim_create_autocmd("CursorHold", { - callback = function() - vim.diagnostic.open_float(nil, {focusable = false}) - end, - group = diag_float_grp - }) -- Goto previous/next diagnostic warning/error vim.keymap.set("n", "g[", vim.diagnostic.goto_prev, keymap_opts)