robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
502324a7b5
master
1" Vim syntax file 2" Language: PRQL 3" Maintainer: vanillajonathan 4" Last Change: 2025-03-07 5" 6" https://prql-lang.org/ 7" https://github.com/PRQL/prql 8 9" quit when a syntax file was already loaded. 10if exists ( "b:current_syntax" ) 11finish 12endif 13 14" We need nocompatible mode in order to continue lines with backslashes. 15" Original setting will be restored. 16let s: cpo_save = & cpo 17set cpo & vim 18 19syn keyword prqlBoolean false true 20syn keyword prqlSelf this that 21syn keyword prqlStatement null 22syn keyword prqlConditional case 23syn keyword prqlStatement prql let type alias in 24syn keyword prqlRepeat loop 25syn match prqlOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\|\~\)=\? " 26syn match prqlOperator display "&&\||| " 27syn keyword prqlInclude module 28 29" Annotations 30syn match prqlAnnotation "@ "display contained 31syn match prqlAnnotationName "@\s * {\h\%(\w\|=\) * } "display contains = prqlAnnotation 32 33syn match prqlFunction "\h\w * "display contained 34 35syn match prqlComment "#. * $ "contains = prqlTodo , @Spell 36syn keyword prqlTodo FIXME NOTE TODO XXX contained 37 38" Triple-quoted strings can contain doctests. 39syn region prqlString matchgroup = prqlQuotes 40 \start = +\z( [ '" ] \) +end = "\z1 " skip="\\\\\|\\\z1" 41\ contains =prqlEscape,@Spell 42syn region prqlString matchgroup = prqlTripleQuotes 43 \start = +\z('''\|"""\) +end = "\z1 "keepend 44 \contains = prqlEscape , prqlSpaceError , prqlDoctest , @Spell 45syn region prqlFString matchgroup = prqlQuotes 46 \start = +[ f ] \z( [ '" ] \) +end = "\z1 " skip="\\\\\|\\\z1" 47\ contains =prqlEscape,@Spell 48syn region prqlFString matchgroup = prqlTripleQuotes 49 \start = +f\z('''\|"""\) +end = "\z1 "keepend 50 \contains = prqlEscape , prqlSpaceError , prqlDoctest , @Spell 51syn region prqlRString matchgroup = prqlQuotes 52 \start = +r\z( [ '" ] \) +end = "\z1 " skip="\\\\\|\\\z1" 53\ contains =@Spell 54syn region prqlRString matchgroup = prqlTripleQuotes 55 \start = +r\z('''\|"""\) +end = "\z1 "keepend 56 \contains = prqlSpaceError , prqlDoctest , @Spell 57syn region prqlSString matchgroup = prqlQuotes 58 \start = +s\z( [ '" ] \) +end = "\z1 " skip="\\\\\|\\\z1" 59\ contains =@Spell 60syn region prqlSString matchgroup = prqlTripleQuotes 61 \start = +s\z('''\|"""\) +end = "\z1 "keepend 62 \contains = prqlSpaceError , prqlDoctest , @Spell 63 64syn match prqlEscape +\\ [ bfnrt'"\\ ] +contained 65syn match prqlEscape "\\\o\{1,3} "contained 66syn match prqlEscape "\\x\x\{2} "contained 67syn match prqlEscape "\%(\\u\x\{1,6}\) "contained 68syn match prqlEscape "\\$ " 69 70" It is very important to understand all details before changing the 71" regular expressions below or their order. 72" The word boundaries are *not* the floating-point number boundaries 73" because of a possible leading or trailing decimal point. 74" The expressions below ensure that all valid number literals are 75" 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) 84syn match prqlNumber "\<0 [ oO ] \%(_\=\o\)\+\> " 85syn match prqlNumber "\<0 [ xX ] \%(_\=\x\)\+\> " 86syn match prqlNumber "\<0 [ bB ] \%(_\= [ 01 ] \)\+\> " 87syn match prqlNumber "\<\%( [ 1-9 ] \%(_\=\d\) * \|0\+\%(_\=0\) * \)\> " 88syn match prqlNumber "\<\d\%(_\=\d\) * [ jJ ] \> " 89syn match prqlNumber "\<\d\%(_\=\d\) * [ eE ][ +- ] \=\d\%(_\=\d\) * [ jJ ] \=\> " 90syn match prqlNumber 91 \ "\<\d\%(_\=\d\) * \.\%( [ eE ][ +- ] \=\d\%(_\=\d\) * \)\= [ jJ ] \=\%(\W\|$\)\@= " 92syn match prqlNumber 93 \ "\%(^\|\W\)\zs\%(\d\%(_\=\d\) * \)\=\.\d\%(_\=\d\) * \%( [ eE ][ +- ] \=\d\%(_\=\d\) * \)\= [ jJ ] \=\> " 94endif 95 96" https://prql-lang.org/book/reference/stdlib/transforms/ 97" 98" PRQL built-in functions are in alphabetical order. 99" 100 101" Built-in functions 102syn keyword prqlBuiltin aggregate derive filter from group join select sort take window 103 104" Built-in types 105syn keyword prqlType bool float int int8 int16 int32 int64 int128 text date time timestamp 106 107" avoid highlighting attributes as builtins 108syn match prqlAttribute /\.\h\w * /hs= s+1 109 \contains = ALLBUT , prqlBuiltin , prqlFunction 110 \transparent 111 112if exists ( "prql_space_error_highlight" ) 113" trailing whitespace 114syn match prqlSpaceError display excludenl "\s\+$ " 115" mixed tabs and spaces 116syn match prqlSpaceError display "\+\t " 117syn match prqlSpaceError display "\t\+ " 118endif 119 120" Do not spell doctests inside strings. 121" Notice that the end of a string, either ''', or """, will end the contained 122" doctest too. Thus, we do *not* need to have it as an end pattern. 123if ! exists ( "prql_no_doctest_highlight" ) 124if ! exists ( "prql_no_doctest_code_highlight" ) 125syn region prqlDoctest 126 \start = "^\s * >>>\s "end = "^\s * $ " 127 \contained contains = ALLBUT , prqlDoctest , prqlFunction , @Spell 128syn region prqlDoctestValue 129 \start = +^\s * \%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\+ +end = "$ " 130 \contained 131else 132syn region prqlDoctest 133 \start = "^\s * >>> "end = "^\s * $ " 134 \contained contains = @NoSpell 135endif 136endif 137 138" The default highlight links. Can be overridden later. 139hi def link prqlBoolean Boolean 140hi def link prqlStatement Statement 141hi def link prqlType Type 142hi def link prqlConditional Conditional 143hi def link prqlRepeat Repeat 144hi def link prqlOperator Operator 145hi def link prqlInclude Include 146hi def link prqlAnnotation Define 147hi def link prqlAnnotationName Function 148hi def link prqlFunction Function 149hi def link prqlComment Comment 150hi def link prqlTodo Todo 151hi def link prqlSelf Constant 152hi def link prqlString String 153hi def link prqlFString String 154hi def link prqlRString String 155hi def link prqlSString String 156hi def link prqlQuotes String 157hi def link prqlTripleQuotes prqlQuotes 158hi def link prqlEscape Special 159if ! exists ( "prql_no_number_highlight" ) 160hi def link prqlNumber Number 161endif 162if ! exists ( "prql_no_builtin_highlight" ) 163hi def link prqlBuiltin Function 164endif 165if exists ( "prql_space_error_highlight" ) 166hi def link prqlSpaceError Error 167endif 168if ! exists ( "prql_no_doctest_highlight" ) 169hi def link prqlDoctest Special 170hi def link prqlDoctestValue Define 171endif 172 173let b: current_syntax = "prql" 174 175let & cpo = s: cpo_save 176unlet s: cpo_save 177 178" vim:set sw=2 sts=2 ts=8 noet: