From 002e59006fe2345f32ce7288e54e1a4c9dc0f527 Mon Sep 17 00:00:00 2001 From: James Santucci Date: Wed, 11 Sep 2024 00:07:13 -0400 Subject: [PATCH] Set up neotest-haskell + neotest bindings (#100) * wip -- plugins and bindings * update inputs * Add the nice parts of neotest conf to custom-neotest * Add more useful bindings output pane toggle + clear, summary pane toggle --- attrs/vimPlugins.nix | 3 +++ dotfiles/neovim/ftplugin/haskell.lua | 10 ++++++++++ dotfiles/neovim/init.lua | 1 + dotfiles/neovim/lua/custom-neotest.lua | 18 ++++++++++++++++++ flake.lock | 12 ++++++------ 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 dotfiles/neovim/lua/custom-neotest.lua diff --git a/attrs/vimPlugins.nix b/attrs/vimPlugins.nix index c7ff6df..61b44a8 100644 --- a/attrs/vimPlugins.nix +++ b/attrs/vimPlugins.nix @@ -44,6 +44,9 @@ with vimPlugins; luasnip markdown-preview-nvim markdownNvimPlugin + neotest + neotest-haskell + neotest-python nvim-cmp nvim-dap nvim-dap-ui diff --git a/dotfiles/neovim/ftplugin/haskell.lua b/dotfiles/neovim/ftplugin/haskell.lua index 362d10d..9e95426 100644 --- a/dotfiles/neovim/ftplugin/haskell.lua +++ b/dotfiles/neovim/ftplugin/haskell.lua @@ -1 +1,11 @@ vim.opt.colorcolumn = "120" + +require("neotest").setup { + adapters = { + require("neotest-haskell") { + build_tools = { "cabal" }, + frameworks = { "hspec", "tasty", "sydtest" }, + }, + } +} + diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index c8bc6b2..f1d86cb 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -10,6 +10,7 @@ require("completion-config") require("custom-dap-config") require("custom-lsp-config") require("custom-luasnip") +require("custom-neotest") require("custom-rest-nvim") require("custom-treesitter") require("custom-vimwiki") diff --git a/dotfiles/neovim/lua/custom-neotest.lua b/dotfiles/neovim/lua/custom-neotest.lua new file mode 100644 index 0000000..411164a --- /dev/null +++ b/dotfiles/neovim/lua/custom-neotest.lua @@ -0,0 +1,18 @@ +vim.api.nvim_set_keymap("n", "tr", + "lua require('neotest').run.run()", + { noremap = true, desc = "Run nearest test" }) +vim.api.nvim_set_keymap("n", "tt", + "lua require('neotest').run.run_last()", + { noremap = true, desc = "Re-run last test" }) +vim.api.nvim_set_keymap("n", "tf", + "lua require('neotest').run.run(vim.fn.expand('%'))", + { noremap = true, desc = "Run all tests in file" }) +vim.api.nvim_set_keymap("n", "tot", + "lua require('neotest').output_panel.toggle()", + { noremap = true, desc = "Toggle test output pane" }) +vim.api.nvim_set_keymap("n", "toc", + "lua require('neotest').output_panel.clear()", + { noremap = true, desc = "Clear test output pane" }) +vim.api.nvim_set_keymap("n", "ts", + "lua require('neotest').summary.toggle()", + { noremap = true, desc = "Toggle test summary pane" }) diff --git a/flake.lock b/flake.lock index f56c687..298e4c0 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1720042825, - "narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=", + "lastModified": 1725703823, + "narHash": "sha256-tDgM4d8mLK0Hd6YMB2w1BqMto1XBXADOzPEaLl10VI4=", "owner": "nix-community", "repo": "home-manager", - "rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073", + "rev": "208df2e558b73b6a1f0faec98493cb59a25f62ba", "type": "github" }, "original": { @@ -55,11 +55,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1723688146, - "narHash": "sha256-sqLwJcHYeWLOeP/XoLwAtYjr01TISlkOfz+NG82pbdg=", + "lastModified": 1725826545, + "narHash": "sha256-L64N1rpLlXdc94H+F6scnrbuEu+utC03cDDVvvJGOME=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c3d4ac725177c030b1e289015989da2ad9d56af0", + "rev": "f4c846aee8e1e29062aa8514d5e0ab270f4ec2f9", "type": "github" }, "original": {