From ce7a8203331c70a537e4c75d23309ef23041fa9c Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 21 Jan 2025 03:29:50 -0600 Subject: [PATCH] feat: setup neotest --- lazy-lock.json | 7 ++++++ lua/plugins/neotest.lua | 54 +++++++++++++++++++++++++++++++++++++++++ lua/vim-options.lua | 4 ++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 lua/plugins/neotest.lua diff --git a/lazy-lock.json b/lazy-lock.json index fa5cb3f..524c742 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,4 +1,5 @@ { + "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, "catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, @@ -12,6 +13,12 @@ "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.icons": { "branch": "main", "commit": "910db5df9724d65371182948f921fce23c2c881e" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "e6645ecfcba3e064446a6def1c10d788c9873f51" }, + "neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" }, + "neotest-dotnet": { "branch": "main", "commit": "5a2fa35c3c6a72cfd3fc6a28b3d1af6e68e6c3a8" }, + "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, + "neotest-playwright": { "branch": "master", "commit": "6266945039dac27a354de33d2f2a66e75485d5e9" }, + "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, + "neotest-vitest": { "branch": "main", "commit": "3e338b77700853f725856c37ff5a3cf9295bffae" }, "none-ls.nvim": { "branch": "main", "commit": "af318216b744f2fe2d5afa6febb01f455ae61d6c" }, "nuget.nvim": { "branch": "main", "commit": "ce137d6503e96657d133b48946f8739c8600834b" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua new file mode 100644 index 0000000..fc5bb11 --- /dev/null +++ b/lua/plugins/neotest.lua @@ -0,0 +1,54 @@ +return { + "nvim-neotest/neotest", + dependencies = { + "antoinemadec/FixCursorHold.nvim", + "nvim-neotest/neotest-python", + "nvim-neotest/neotest-jest", + "marilari88/neotest-vitest", + "thenbe/neotest-playwright", + "issafalcon/neotest-dotnet", + }, + config = function() + local neotest = require("neotest") + + neotest.setup({ + log_level = "debug", + adapters = { + require("neotest-python"), + require("neotest-jest"), + require("neotest-vitest"), + require("neotest-playwright").adapter({ + options = { + persist_project_selection = true, + enable_dynamic_test_discovery = true, + preset = "headed", + experimental = { + telescope = { + enable = true, + }, + }, + }, + }), + require("neotest-dotnet")({ + discovery_root = "solution", + }), + }, + }) + + vim.keymap.set("n", "tr", neotest.run.run, { desc = "Run nearest test" }) + vim.keymap.set("n", "ts", neotest.run.stop, { desc = "Stop nearest test" }) + + vim.keymap.set("n", "tf", function() + neotest.run.run(vim.fn.expand("%")) + end, { desc = "Run file tests" }) + + vim.keymap.set("n", "to", neotest.output.open, { desc = "Display output" }) + vim.keymap.set("n", "top", neotest.output_panel.open, { desc = "Display output panel" }) + vim.keymap.set("n", "topc", neotest.output_panel.clear, { desc = "Clear output" }) + vim.keymap.set("n", "", neotest.summary.open, { desc = "Display summary" }) + vim.keymap.set("n", "tsr", neotest.summary.run_marked, { desc = "Run marked tests" }) + vim.keymap.set("n", "tsc", neotest.summary.clear_marked, { desc = "Clear marked tests" }) + vim.keymap.set("n", "tw", neotest.watch.watch, { desc = "Start watching tests" }) + vim.keymap.set("n", "twc", neotest.watch.stop, { desc = "Stop watching tests" }) + end, +} diff --git a/lua/vim-options.lua b/lua/vim-options.lua index fc248c5..39d4cdb 100644 --- a/lua/vim-options.lua +++ b/lua/vim-options.lua @@ -5,7 +5,9 @@ vim.cmd("set shiftwidth=2") vim.cmd("set number") vim.cmd("set relativenumber") vim.cmd("set shell=pwsh") -vim.cmd("let &shellcmdflag = '-NoLogo'") +vim.cmd("set shellcmdflag=-Command") +vim.cmd("set shellquote=") +vim.cmd("set shellxquote=") vim.g.mapleader = " " vim.g.maplocalleader = "\\"