Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse query precedence ordering #9458

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2481,15 +2481,17 @@ impl<'a> Iterator for HighlightIter<'a> {
}
}

// Once a highlighting pattern is found for the current node, skip over
// any later highlighting patterns that also match this node. Captures
// Use the last capture found for the current node, skipping over any
// highlight patterns that also match this node. Captures
// for a given node are ordered by pattern index, so these subsequent
// captures are guaranteed to be for highlighting, not injections or
// local variables.
while let Some((next_match, next_capture_index)) = captures.peek() {
let next_capture = next_match.captures[*next_capture_index];
if next_capture.node == capture.node {
captures.next();
match_.remove();
capture = next_capture;
match_ = captures.next().unwrap().0;
} else {
break;
}
Expand Down
8 changes: 4 additions & 4 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "julia"
source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "8fb38abff74652c4faddbf04d2d5bbbc6b4bae25" }
source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "e84f10db8eeb8b9807786bfc658808edaa1b4fa2" }

[[language]]
name = "java"
Expand Down Expand Up @@ -1658,7 +1658,7 @@ language-servers = [ "docker-langserver" ]

[[grammar]]
name = "dockerfile"
source = { git = "https://github.com/camdencheek/tree-sitter-dockerfile", rev = "8ee3a0f7587b2bd8c45c8cb7d28bd414604aec62" }
source = { git = "https://github.com/camdencheek/tree-sitter-dockerfile", rev = "868e44ce378deb68aac902a9db68ff82d2299dd0" }

[[language]]
name = "docker-compose"
Expand Down Expand Up @@ -1918,7 +1918,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "ron"
source = { git = "https://github.com/zee-editor/tree-sitter-ron", rev = "7762d709a0f7c1f9e269d0125a2e8a7a69006146" }
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-ron", rev = "78938553b93075e638035f624973083451b29055" }

[[language]]
name = "robot"
Expand Down Expand Up @@ -2410,7 +2410,7 @@ formatter = { command = "cue", args = ["fmt", "-"] }

[[grammar]]
name = "cue"
source = { git = "https://github.com/eonpatapon/tree-sitter-cue", rev = "61843e3beebf19417e4fede4e8be4df1084317ad" }
source = { git = "https://github.com/eonpatapon/tree-sitter-cue", rev = "8a5f273bfa281c66354da562f2307c2d394b6c81" }

[[language]]
name = "slint"
Expand Down
9 changes: 5 additions & 4 deletions runtime/queries/awk/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@
(number) @constant.numeric
(string) @string

(func_call name: (identifier) @function)
(func_def name: (identifier) @function)

(field_ref (_) @variable)
[
(identifier)
(field_ref)
] @variable

(func_call name: (identifier) @function)
(func_def name: (identifier) @function)

(field_ref (_) @variable)

(ns_qualified_name "::" @operator)
(ns_qualified_name (namespace) @namespace)
10 changes: 8 additions & 2 deletions runtime/queries/bash/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

(command_name) @function

(variable_name) @variable.other.member
(variable_name) @variable

((variable_name) @constant
(#match? @constant "^[A-Z][A-Z_0-9]*$"))

[
"if"
Expand Down Expand Up @@ -48,6 +51,9 @@

(comment) @comment

((word) @constant.builtin.boolean
(#any-of? @constant.builtin.boolean "true" "false"))

(function_definition name: (word) @function)

(file_descriptor) @constant.numeric.integer
Expand All @@ -56,7 +62,7 @@
(command_substitution)
(process_substitution)
(expansion)
]@embedded
] @embedded

[
"$"
Expand Down
23 changes: 12 additions & 11 deletions runtime/queries/c/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

(identifier) @variable

((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))

"sizeof" @keyword

[
Expand Down Expand Up @@ -109,6 +115,12 @@
(char_literal) @constant.character
(escape_sequence) @constant.character.escape

(field_identifier) @variable.other.member
(statement_identifier) @label
(type_identifier) @type
(primitive_type) @type.builtin
(sized_type_specifier) @type.builtin

(call_expression
function: (identifier) @function)
(call_expression
Expand All @@ -128,15 +140,4 @@
(attribute
name: (identifier) @attribute)

(field_identifier) @variable.other.member
(statement_identifier) @label
(type_identifier) @type
(primitive_type) @type.builtin
(sized_type_specifier) @type.builtin

((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))

(identifier) @variable

(comment) @comment
11 changes: 7 additions & 4 deletions runtime/queries/capnp/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
; Preproc

(unique_id) @keyword.directive
(top_level_annotation_body) @keyword.directive
[
(unique_id)
(top_level_annotation_body)
] @keyword.directive

; Includes

[
"import"
"$import"
"embed"
"using"
] @keyword.control.import

(import_path) @string
Expand Down Expand Up @@ -84,10 +87,10 @@
"union"
] @keyword.storage.type

"extends" @keyword

[
"extends"
"namespace"
"using"
(annotation_target)
] @special

Expand Down
18 changes: 9 additions & 9 deletions runtime/queries/cel/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
"in"
] @keyword

; Function calls

(call_expression
function: (identifier) @function)

(member_call_expression
function: (identifier) @function)

; Identifiers

(identifier) @variable.other.member

(select_expression
operand: (identifier) @type)

(select_expression
operand: (select_expression
member: (identifier) @type))

(identifier) @variable.other.member
; Function calls

(call_expression
function: (identifier) @function)

(member_call_expression
function: (identifier) @function)

; Literals

Expand Down
16 changes: 8 additions & 8 deletions runtime/queries/clojure/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

(comment) @comment

;; other symbols
(sym_lit) @variable

;; other calls
(list_lit
.
(sym_lit) @function)

;; metadata experiment
(meta_lit
marker: "^" @punctuation)
Expand Down Expand Up @@ -61,20 +69,12 @@
((sym_lit) @operator
(#match? @operator "^%"))

;; other calls
(list_lit
.
(sym_lit) @function)

;; interop-ish
(list_lit
.
(sym_lit) @function.method
(#match? @function.method "^\\."))

;; other symbols
(sym_lit) @variable

;; quote
(quoting_lit) @constant.character.escape

Expand Down
4 changes: 2 additions & 2 deletions runtime/queries/cpp/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
; inherits: c

; Functions

; These casts are parsed as function calls, but are not.
Expand Down Expand Up @@ -132,5 +134,3 @@
; Strings

(raw_string_literal) @string

; inherits: c
Loading