aboutsummaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorStanislaw Gruszka <stf_xl@wp.pl>2026-01-08 06:59:10 +0100
committerGitHub <noreply@github.com>2026-01-07 21:59:10 -0800
commit9177f2ff061627f0af0f994e3a3c620a84c0c59b (patch)
treea8a25854fccc8170114fffce7fdc27b75309a4ce /runtime
parentfeat(kos): highlights improvements (#8404) (diff)
downloadnvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.tar
nvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.tar.gz
nvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.tar.bz2
nvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.tar.lz
nvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.tar.xz
nvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.tar.zst
nvim-treesitter-9177f2ff061627f0af0f994e3a3c620a84c0c59b.zip
feat(parsers): add bpftrace (#8399)
Co-authored-by: Riley Bruins <ribru17@hotmail.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/bpftrace/highlights.scm228
-rw-r--r--runtime/queries/bpftrace/injections.scm12
2 files changed, 240 insertions, 0 deletions
diff --git a/runtime/queries/bpftrace/highlights.scm b/runtime/queries/bpftrace/highlights.scm
new file mode 100644
index 000000000..30a489537
--- /dev/null
+++ b/runtime/queries/bpftrace/highlights.scm
@@ -0,0 +1,228 @@
+; Comments
+[
+ (line_comment)
+ (block_comment)
+] @comment @spell
+
+; String and numeric literals
+(string_literal) @string
+
+(escape_sequence) @string.escape
+
+(integer_literal) @number
+
+(boolean_literal) @boolean
+
+; Variables
+(identifier) @variable
+
+(args_keyword) @variable.builtin
+
+((identifier) @variable.builtin
+ (#lua-match? @variable.builtin "^arg[0-9]+$"))
+
+(scratch_variable) @variable
+
+(map_variable) @variable
+
+(script_parameter) @variable.parameter
+
+; Macro
+(macro_definition
+ (identifier) @function.macro)
+
+; Probes
+; fentry/fexit, kprobe/kretprobe, rawtracepoint
+(probe
+ provider: (_) @type.builtin
+ module: (wildcard_identifier) @module
+ function: (wildcard_identifier) @property)
+
+(probe
+ provider: (_) @type.builtin
+ function: (wildcard_identifier) @property)
+
+; uprobe/uretprobe
+(probe
+ provider: (uprobe_uretprobe_provider) @type.builtin
+ binary: (file_identifier) @string.special.path
+ function: (identifier) @property)
+
+; tracepoint
+(probe
+ provider: (_) @type.builtin
+ subsys: (wildcard_identifier) @module
+ event: (wildcard_identifier) @property)
+
+; software/hardware
+(probe
+ provider: (_) @type.builtin
+ event: (identifier_with_dash) @property
+ count: (integer_literal) @number)
+
+(probe
+ provider: (_) @type.builtin
+ event: (identifier_with_dash) @property)
+
+; bench/test
+(probe
+ provider: (bench_test_provider) @type.builtin
+ function: (identifier) @property)
+
+; profile/interval
+(probe
+ provider: (profile_interval_provider) @type.builtin
+ unit: (time_unit) @string.special
+ count: (integer_literal) @property)
+
+(probe
+ provider: (profile_interval_provider) @type.builtin
+ count: (integer_literal) @number)
+
+; iter
+(probe
+ provider: (iter_provider) @type.builtin
+ object: (identifier) @module
+ pin: (file_identifier) @property)
+
+(probe
+ provider: (iter_provider) @type.builtin
+ object: (identifier) @module)
+
+; ustd
+(probe
+ provider: (ustd_provider) @type.builtin
+ binary: (file_identifier) @string.special.path
+ namespace: (identifier) @variable
+ function: (identifier) @property)
+
+(probe
+ provider: (ustd_provider) @type.builtin
+ binary: (file_identifier) @string.special.path
+ function: (identifier) @property)
+
+; watchpoint/asyncwatchpoint
+(probe
+ provider: (watchpoint_provider) @type.builtin
+ address: (integer_literal) @number
+ length: (integer_literal) @number
+ mode: (watchpoint_mode) @property)
+
+; Types
+(type_specifier) @type
+
+(integer_type) @type.builtin
+
+[
+ "BEGIN"
+ "begin"
+ "END"
+ "end"
+] @type.builtin
+
+; Keywords
+(hashbang) @keyword.directive
+
+(return_statement) @keyword.return
+
+[
+ "config"
+ "let"
+ "macro"
+ "offsetof"
+ "sizeof"
+] @keyword
+
+[
+ "if"
+ "else"
+] @keyword.conditional
+
+[
+ "for"
+ "unroll"
+ "while"
+ (break_statement)
+ (continue_statement)
+] @keyword.repeat
+
+"import" @keyword.import
+
+(field_expression
+ field: (identifier) @property)
+
+(call_expression
+ function: (identifier) @function.call)
+
+; Punctuations
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ ","
+ ";"
+ ":"
+ "."
+] @punctuation.delimiter
+
+; Operators
+[
+ ; Field access
+ "->"
+ ; Range
+ ".."
+ ; Assignment
+ "="
+ "<<="
+ ">>="
+ "+="
+ "-="
+ "*="
+ "/="
+ "%="
+ "&="
+ "|="
+ "^="
+ ; Update
+ "--"
+ "++"
+ ; Arithmetic
+ "%"
+ "+"
+ "-"
+ "*"
+ "/"
+ ; Relational
+ "<="
+ "<"
+ ">="
+ ">"
+ "=="
+ "!="
+ ; Bitwise
+ "&"
+ "^"
+ "|"
+ "~"
+ "<<"
+ ">>"
+ ; Logical
+ "&&"
+ "||"
+ "!"
+] @operator
+
+(conditional_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
+
+(predicate
+ "/" @punctuation.delimiter)
diff --git a/runtime/queries/bpftrace/injections.scm b/runtime/queries/bpftrace/injections.scm
new file mode 100644
index 000000000..8907d9f84
--- /dev/null
+++ b/runtime/queries/bpftrace/injections.scm
@@ -0,0 +1,12 @@
+([
+ (c_struct)
+ (c_preproc)
+ (c_preproc_block)
+] @injection.content
+ (#set! injection.language "c"))
+
+([
+ (line_comment)
+ (block_comment)
+] @injection.content
+ (#set! injection.language "comment"))