helix
helix copied to clipboard
Syntax highlighting breaking inside injected Language
Summary
I am using a custom html
injections.scm
.
The injection is working, and also correct parsing subtree is being produced however the highlighting breaks, unless, I add a space after the "
for some odd reasons.
Reproduction Steps
I tried this:
- add this to the following path:
~/.config/helix/runtime/queries/html/injections.scm
;; HTM Defaults
;----------------
((comment) @injection.content
(#set! injection.language "comment"))
((script_element
(raw_text) @injection.content)
(#set! injection.language "javascript"))
((style_element
(raw_text) @injection.content)
(#set! injection.language "css"))
;; User Defined
----------------
; ; x-foo="javascript"
((attribute
(attribute_name) @_attr
(#match? @_attr "^x-[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content))
(#set! injection.language "javascript"))
; ; <x-foo ::bar="baz" />
(element
(_
(tag_name) @_tag
(#match? @_tag "^x-[a-z]+")
(attribute
(attribute_name) @_attr
(#match? @_attr "^::[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))))
; <x-foo :bar="$baz" />
(element
(_
(tag_name) @_tag
(#match? @_tag "^x-[a-z]+")
(attribute
(attribute_name) @_attr
(#match? @_attr "^:[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "php-only"))))
- Do
hx test.html
- ensure the
language
ishtml
- Type the following
<x-util.button x-data="console.log" ::test="console.log()" :url="route('register')" />
As you can see in the photo below the highlights are not correct, but when you do :tree-sitter-subtree
correct tree is shown
I expected this to happen:
-
Note the extra
spaces
to get the correct highlight
Instead, this happened:
- As you can see, the correct language (
php
) is injected but is NOT highlighted as such unless I put space between"
and thephp
code.
Helix log
~/.cache/helix/helix.log
│ File: helix.log
1 │ 2024-07-11T18:21:48.406 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability │ registration is not enabled. Please report this upstream to the language server 2 │ 2024-07-11T18:21:50.157 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability │ registration is not enabled. Please report this upstream to the language server
please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines
Platform
MacOS
Terminal Emulator
xterm-256color
Installation Method
source
Helix Version
24.03-237-gfc97ecc3