From c8a666f04a15504471e52d25e2afdb97fbb99efa Mon Sep 17 00:00:00 2001 From: David Yonge-Mallo Date: Mon, 13 Jul 2026 16:28:07 +0200 Subject: [PATCH] docs(TIPS): pass `modeline = false` in the treesitter-context hook `nvim_exec_autocmds` processes modelines after firing the requested autocmds by default. On a diffview buffer (non-modifiable), a modeline that sets `fileencoding` raises E21, aborting the diff open. --- TIPS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TIPS.md b/TIPS.md index 2845506d..c2b61e1c 100644 --- a/TIPS.md +++ b/TIPS.md @@ -340,9 +340,14 @@ known issues and workarounds: -- The group name is an internal detail of nvim-treesitter-context -- and may differ across versions; verify it matches your install -- or omit it to fire all BufReadPost handlers. + -- `modeline = false` prevents `nvim_exec_autocmds`'s default + -- post-autocmd modeline pass from running `:set` commands (e.g. + -- `fileencoding`) against the diffview buffer, which is + -- non-modifiable and would raise E21. pcall(vim.api.nvim_exec_autocmds, "BufReadPost", { buffer = bufnr, group = "treesitter_context_update", + modeline = false, }) end, view_closed = function()