Problem
Intermittent crash when a filewatch-triggered reload fires FileType/Syntax autocmds while treesitter is mid-reparse:
...headlines.nvim/lua/headlines/init.lua:199: attempt to concatenate local 'name' (a nil value)
make_reverse_highlight (init.lua:199)
refresh (init.lua:303)
Cause
During the racy reload the heading node text comes back empty, so level = #vim.trim(...) = 0, making c.headline_highlights[math.min(level, #c.headline_highlights)] → headline_highlights[0] → nil. That nil hl_group is passed to make_reverse_highlight, which concatenates name .. "Reverse" and throws E5108. Only happens with fat_headlines = true (the only caller).
Workaround
Monkeypatch in nvim/lua/dko/plugins/markdown.lua — wrap make_reverse_highlight to return "Normal" when name is nil, then call setup:
config = function(_, opts)
local headlines = require("headlines")
local make_reverse_highlight = headlines.make_reverse_highlight
headlines.make_reverse_highlight = function(name)
if not name then return "Normal" end
return make_reverse_highlight(name)
end
headlines.setup(opts)
end,
TODO
- Revisit/remove the monkeypatch if headlines.nvim guards the nil hl_group upstream.
Problem
Intermittent crash when a filewatch-triggered reload fires
FileType/Syntaxautocmds while treesitter is mid-reparse:Cause
During the racy reload the heading node text comes back empty, so
level = #vim.trim(...) = 0, makingc.headline_highlights[math.min(level, #c.headline_highlights)]→headline_highlights[0]→nil. Thatnilhl_group is passed tomake_reverse_highlight, which concatenatesname .. "Reverse"and throwsE5108. Only happens withfat_headlines = true(the only caller).Workaround
Monkeypatch in
nvim/lua/dko/plugins/markdown.lua— wrapmake_reverse_highlightto return"Normal"whennameis nil, then callsetup:TODO