aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/neotest.lua
blob: 1034d333e22303078d0942c50bf512bdbbc4c472 (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
local M = {}

function M.setup()
  local ok, neotest = pcall(require, "neotest")
  if not ok or not neotest then
    return false
  end

  -- Safely require adapters
  local python_ok, python_adapter = pcall(require, "neotest-python")
  local plenary_ok, plenary_adapter = pcall(require, "neotest-plenary")
  local vim_test_ok, vim_test_adapter = pcall(require, "neotest-vim-test")

  local adapters = {}
  if python_ok and python_adapter then
    table.insert(adapters, python_adapter({
      dap = { justMyCode = false },
    }))
  end
  
  if plenary_ok and plenary_adapter then
    table.insert(adapters, plenary_adapter)
  end
  
  if vim_test_ok and vim_test_adapter then
    table.insert(adapters, vim_test_adapter({
      ignore_file_types = { "python", "vim", "lua" },
    }))
  end

  neotest.setup({
    adapters = adapters,
  })
  
  return true
end

return M