From e64d30b948eade6ba2b849fae858d32dca84b782 Mon Sep 17 00:00:00 2001 From: Simon Walker Date: Tue, 21 May 2024 17:10:02 +0100 Subject: [PATCH] Switch to neotest --- home/nixvim/default.nix | 4 +++- home/nixvim/neotest.nix | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 home/nixvim/neotest.nix diff --git a/home/nixvim/default.nix b/home/nixvim/default.nix index 8c64b3d0..697fbdd6 100644 --- a/home/nixvim/default.nix +++ b/home/nixvim/default.nix @@ -39,6 +39,7 @@ in { ./trouble.nix ./zen-mode.nix ./vim-test.nix + ./neotest.nix ]; config = { # custom overrides @@ -54,7 +55,8 @@ in { context.enable = true; octo-nvim.enable = true; oil.enable = true; - vim-test.enable = true; + vim-test.enable = false; + neotest.enable = true; }; # defaults programs.nixvim = { diff --git a/home/nixvim/neotest.nix b/home/nixvim/neotest.nix new file mode 100644 index 00000000..92d10aff --- /dev/null +++ b/home/nixvim/neotest.nix @@ -0,0 +1,48 @@ +{ + lib, + config, + ... +}: +with lib; let + keymap = { + key, + action, + mode ? "n", + lua ? true, + }: { + inherit action mode key lua; + options = { + noremap = true; + silent = true; + }; + }; + cfg = config.me.nixvim.neotest; +in { + options.me.nixvim.neotest.enable = mkEnableOption "neotest"; + config = mkIf cfg.enable { + programs.nixvim = { + plugins.neotest = { + enable = true; + adapters = { + go.enable = true; + python.enable = true; + rust.enable = true; + }; + }; + keymaps = [ + (keymap { + key = "tf"; + action = ''require("neotest").run.run(vim.fn.expand("%"))''; + }) + (keymap { + key = "tl"; + action = ''require("neotest").run.run_last()''; + }) + (keymap { + key = "tn"; + action = ''require("neotest").run.run()''; + }) + ]; + }; + }; +}