|
| 1 | +" Vim syntax file |
| 2 | +" Language: bpftrace |
| 3 | +" Maintainer: Stanislaw Gruszka <stf_xl@wp.pl> |
| 4 | +" Last Change: 2025 Dec 22 |
| 5 | + |
| 6 | +" Quit when a syntax file was already loaded |
| 7 | +if exists("b:current_syntax") |
| 8 | + finish |
| 9 | +endif |
| 10 | + |
| 11 | +let s:cpo_save = &cpo |
| 12 | +set cpo&vim |
| 13 | + |
| 14 | +syn keyword bpftraceConditional if else |
| 15 | +syn keyword bpftraceRepeat while for unroll |
| 16 | +syn keyword bpftraceStatement break continue return |
| 17 | +syn keyword bpftraceKeyword let macro import config |
| 18 | +syn keyword bpftraceOperator sizeof offsetof |
| 19 | + |
| 20 | +syn keyword bpftraceProbe BEGIN END begin end |
| 21 | +syn match bpftraceProbe "\v<(bench|self|test)\ze:" |
| 22 | +syn match bpftraceProbe "\v<(fentry|fexit|kfunc|kretfunc|kprobe|kretprobe)\ze:" |
| 23 | +syn match bpftraceProbe "\v<(profile|interval|iterator|hardware|software|uprobe|uretprobe)\ze:" |
| 24 | +syn match bpftraceProbe "\v<(usdt|tracepoint|rawtracepoint|watchpoint|asyncwatchpoint)\ze:" |
| 25 | +syn match bpftraceProbe "\v(^|[^:])<\zs(h|i|it|f|fr|k|kr|p|rt|s|t|u|ur|U|w|aw)\ze:" |
| 26 | + |
| 27 | +syn keyword bpftraceType bool int8 int16 int32 int64 |
| 28 | +syn keyword bpftraceType uint8 uint16 uint32 uint64 |
| 29 | +syn keyword bpftraceType struct |
| 30 | + |
| 31 | +syn match bpftraceMacro "\<\h\w*\ze\_s*(" |
| 32 | + |
| 33 | +syn match bpftraceNumber display "[+-]\=\<\d\+\>" |
| 34 | +syn match bpftraceNumber display "\<0x\x\+\>" |
| 35 | + |
| 36 | +syn keyword bpftraceBoolean true false |
| 37 | + |
| 38 | +syn region bpftraceString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell extend |
| 39 | + |
| 40 | +syn keyword bpftraceTodo contained TODO FIXME XXX |
| 41 | +syn match bpftraceShebang /\%^#![^[].*/ |
| 42 | +syn region bpftraceCommentLine start="//" end="$" contains=bpftraceTodo,@Spell |
| 43 | +syn region bpftraceCommentBlock matchgroup=bpftraceCommentBlock start="/\*" end="\*/" contains=bpftraceTodo,@Spell |
| 44 | + |
| 45 | +" Define the default highlighting. |
| 46 | +hi def link bpftraceConditional Conditional |
| 47 | +hi def link bpftraceMacro Macro |
| 48 | +hi def link bpftraceRepeat Repeat |
| 49 | +hi def link bpftraceKeyword Keyword |
| 50 | +hi def link bpftraceNumber Number |
| 51 | +hi def link bpftraceBoolean Boolean |
| 52 | +hi def link bpftraceShebang Comment |
| 53 | +hi def link bpftraceCommentLine Comment |
| 54 | +hi def link bpftraceCommentBlock Comment |
| 55 | +hi def link bpftraceString String |
| 56 | +hi def link bpftraceType Type |
| 57 | +hi def link bpftraceProbe Identifier |
| 58 | + |
| 59 | +syn sync minlines=100 |
| 60 | + |
| 61 | +let b:current_syntax = "bpftrace" |
| 62 | + |
| 63 | +let &cpo = s:cpo_save |
| 64 | +unlet s:cpo_save |
| 65 | + |
| 66 | +" vim: ts=8 sw=8 noexpandtab |
0 commit comments