Skip to content

[audit] Fix unsatisfiable kind check in tree-sitter-d2 PackChanged hook - #348

Draft
stanfish06 wants to merge 1 commit into
masterfrom
audit/tree-sitter-d2-packchanged-cond
Draft

stanfish06 wants to merge 1 commit into
masterfrom
audit/tree-sitter-d2-packchanged-cond

Conversation

@stanfish06

Copy link
Copy Markdown
Owner

What

lua/config/plugins.lua:232 — the PackChanged autocmd's tree-sitter-d2 branch required:

elseif name == "tree-sitter-d2" and kind == "install" and kind == "update" then

kind is a single string; it can never equal "install" and "update" at the same time, so this branch is dead code — the vim.system({ "make", "nvim-install" }, ...) call that builds the native parser library for D2 diagram highlighting never runs after vim.pack.add/vim.pack.update install or update tree-sitter-d2.

Where

lua/config/plugins.lua:206-239 — the PackChanged handler. The branch already runs under an early filter (if kind ~= "install" and kind ~= "update" then return end, line 209) that guarantees kind is one of those two values by the time any branch executes, exactly as the fff.nvim and blink.cmp branches above it already assume (neither re-checks kind).

Why it matters

Without the native build step firing, a fresh install or update of tree-sitter-d2 leaves the D2 grammar's compiled parser missing/stale, breaking D2 diagram syntax highlighting/parsing until someone runs make nvim-install by hand inside the plugin's pack directory.

Fix

Drop the impossible extra condition so the branch matches its siblings:

elseif name == "tree-sitter-d2" then

Mechanical, one-line, no behavior change beyond making the existing intended build step actually run.



Generated by Claude Code

The PackChanged callback for tree-sitter-d2 required kind to equal both
"install" and "update" simultaneously, which is never true, so the
`make nvim-install` native-parser build never ran after installing or
updating the plugin. The surrounding handler already filters events to
just install/update kinds before this branch runs (see the early
return a few lines up), so the extra check was both redundant and
wrong — drop it, matching the fff.nvim/blink.cmp branches above it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CV1pGQRo9Rzc64fQSsYpHQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants