robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1" Vim syntax file 2" Language: JavaScript 3" Maintainer: This runtime file is looking for a maintainer. 4" Previous Maintainer: Claudio Fleiner <claudio@fleiner.com> 5" Contributors: Scott Shattuck <ss@technicalpursuit.com> 6" Kevin Locke 7" LongJohnCoder 8" Devin Weaver 9" Last Change: 2026 Jun 07 10 11" tuning parameters: 12" unlet javaScript_fold 13 14if ! exists ( "main_syntax" ) 15" quit when a syntax file was already loaded 16if exists ( "b:current_syntax" ) 17finish 18endif 19let main_syntax = 'javascript' 20elseif exists ( "b:current_syntax" ) && b: current_syntax == "javascript" 21finish 22endif 23 24let s: cpo_save = & cpo 25set cpo & vim 26 27 28syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained 29syn match javaScriptLineComment "\/\/. * "contains = @Spell , javaScriptCommentTodo 30syn match javaScriptCommentSkip "^ [ \t ] * \*\($\| [ \t ] \+\) " 31syn region javaScriptComment start = "/\* "end = "\*/ "contains = @Spell , javaScriptCommentTodo 32syn match javaScriptSpecial "\\\d\d\d\|\\. " 33syn region javaScriptStringD start = +" +skip = +\\\\\|\\" +end = +"\|$ +contains = javaScriptSpecial , @htmlPreproc 34syn region javaScriptStringS start = +' +skip = +\\\\\|\\' +end = +'\|$ +contains = javaScriptSpecial , @htmlPreproc 35syn region javaScriptStringT start = +` +skip = +\\\\\|\\` +end = +` +contains = javaScriptSpecial , javaScriptEmbed , @htmlPreproc 36 37syn region javaScriptEmbed start = +${ +end = +} +contains = @javaScriptEmbededExpr 38 39" number handling by Christopher Leonard chris.j.leonard@gmx.com 40syn match javaScriptSpecialCharacter "'\\.' " 41syn match javaScriptNumber "\<0 [ bB ][ 0-1 ] \+\(_ [ 0-1 ] \+\) * \> " 42syn match javaScriptNumber "\<0 [ oO ][ 0-7 ] \+\(_ [ 0-7 ] \+\) * \> " 43syn match javaScriptNumber "\<0\( [ 0-7 ] \+\(_ [ 0-7 ] \+\) * \)\?\> " 44syn match javaScriptNumber "\<0 [ xX ][ 0-9a-fA-F ] \+\(_ [ 0-9a-fA-F ] \+\) * \> " 45syn match javaScriptNumber "\<\d\+\(_\d\+\) * [ eE ][ +- ] \?\d\+\> " 46syn match javaScriptNumber "\< [ 1-9 ] \d * \(_\d\+\) * \(\.\(\d\+\(_\d\+\) * \( [ eE ][ +- ] \?\d\+\)\?\)\?\)\?\> " 47syn match javaScriptNumber "\<\(\d\+\(_\d\+\) * \)\?\.\d\+\(_\d\+\) * \( [ eE ][ +- ] \?\d\+\)\?\> " 48syn match javaScriptNumber "\<\d\+\(_\d\+\) * \.\(\d\+\(_\d\+\) * \( [ eE ][ +- ] \?\d\+\)\?\)\?\> " 49syn region javaScriptRegexpString 50 \start = +\%( [ ,(=+ ] \s * \)\@8<=/ [ ^/* ] + 51 \skip = +\\\\\|\\/ + 52 \end = +/ [ dgimsuvy ] \{0,7\}\ze\s * $ + 53 \end = +/ [ dgimsuvy ] \{0,7\}\ze\s * [ +;.,)\]} ] + 54 \end = +/ [ dgimsuvy ] \{0,7\}\ze\s\+\/ + 55 \contains = @htmlPreproc , javaScriptComment 56 \oneline 57 58syn keyword javaScriptConditional if else switch 59syn keyword javaScriptRepeat while for do in of 60syn keyword javaScriptBranch break continue 61syn keyword javaScriptOperator new delete instanceof typeof 62syn keyword javaScriptType Array Boolean Date Function Number Object String RegExp Symbol 63syn keyword javaScriptStatement return with await yield 64syn keyword javaScriptBoolean true false 65syn keyword javaScriptNull null undefined 66syn keyword javaScriptIdentifier arguments this 67syn keyword javaScriptLabel case default 68syn keyword javaScriptException try catch finally throw 69syn keyword javaScriptMessage alert confirm prompt status 70syn keyword javaScriptGlobal self window top parent 71syn keyword javaScriptMember document event location 72syn keyword javaScriptDeprecated escape unescape 73syn keyword javaScriptReserved abstract as boolean byte char class const debugger double enum export extends final float from goto implements import int interface let long native package private protected public short super synchronized throws transient var void volatile async using 74syn keyword javaScriptModifier static 75 76syn cluster javaScriptEmbededExpr contains = javaScriptBoolean , javaScriptNull , javaScriptIdentifier , javaScriptStringD , javaScriptStringS , javaScriptStringT 77 78if exists ( "javaScript_fold" ) 79syn match javaScriptFunction "\<function\> " 80syn region javaScriptFunctionFold start = "\<function\>. * [ ^}; ] $ "end = "^\z1}. * $ "transparent fold keepend 81 82syn syncmatch javaScriptSync groupherejavaScriptFunctionFold "\<function\> " 83syn syncmatch javaScriptSync grouphereNONE "^} " 84 85setlocal foldmethod = syntax 86setlocal foldtext = getline (v:foldstart) 87else 88syn keyword javaScriptFunction function 89syn match javaScriptBraces "[ {}\[\] ] " 90syn match javaScriptParens "[ () ] " 91endif 92 93if main_syntax == "javascript" 94syn sync fromstart 95syn sync maxlines= 100 96 97syn sync ccommentjavaScriptComment 98endif 99 100" Define the default highlighting. 101" Only when an item doesn't have highlighting yet 102hi def link javaScriptComment Comment 103hi def link javaScriptLineComment Comment 104hi def link javaScriptCommentTodo Todo 105hi def link javaScriptSpecial Special 106hi def link javaScriptStringS String 107hi def link javaScriptStringD String 108hi def link javaScriptStringT String 109hi def link javaScriptCharacter Character 110hi def link javaScriptSpecialCharacter javaScriptSpecial 111hi def link javaScriptNumber Number 112hi def link javaScriptConditional Conditional 113hi def link javaScriptRepeat Repeat 114hi def link javaScriptBranch Conditional 115hi def link javaScriptOperator Operator 116hi def link javaScriptType Type 117hi def link javaScriptStatement Statement 118hi def link javaScriptFunction Keyword 119hi def link javaScriptBraces Function 120hi def link javaScriptError Error 121hi def link javaScrParenError javaScriptError 122hi def link javaScriptNull Keyword 123hi def link javaScriptBoolean Boolean 124hi def link javaScriptRegexpString String 125 126hi def link javaScriptIdentifier Identifier 127hi def link javaScriptLabel Label 128hi def link javaScriptException Exception 129hi def link javaScriptMessage Keyword 130hi def link javaScriptGlobal Keyword 131hi def link javaScriptMember Keyword 132hi def link javaScriptDeprecated Exception 133hi def link javaScriptReserved Keyword 134hi def link javaScriptModifier StorageClass 135hi def link javaScriptDebug Debug 136hi def link javaScriptConstant Label 137hi def link javaScriptEmbed Special 138 139 140 141let b: current_syntax = "javascript" 142if main_syntax == 'javascript' 143unlet main_syntax 144endif 145 146" Svelte 5 runes ($state, $derived, $props, ...) inside .svelte.js modules. 147if expand ( '%:t' ) =~# '\.svelte\.js$' 148syntax match svelteRune "\$\w\+ "containedin = ALL 149highlight default link svelteRune Statement 150endif 151 152let & cpo = s: cpo_save 153unlet s: cpo_save 154 155" vim: ts=8