mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-07 14:00:00 -04:00
https://cel.dev `.cel` (supported on nvim nightly: https://github.com/neovim/neovim/pull/37834) CEL is an expression-based language that's embeddable, so sorry for the short example. (Many more on https://celbyexample.com.) <details> <summary>Representative code sample</summary> ``` // From cel.dev homepage // Simple predicates 'tacocat'.startsWith('taco') ``` </details> https://github.com/bufbuild/tree-sitter-cel <details> <summary>Parsed tree for code sample</summary> ``` (expr ; [0, 0] - [3, 0] (comment) ; [0, 0] - [0, 24] (comment) ; [1, 0] - [1, 20] (member_call_expression ; [2, 0] - [2, 28] operand: (string_literal ; [2, 0] - [2, 9] (single_quoted_string_literal)) ; [2, 0] - [2, 9] function: (identifier) ; [2, 10] - [2, 20] arguments: (arguments ; [2, 20] - [2, 28] (string_literal ; [2, 21] - [2, 27] (single_quoted_string_literal))))) ; [2, 21] - [2, 27] ``` </details> Source of queries: written from scratch; cobbled together from other tree-sitter repositories. <details> <summary>Screenshots of code sample</summary> <!-- paste screenshot of code sample using provided queries here --> </details> <!-- CHECKLIST: _Before_ submitting, make sure * `./scripts/install-parsers.lua <language>` works without warnings * `./scripts/install-parsers.lua --generate <language>` works without warnings * `make query` works without warning * `make docs` is run -->
95 lines
1.2 KiB
Scheme
95 lines
1.2 KiB
Scheme
; Syntax highlighting queries for CEL (Common Expression Language).
|
|
; Maps CEL grammar nodes to standard tree-sitter highlight capture names.
|
|
; Operators
|
|
[
|
|
"-"
|
|
"!"
|
|
"*"
|
|
"/"
|
|
"&&"
|
|
"%"
|
|
"+"
|
|
"<"
|
|
"<="
|
|
"!="
|
|
"=="
|
|
">"
|
|
">="
|
|
"||"
|
|
] @operator
|
|
|
|
; Ternary operator
|
|
"?" @operator
|
|
|
|
(conditional_expression
|
|
":" @operator)
|
|
|
|
(map_entry
|
|
":" @punctuation.delimiter)
|
|
|
|
(field_initializer
|
|
":" @punctuation.delimiter)
|
|
|
|
; Punctuation
|
|
[
|
|
"("
|
|
")"
|
|
"["
|
|
"]"
|
|
"{"
|
|
"}"
|
|
] @punctuation.bracket
|
|
|
|
"," @punctuation.delimiter
|
|
|
|
"." @punctuation.delimiter
|
|
|
|
; Keywords
|
|
"in" @keyword.operator
|
|
|
|
(reserved_keyword) @keyword
|
|
|
|
; Function calls
|
|
(call_expression
|
|
function: (identifier) @function.call)
|
|
|
|
(absolute_expression
|
|
name: (identifier) @function.call
|
|
arguments: (arguments))
|
|
|
|
(member_call_expression
|
|
function: [
|
|
(identifier)
|
|
(reserved_keyword)
|
|
] @function.method.call)
|
|
|
|
; Member access
|
|
(select_expression
|
|
member: [
|
|
(identifier)
|
|
(reserved_keyword)
|
|
] @variable.member)
|
|
|
|
; Variables
|
|
(identifier) @variable
|
|
|
|
; Literals
|
|
[
|
|
(string_literal)
|
|
(bytes_literal)
|
|
] @string
|
|
|
|
[
|
|
(int_literal)
|
|
(uint_literal)
|
|
] @number
|
|
|
|
(float_literal) @number.float
|
|
|
|
[
|
|
(true)
|
|
(false)
|
|
(null)
|
|
] @constant.builtin
|
|
|
|
(comment) @comment @spell
|