summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/neotest.lua
blob: 5e22696aac8bcd28e4e0ee41ba80c44ce2640e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
return {
  {
    "nvim-neotest/neotest",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-treesitter/nvim-treesitter",
      "antoinemadec/FixCursorHold.nvim",

      "nvim-neotest/neotest-python",
      "rouge8/neotest-rust",
      "nvim-neotest/neotest-go",
    },
    keys = {
      { "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run buffer" },
      { "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run all files" },
      { "<leader>tr", function() require("neotest").run.run() end, desc = "Run nearest test" },
      { "<leader>td", function() require("neotest").run.run({strategy="dap"}) end, desc = "Debug nearest test" },
      { "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle summary" },
      { "<leader>to", function() require("neotest").output.open({enter=true, auto_close=true}) end, desc = "Show output" },
      { "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle output panel" },
      { "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop" },
      { "<leader>twt", function() require("neotest").watch.watch(vim.fn.expand("%")) end, desc = "Watch buffer" },
      { "<leader>twT", function() require("neotest").watch.watch(vim.loop.cwd()) end, desc = "Watch all files" },
      { "<leader>twr", function() require("neotest").watch.watch() end, desc = "Watch nearest test" },
      { "<leader>tws", function() require("neotest").watch.stop() end, desc = "Stop watching" },
    },
    config = function()
      local neotest_ns = vim.api.nvim_create_namespace("neotest")
      vim.diagnostic.config({
        virtual_text = {
          format = function(diagnostic)
            return diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
          end,
        },
      }, neotest_ns)

      require("neotest").setup({
        adapters = {
          require("neotest-python"),
          require("neotest-rust"),
          require("neotest-go"),
        },
      })
    end,
  },
}