codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: PRQL3" Maintainer: vanillajonathan4" Last Change: 2025-03-075"6" https://prql-lang.org/7" https://github.com/PRQL/prql8 9" quit when a syntax file was already loaded.10if exists("b:current_syntax")11 finish12endif13 14" We need nocompatible mode in order to continue lines with backslashes.15" Original setting will be restored.16let s:cpo_save = &cpo17set cpo&vim18 19syn keyword prqlBoolean false true20syn keyword prqlSelf this that21syn keyword prqlStatement null22syn keyword prqlConditional case23syn keyword prqlStatement prql let type alias in24syn keyword prqlRepeat loop25syn match prqlOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\|\~\)=\?"26syn match prqlOperator display "&&\|||"27syn keyword prqlInclude module28 29" Annotations30syn match prqlAnnotation "@" display contained31syn match prqlAnnotationName "@\s*{\h\%(\w\|=\)*}" display contains=prqlAnnotation32 33syn match prqlFunction "\h\w*" display contained34 35syn match prqlComment "#.*$" contains=prqlTodo,@Spell36syn keyword prqlTodo FIXME NOTE TODO XXX contained37 38" Triple-quoted strings can contain doctests.39syn region prqlString matchgroup=prqlQuotes40 \ start=+\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"41 \ contains=prqlEscape,@Spell42syn region prqlString matchgroup=prqlTripleQuotes43 \ start=+\z('''\|"""\)+ end="\z1" keepend44 \ contains=prqlEscape,prqlSpaceError,prqlDoctest,@Spell45syn region prqlFString matchgroup=prqlQuotes46 \ start=+[f]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"47 \ contains=prqlEscape,@Spell48syn region prqlFString matchgroup=prqlTripleQuotes49 \ start=+f\z('''\|"""\)+ end="\z1" keepend50 \ contains=prqlEscape,prqlSpaceError,prqlDoctest,@Spell51syn region prqlRString matchgroup=prqlQuotes52 \ start=+r\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"53 \ contains=@Spell54syn region prqlRString matchgroup=prqlTripleQuotes55 \ start=+r\z('''\|"""\)+ end="\z1" keepend56 \ contains=prqlSpaceError,prqlDoctest,@Spell57syn region prqlSString matchgroup=prqlQuotes58 \ start=+s\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"59 \ contains=@Spell60syn region prqlSString matchgroup=prqlTripleQuotes61 \ start=+s\z('''\|"""\)+ end="\z1" keepend62 \ contains=prqlSpaceError,prqlDoctest,@Spell63 64syn match prqlEscape +\\[bfnrt'"\\]+ contained65syn match prqlEscape "\\\o\{1,3}" contained66syn match prqlEscape "\\x\x\{2}" contained67syn match prqlEscape "\%(\\u\x\{1,6}\)" contained68syn match prqlEscape "\\$"69 70" It is very important to understand all details before changing the71" regular expressions below or their order.72" The word boundaries are *not* the floating-point number boundaries73" because of a possible leading or trailing decimal point.74" The expressions below ensure that all valid number literals are75" highlighted, and invalid number literals are not. For example,76"77" - a decimal point in '4.' at the end of a line is highlighted,78" - a second dot in 1.0.0 is not highlighted,79" - 08 is not highlighted,80" - 08e0 or 08j are highlighted,81"82if !exists("prql_no_number_highlight")83 " numbers (including complex)84 syn match prqlNumber "\<0[oO]\%(_\=\o\)\+\>"85 syn match prqlNumber "\<0[xX]\%(_\=\x\)\+\>"86 syn match prqlNumber "\<0[bB]\%(_\=[01]\)\+\>"87 syn match prqlNumber "\<\%([1-9]\%(_\=\d\)*\|0\+\%(_\=0\)*\)\>"88 syn match prqlNumber "\<\d\%(_\=\d\)*[jJ]\>"89 syn match prqlNumber "\<\d\%(_\=\d\)*[eE][+-]\=\d\%(_\=\d\)*[jJ]\=\>"90 syn match prqlNumber91 \ "\<\d\%(_\=\d\)*\.\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\%(\W\|$\)\@="92 syn match prqlNumber93 \ "\%(^\|\W\)\zs\%(\d\%(_\=\d\)*\)\=\.\d\%(_\=\d\)*\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\>"94endif95 96" https://prql-lang.org/book/reference/stdlib/transforms/97"98" PRQL built-in functions are in alphabetical order.99"100 101" Built-in functions102syn keyword prqlBuiltin aggregate derive filter from group join select sort take window103 104" Built-in types105syn keyword prqlType bool float int int8 int16 int32 int64 int128 text date time timestamp106 107" avoid highlighting attributes as builtins108syn match prqlAttribute /\.\h\w*/hs=s+1109 \ contains=ALLBUT,prqlBuiltin,prqlFunction110 \ transparent111 112if exists("prql_space_error_highlight")113 " trailing whitespace114 syn match prqlSpaceError display excludenl "\s\+$"115 " mixed tabs and spaces116 syn match prqlSpaceError display " \+\t"117 syn match prqlSpaceError display "\t\+ "118endif119 120" Do not spell doctests inside strings.121" Notice that the end of a string, either ''', or """, will end the contained122" doctest too. Thus, we do *not* need to have it as an end pattern.123if !exists("prql_no_doctest_highlight")124 if !exists("prql_no_doctest_code_highlight")125 syn region prqlDoctest126 \ start="^\s*>>>\s" end="^\s*$"127 \ contained contains=ALLBUT,prqlDoctest,prqlFunction,@Spell128 syn region prqlDoctestValue129 \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$"130 \ contained131 else132 syn region prqlDoctest133 \ start="^\s*>>>" end="^\s*$"134 \ contained contains=@NoSpell135 endif136endif137 138" The default highlight links. Can be overridden later.139hi def link prqlBoolean Boolean140hi def link prqlStatement Statement141hi def link prqlType Type142hi def link prqlConditional Conditional143hi def link prqlRepeat Repeat144hi def link prqlOperator Operator145hi def link prqlInclude Include146hi def link prqlAnnotation Define147hi def link prqlAnnotationName Function148hi def link prqlFunction Function149hi def link prqlComment Comment150hi def link prqlTodo Todo151hi def link prqlSelf Constant152hi def link prqlString String153hi def link prqlFString String154hi def link prqlRString String155hi def link prqlSString String156hi def link prqlQuotes String157hi def link prqlTripleQuotes prqlQuotes158hi def link prqlEscape Special159if !exists("prql_no_number_highlight")160 hi def link prqlNumber Number161endif162if !exists("prql_no_builtin_highlight")163 hi def link prqlBuiltin Function164endif165if exists("prql_space_error_highlight")166 hi def link prqlSpaceError Error167endif168if !exists("prql_no_doctest_highlight")169 hi def link prqlDoctest Special170 hi def link prqlDoctestValue Define171endif172 173let b:current_syntax = "prql"174 175let &cpo = s:cpo_save176unlet s:cpo_save177 178" vim:set sw=2 sts=2 ts=8 noet:179 