You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.6 KiB

1 month ago
1 month ago
  1. return {
  2. "nvim-neotest/neotest",
  3. dependencies = {
  4. "nvim-lua/plenary.nvim",
  5. "nvim-treesitter/nvim-treesitter",
  6. "antoinemadec/FixCursorHold.nvim",
  7. "nvim-neotest/nvim-nio",
  8. -- Adapters
  9. "tovijaeschke/neotest-phpunit",
  10. "nvim-neotest/neotest-go",
  11. },
  12. config = function()
  13. local neotest = require("neotest")
  14. local keymap = vim.keymap
  15. keymap.set("n", "<leader>tr", function()
  16. neotest.run.run()
  17. end, { desc = "Run neotest on current function" })
  18. keymap.set("n", "<leader>tR", function()
  19. neotest.run.run_last()
  20. end, { desc = "Run neotest on most recent test" })
  21. keymap.set("n", "<leader>tS", function()
  22. neotest.run.stop()
  23. end, { desc = "Stop running tests" })
  24. keymap.set("n", "<leader>ta", function()
  25. neotest.run.attach()
  26. end, { desc = "Attach to the currently running test" })
  27. keymap.set("n", "<leader>to", function()
  28. neotest.output.open()
  29. end, { desc = "Open the output of the test" })
  30. keymap.set("n", "<leader>ts", function()
  31. neotest.summary.toggle()
  32. end, { desc = "Toggle neotest summary pane" })
  33. local neotest_ns = vim.api.nvim_create_namespace("neotest")
  34. vim.diagnostic.config({
  35. virtual_text = {
  36. format = function(diagnostic)
  37. local message =
  38. diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
  39. return message
  40. end,
  41. },
  42. }, neotest_ns)
  43. vim.env.PROJECT_ROOT = vim.fn.getcwd() .. "/backend/"
  44. vim.env.ENV_PATH = vim.fn.getcwd() .. "/backend/.env"
  45. neotest.setup({
  46. adapters = {
  47. require("neotest-phpunit")({
  48. root_files = { "phpunit.xml", "composer.json" },
  49. phpunit_cmd = { "docker", "compose", "exec", "fpm", "./vendor/bin/phpunit" },
  50. -- phpunit_cmd = { "docker", "compose", "exec", "app-fpm", "./vendor/bin/phpunit" },
  51. filter_dirs = { "vendor" },
  52. mapped_docker_dir = "/var/www",
  53. append_to_cwd = "/api",
  54. }),
  55. require("neotest-go")({
  56. root = function()
  57. return './backend'
  58. end,
  59. experimental = {
  60. test_table = true,
  61. },
  62. args = { "-count=1", "-timeout=60s" },
  63. })
  64. },
  65. })
  66. end,
  67. }