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.
This commit is contained in:
Marty Oehme 2023-09-23 08:37:29 +02:00
parent e016b0a056
commit 8a5381a4aa
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -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({ ["<localleader>t"] = { name = "+test" } })
break
end
end
end,
keys = {
{
"<leader>st",
[[<cmd>lua require('neotest').summary.toggle()<cr>]],
desc = "toggle test list",
silent = true,
},
{
"<leader>sT",
[[<cmd>lua require('neotest').output_panel.toggle()<cr>]],
desc = "toggle test output",
silent = true,
},
{
"<localleader>to",
[[<cmd>lua require('neotest').output.open()<cr>]],
desc = "toggle test output",
silent = true,
},
{
"<localleader>tt",
[[<cmd>lua require('neotest').run.run()<cr>]],
desc = "run nearest test",
silent = true,
},
{
"<localleader>td",
[[<cmd>lua require('neotest').run.run({strategy = "dap"})<cr>]],
desc = "debug nearest test",
silent = true,
}, -- REQUIRES DAP
{
"<localleader>tT",
[[<cmd>lua require('neotest').run.run(vim.fn.expand("%"))<cr>]],
desc = "test current file",
silent = true,
},
{
"<localleader>tr",
[[<cmd>lua require('neotest').run.run_last()<cr>]],
desc = "re-run last test",
silent = true,
},
{
"<localleader>tw",
[[<cmd>lua require('neotest').watch.toggle()<cr>]],
desc = "watch current test",
silent = true,
},
{
"<localleader>tW",
[[<cmd>lua require('neotest').watch.toggle(vim.fn.expand("%"))<cr>]],
desc = "watch current file",
silent = true,
},
},
},
}