diff --git a/nix/nixvim/extra-config/default.nix b/nix/nixvim/extra-config/default.nix index 5dbeaae..f6be7f2 100644 --- a/nix/nixvim/extra-config/default.nix +++ b/nix/nixvim/extra-config/default.nix @@ -26,4 +26,4 @@ require('scala-zio-quickfix').setup({}); '' ) - + import ./harpoon.lua.nix ++ import ./harpoon.lua.nix diff --git a/nix/nixvim/keymaps/neotest.nix b/nix/nixvim/keymaps/neotest.nix index 0a4adc4..227e07c 100644 --- a/nix/nixvim/keymaps/neotest.nix +++ b/nix/nixvim/keymaps/neotest.nix @@ -99,4 +99,12 @@ desc = "neotest: jump to next failed test"; }; } + { + key = "tS"; + action = ":lua require('neotest').summary.toggle()"; + mode = "n"; + options = { + desc = "neotest: [t]est [S]ummary"; + }; + } ] diff --git a/nix/nixvim/plugins/neotest.nix b/nix/nixvim/plugins/neotest.nix index 7907bf3..64f7d67 100644 --- a/nix/nixvim/plugins/neotest.nix +++ b/nix/nixvim/plugins/neotest.nix @@ -9,6 +9,16 @@ let hash = "sha256-RFEPtWPVHKehfc6PMF6ya0UaDpFIJDD8bFG8xwXPpsk="; }; }); + + neotest-python = (pkgs.vimUtils.buildVimPlugin { + name = "neotest-python"; + src = pkgs.fetchFromGitHub { + owner = "olisikh"; + repo = "neotest-python"; + rev = "fix/no_tests_found"; + hash = "sha256-Fk+hMsDYPg48R0f52xOdr0X1+JmwciuRoMtMEsnA8L0="; + }; + }); in { neotest = { @@ -27,6 +37,7 @@ in adapters = { python = { enable = true; + package = neotest-python; settings = { args = [ "-s" ]; pytest_discover_instances = true; @@ -38,28 +49,32 @@ in return false end - local file = io.open(file_path, 'r') + -- NOTE: check if there the file is starting or ending with test keyword + local path_segments = vim.split(file_path, "/") + local file_name = path_segments[#path_segments] + if vim.startswith(file_name, "test_") then + return true + elseif vim.endswith(file_name, "_test.py" ) then + return true + end + + local file = io.open(file_path, "r") if file == nil then return false end - local content = file:read('a') + local content = file:read("a") file:close() if content == nil then return false end - local has_tests = content:match('def test') - -- NOTE: check if there are functions that start with test_ - if content:match('def test_') then + if content:match("def test_") then return true end - -- NOTE: check if there are files starting or ending with test - local path_segments = vim.split(file_path, "/") - local file_name = elems[#path_segments] - return vim.startswith(file_name, "test_") or vim.endswith(file_name, "_test.py") + return false end ''; }; @@ -73,6 +88,7 @@ in java.enable = true; vitest.enable = true; jest.enable = true; + # gradle.enable = true; # TODO: check out this plugin, maybe it's a nice universal plugin to run even kotlin tests? }; }; }