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.

78 lines
2.6 KiB

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