Skip to content

Fix highlighting lag and helm-ls settings on real charts - #32

Merged
cabrinha merged 10 commits into
mainfrom
cursor/helm-speed-accuracy-ef72
Aug 27, 2026
Merged

cabrinha merged 10 commits into
mainfrom
cursor/helm-speed-accuracy-ef72

Conversation

@cabrinha

@cabrinha cabrinha commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Fixes empty YAML mappings breaking highlight after edit (#22) as far as the grammar and injection model allow, incomplete file detection (#9), and helm-ls / yamlls settings that never reached the server (#17).

Query-load bugs (invalid backtick in brackets.scm, dual @content / @injection.content) are unchanged and still fixed. Helm loads. .tpl is Helm.

Issue #22

Zed retest of 5095657 (per-node YAML, no combined) on tests/fixtures/empty-mapping.tpl: keys above and on emptyDir: {} x stayed colored; keys below (- name: config, configMap:, name:) went plain; {{ }} on line 18 stayed colored; undo restored. That is not the full-file combined wipe (zed#57341).

Cause: the #53 / rest-of-line token still ended at }. EOL is the next (text) node's start (the newline + keys below). Zed's incremental injection only re-queries the changed byte range and prunes layers that touch it, so the keys-below YAML layer is dropped (or re-parsed as a fragment that starts with x, which tree-sitter-yaml cannot highlight).

This tip's lexer is /[^{]+\{\}[^\n{]*\n?/: {}, rest of line, and the trailing newline are one token. The following keys start on the next line, outside the EOL insert. After emptyDir: {} x they remain a clean YAML fragment. YAML is still injected per (text) node, not combined.

extension.toml pins vendor/tree-sitter-helm @ d4a62d1. Rebuild the dev extension so Zed compiles that parser.c (it does not use the working tree grammar otherwise).

What changed

Grammar. Vendored helm dialect: empty-brace token includes rest of line and newline.

YAML injection. @content + #set! language yaml only. No combined.

Highlight / brackets / file detection / helm-ls. Same as earlier revisions of this PR.

How I tested

tree-sitter 0.25.10 on empty-mapping.yaml / .tpl:

  • Full parse: the emptyDir: {} text node ends at the start of the next line (erow=15 ecol=0), not at }
  • Incremental space then x after }: emptyDir: {} x stays in that node; the next node is still - name: config / configMap and does not start with x
  • check-grammar.sh fails if the {} node stops at } or if combined / dual captures come back

Please rebuild Helm from this tip, open tests/fixtures/empty-mapping.tpl, type space then x at the end of emptyDir: {}. Keys above and below should stay colored.

Open in Web Open in Cursor 

Empty YAML mappings like emptyDir: {} split the go-template lexer into
separate { and } text nodes, which Zed's combined YAML injection drops
during incremental edits. Pin the grammar to the lexer fix that keeps
{} as one text node.

Highlight queries now match builtins with #any-of? on function names
only, and cover include, tpl, sha512sum, plus .Values/.Release. File
detection covers helmfile and .tpl without stealing every YAML file.
helm-ls workspace config is wrapped under helm-ls so yamlls.enabled
actually applies, languageId is helm, and yaml-language-server is
passed through when it is on PATH.
@cabrinha
cabrinha marked this pull request as ready for review August 26, 2026 23:29
@cabrinha
cabrinha requested a review from austinorth August 26, 2026 23:30
@cursor
cursor Bot force-pushed the cursor/helm-speed-accuracy-ef72 branch from 15da7e7 to 42f4fe9 Compare August 26, 2026 23:34
Zed refuses to register the Helm language when brackets.scm names a
node type the helm dialect grammar does not emit. The backtick rule
was that: .tpl files showed as Unknown and highlighting never ran.

Keep {{ }}, {{- -}}, (), and " pairs. Compile every .scm query against
the pinned grammar in check-grammar.sh so a bad node type fails CI
instead of Zed language load.
Zed fails language load when injections.scm sets both @content and
@injection.content on the same pattern. Helm never registered: .tpl
stayed Unknown and the language picker had no Helm entry.

Keep the published @content + language/combined form. Zed accepts
either capture style, not both. check-grammar.sh now rejects a
dual-capture injections.scm because tree-sitter query does not.
tree-sitter query still compiles @content and @injection.content on
the same pattern. Zed's language_registry does not, and Helm never
registers.

Keep the published @content + language/combined query so combined YAML
injection still covers emptyDir: {}. check-grammar.sh now mirrors the
Zed capture-name check and asserts the exact dual-capture query from
Zed.log is rejected.
The #53 grammar pin is in the wasm Zed compiles: dialects/helm/src
keeps `{}` as one text node on full parse and after an incremental
edit next to the mapping. Combined YAML injection is still set.

Smoke testing PR #32 in Zed still drops YAML keys when typing next
to emptyDir: {}. That matches zed-industries/zed#57341. tree-sitter
and Neovim restitch the fragments; Zed's combined layer does not
on buffer updates. Removing combined would only hide the core bug
and would stop YAML from stitching across {{ }} on load.

check-grammar.sh now asserts the empty-brace tokens are in the
pinned grammar.json and that an incremental edit after {} does not
split a lone `{` node.
Zed screenshots of empty-mapping.tpl on this PR: YAML keys and {{ }}
highlighted on open; after typing space then x at the end of
emptyDir: {}, every YAML key went plain while {{ }} stayed colored;
undo did not restore. That is zed-industries/zed#57341. Combined
injection is one YAML layer; an incremental splice drops it.

Keep the #53 grammar pin so {} is one text node. Inject each (text)
node as its own YAML layer so an edit next to emptyDir: {} cannot
wipe keys in other fragments. Do not set combined. Dual-capture
query-load fixes are unchanged.
#53 stopped the text token at `}`. Typing at EOL after emptyDir: {}
inserted into the next (text) node, so YAML for keys below started
with those characters and went plain (configMap, name).

Keep `{}` plus [^\n{]* in one token. Keys on later lines stay a
clean YAML fragment. Still no combined injection (zed#57341).
Query-load fixes are unchanged.
Zed compiles parser.c from this pin, not the working tree. Point
grammars.helm at vendor/tree-sitter-helm @ 22fd4dc so the emptyDir
EOL fix is what the extension actually loads.
5095657 and the rest-of-line token still ended at `}`. Typing at EOL
after emptyDir: {} sat on the next (text) node's start. Zed dropped
that node's YAML layer: keys below went plain, {{ }} stayed colored.

Eat the trailing newline in the {} token. The following keys start
on the next line, outside the edit range, and stay a valid YAML
fragment. Still no combined injection (zed#57341).
Zed compiles parser.c from this pin. Point grammars.helm at
vendor/tree-sitter-helm @ d4a62d1 so an EOL edit after emptyDir: {}
is inside that text node, not on the following keys' YAML layer.
@cabrinha
cabrinha merged commit 3f0ec2b into main Aug 27, 2026
1 check passed
cursor Bot pushed a commit that referenced this pull request Aug 27, 2026
extension.toml now pins vendor/tree-sitter-helm @ d4a62d1 from #32.
Keep tests/grammar-pin.sha in lockstep, compile queries against the
local vendor copy, and reject combined YAML injection the same way
check-grammar.sh does.
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.

1 participant