commit ae93639ec440796073ea77941091c3ec83905cdc
parent 8ed68fda50140e4a90c44075838f406b3d118196
Author: glepnir <glephunter@gmail.com>
Date: Tue, 27 Jan 2026 22:06:50 +0800
fix(health): use FileType autocmd for bug report winbar #37486
Problem: In float mode, vim.schedule() may run before filetype is set,
so winbar is not shown.
Solution: Use FileType autocmd to ensure winbar is set after filetype.
Also use type=Bug in URL.
Diffstat:
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/runtime/lua/vim/health/health.lua b/runtime/lua/vim/health/health.lua
@@ -612,25 +612,31 @@ local function check_sysinfo()
)
)
- local encoded_body = vim.uri_encode(body) --- @type string
- local issue_url = 'https://github.com/neovim/neovim/issues/new?labels=bug&body=' .. encoded_body
- vim.schedule(function()
- local win = vim.api.nvim_get_current_win()
- local buf = vim.api.nvim_win_get_buf(win)
- if vim.bo[buf].filetype ~= 'checkhealth' then
- return
- end
- _G.nvim_health_bugreport_open = function()
- vim.ui.open(issue_url)
- end
- vim.wo[win].winbar =
- '%#WarningMsg#%@v:lua.nvim_health_bugreport_open@Click to Create Bug Report on GitHub%X%*'
- vim.api.nvim_create_autocmd('BufDelete', {
- buffer = buf,
- once = true,
- command = 'lua _G.nvim_health_bugreport_open = nil',
- })
- end)
+ vim.api.nvim_create_autocmd('FileType', {
+ pattern = 'checkhealth',
+ once = true,
+ callback = function(args)
+ local buf = args.buf
+ local win = vim.fn.bufwinid(buf)
+ if win == -1 then
+ return
+ end
+ local encoded_body = vim.uri_encode(body) --- @type string
+ local issue_url = 'https://github.com/neovim/neovim/issues/new?type=Bug&body=' .. encoded_body
+
+ _G.nvim_health_bugreport_open = function()
+ vim.ui.open(issue_url)
+ end
+ vim.wo[win].winbar =
+ '%#WarningMsg#%@v:lua.nvim_health_bugreport_open@Click to Create Bug Report on GitHub%X%*'
+
+ vim.api.nvim_create_autocmd('BufDelete', {
+ buffer = buf,
+ once = true,
+ command = 'lua _G.nvim_health_bugreport_open = nil',
+ })
+ end,
+ })
end
function M.check()