71 lines
2.1 KiB
Lua
Executable File
71 lines
2.1 KiB
Lua
Executable File
-- plugins/neotest_config.lua
|
|
return {
|
|
-- Load neotest
|
|
{
|
|
"nvim-neotest/neotest",
|
|
dependencies = {
|
|
-- For JavaScript, TypeScript (Vite)
|
|
"marilari88/neotest-vitest",
|
|
-- For Python
|
|
"nvim-neotest/neotest-python",
|
|
-- For C, C++, Rust
|
|
"orjangj/neotest-ctest",
|
|
"rouge8/neotest-rust",
|
|
},
|
|
config = function()
|
|
local neotest = require("neotest")
|
|
local keymap = vim.keymap.set
|
|
|
|
-- General setup for neotest
|
|
neotest.setup({
|
|
adapters = {
|
|
-- Vite Adapter for JavaScript/TypeScript
|
|
require("neotest-vitest"),
|
|
-- Python Adapter
|
|
require("neotest-python"),
|
|
-- C/C++ Adapter
|
|
require("neotest-ctest"),
|
|
-- Rust Adapter
|
|
require("neotest-rust"),
|
|
},
|
|
})
|
|
|
|
-- Keybinding Setup
|
|
local opts = { noremap = true, silent = true }
|
|
|
|
-- Run nearest test
|
|
opts.desc = "Run nearest test"
|
|
keymap("n", "<leader><leader>tr", '<cmd>lua require("neotest").run.run()<cr>', opts)
|
|
|
|
-- Run all tests in the current file
|
|
opts.desc = "Run all tests in current file"
|
|
keymap("n", "<leader><leader>tf", '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))', opts)
|
|
|
|
-- Run all tests in the entire project
|
|
opts.desc = "Run all tests in project"
|
|
keymap("n", "<leader><leader>ta", "<cmd>Neotest run<cr>", opts)
|
|
|
|
-- Stop running tests
|
|
opts.desc = "Stop tests"
|
|
keymap("n", "<leader><leader>ts", "<cmd>Neotest stop<cr>", opts)
|
|
|
|
opts.desc = "Jump to next test"
|
|
keymap("n", "<leader><leader>tn", "<cmd>Neotest jump next<cr>", opts)
|
|
|
|
opts.desc = "Jump to previous test"
|
|
keymap("n", "<leader><leader>tp", "<cmd>Neotest jump prev<cr>", opts)
|
|
|
|
-- Show test summary
|
|
opts.desc = "Show neotest test summary"
|
|
keymap("n", "<leader><leader>tv", "<cmd>Neotest summary<cr>", opts)
|
|
|
|
-- Toggle the Neotest panel
|
|
opts.desc = "Show neotest output"
|
|
keymap("n", "<leader><leader>to", "<cmd>Neotest output<cr>", opts)
|
|
|
|
opts.desc = "Show neotest output as panel"
|
|
keymap("n", "<leader><leader>tn", "<cmd>Neotest output-panel<cr>", opts)
|
|
end,
|
|
},
|
|
}
|