Skip to content

Modernize highlight capture names to align with nvim-treesitter conventions (v0.5.0) #46

@aldoborrero

Description

@aldoborrero

Context

PR #32 fixed the No handler for is-not? error that nvim-treesitter users were hitting (see #12). But PerchunPak's follow-up comment on that issue highlighted a deeper divergence: nvim-treesitter vendors its own Nix queries because our capture names don't match nvim-treesitter's current conventions. Nvim-treesitter is now archived (2026-04-03), so those vendored queries are frozen and won't track future grammar updates.

Aligning our capture names with the modern tree-sitter conventions (used by nvim-treesitter, Helix, Zed, and most current tree-sitter theme ecosystems) means:

  • Modern themes (Tokyo Night, Catppuccin, Gruvbox-Material, etc.) highlight Nix out-of-box without per-theme mappings.
  • When a post-archival Neovim integration picks up Nix queries, ours plug in directly — no vendoring gap.
  • Theme authors have one set of captures to target.

Proposed rename table

Current v0.5.0
@escape @string.escape
@string.special.uri @string.special.url
@keyword (flat) for if, then, else @keyword.conditional
@keyword (flat) for or (in select-default) @keyword.operator
@keyword for let, inherit, in, rec, with, assert @keyword (unchanged)
(missing) on (comment) add @spell so nvim triggers spellcheck
@variable.builtin for true, false @boolean
@variable.builtin for null @constant.builtin
@variable.builtin for builtins, __currentSystem, etc. @variable.builtin (unchanged)
@embedded inside (interpolation) drop (let the injected language's theme take over)
@property (attrset keys, select attrs, binding lhs) consider @variable.member (some conventions use this for attrset keys) — needs evaluation

Files to touch

  • queries/highlights.scm — capture renames (~15-20 lines).
  • test/highlight/basic.nix — update every # ^ <capture> annotation that references a renamed capture (63 assertions; many will NOT need changes since only the affected ones move).
  • docs/highlight-groups.md — regenerate the reference list.
  • CHANGELOG.md — section under v0.5.0 "Changed (breaking for some theme consumers)".

Why v0.5.0 and not v0.4.0

This is strictly breaking for consumers who string-map capture names (older themes, custom editor configs). v0.4.0 is intended as a purely additive / non-breaking release (bindings, fixes, doc-comment split). The modernization rightfully lives in a separate minor bump so downstream has a clear upgrade signal.

Out of scope for this issue

  • Changing any grammar rule or node type (pure query work).
  • Adding new queries (e.g. folds.scm) — covered separately.

Verification plan

  • tree-sitter test — all 63 (or however many after this lands) highlight assertions pass against the new annotations.
  • Eyeball the output of tree-sitter highlight on a representative Nix file to confirm nvim-treesitter-like coloring.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions