ajhahn.de
← Flash
Vim Script 25 lines
" Standalone .flash files: use the Flash-exact regex syntax (syntax/flash.vim),
" not the Zig treesitter parser. The zig parser mis-parses Flash-specific syntax
" (`use X link Y` imports, `:=`) — ~0.5 ERROR nodes per line on real Flash code,
" and those regions render uncolored. The regex syntax has zero parse errors and
" colors every Flash construct correctly.
"
" The tutorial's ```flash markdown fences keep using treesitter-zig — that is a
" separate injection path (language registered in the user's config) and is not
" touched here; this only governs buffers whose filetype is `flash`.
"
" Deferred via vim.schedule so it runs AFTER any FileType handler that auto-starts
" a treesitter highlighter (NvChad), then stops it for this buffer and switches on
" the regex syntax. Removing the ftplugin symlink fully reverts to treesitter-zig.

lua << EOF
local buf = vim.api.nvim_get_current_buf()
vim.schedule(function()
  if not vim.api.nvim_buf_is_valid(buf) then return end
  pcall(vim.treesitter.stop, buf)
  if vim.bo[buf].syntax ~= 'flash' then
    vim.bo[buf].syntax = 'flash'
  end
end)
EOF