From 8a5381a4aa22b1c53e1e52a0b4ff3dd91fc1fbda Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 23 Sep 2023 08:37:29 +0200 Subject: [PATCH] nvim: Add test setup for python to ide Added neotest with some mappings to run tests and view outputs, as well as neotest-python for now to make it work under python. Added registering with which-key if it exists. --- nvim/.config/nvim/lua/plugins/ide.lua | 86 ++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/ide.lua b/nvim/.config/nvim/lua/plugins/ide.lua index 1fe0a9e..47321bf 100644 --- a/nvim/.config/nvim/lua/plugins/ide.lua +++ b/nvim/.config/nvim/lua/plugins/ide.lua @@ -13,6 +13,8 @@ return { backends = { "treesitter", "lsp", "markdown", "man" }, }, }, + + -- lsp setup { "junnplus/lsp-setup.nvim", dependencies = { @@ -51,6 +53,7 @@ return { require("plugins.config.lsp") end, }, + -- completion setup { "hrsh7th/nvim-cmp", branch = "main", @@ -82,7 +85,88 @@ return { end, event = { "InsertEnter", "CmdlineEnter", "VeryLazy" }, }, + -- loading animations for some LSP { "j-hui/fidget.nvim", config = true, tag = "legacy", event = "VeryLazy" }, - -- a pretend-lsp for formatters and linters + + -- testing setup + { + "nvim-neotest/neotest", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "antoinemadec/FixCursorHold.nvim", + + "nvim-neotest/neotest-python", + }, + config = function() + require("neotest").setup({ + adapters = { + require("neotest-python"), + }, + }) + for _, v in pairs(require("lazy").plugins()) do + if v[1] == "folke/which-key.nvim" then + require("which-key").register({ ["t"] = { name = "+test" } }) + break + end + end + end, + keys = { + { + "st", + [[lua require('neotest').summary.toggle()]], + desc = "toggle test list", + silent = true, + }, + { + "sT", + [[lua require('neotest').output_panel.toggle()]], + desc = "toggle test output", + silent = true, + }, + { + "to", + [[lua require('neotest').output.open()]], + desc = "toggle test output", + silent = true, + }, + { + "tt", + [[lua require('neotest').run.run()]], + desc = "run nearest test", + silent = true, + }, + { + "td", + [[lua require('neotest').run.run({strategy = "dap"})]], + desc = "debug nearest test", + silent = true, + }, -- REQUIRES DAP + { + "tT", + [[lua require('neotest').run.run(vim.fn.expand("%"))]], + desc = "test current file", + silent = true, + }, + { + "tr", + [[lua require('neotest').run.run_last()]], + desc = "re-run last test", + silent = true, + }, + { + "tw", + [[lua require('neotest').watch.toggle()]], + desc = "watch current test", + silent = true, + }, + { + "tW", + [[lua require('neotest').watch.toggle(vim.fn.expand("%"))]], + desc = "watch current file", + silent = true, + }, + }, + }, }