diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index 33b1dd041..8b4291741 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -28,6 +28,7 @@ Language | Tier | Queries | Maintainer [bitbake](https://github.com/tree-sitter-grammars/tree-sitter-bitbake) | unstable | `HFIJL` | @amaanq [blade](https://github.com/EmranMR/tree-sitter-blade) | unstable | `HFIJ ` | @calebdw [bp](https://github.com/ambroisie/tree-sitter-bp)[^bp] | unstable | `HFIJL` | @ambroisie +[bpftrace](https://github.com/sgruszka/tree-sitter-bpftrace) | unstable | `H  J ` | @sgruszka [brightscript](https://github.com/ajdelcimmuto/tree-sitter-brightscript) | unstable | `HFIJ ` | @ajdelcimmuto [c](https://github.com/tree-sitter/tree-sitter-c) | unstable | `HFIJL` | @amaanq [c3](https://github.com/c3lang/tree-sitter-c3) | unstable | `HFIJ ` | @cbuttner diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index ab1ecc464..59b2643cd 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -140,6 +140,14 @@ return { readme_note = 'Android Blueprint', tier = 2, }, + bpftrace = { + install_info = { + revision = '9cdfa285bb4fd3abc74cce6e2fb46f381feca987', + url = 'https://github.com/sgruszka/tree-sitter-bpftrace', + }, + maintainers = { '@sgruszka' }, + tier = 2, + }, brightscript = { install_info = { revision = '253fdfaa23814cb46c2d5fc19049fa0f2f62c6da', 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"))