Skip to content

feat(nvim): collapse neotest diagnostic virtual text to one line#199

Draft
fredrikaverpil wants to merge 1 commit into
mainfrom
claude/neovim-pr-rebase-test-dbuz0t
Draft

feat(nvim): collapse neotest diagnostic virtual text to one line#199
fredrikaverpil wants to merge 1 commit into
mainfrom
claude/neovim-pr-rebase-test-dbuz0t

Conversation

@fredrikaverpil

@fredrikaverpil fredrikaverpil commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Why?

  • neotest renders diagnostic messages as virtual text, but testify failures are full of tabs and newlines, so the virtual text is barely readable.
  • Supersedes feat(nvim): neotest improved diagnostics #151, which made the same improvement against the old lazy.nvim config (lua/plugins/neotest.lua) that no longer exists after the migration to native vim.pack.

What?

  • Register a vim.diagnostic format function on the neotest namespace that strips newlines/tabs and squeezes runs of whitespace, in the current plugin/neotest.lua.
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)

Notes

  • Verified live in headless Neovim: a testify-style message collapses from \n\tError Trace:\tfoo_test.go:42\n\tError:\t\tNot equal:\n... to Error Trace: foo_test.go:42 Error: Not equal: expected: 3 actual : 4 Test: TestAdd — no newlines, tabs, double-spaces, or leading whitespace.
  • Closes feat(nvim): neotest improved diagnostics #151 in favor of this PR.

Register a vim.diagnostic format function on the neotest namespace so
virtual text strips newlines and tabs and squeezes runs of whitespace.
Testify failure messages are heavy with tabs and newlines, which makes
the generated virtual text hard to read otherwise.

Ports the improvement from PR #151 into the native vim.pack config, where
the neotest setup now lives in plugin/neotest.lua.

Claude-Session: https://claude.ai/code/session_017QUciwPDn2E3u5a7YsBzZz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant