Open kmoschcau opened 1 week ago
This is not a bug. bufnr
is not 0
for the scratch buffer. Should close.
If you need to show diagnostic for the buffer where the cursor is, try
require("trouble").toggle({ mode = "diagnostics", filter = { buf = vim.fn.bufnr() } })
How is it not 0, if everywhere in nvim's API, a buffer ID of 0 means the current buffer? It works that way with telescope (require("telescope.builtin").diagnostics { bufnr = 0 }
). Trouble's documentation also mentions that buf = 0
filters for the current buffer. So either this is a bug or the documentation needs to be updated.
My mistake. buf = 0
is a special case. See https://github.com/folke/trouble.nvim/blob/2d8610a07033f2b367e71230ab128f8b89c2639d/lua/trouble/filter.lua#L34-L39
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.11.0-dev
Operating system/version
Ubuntu 22.04, WSL2, Windows 11
Describe the bug
When I toggle trouble for a scratch buffer, I get the following notification:
Steps To Reproduce
buf = 0
Expected Behavior
Trouble should list the diagnostics for the scratch buffer, just like Telescope is able to.
Repro