├── README.md ├── ftdetect └── razor.vim ├── ftplugin └── razor.vim ├── include └── razorcs.vim ├── indent └── razor.vim └── syntax └── razor.vim /README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | This plugin provides filetype support — including syntax highlighting and indentation — for [Razor](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor) markup files. Out of the box, it detects `*.cshtml` and `*.razor` files. 4 | 5 | Custom highlighting is defined for HTML and C# by this plugin in order to ensure that they are properly integrated; this highlighting will only affect Razor files, not regular HTML and C# files. If you'd like to use the C# highlighting for regular C# files as well, you can install my [vim-cs](https://github.com/jlcrochet/vim-cs) plugin. 6 | 7 | ## Installation 8 | 9 | This is a standard Vim plugin which can be installed using your plugin manager of choice. If you do not already have a plugin manager, I recommend [vim-plug](https://github.com/junegunn/vim-plug). 10 | -------------------------------------------------------------------------------- /ftdetect/razor.vim: -------------------------------------------------------------------------------- 1 | " Vim ftdetect file 2 | " Language: Razor (https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor) 3 | " Author: Jeffrey Crochet 4 | " URL: https://github.com/jlcrochet/vim-razor 5 | 6 | autocmd BufRead,BufNewFile *.razor,*.cshtml setfiletype razor 7 | -------------------------------------------------------------------------------- /ftplugin/razor.vim: -------------------------------------------------------------------------------- 1 | " Vim ftplugin file 2 | " Language: Razor (https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor) 3 | " Author: Jeffrey Crochet 4 | " URL: https://github.com/jlcrochet/vim-razor 5 | 6 | " Only do this when not done yet for this buffer 7 | if get(b:, "did_ftplugin") 8 | finish 9 | endif 10 | 11 | let b:did_ftplugin = 1 12 | 13 | runtime! ftplugin/html.vim 14 | 15 | setlocal 16 | \ comments=s1:@*,mb:*,ex:*@,:///,:// 17 | \ commentstring=@*%s*@ 18 | \ suffixesadd=.cshtml,.razor 19 | 20 | let b:undo_ftplugin = "setlocal comments< commentstring< suffixesadd<" 21 | 22 | " Change the :browse filter to primarily show HTML-related files. 23 | " 24 | " NOTE: Modified from ftplugin/html.vim to include Razor files 25 | if has("gui_win32") 26 | if exists("b:browsefilter") 27 | let b:browsefilter = "Razor Files (*.cshtml,*.razor)\t*.cshtml;*.razor\n"..b:browsefilter 28 | else 29 | let b:browsefilter = "Razor Files (*.cshtml,*.razor)\t*.cshtml;*.razor\n" 30 | endif 31 | 32 | let b:undo_ftplugin ..= " | unlet b:browsefilter" 33 | endif 34 | -------------------------------------------------------------------------------- /include/razorcs.vim: -------------------------------------------------------------------------------- 1 | " Syntax {{{1 2 | syn sync fromstart 3 | 4 | " Miscellaneous (low priority) {{{2 5 | syn keyword razorcsKeywordError contained 6 | \ abstract as 7 | \ base bool break byte 8 | \ case catch char checked class const continue 9 | \ decimal default delegate do double 10 | \ else enum event explicit extern 11 | \ false finally fixed float for foreach 12 | \ goto 13 | \ if implicit in int interface internal is 14 | \ lock long 15 | \ namespace new null 16 | \ object operator out override 17 | \ params private protected public 18 | \ readonly ref return 19 | \ sbyte sealed short sizeof stackalloc static string struct switch 20 | \ this throw true try typeof 21 | \ uint ulong unchecked unsafe ushort using 22 | \ virtual void volatile 23 | \ while 24 | 25 | syn match razorcsDelimiter /\%#=1,/ containedin=@razorcsExtra,razorInvocation,razorIndex 26 | syn match razorcsDelimiter /\%#=1;/ containedin=@razorcsBlocks 27 | 28 | syn region razorcsBlock matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contains=@razorcs fold 29 | 30 | " LHS {{{2 31 | syn keyword razorcsStatement alias nextgroup=razorcsIdentifier skipwhite skipempty 32 | 33 | syn keyword razorcsStatement class struct nextgroup=razorcsTypeName skipwhite skipempty 34 | syn match razorcsTypeName /\%#=1\K\k*\%(\_s*<.\{-}>\)\=/ contained contains=razorcsKeywordError,razorcsGenericParameters nextgroup=razorcsTypeBlock,razorcsTypeInheritanceOperator,razorcsTypeConstraint,razorcsTypeConstructorParameters skipwhite skipempty 35 | syn region razorcsTypeConstructorParameters matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsType,razorcsTypeIdentifier,razorcsModifier,razorcsCollectionExpressionOrAttributes nextgroup=razorcsTypeBlock,razorcsTypeInheritanceOperator,razorcsTypeConstraint skipwhite skipempty 36 | syn region razorcsGenericParameters matchgroup=razorcsDelimiter start=/\%#=1/ contained contains=razorcsGenericParameter,razorcsModifier nextgroup=razorcsTypeBlock skipwhite skipempty 37 | syn match razorcsGenericParameter /\%#=1\K\k*/ contained contains=razorcsKeywordError 38 | syn match razorcsTypeInheritanceOperator /\%#=1:/ contained nextgroup=razorcsTypeInheritee,razorcsTypeInheriteeKeyword skipwhite skipempty 39 | syn match razorcsTypeInheritee /\%#=1\K\k*\%(\_s*<.\{-}>\)\=/ contained contains=razorcsKeywordError,razorcsGeneric nextgroup=razorcsTypeBlock,razorcsTypeInheriteeMemberOperator,razorcsTypeInheriteeComma,razorcsTypeConstraint,razorcsTypeInheriteeArguments,razorcsTypeConstraintModifier skipwhite skipempty 40 | syn keyword razorcsTypeInheriteeKeyword contained nextgroup=razorcsTypeBlock,razorcsTypeInheriteeComma,razorcsTypeConstraint,razorcsTypeConstraintModifier skipwhite skipempty 41 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 42 | \ char bool object string void dynamic 43 | \ class struct enum default notnull 44 | syn match razorcsTypeConstraintModifier /\%#=1?/ contained nextgroup=razorcsTypeInheriteeMemberOperator,razorcsTypeInheriteeComma,razorcsTypeConstraint skipwhite skipempty 45 | syn keyword razorcsTypeInheriteeKeyword new contained nextgroup=razorcsTypeInheriteeArguments,razorcsTypeInheritee skipwhite skipempty 46 | syn keyword razorcsTypeInheriteeKeyword managed unmanaged contained nextgroup=razorcsTypeBlock,razorcsTypeInheriteeComma skipwhite skipempty 47 | syn region razorcsTypeInheriteeArguments matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorcsTypeBlock,razorcsTypeInheriteeComma,razorcsTypeConstraint,razorcsTypeConstraintLambdaOperator skipwhite skipempty 48 | syn match razorcsTypeConstraintLambdaOperator /\%#=1=>/ contained nextgroup=razorcsTypeInheriteeKeyword skipwhite skipempty 49 | syn match razorcsTypeInheriteeMemberOperator /\%#=1\./ contained nextgroup=razorcsTypeInheritee,razorcsTypeInheriteeKeyword skipwhite skipempty 50 | syn match razorcsTypeInheriteeComma /\%#=1,/ contained nextgroup=razorcsTypeInheritee,razorcsTypeInheriteeKeyword skipwhite skipempty 51 | syn keyword razorcsTypeConstraint where contained nextgroup=razorcsTypeVariable skipwhite skipempty 52 | syn match razorcsTypeVariable /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsTypeInheritanceOperator skipwhite skipempty 53 | syn region razorcsTypeBlock matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=razorcsStatement,razorcsModifier,razorcsType,razorcsTypeIdentifier,razorcsBlock,razorcsDeclaratorComma,razorcsCollectionExpressionOrAttributes,razorcsOperatorModifier,razorcsTypeTuple,razorcsConstructor fold 54 | 55 | syn keyword razorcsStatement interface nextgroup=razorcsInterfaceName skipwhite skipempty 56 | syn match razorcsInterfaceName /\%#=1\K\k*\%(\_s*<.\{-}>\)\=/ contained contains=razorcsKeywordError,razorcsGenericParameters nextgroup=razorcsTypeBlock,razorcsTypeInheritanceOperator,razorcsTypeConstraint skipwhite skipempty 57 | 58 | syn keyword razorcsStatement record nextgroup=razorcsTypeName,razorcsRecordModifier skipwhite skipempty 59 | syn keyword razorcsRecordModifier class struct contained nextgroup=razorcsTypeName skipwhite skipempty 60 | 61 | syn match razorcsDestructorSign /\%#=1\~/ contained containedin=razorcsTypeBlock nextgroup=razorcsDestructor skipwhite skipempty 62 | syn match razorcsDestructor /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsParameters skipwhite skipempty 63 | 64 | syn keyword razorcsStatement enum nextgroup=razorcsEnumName skipwhite skipempty 65 | syn match razorcsEnumName /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsEnumBlock,razorcsEnumInheritanceOperator skipwhite skipempty 66 | syn match razorcsEnumInheritanceOperator /\%#=1:/ contained nextgroup=razorcsEnumType skipwhite skipempty 67 | syn keyword razorcsEnumType byte sbyte short ushort int uint long ulong nint nuint contained nextgroup=razorcsEnumBlock skipwhite skipempty 68 | syn region razorcsEnumBlock matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=razorcsDeclarator fold 69 | 70 | syn keyword razorcsStatement namespace nextgroup=razorcsNamespaceName skipwhite skipempty 71 | syn match razorcsNamespaceName /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsNamespaceNameSeparator,razorcsNamespaceBlock skipwhite skipempty 72 | syn match razorcsNamespaceNameSeparator /\%#=1\./ contained nextgroup=razorcsNamespaceName skipwhite skipempty 73 | syn region razorcsNamespaceBlock matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=@razorcs fold 74 | 75 | syn keyword razorcsStatement if switch while nextgroup=razorcsCondition skipwhite skipempty 76 | syn region razorcsCondition matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorcsBlock skipwhite skipempty 77 | 78 | syn keyword razorcsStatement else do nextgroup=razorcsBlock skipwhite skipempty 79 | 80 | syn keyword razorcsStatement case nextgroup=@razorcsPatterns skipwhite skipempty 81 | 82 | syn keyword razorcsStatement default nextgroup=razorcsCaseOperator skipwhite skipempty 83 | syn match razorcsCaseOperator /\%#=1:/ contained nextgroup=razorcsBlock skipwhite skipempty 84 | 85 | syn keyword razorcsStatement for foreach nextgroup=razorcsIteratorExpression skipwhite skipempty 86 | syn region razorcsIteratorExpression matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcs nextgroup=razorcsBlock skipwhite skipempty 87 | 88 | syn keyword razorcsStatement break continue yield 89 | 90 | syn keyword razorcsStatement goto 91 | 92 | syn keyword razorcsStatement return throw nextgroup=@razorcsRHS skipwhite skipempty 93 | 94 | syn keyword razorcsStatement try finally nextgroup=razorcsBlock skipwhite skipempty 95 | syn keyword razorcsStatement catch nextgroup=razorcsCatchCondition skipwhite skipempty 96 | syn region razorcsCatchCondition matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsTypeIdentifier nextgroup=razorcsOperatorKeyword,razorcsBlock skipwhite skipempty 97 | 98 | syn keyword razorcsStatement checked unchecked nextgroup=razorcsBlock skipwhite skipempty 99 | 100 | syn keyword razorcsStatement lock nextgroup=razorcsCondition skipwhite skipempty 101 | 102 | syn keyword razorcsStatement using nextgroup=razorcsGuardedStatement,razorcsStatement,razorcsIdentifier,razorcsUsingStatic skipwhite skipempty 103 | syn keyword razorcsUsingStatic static contained nextgroup=razorcsIdentifier skipwhite skipwhite 104 | syn keyword razorcsStatement fixed nextgroup=razorcsGuardedStatement skipwhite skipempty 105 | syn region razorcsGuardedStatement matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcs 106 | 107 | syn keyword razorcsOperatorModifier operator nextgroup=razorcsOperatorMethod,razorcsBooleanOperatorMethod,razorcsConversionMethod,razorcsConversionMethodKeyword skipwhite skipempty 108 | syn match razorcsOperatorMethod /\%#=1\%(++\=\|--\=\|[~*/%&|^]\|[=!]=\|<[<=]\=\|>[>=]\=\|\.\.\)/ contained nextgroup=razorcsParameters skipwhite skipempty 109 | syn keyword razorcsBooleanOperatorMethod true false contained nextgroup=razorcsParameters skipwhite skipempty 110 | syn match razorcsConversionMethod /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsParameters skipwhite skipempty 111 | syn keyword razorcsConversionMethodKeyword contained nextgroup=razorcsParameters skipwhite skipempty 112 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 113 | \ char bool object string void dynamic 114 | 115 | syn keyword razorcsType nextgroup=razorcsDeclarator,razorcsIndexerThis,razorcsMemberOperator,razorcsInvocation,razorcsTypeModifier,razorcsOperatorModifier skipwhite skipempty 116 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 117 | \ char bool object string void dynamic 118 | 119 | syn keyword razorcsStatement var nextgroup=razorcsDeclarator,razorcsTupleDeclarator skipwhite skipempty 120 | syn region razorcsTupleDeclarator matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsDeclarator,razorcsTupleDeclarator nextgroup=razorcsAssignmentOperator skipwhite skipempty 121 | 122 | syn match razorcsIdentifier /\%#=1\K\k*\%(<.\{-}>\)\=\%([*?]\.\@!\|\[.\{-}\]\)*/ contains=razorcsGeneric,razorcsTypeModifier nextgroup=razorcsDeclarator,razorcsIndexerThis,@razorcsOperators,razorcsInvocation,razorcsIndex,razorcsOperatorModifier,razorcsPropertyBlock skipwhite skipempty 123 | syn region razorcsGeneric matchgroup=razorcsDelimiter start=/\%#=1/ contained contains=razorcsType,razorcsTypeTuple,razorcsTypeIdentifier,razorcsModifier nextgroup=razorcsDeclarator,razorcsIndexerThis,razorcsOperatorModifier,razorcsPropertyBlock skipwhite skipempty 124 | syn region razorcsInvocation matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorcsInvocation,razorcsIndex,@razorcsOperators skipwhite skipempty 125 | syn region razorcsIndex matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1\]/ contained contains=@razorcsRHS nextgroup=razorcsInvocation,razorcsIndex,@razorcsOperators skipwhite skipempty 126 | 127 | syn keyword razorcsConstant this base nextgroup=@razorcsOperators,razorcsInvocation,razorcsIndex skipwhite skipempty 128 | 129 | syn keyword razorcsIndexerThis this contained nextgroup=razorcsIndexerParameters skipwhite skipempty 130 | syn region razorcsIndexerParameters matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1\]/ contained contains=razorcsTypeIdentifier,razorcsModifier nextgroup=razorcsPropertyBlock,razorcsLambdaOperator skipwhite skipempty 131 | 132 | syn match razorcsDeclarator /\%#=1\K\k*\%(\_s*<.\{-}>\)\=/ contained contains=razorcsKeywordError,razorcsGenericParameters nextgroup=razorcsAssignmentOperator,razorcsLambdaOperator,razorcsParameters,razorcsPropertyBlock,razorcsDeclaratorMemberOperator,razorcsOperatorKeyword skipwhite skipempty 133 | syn match razorcsNotDeclarator /\%#=1\<\K\k*\%(\_s*<.\{-}>\)\=\ze\s*\./ contained containedin=razorcsDeclarator contains=razorcsGeneric 134 | syn match razorcsDeclaratorMemberOperator /\%#=1\./ contained nextgroup=razorcsDeclarator,razorcsIdentifier,razorcsIndexerThis skipwhite skipempty 135 | syn region razorcsParameters matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsTypeIdentifier,razorcsModifier,razorcsThisModifier,razorcsTypeTuple,razorcsCollectionExpressionOrAttributes nextgroup=razorcsLambdaOperator,razorcsBlock,razorcsMethodTypeConstraint skipwhite skipempty 136 | syn keyword razorcsThisModifier this contained 137 | syn region razorcsPropertyBlock matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=razorcsAccessor,razorcsModifier nextgroup=razorcsAssignmentOperator skipwhite skipempty fold 138 | syn keyword razorcsAccessor get set init add remove contained nextgroup=razorcsBlock,razorcsLambdaOperator skipwhite skipempty 139 | syn match razorcsDeclaratorComma /\%#=1,/ nextgroup=razorcsDeclarator skipwhite skipempty 140 | 141 | syn match razorcsMethodTypeInheritanceOperator /\%#=1:/ contained nextgroup=razorcsMethodTypeInheritee,razorcsMethodTypeInheriteeKeyword skipwhite skipempty 142 | syn match razorcsMethodTypeInheritee /\%#=1\K\k*\%(\_s*<.\{-}>\)\=/ contained contains=razorcsKeywordError,razorcsGeneric nextgroup=razorcsMethodTypeInheriteeMemberOperator,razorcsMethodTypeInheriteeComma,razorcsMethodTypeConstraint,razorcsMethodTypeConstraintModifier,razorcsMethodTypeInheriteeArguments,razorcsLambdaOperator skipwhite skipempty 143 | syn keyword razorcsMethodTypeInheriteeKeyword contained nextgroup=razorcsMethodTypeInheriteeComma,razorcsMethodTypeConstraint,razorcsMethodTypeConstraintModifier,razorcsMethodTypeConstraintLambdaOperator skipwhite skipempty 144 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 145 | \ char bool object string void dynamic 146 | \ class struct enum default notnull 147 | syn match razorcsMethodTypeConstraintModifier /\%#=1?/ contained nextgroup=razorcsMethodTypeInheriteeMemberOperator,razorcsMethodTypeInheriteeComma,razorcsMethodTypeConstraint,razorcsLambdaOperator skipwhite skipempty 148 | syn keyword razorcsMethodTypeInheriteeKeyword new contained nextgroup=razorcsMethodTypeInheriteeArguments,razorcsMethodTypeInheritee skipwhite skipempty 149 | syn keyword razorcsMethodTypeInheriteeKeyword managed unmanaged contained nextgroup=razorcsMethodTypeInheriteeComma,razorcsLambdaOperator skipwhite skipempty 150 | syn region razorcsMethodTypeInheriteeArguments matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained nextgroup=razorcsMethodTypeInheriteeComma,razorcsMethodTypeConstraint,razorcsMethodTypeConstraintLambdaOperator skipwhite skipempty 151 | syn match razorcsMethodTypeConstraintLambdaOperator /\%#=1=>/ contained nextgroup=razorcsMethodTypeInheriteeKeyword skipwhite skipempty 152 | syn match razorcsMethodTypeInheriteeMemberOperator /\%#=1\./ contained nextgroup=razorcsMethodTypeInheritee,razorcsMethodTypeInheriteeKeyword skipwhite skipempty 153 | syn match razorcsMethodTypeInheriteeComma /\%#=1,/ contained nextgroup=razorcsMethodTypeInheritee,razorcsMethodTypeInheriteeKeyword skipwhite skipempty 154 | syn keyword razorcsMethodTypeConstraint where contained nextgroup=razorcsMethodTypeVariable skipwhite skipempty 155 | syn match razorcsMethodTypeVariable /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsMethodTypeInheritanceOperator skipwhite skipempty 156 | 157 | syn region razorcsTypeTuple matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsType,razorcsTypeTuple,razorcsIdentifier nextgroup=razorcsDeclarator,razorcsIndexerThis,razorcsTypeModifier,razorcsOperatorModifier skipwhite skipempty 158 | 159 | syn region razorcsGroup matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contains=@razorcsRHS,razorcsRHSTypeIdentifier nextgroup=@razorcsOperators,razorcsDeclarator,razorcsInvocation,razorcsIndex skipwhite skipempty 160 | 161 | syn region razorcsCollectionExpressionOrAttributes matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1\]/ contains=@razorcsRHS,razorcsAttribute 162 | 163 | syn match razorcsAssignmentOperator /\%#=1=/ contained nextgroup=@razorcsRHS,razorcsRHSTypeIdentifier,razorcsInitializer skipwhite skipempty 164 | 165 | syn match razorcsLambdaOperator /\%#=1=>/ contained nextgroup=@razorcsRHS,razorcsBlock skipwhite skipempty 166 | 167 | syn match razorcsMemberOperator /\%#=1?\=\./ contained nextgroup=razorcsIdentifier,razorcsConstant skipwhite skipempty 168 | syn match razorcsMemberOperator /\%#=1->/ contained nextgroup=razorcsIdentifier skipwhite skipempty 169 | syn match razorcsMemberOperator /\%#=1::/ contained nextgroup=razorcsIdentifier skipwhite skipempty 170 | 171 | syn match razorcsNullForgivingOperator /\%#=1!/ contained nextgroup=razorcsMemberOperator,razorcsInvocation,razorcsIndex skipwhite skipempty 172 | 173 | syn match razorcsIncrementOperator /\%#=1++/ 174 | syn match razorcsDecrementOperator /\%#=1--/ 175 | syn match razorcsPointerOperator /\%#=1[*&]/ 176 | 177 | " RHS {{{2 178 | syn cluster razorcsLiterals contains= 179 | \ razorcsNumber,razorcsBoolean,razorcsNull,razorcsRHSConstant,razorcsCharacter,razorcsString 180 | 181 | syn cluster razorcsRHS contains= 182 | \ @razorcsLiterals, 183 | \ razorcsUnaryOperator,razorcsUnaryOperatorKeyword,razorcsRHSIdentifier,razorcsRHSType, 184 | \ razorcsRHSGroup,razorcsCollectionExpressionOrAttributes,razorcsLINQExpression 185 | 186 | syn cluster razorcsOperators contains=razorcsOperator,razorcsOperatorKeyword,razorcsComment 187 | 188 | syn match razorcsUnaryOperator /\%#=1++\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 189 | syn match razorcsUnaryOperator /\%#=1--\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 190 | syn match razorcsUnaryOperator /\%#=1\.\./ contained nextgroup=@razorcsRHS skipwhite skipempty 191 | syn match razorcsUnaryOperator /\%#=1[!~*&^]/ contained nextgroup=@razorcsRHS skipwhite skipempty 192 | 193 | syn keyword razorcsUnaryOperatorKeyword new nextgroup=razorcsRHSIdentifier,razorcsRHSType,razorcsInitializer,razorcsRHSInvocation,razorcsRHSIndex skipwhite skipempty 194 | syn keyword razorcsUnaryOperatorKeyword stackalloc nextgroup=razorcsRHSIdentifier,razorcsRHSType,razorcsInitializer,razorcsRHSIndex skipwhite skipempty 195 | syn keyword razorcsUnaryOperatorKeyword out in contained nextgroup=@razorcsRHS skipwhite skipempty 196 | syn keyword razorcsUnaryOperatorKeyword ref contained nextgroup=@razorcsRHS,razorcsReadonly skipwhite skipempty 197 | syn keyword razorcsReadonly readonly contained nextgroup=@razorcsRHS skipwhite skipempty 198 | syn keyword razorcsUnaryOperatorKeyword await nextgroup=razorcsStatement,@razorcsRHS skipwhite skipempty 199 | syn keyword razorcsUnaryOperatorKeyword async params contained nextgroup=razorcsRHSTypeIdentifier,razorcsRHSType,razorcsRHSGroup skipwhite skipempty 200 | syn keyword razorcsUnaryOperatorKeyword throw nextgroup=@razorcsRHS skipwhite skipempty 201 | syn keyword razorcsUnaryOperatorKeyword static contained nextgroup=razorcsRHSType,razorcsRHSIdentifier skipwhite skipempty 202 | syn keyword razorcsUnaryOperatorKeyword delegate contained nextgroup=razorcsFunctionPointerModifier skipwhite skipempty 203 | syn keyword razorcsUnaryOperatorKeyword not contained nextgroup=@razorcsPatterns skipwhite skipempty 204 | 205 | syn keyword razorcsUnaryOperatorKeyword default contained nextgroup=razorcsRHSInvocation,@razorcsOperators skipwhite skipempty 206 | syn keyword razorcsUnaryOperatorKeyword typeof checked unchecked sizeof nameof contained nextgroup=razorcsRHSInvocation skipwhite skipempty 207 | 208 | syn keyword razorcsUnaryOperatorKeyword var contained nextgroup=razorcsRHSDeclarator,razorcsRHSTupleDeclarator skipwhite skipempty 209 | syn match razorcsRHSDeclarator /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=@razorcsOperators skipwhite skipempty 210 | syn region razorcsRHSTupleDeclarator matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsRHSDeclarator nextgroup=@razorcsOperators skipwhite skipempty 211 | 212 | syn keyword razorcsRHSType contained nextgroup=razorcsMemberOperator,razorcsRHSGroup,razorcsRHSIndex,razorcsRHSDeclarator,razorcsTypeModifier,razorcsOperatorKeyword skipwhite skipempty 213 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 214 | \ char bool object string void dynamic 215 | 216 | syn match razorcsRHSIdentifier /\%#=1\K\k*\%(<.\{-}>\)\=/ contained contains=razorcsKeywordError,razorcsGeneric nextgroup=@razorcsOperators,razorcsRHSInvocation,razorcsRHSIndex,razorcsInitializer,razorcsOperatorModifier skipwhite skipempty 217 | syn region razorcsRHSInvocation matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=@razorcsOperators,razorcsInitializer,razorcsRHSInvocation,razorcsRHSIndex skipwhite skipempty 218 | syn region razorcsRHSIndex matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1\]/ contained contains=@razorcsRHS nextgroup=@razorcsOperators,razorcsRHSInvocation,razorcsRHSIndex,razorcsInitializer skipwhite skipempty 219 | 220 | syn region razorcsInitializer matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=@razorcsRHS,razorcsInitializer,razorcsIndexSetter nextgroup=@razorcsOperators skipwhite skipempty 221 | 222 | syn match razorcsNumber /\%#=1\c\d\+\%(_\+\d\+\)*\%(\%(lu\=\|ul\=\)\|[dmf]\|\.\d\+\%(_\+\d\+\)*\%(e[+-]\=\d\+\%(_\+\d\+\)*\)\=[dmf]\=\|e[+-]\=\d\+\%(_\+\d\+\)*[dmf]\=\)\=/ contained nextgroup=@razorcsOperators skipwhite skipempty 223 | syn match razorcsNumber /\%#=1\c0b_*[01]\+\%(_\+[01]\+\)*\%(lu\=\|ul\=\)\=/ contained nextgroup=@razorcsOperators skipwhite skipempty 224 | syn match razorcsNumber /\%#=1\c0x_*\x\+\%(_\+\x\+\)*\%(\%(lu\=\|ul\=\)\|[dmf]\|e[+-]\=\d\+\%(_\+\d\+\)*[dmf]\=\)\=/ contained nextgroup=@razorcsOperators skipwhite skipempty 225 | syn match razorcsNumber /\%#=1\c\.\d\+\%(_\+\d\+\)*\%(e[+-]\=\d\+\%(_\+\d\+\)*\)\=[dmf]\=/ contained nextgroup=@razorcsOperators skipwhite skipempty 226 | 227 | syn keyword razorcsBoolean true false contained nextgroup=@razorcsOperators skipwhite skipempty 228 | syn keyword razorcsNull null contained nextgroup=@razorcsOperators skipwhite skipempty 229 | syn keyword razorcsRHSConstant this base contained nextgroup=@razorcsOperators,razorcsRHSInvocation,razorcsRHSIndex skipwhite skipempty 230 | 231 | syn region razorcsCharacter matchgroup=razorcsCharacterDelimiter start=/\%#=1'/ end=/\%#=1'/ contained contains=razorcsEscapeSequence,razorcsEscapeSequenceError nextgroup=@razorcsOperators skipwhite skipempty 232 | 233 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1"/ matchgroup=razorcsStringEnd end=/\%#=1"\%(u8\)\=/ contained contains=razorcsEscapeSequence,razorcsEscapeSequenceError nextgroup=@razorcsOperators skipwhite skipempty 234 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1\$"/ matchgroup=razorcsStringEnd end=/\%#=1"\%(u8\)\=/ contained contains=razorcsBraceEscape,razorcsEscapeSequence,razorcsEscapeSequenceError,razorcsStringInterpolation,razorcsStringInterpolationError nextgroup=@razorcsOperators skipwhite skipempty 235 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1@"/ matchgroup=razorcsStringEnd end=/\%#=1"\%(u8\)\=/ contained skip=/\%#=1""/ contains=razorcsQuoteEscape nextgroup=@razorcsOperators skipwhite skipempty 236 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1\$@"/ matchgroup=razorcsStringEnd end=/\%#=1"\%(u8\)\=/ contained skip=/\%#=1""/ contains=razorcsQuoteEscape,razorcsBraceEscape,razorcsStringInterpolation,razorcsStringInterpolationError nextgroup=@razorcsOperators skipwhite skipempty 237 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1@\$"/ matchgroup=razorcsStringEnd end=/\%#=1"\%(u8\)\=/ contained skip=/\%#=1""/ contains=razorcsQuoteEscape,razorcsBraceEscape,razorcsStringInterpolation,razorcsStringInterpolationError nextgroup=@razorcsOperators skipwhite skipempty 238 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1\z("\{3,}\)/ matchgroup=razorcsStringEnd end=/\%#=1\z1\%(u8\)\=/ contained nextgroup=@razorcsOperators skipwhite skipempty 239 | syn region razorcsString matchgroup=razorcsStringStart start=/\%#=1\$\+\z("\{3,}\)/ matchgroup=razorcsStringEnd end=/\%#=1\z1\%(u8\)\=/ contained contains=razorcsBraceEscape,razorcsStringInterpolation,razorcsStringInterpolationError nextgroup=@razorcsOperators skipwhite skipempty 240 | 241 | syn match razorcsStringInterpolationError /\%#=1[{}]/ contained 242 | syn region razorcsStringInterpolation matchgroup=razorcsStringInterpolationDelimiter start=/\%#=1{/ end=/\%#=1\%([,:].\{-}\)\=}/ contained contains=@razorcsRHS 243 | 244 | syn match razorcsEscapeSequenceError /\%#=1\\./ contained 245 | syn match razorcsEscapeSequence /\%#=1\\\%(['"\\0abfnrtv]\|x\x\{1,4}\|u\x\{4}\|U\x\{8}\)/ contained 246 | 247 | syn match razorcsQuoteEscape /\%#=1""/ contained 248 | syn match razorcsBraceEscape /\%#=1{{/ contained 249 | syn match razorcsBraceEscape /\%#=1}}/ contained 250 | 251 | syn match razorcsOperator /\%#=1!/ contained nextgroup=@razorcsOperators,razorcsRHSInvocation,razorcsRHSIndex skipwhite skipempty 252 | syn match razorcsOperator /\%#=1=/ contained nextgroup=@razorcsRHS,razorcsInitializer skipwhite skipempty 253 | syn match razorcsOperator /\%#=1[=!]=/ contained nextgroup=@razorcsRHS skipwhite skipempty 254 | syn match razorcsOperator /\%#=1[+*/%]=\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 255 | syn match razorcsOperator /\%#=1=>/ contained nextgroup=@razorcsRHS,razorcsBlock skipwhite skipempty 256 | syn match razorcsOperator /\%#=1-[>=]\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 257 | syn match razorcsOperator /\%#=1++/ contained nextgroup=@razorcsOperators skipwhite skipempty 258 | syn match razorcsOperator /\%#=1--/ contained nextgroup=@razorcsOperators skipwhite skipempty 259 | syn match razorcsOperator /\%#=1<<\==\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 260 | syn match razorcsOperator /\%#=1>>\=>\==\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 261 | syn match razorcsOperator /\%#=1&&\==\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 262 | syn match razorcsOperator /\%#=1||\==\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 263 | syn match razorcsOperator /\%#=1?\%(?=\=\)\=/ contained nextgroup=@razorcsRHS skipwhite skipempty 264 | 265 | syn match razorcsOperator /\%#=1\./ contained nextgroup=razorcsRHSIdentifier,razorcsRHSConstant skipwhite skipempty 266 | syn match razorcsOperator /\%#=1\.\./ contained nextgroup=@razorcsRHS skipwhite skipempty 267 | syn match razorcsOperator /\%#=1?\./ contained nextgroup=razorcsRHSIdentifier,razorcsRHSConstant skipwhite skipempty 268 | syn match razorcsOperator /\%#=1:/ contained nextgroup=@razorcsRHS,razorcsStatement skipwhite skipempty 269 | syn match razorcsOperator /\%#=1::/ contained nextgroup=razorcsRHSIdentifier skipwhite skipempty 270 | 271 | syn region razorcsRHSGroup matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS,razorcsRHSTypeIdentifier nextgroup=@razorcsRHS,@razorcsOperators skipwhite skipempty 272 | syn match razorcsRHSTypeIdentifier /\%#=1\K\k*\%(<.\{-}>\)\=\%([*?]\.\@!\|\[.\{-}\]\)*/ contained contains=razorcsType,razorcsKeywordError,razorcsGeneric,razorcsTypeModifier nextgroup=@razorcsOperators,razorcsRHSGroup,razorcsRHSIndex,razorcsDeclarator skipwhite skipempty 273 | 274 | syn keyword razorcsOperatorKeyword as contained nextgroup=razorcsRHSTypeIdentifier skipwhite skipempty 275 | syn keyword razorcsOperatorKeyword in when contained nextgroup=@razorcsRHS skipwhite skipempty 276 | syn keyword razorcsOperatorKeyword and or contained nextgroup=@razorcsPatterns skipwhite skipempty 277 | 278 | syn keyword razorcsOperatorKeyword is contained nextgroup=@razorcsPatterns skipwhite skipempty 279 | syn keyword razorcsOperatorKeyword switch contained nextgroup=razorcsPatternBlock skipwhite skipempty 280 | syn region razorcsPatternBlock matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=@razorcsPatterns nextgroup=@razorcsOperators skipwhite skipempty fold 281 | 282 | syn cluster razorcsPatterns contains=razorcsPatternType,razorcsPatternTypeIdentifier,razorcsUnaryOperatorKeyword,@razorcsLiterals,razorcsOperator,razorcsPatternGroup,razorcsPatternProperties,razorcsPatternList 283 | 284 | syn keyword razorcsPatternType contained nextgroup=razorcsPatternDeclarator,razorcsPatternTypeMemberOperator,razorcsPatternGroup,razorcsPatternProperties,razorcsOperatorKeyword skipwhite skipempty 285 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 286 | \ char bool object string void dynamic 287 | 288 | syn match razorcsPatternTypeIdentifier /\%#=1\K\k*\%(<.\{-}>\)\=/ contained contains=razorcsGeneric,razorcsKeywordError nextgroup=razorcsPatternDeclarator,razorcsLambdaOperator,razorcsPatternTypeMemberOperator,razorcsPatternGroup,razorcsPatternProperties,razorcsOperatorKeyword skipwhite skipempty 289 | 290 | syn match razorcsPatternTypeMemberOperator /\%#=1\./ contained nextgroup=razorcsPatternTypeIdentifier skipwhite skipempty 291 | 292 | syn match razorcsPatternDeclarator /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=@razorcsOperators skipwhite skipempty 293 | 294 | syn region razorcsPatternGroup matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsPatterns nextgroup=@razorcsOperators,razorcsPatternDeclarator,razorcsPatternProperties skipwhite skipempty 295 | 296 | syn region razorcsPatternProperties matchgroup=razorcsDelimiter start=/\%#=1{/ end=/\%#=1}/ contained contains=razorcsPatternProperty nextgroup=@razorcsOperators,razorcsPatternDeclarator skipwhite skipempty 297 | syn match razorcsPatternProperty /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsPatternPropertyColon,razorcsPatternPropertyMemberOperator skipwhite skipempty 298 | syn match razorcsPatternPropertyColon /\%#=1:/ contained nextgroup=@razorcsPatterns skipwhite skipempty 299 | syn match razorcsPatternPropertyMemberOperator /\%#=1\./ contained nextgroup=razorcsPatternProperty skipwhite skipempty 300 | 301 | syn region razorcsPatternList matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1]/ contained contains=@razorcsPatterns,razorcsPatternSlice,razorcsPatternListVar nextgroup=@razorcsOperators skipwhite skipempty 302 | syn match razorcsPatternSlice /\%#=1\.\./ contained 303 | syn keyword razorcsPatternListVar var contained nextgroup=razorcsPatternListDeclarator skipwhite skipempty 304 | syn match razorcsPatternListDeclarator /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsPatternListDeclaratorComma skipwhite skipempty 305 | syn match razorcsPatternListDeclaratorComma /\%#=1,/ contained nextgroup=razorcsPatternListDeclarator skipwhite skipempty 306 | 307 | syn keyword razorcsOperatorKeyword with contained nextgroup=razorcsInitializer skipwhite skipempty 308 | 309 | syn region razorcsIndexSetter matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1]/ contained contains=@razorcsRHS nextgroup=razorcsAssignmentOperator skipwhite skipempty 310 | 311 | syn region razorcsLINQExpression start=/\%#=1\/ end=/\%#=1[)\]};]\@=/ contained transparent contains=razorcsLINQKeyword,@razorcsRHS 312 | syn keyword razorcsLINQKeyword from into contained nextgroup=razorcsLINQDeclarator,razorcsLINQDeclaration skipwhite skipempty 313 | syn match razorcsLINQDeclaration /\%#=1\K\k*\%(\.\K\k*\)*\%(<.\{-}>\)\=\s\+\%(in\>\)\@!\K\k*/ contained contains=razorcsType,razorcsIdentifier 314 | syn keyword razorcsLINQKeyword let join contained nextgroup=razorcsLINQDeclarator skipwhite skipempty 315 | syn keyword razorcsLINQKeyword in where select orderby group by ascending descending on equals contained 316 | syn match razorcsLINQDeclarator /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsAssignmentOperator skipwhite skipempty 317 | 318 | " Miscellaneous (high priority) {{{2 319 | syn region razorcsComment matchgroup=razorcsCommentStart start=/\%#=1\/\// end=/\%#=1$/ contains=razorcsTodo containedin=@razorcsExtra 320 | syn region razorcsComment matchgroup=razorcsCommentStart start=/\%#=1\/\*/ matchgroup=razorcsCommentEnd end=/\%#=1\*\// contains=razorcsTodo containedin=@razorcsExtra 321 | syn region razorcsComment matchgroup=razorcsCommentStart start=/\%#=1\/\/\// end=/\%#=1$/ keepend contains=razorcsTodo,razorcsXMLTagStart containedin=@razorcsExtra 322 | syn keyword razorcsTodo TODO NOTE XXX FIXME HACK TBD contained 323 | 324 | syn match razorcsXMLTagStart /\%#=1<\/\=/ contained nextgroup=razorcsXMLTagName 325 | syn match razorcsXMLTagName /\%#=1\a[^[:space:]\>]*/ contained nextgroup=razorcsXMLAttribute,razorcsXMLTagEnd skipwhite 326 | syn match razorcsXMLAttribute /\%#=1[^>/=[:space:]]\+/ contained nextgroup=razorcsXMLAttributeOperator,razorcsXMLTagEnd skipwhite 327 | syn match razorcsXMLAttributeOperator /\%#=1=/ contained nextgroup=razorcsXMLValue skipwhite 328 | syn region razorcsXMLValue matchgroup=razorcsXMLValueDelimiter start=/\%#=1"/ end=/\%#=1"/ contained nextgroup=razorcsXMLTagEnd skipwhite 329 | syn region razorcsXMLValue matchgroup=razorcsXMLValueDelimiter start=/\%#=1'/ end=/\%#=1'/ contained nextgroup=razorcsXMLTagEnd skipwhite 330 | syn match razorcsXMLTagEnd /\%#=1\/\=>/ contained 331 | 332 | syn match razorcsDirective /\%#=1#.*/ containedin=@razorcsBlocks 333 | syn region razorcsRegion matchgroup=razorcsDirective start=/\%#=1#region\>.*/ end=/\%#=1#endregion\>.*/ containedin=@razorcsBlocks,razorcsRegion transparent fold 334 | 335 | syn match razorcsTypeModifier /\%#=1[*?]/ contained nextgroup=razorcsDeclarator,razorcsTypeModifier skipwhite skipempty 336 | syn region razorcsTypeModifier matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1\]/ contained contains=@razorcsRHS nextgroup=razorcsDeclarator,razorcsInitializer,razorcsTypeModifier skipwhite skipempty 337 | 338 | syn match razorcsTypeIdentifier /\%#=1\K\k*\%(<.\{-}>\)\=\%([*?]\.\@!\|\[.\{-}\]\)*/ contained contains=razorcsType,razorcsKeywordError,razorcsGeneric,razorcsTypeModifier nextgroup=razorcsDeclarator,razorcsIndexerThis,razorcsTypeMemberOperator,razorcsOperatorModifier skipwhite skipempty 339 | syn match razorcsTypeMemberOperator /\%#=1\./ contained nextgroup=razorcsTypeIdentifier skipwhite skipempty 340 | syn match razorcsTypeMemberOperator /\%#=1::/ contained nextgroup=razorcsTypeIdentifier skipwhite skipempty 341 | 342 | syn match razorcsConstructor /\%#=1\K\k*(\@=/ contained contains=razorcsKeywordError nextgroup=razorcsConstructorParameters 343 | syn region razorcsConstructorParameters matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=razorcsType,razorcsTypeIdentifier,razorcsModifier,razorcsCollectionExpressionOrAttributes nextgroup=razorcsLambdaOperator,razorcsConstructorInheritanceOperator skipwhite skipempty 344 | syn match razorcsConstructorInheritanceOperator /\%#=1:/ contained nextgroup=razorcsMethodConstant skipwhite skipempty 345 | syn keyword razorcsMethodConstant this base contained nextgroup=razorcsMethodConstantParameters skipwhite skipempty 346 | syn region razorcsMethodConstantParameters matchgroup=razorcsDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorcsLambdaOperator skipwhite skipempty 347 | 348 | syn match razorcsAttribute /\%#=1\K\k*/ contained nextgroup=@razorcsOperators skipwhite skipempty 349 | 350 | syn keyword razorcsModifier nextgroup=razorcsModifier,razorcsType,razorcsTypeIdentifier,razorcsStatement skipwhite skipempty 351 | \ abstract async 352 | \ const 353 | \ event explicit extern 354 | \ fixed 355 | \ global 356 | \ implicit in internal 357 | \ new 358 | \ out override 359 | \ params partial private protected public 360 | \ ref readonly required 361 | \ sealed static 362 | \ unsafe 363 | \ virtual volatile 364 | 365 | syn keyword razorcsModifier delegate nextgroup=razorcsFunctionPointerModifier,razorcsModifier,razorcsType,razorcsTypeIdentifier,razorcsStatement skipwhite skipempty 366 | syn match razorcsFunctionPointerModifier /\%#=1\*/ contained nextgroup=razorcsGeneric,razorcsFunctionPointerManaged skipwhite skipempty 367 | syn keyword razorcsFunctionPointerManaged managed unmanaged contained nextgroup=razorcsGeneric,razorcsFunctionPointerTypes skipwhite skipempty 368 | syn region razorcsFunctionPointerTypes matchgroup=razorcsDelimiter start=/\%#=1\[/ end=/\%#=1\]/ contained contains=razorcsTypeIdentifier nextgroup=razorcsGeneric skipwhite skipempty 369 | 370 | syn cluster razorcsBlocks contains=razorcs\a\{-}Block 371 | 372 | syn cluster razorcsExtra contains= 373 | \ ALLBUT, 374 | \ razorcsString,razorcsCharacter,razorcsComment,razorcsXMLTagName,razorcsXMLAttribute,razorcsXMLValue, 375 | \ razorcsDirective,razorcsEscapeSequenceError, 376 | \ razorcs\a\{-}Comma 377 | 378 | " Highlighting {{{1 379 | hi def link razorcsComment Comment 380 | hi def link razorcsCommentStart razorcsComment 381 | hi def link razorcsCommentEnd razorcsCommentStart 382 | hi def link razorcsTodo Todo 383 | hi def link razorcsDirective PreProc 384 | hi def link razorcsStatement Statement 385 | hi def link razorcsTypeName Typedef 386 | hi def link razorcsInterfaceName razorcsTypeName 387 | hi def link razorcsRecordModifier razorcsStatement 388 | hi def link razorcsGenericParameter razorcsDeclarator 389 | hi def link razorcsTypeInheritanceOperator razorcsOperator 390 | hi def link razorcsTypeConstraintLambdaOperator razorcsOperator 391 | hi def link razorcsTypeInheriteeMemberOperator razorcsMemberOperator 392 | hi def link razorcsTypeConstraint razorcsStatement 393 | hi def link razorcsTypeConstraintModifier razorcsTypeModifier 394 | hi def link razorcsTypeInheriteeKeyword Keyword 395 | hi def link razorcsMethodTypeInheritanceOperator razorcsTypeInheritanceOperator 396 | hi def link razorcsMethodTypeConstraintLambdaOperator razorcsTypeConstraintLambdaOperator 397 | hi def link razorcsMethodTypeInheriteeMemberOperator razorcsTypeInheriteeMemberOperator 398 | hi def link razorcsMethodTypeConstraint razorcsTypeConstraint 399 | hi def link razorcsMethodTypeInheriteeKeyword razorcsTypeInheriteeKeyword 400 | hi def link razorcsMethodTypeConstraintModifier razorcsTypeConstraintModifier 401 | hi def link razorcsTypeVariable razorcsIdentifier 402 | hi def link razorcsEnumName Typedef 403 | hi def link razorcsEnumInheritanceOperator razorcsOperator 404 | hi def link razorcsEnumType razorcsType 405 | hi def link razorcsNamespaceName Typedef 406 | hi def link razorcsNamespaceNameSeparator razorcsOperator 407 | hi def link razorcsDelimiter Delimiter 408 | hi def link razorcsModifier Keyword 409 | hi def link razorcsFunctionPointerModifier razorcsTypeModifier 410 | hi def link razorcsOperatorModifier razorcsModifier 411 | hi def link razorcsOperatorMethod razorcsOperator 412 | hi def link razorcsBooleanOperatorMethod razorcsBoolean 413 | hi def link razorcsConversionMethodKeyword razorcsType 414 | hi def link razorcsIncrementOperator razorcsOperator 415 | hi def link razorcsDecrementOperator razorcsOperator 416 | hi def link razorcsPointerOperator razorcsOperator 417 | hi def link razorcsType Type 418 | hi def link razorcsTypeModifier razorcsOperator 419 | hi def link razorcsTypeIdentifier razorcsIdentifier 420 | hi def link razorcsRHSTypeIdentifier razorcsTypeIdentifier 421 | hi def link razorcsTypeMemberOperator razorcsMemberOperator 422 | hi def link razorcsDeclarator Identifier 423 | hi def link razorcsNotDeclarator razorcsIdentifier 424 | hi def link razorcsDeclaratorMemberOperator razorcsMemberOperator 425 | hi def link razorcsConstructor razorcsDeclarator 426 | hi def link razorcsConstructorInheritanceOperator razorcsOperator 427 | hi def link razorcsDestructorSign razorcsOperator 428 | hi def link razorcsDestructor razorcsConstructor 429 | hi def link razorcsMethodConstant razorcsConstant 430 | hi def link razorcsConstant Constant 431 | hi def link razorcsRHSConstant razorcsConstant 432 | hi def link razorcsIndexerThis razorcsConstant 433 | hi def link razorcsThisModifier razorcsConstant 434 | hi def link razorcsOperator Operator 435 | hi def link razorcsAssignmentOperator razorcsOperator 436 | hi def link razorcsMemberOperator razorcsOperator 437 | hi def link razorcsNullForgivingOperator razorcsOperator 438 | hi def link razorcsLambdaOperator razorcsOperator 439 | hi def link razorcsAccessor razorcsStatement 440 | hi def link razorcsOperatorKeyword Keyword 441 | hi def link razorcsUnaryOperatorKeyword razorcsOperatorKeyword 442 | hi def link razorcsRHSDeclarator razorcsDeclarator 443 | hi def link razorcsRHSIdentifier razorcsIdentifier 444 | hi def link razorcsRHSType razorcsType 445 | hi def link razorcsLINQKeyword Keyword 446 | hi def link razorcsUnaryOperator razorcsOperator 447 | hi def link razorcsNumber Number 448 | hi def link razorcsBoolean Boolean 449 | hi def link razorcsNull Constant 450 | hi def link razorcsCharacter Character 451 | hi def link razorcsCharacterDelimiter razorcsDelimiter 452 | hi def link razorcsString String 453 | hi def link razorcsStringStart razorcsDelimiter 454 | hi def link razorcsStringEnd razorcsStringStart 455 | hi def link razorcsStringInterpolationDelimiter razorcsDelimiter 456 | hi def link razorcsStringInterpolationError Error 457 | hi def link razorcsEscapeSequence SpecialChar 458 | hi def link razorcsEscapeSequenceError Error 459 | hi def link razorcsQuoteEscape razorcsEscapeSequence 460 | hi def link razorcsBraceEscape razorcsEscapeSequence 461 | hi def link razorcsKeywordError Error 462 | hi def link razorcsAttribute razorcsIdentifier 463 | hi def link razorcsAttributeDelimiter razorcsDelimiter 464 | hi def link razorcsXMLTagStart Delimiter 465 | hi def link razorcsXMLTagName Special 466 | hi def link razorcsXMLTagEnd razorcsXMLTagStart 467 | hi def link razorcsXMLAttribute Keyword 468 | hi def link razorcsXMLAttributeOperator Operator 469 | hi def link razorcsXMLValue String 470 | hi def link razorcsXMLValueDelimiter razorcsDelimiter 471 | hi def link razorcsPatternType razorcsType 472 | hi def link razorcsPatternTypeIdentifier razorcsTypeIdentifier 473 | hi def link razorcsPatternTypeMemberOperator razorcsMemberOperator 474 | hi def link razorcsPatternDeclarator razorcsDeclarator 475 | hi def link razorcsPatternPropertyMemberOperator razorcsMemberOperator 476 | hi def link razorcsPatternSlice razorcsOperator 477 | hi def link razorcsDeclaratorComma razorcsDelimiter 478 | hi def link razorcsTypeInheriteeComma razorcsDeclaratorComma 479 | hi def link razorcsCaseOperator razorcsOperator 480 | hi def link razorcsLINQDeclarator razorcsDeclarator 481 | hi def link razorcsFunctionPointerManaged razorcsModifier 482 | hi def link razorcsPatternListVar razorcsStatement 483 | hi def link razorcsPatternListDeclarator razorcsDeclarator 484 | hi def link razorcsPatternListDeclaratorComma razorcsDeclaratorComma 485 | hi def link razorcsReadonly razorcsUnaryOperatorKeyword 486 | hi def link razorcsUsingStatic razorcsModifier 487 | " }}}1 488 | 489 | " vim:fdm=marker 490 | -------------------------------------------------------------------------------- /indent/razor.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language: Razor (https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor) 3 | " Author: Jeffrey Crochet 4 | " URL: https://github.com/jlcrochet/vim-razor 5 | 6 | if get(b:, "did_indent") 7 | finish 8 | endif 9 | 10 | if exists("*GetRazorIndent") 11 | setlocal 12 | \ indentexpr=GetRazorIndent() 13 | \ cinoptions+=j1,J1 14 | 15 | let &indentkeys = &cinkeys..",<>>" 16 | let b:did_indent = 1 17 | 18 | finish 19 | endif 20 | 21 | runtime! indent/javascript.vim indent/javascript.lua | unlet! b:did_indent 22 | let s:js_indentexpr = &indentexpr 23 | 24 | runtime! indent/css.vim indent/css.lua 25 | let s:css_indentexpr = &indentexpr 26 | 27 | setlocal 28 | \ indentexpr=GetRazorIndent() 29 | \ cinoptions+=j1,J1 30 | 31 | let &indentkeys = &cinkeys..",<>>" 32 | let b:did_indent = 1 33 | 34 | const s:skip_delimiter = 'synID(line("."), col("."), 0)->synIDattr("name") !~# ''^razor\%(cs\)\=Delimiter$''' 35 | 36 | let s:line = 0 37 | let s:first_char = 0 38 | let s:first_idx = 0 39 | let s:prev_lnum = 0 40 | 41 | function GetRazorIndent() abort 42 | let s:prev_lnum = prevnonblank(v:lnum - 1) 43 | 44 | if s:prev_lnum == 0 45 | return 0 46 | endif 47 | 48 | let s:line = getline(v:lnum) 49 | let s:first_idx = indent(v:lnum) 50 | let s:first_char = s:line[s:first_idx] 51 | 52 | let shift = 0 53 | 54 | let stack = synstack(v:lnum, s:first_idx + 1) 55 | 56 | if stack->len() > 0 57 | call reverse(stack) 58 | 59 | let name = synIDattr(stack[0], 'name') 60 | 61 | if s:is_multiline(name) 62 | return -1 63 | elseif name ==# 'razorhtmlTagStart' 64 | if s:line[s:first_idx + 1] ==# '/' 65 | return s:html_indent() - shiftwidth() 66 | endif 67 | elseif name ==# 'razorhtmlTagEnd' 68 | let [l, c] = searchpos('<', "bW") 69 | let name = s:syn_name_at(l, c) 70 | 71 | while name !=# 'razorhtmlTagStart' 72 | let [l, c] = searchpos('<', "bW") 73 | let name = s:syn_name_at(l, c) 74 | endwhile 75 | 76 | return indent(l) 77 | elseif name ==# 'razorDelimiter' || name ==# 'razorcsDelimiter' 78 | if s:first_char ==# ')' || s:first_char ==# ']' || s:first_char ==# '}' 79 | return cindent(v:lnum) 80 | endif 81 | elseif name[:8] ==# 'razorhtml' && name[-9:] ==# 'Attribute' 82 | let [l, c] = searchpos('<', "bW", s:prev_lnum) 83 | 84 | if l == 0 85 | return indent(s:prev_lnum) 86 | endif 87 | 88 | let name = s:syn_name_at(l, c) 89 | 90 | while name !=# 'razorhtmlTagStart' 91 | let [l, c] = searchpos('<', "bW", s:prev_lnum) 92 | 93 | if l == 0 94 | return indent(s:prev_lnum) 95 | endif 96 | 97 | let name = s:syn_name_at(l, c) 98 | endwhile 99 | 100 | if l == 0 101 | return indent(s:prev_lnum) 102 | else 103 | let [_, space] = searchpos('\s', "z", s:prev_lnum) 104 | 105 | if space == 0 106 | return indent(l) + shiftwidth() 107 | else 108 | let [_, nonspace] = searchpos('\S', "z", s:prev_lnum) 109 | 110 | if nonspace == 0 111 | return indent(l) + shiftwidth() 112 | else 113 | return nonspace - 1 114 | endif 115 | endif 116 | endif 117 | endif 118 | 119 | for id in stack 120 | let name = synIDattr(id, 'name') 121 | 122 | if name ==# 'razorhtmlTagBlock' 123 | return s:html_indent() 124 | elseif name ==# 'razorhtmlScriptBlock' 125 | return s:js_indent() 126 | elseif name ==# 'razorhtmlStyleBlock' 127 | return s:css_indent() 128 | elseif name ==# 'razorInvocation' || name ==# 'razorIndex' || name ==# 'razorExplicitExpression' || name ==# 'razorcsCollectionOrAttributes' 129 | return cindent(v:lnum) 130 | elseif name ==# 'razorBlock' || name ==# 'razorcsTypeBlock' 131 | return s:cs_indent() 132 | endif 133 | endfor 134 | endif 135 | 136 | return s:html_indent() 137 | endfunction 138 | 139 | function s:html_indent() abort 140 | let [brackets, tags, _, closers] = s:get_html_line_info(s:prev_lnum) 141 | 142 | while brackets != 0 || closers > 0 143 | let s:prev_lnum = prevnonblank(s:prev_lnum - 1) 144 | 145 | if s:prev_lnum == 0 146 | return 0 147 | endif 148 | 149 | let [b, t, o, c] = s:get_html_line_info(s:prev_lnum) 150 | 151 | let brackets += b 152 | let tags += t 153 | let closers -= o 154 | let closers += c 155 | endwhile 156 | 157 | while s:is_multiline(s:syn_name_at(s:prev_lnum, 1)) 158 | let s:prev_lnum = prevnonblank(s:prev_lnum - 1) 159 | endwhile 160 | 161 | if tags > 0 162 | return indent(s:prev_lnum) + shiftwidth() 163 | else 164 | return indent(s:prev_lnum) 165 | endif 166 | endfunction 167 | 168 | function s:get_html_line_info(lnum) abort 169 | let brackets = 0 170 | let tags = 0 171 | let openers = 0 172 | let closers = 0 173 | 174 | let line = getline(a:lnum) 175 | let [char, idx, col] = line->matchstrpos('[()[\]{}<>]') 176 | 177 | while idx != -1 178 | if char ==# '<' 179 | let name = s:syn_name_at(a:lnum, col) 180 | 181 | if name ==# 'razorhtmlComment' 182 | break 183 | elseif name ==# 'razorhtmlTagStart' 184 | let brackets += 1 185 | let tags += 1 186 | 187 | let next_char = line[col] 188 | 189 | if next_char ==# '/' 190 | let tags -= 2 191 | else 192 | let name = line->matchstr('^\a[^[:space:]/>]*', idx + 1) 193 | 194 | if name !=# '' 195 | if s:is_void_element(name) 196 | let tags -= 1 197 | endif 198 | 199 | let idx += len(name) - 1 200 | endif 201 | endif 202 | endif 203 | elseif char ==# '>' 204 | if s:syn_name_at(a:lnum, col) ==# 'razorhtmlTagEnd' 205 | let brackets -= 1 206 | 207 | if line[idx - 1] ==# '/' 208 | let tags -= 1 209 | endif 210 | endif 211 | elseif char ==# '(' || char ==# '[' || char ==# '{' 212 | let name = s:syn_name_at(a:lnum, col) 213 | 214 | if name ==# 'razorDelimiter' || name ==# 'razorcsDelimiter' 215 | let openers += 1 216 | endif 217 | elseif char ==# ')' || char ==# ']' || char ==# '}' 218 | let name = s:syn_name_at(a:lnum, col) 219 | 220 | if name ==# 'razorDelimiter' || name ==# 'razorcsDelimiter' 221 | if openers > 0 222 | let openers -= 1 223 | else 224 | let closers += 1 225 | endif 226 | endif 227 | endif 228 | 229 | let [char, idx, col] = line->matchstrpos('[()[\]{}<>]', idx + 1) 230 | endwhile 231 | 232 | return [brackets, tags, openers, closers] 233 | endfunction 234 | 235 | function s:is_void_element(name) abort 236 | return 237 | \ a:name ==? 'area' || 238 | \ a:name ==? 'base' || 239 | \ a:name ==? 'br' || 240 | \ a:name ==? 'col' || 241 | \ a:name ==? 'command' || 242 | \ a:name ==? 'embed' || 243 | \ a:name ==? 'hr' || 244 | \ a:name ==? 'img' || 245 | \ a:name ==? 'input' || 246 | \ a:name ==? 'keygen' || 247 | \ a:name ==? 'link' || 248 | \ a:name ==? 'meta' || 249 | \ a:name ==? 'param' || 250 | \ a:name ==? 'source' || 251 | \ a:name ==? 'track' || 252 | \ a:name ==? 'wbr' 253 | endfunction 254 | 255 | function s:cs_indent() abort 256 | let prev_line = getline(s:prev_lnum) 257 | let first_idx = indent(s:prev_lnum) 258 | let first_char = prev_line[first_idx] 259 | 260 | while first_char ==# '#' || s:is_multiline(s:syn_name_at(s:prev_lnum, 1)) 261 | let s:prev_lnum = prevnonblank(s:prev_lnum - 1) 262 | 263 | if s:prev_lnum == 0 264 | return 0 265 | endif 266 | 267 | let prev_line = getline(s:prev_lnum) 268 | let first_idx = indent(s:prev_lnum) 269 | let first_char = prev_line[first_idx] 270 | endwhile 271 | 272 | if first_char ==# '[' || first_char ==# ']' 273 | if s:syn_name_at(s:prev_lnum, first_idx + 1) ==# 'razorcsDelimiter' 274 | return indent(s:prev_lnum) 275 | endif 276 | elseif first_char ==# '}' 277 | let name = s:syn_name_at(s:prev_lnum, first_idx + 1) 278 | 279 | if name ==# 'razorDelimiter' || name ==# 'razorcsDelimiter' 280 | if searchpair('[([{]', '', '[)\]}]', 'b', s:skip_delimiter, s:prev_lnum) 281 | return indent(s:prev_lnum) + shiftwidth() 282 | else 283 | return indent(s:prev_lnum) 284 | endif 285 | endif 286 | elseif first_char ==# '/' 287 | let second_char = prev_line[first_idx + 1] 288 | 289 | if second_char ==# '/' || second_char ==# '*' 290 | if s:syn_name_at(s:prev_lnum, first_idx + 1) ==# 'razorcsCommentStart' 291 | return indent(s:prev_lnum) 292 | endif 293 | endif 294 | elseif first_char ==# '@' 295 | let name = s:syn_name_at(s:prev_lnum, first_idx + 1) 296 | 297 | if name ==# 'razorStart' 298 | if searchpair('[([{]', '', '[)\]}]', 'b', s:skip_delimiter, s:prev_lnum) 299 | return indent(s:prev_lnum) + shiftwidth() 300 | else 301 | return indent(s:prev_lnum) 302 | endif 303 | elseif name ==# 'razorHTMLLineStart' || name ==# 'razorCommentStart' 304 | return indent(s:prev_lnum) 305 | endif 306 | elseif first_char ==# '<' 307 | if s:syn_name_at(s:prev_lnum, first_idx + 1) ==# 'razorhtmlTagStart' 308 | return indent(s:prev_lnum) 309 | endif 310 | elseif first_char ==# '>' 311 | if s:syn_name_at(s:prev_lnum, first_idx + 1) ==# 'razorhtmlTagEnd' 312 | return indent(s:prev_lnum) 313 | endif 314 | endif 315 | 316 | return cindent(v:lnum) 317 | endfunction 318 | 319 | function s:css_indent() abort 320 | if s:line->strpart(s:first_idx + 1, 8) ==? '' 321 | return indent(s:prev_lnum) - shiftwidth() 322 | endif 323 | 324 | while search('\c]\@=', "b", s:prev_lnum) 325 | if s:syn_name_at(s:prev_lnum, col('.')) ==# 'razorhtmlTagStart' 326 | return indent(s:prev_lnum) + shiftwidth() 327 | endif 328 | endwhile 329 | 330 | return eval(s:css_indentexpr) 331 | endfunction 332 | 333 | function s:js_indent() abort 334 | if s:line->strpart(s:first_idx + 1, 9) ==? '' 335 | return indent(s:prev_lnum) - shiftwidth() 336 | endif 337 | 338 | while search('\c]\@=', "b", s:prev_lnum) 339 | if s:syn_name_at(s:prev_lnum, col('.')) ==# 'razorhtmlTagStart' 340 | return indent(s:prev_lnum) + shiftwidth() 341 | endif 342 | endwhile 343 | 344 | return eval(s:js_indentexpr) 345 | endfunction 346 | 347 | function s:syn_name_at(lnum, col) 348 | return synID(a:lnum, a:col, 0)->synIDattr('name') 349 | endfunction 350 | 351 | function s:is_multiline(name) abort 352 | return 353 | \ a:name ==# 'razorComment' || 354 | \ a:name ==# 'razorCommentEnd' || 355 | \ a:name ==# 'razorhtmlComment' || 356 | \ a:name ==# 'razorhtmlCommentEnd' || 357 | \ a:name ==# 'razorcsComment' || 358 | \ a:name ==# 'razorcsCommentEnd' || 359 | \ a:name ==# 'razorcsString' || 360 | \ a:name ==# 'razorcsStringEnd' 361 | endfunction 362 | 363 | " vim:fdm=marker 364 | -------------------------------------------------------------------------------- /syntax/razor.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Razor (https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor) 3 | " Author: Jeffrey Crochet 4 | " URL: https://github.com/jlcrochet/vim-razor 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | syn sync fromstart 11 | 12 | syn cluster razorTop contains=TOP 13 | 14 | " HTML 15 | syn include @razorhtmlCss syntax/css.vim | unlet! b:current_syntax 16 | syn include @razorhtmlJavaScript syntax/javascript.vim | unlet! b:current_syntax 17 | 18 | syn case ignore 19 | 20 | syn match razorhtmlTagStart /\%#=1]*/ contained nextgroup=razorhtmlAttribute,razorhtmlRazorAttribute,razorhtmlTagEnd,razorhtmlTagBlock skipwhite skipempty 22 | syn match razorhtmlAttribute /\%#=1[^[:space:]/>=]\+/ contained nextgroup=razorhtmlTagEnd,razorhtmlTagBlock,razorhtmlAttribute,razorhtmlRazorAttribute,razorhtmlAttributeOperator skipwhite skipempty 23 | syn match razorhtmlAttributeOperator /\%#=1=/ contained nextgroup=razorhtmlValue skipwhite skipempty 24 | syn match razorhtmlValue /\%#=1[^>=[:space:]]\+/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlAttribute,razorhtmlRazorAttribute,razorhtmlTagEnd,razorhtmlTagBlock skipwhite skipempty 25 | syn region razorhtmlValue matchgroup=razorhtmlValueDelimiter start=/\%#=1"/ end=/\%#=1"/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlAttribute,razorhtmlRazorAttribute,razorhtmlTagEnd,razorhtmlTagBlock skipwhite skipempty 26 | syn region razorhtmlValue matchgroup=razorhtmlValueDelimiter start=/\%#=1'/ end=/\%#=1'/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlAttribute,razorhtmlRazorAttribute,razorhtmlTagEnd,razorhtmlTagBlock skipwhite skipempty 27 | syn match razorhtmlTagEnd /\%#=1\/\=>/ contained 28 | syn region razorhtmlTagBlock matchgroup=razorhtmlTagEnd start=/\%#=1>/ matchgroup=razorhtmlTagStart end=/\%#=1<\/!\=/ contained contains=TOP,razorhtmlDoctype nextgroup=razorhtmlEndTagName 29 | syn match razorhtmlEndTagName /\%#=1\a[^[:space:]/>]*/ contained nextgroup=razorhtmlTagEnd 30 | 31 | syn match razorhtmlRazorAttribute /\%#=1@/ contained nextgroup=razorhtmlAttribute,razorhtmlAttributeExplicitExpression 32 | syn region razorhtmlAttributeExplicitExpression matchgroup=razorDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorhtmlTagEnd,razorhtmlTagBlock,razorhtmlAttribute,razorhtmlRazorAttribute,razorhtmlAttributeOperator skipwhite skipempty 33 | 34 | hi def link razorhtmlDelimiter Delimiter 35 | hi def link razorhtmlTagStart razorhtmlDelimiter 36 | hi def link razorhtmlTagEnd razorhtmlTagStart 37 | hi def link razorhtmlTagName Special 38 | hi def link razorhtmlEndTagName razorhtmlTagName 39 | hi def link razorhtmlAttribute Keyword 40 | hi def link razorhtmlRazorAttribute razorStart 41 | hi def link razorhtmlAttributeOperator Operator 42 | hi def link razorhtmlValue String 43 | hi def link razorhtmlValueDelimiter razorhtmlDelimiter 44 | 45 | syn match razorhtmlTagName /\%#=1\%(area\|base\|br\|col\|command\|embed\|hr\|img\|input\|keygen\|link\|meta\|param\|source\|track\|wbr\)[[:space:]/>]\@=/ contained nextgroup=razorhtmlNoBlockAttribute,razorhtmlRazorNoBlockAttribute,razorhtmlTagEnd skipwhite skipempty 46 | syn match razorhtmlNoBlockAttribute /\%#=1[^[:space:]/>=]\+/ contained nextgroup=razorhtmlTagEnd,razorhtmlNoBlockAttribute,razorhtmlRazorNoBlockAttribute,razorhtmlNoBlockAttributeOperator skipwhite skipempty 47 | syn match razorhtmlNoBlockAttributeOperator /\%#=1=/ contained nextgroup=razorhtmlNoBlockValue skipwhite skipempty 48 | syn match razorhtmlNoBlockValue /\%#=1[^>=[:space:]]\+/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlNoBlockAttribute,razorhtmlRazorNoBlockAttribute,razorhtmlTagEnd skipwhite skipempty 49 | syn region razorhtmlNoBlockValue matchgroup=razorhtmlValueDelimiter start=/\%#=1"/ end=/\%#=1"/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlNoBlockAttribute,razorhtmlRazorNoBlockAttribute,razorhtmlTagEnd skipwhite skipempty 50 | syn region razorhtmlNoBlockValue matchgroup=razorhtmlValueDelimiter start=/\%#=1'/ end=/\%#=1'/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlNoBlockAttribute,razorhtmlRazorNoBlockAttribute,razorhtmlTagEnd skipwhite skipempty 51 | 52 | syn match razorhtmlRazorNoBlockAttribute /\%#=1@/ contained nextgroup=razorhtmlNoBlockAttribute,razorhtmlNoBlockAttributeExplicitExpression 53 | syn region razorhtmlNoBlockAttributeExplicitExpression matchgroup=razorDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorhtmlTagEnd,razorhtmlNoBlockAttribute,razorhtmlNoBlockAttributeOperator skipwhite skipempty 54 | 55 | hi def link razorhtmlNoBlockAttribute razorhtmlAttribute 56 | hi def link razorhtmlNoBlockAttributeOperator razorhtmlAttributeOperator 57 | hi def link razorhtmlNoBlockValue razorhtmlValue 58 | hi def link razorhtmlRazorNoBlockAttribute razorhtmlRazorAttribute 59 | 60 | syn match razorhtmlTagName /\%#=1style[[:space:]/>]\@=/ contained nextgroup=razorhtmlStyleAttribute,razorhtmlRazorStyleAttribute,razorhtmlStyleBlock skipwhite skipempty 61 | syn match razorhtmlStyleAttribute /\%#=1[^[:space:]/>=]\+/ contained nextgroup=razorhtmlStyleBlock,razorhtmlStyleAttribute,razorhtmlRazorStyleAttribute,razorhtmlStyleAttributeOperator skipwhite skipempty 62 | syn match razorhtmlStyleAttributeOperator /\%#=1=/ contained nextgroup=razorhtmlStyleValue skipwhite skipempty 63 | syn match razorhtmlStyleValue /\%#=1[^>=[:space:]]\+/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlStyleAttribute,razorhtmlRazorStyleAttribute,razorhtmlStyleBlock skipwhite skipempty 64 | syn region razorhtmlStyleValue matchgroup=razorhtmlValueDelimiter start=/\%#=1"/ end=/\%#=1"/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlStyleAttribute,razorhtmlRazorStyleAttribute,razorhtmlStyleBlock skipwhite skipempty 65 | syn region razorhtmlStyleValue matchgroup=razorhtmlValueDelimiter start=/\%#=1'/ end=/\%#=1'/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlStyleAttribute,razorhtmlRazorStyleAttribute,razorhtmlStyleBlock skipwhite skipempty 66 | syn region razorhtmlStyleBlock matchgroup=razorhtmlTagEnd start=/\%#=1>/ matchgroup=razorhtmlTagStart end=/\%#=1<\/!\=\zestyle>/ contained keepend contains=@razorhtmlCss nextgroup=razorhtmlEndStyleBlock 67 | syn keyword razorhtmlEndStyleBlock style contained nextgroup=razorhtmlTagEnd 68 | 69 | syn match razorhtmlRazorStyleAttribute /\%#=1@/ contained nextgroup=razorhtmlStyleAttribute,razorhtmlStyleAttributeExplicitExpression 70 | syn region razorhtmlStyleAttributeExplicitExpression matchgroup=razorDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorhtmlTagEnd,razorhtmlNoBlockAttribute,razorhtmlNoBlockAttributeOperator skipwhite skipempty 71 | 72 | hi def link razorhtmlStyleAttribute razorhtmlAttribute 73 | hi def link razorhtmlStyleAttributeOperator razorhtmlAttributeOperator 74 | hi def link razorhtmlStyleValue razorhtmlValue 75 | hi def link razorhtmlRazorStyleAttribute razorhtmlRazorAttribute 76 | hi def link razorhtmlEndStyleBlock razorhtmlEndTagName 77 | 78 | syn match razorhtmlTagName /\%#=1script[[:space:]/>]\@=/ contained nextgroup=razorhtmlScriptAttribute,razorhtmlRazorScriptAttribute,razorhtmlScriptBlock skipwhite skipempty 79 | syn match razorhtmlScriptAttribute /\%#=1[^[:space:]/>=]\+/ contained nextgroup=razorhtmlScriptBlock,razorhtmlScriptAttribute,razorhtmlRazorScriptAttribute,razorhtmlScriptAttributeOperator skipwhite skipempty 80 | syn match razorhtmlScriptAttributeOperator /\%#=1=/ contained nextgroup=razorhtmlScriptValue skipwhite skipempty 81 | syn match razorhtmlScriptValue /\%#=1[^>=[:space:]]\+/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlScriptAttribute,razorhtmlRazorScriptAttribute,razorhtmlScriptBlock skipwhite skipempty 82 | syn region razorhtmlScriptValue matchgroup=razorhtmlValueDelimiter start=/\%#=1"/ end=/\%#=1"/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlScriptAttribute,razorhtmlRazorScriptAttribute,razorhtmlScriptBlock skipwhite skipempty 83 | syn region razorhtmlScriptValue matchgroup=razorhtmlValueDelimiter start=/\%#=1'/ end=/\%#=1'/ contained contains=razorhtmlCharacterReference nextgroup=razorhtmlScriptAttribute,razorhtmlRazorScriptAttribute,razorhtmlScriptBlock skipwhite skipempty 84 | syn region razorhtmlScriptBlock matchgroup=razorhtmlTagEnd start=/\%#=1>/ matchgroup=razorhtmlTagStart end=/\%#=1<\/!\=\zescript>/ contained keepend contains=@razorhtmlJavaScript nextgroup=razorhtmlEndScriptBlock 85 | syn keyword razorhtmlEndScriptBlock script contained nextgroup=razorhtmlTagEnd 86 | 87 | syn match razorhtmlRazorScriptAttribute /\%#=1@/ contained nextgroup=razorhtmlScriptAttribute,razorhtmlScriptAttributeExplicitExpression 88 | syn region razorhtmlScriptAttributeExplicitExpression matchgroup=razorDelimiter start=/\%#=1(/ end=/\%#=1)/ contained contains=@razorcsRHS nextgroup=razorhtmlTagEnd,razorhtmlNoBlockAttribute,razorhtmlNoBlockAttributeOperator skipwhite skipempty 89 | 90 | hi def link razorhtmlScriptAttribute razorhtmlAttribute 91 | hi def link razorhtmlScriptAttributeOperator razorhtmlAttributeOperator 92 | hi def link razorhtmlScriptValue razorhtmlValue 93 | hi def link razorhtmlRazorScriptAttribute razorhtmlRazorAttribute 94 | hi def link razorhtmlEndScriptBlock razorhtmlEndTagName 95 | 96 | syn match razorhtmlCharacterReference /\%#=1&\%(\a\+\|#\%(\d\+\|[xX]\x\+\)\);/ 97 | 98 | syn region razorhtmlComment matchgroup=razorhtmlCommentStart start=/\%#=1/ 99 | syn region razorhtmlDoctype start=/\%#=1]\@=/ end=/\%#=1>/ contains=razorhtmlCharacterReference 100 | 101 | hi def link razorhtmlCharacterReference SpecialChar 102 | hi def link razorhtmlComment Comment 103 | hi def link razorhtmlCommentStart razorhtmlComment 104 | hi def link razorhtmlCommentEnd razorhtmlCommentStart 105 | hi def link razorhtmlDoctype PreProc 106 | 107 | syn case match 108 | 109 | " Razor 110 | syn include @razorcs include/razorcs.vim 111 | 112 | syn match razorStart /\%#=1\k\@1\)\=/ contained contains=razorcsGeneric,razorcsKeywordError,razorExtraMemberOperator 195 | syn match razorExtraMemberOperator /\%#=1\./ contained 196 | syn match razorExtraMemberOperator /\%#=1::/ contained 197 | 198 | syn keyword razorInherits inherits contained nextgroup=razorTypeIdentifier skipwhite 199 | 200 | syn keyword razorModel model contained nextgroup=razorTypeIdentifier skipwhite 201 | 202 | syn keyword razorInject inject contained nextgroup=razorInjectIdentifier skipwhite 203 | syn match razorInjectIdentifier /\%#=1\K\k*\%(\%(\.\|::\)\K\k*\)*\%(<.\{-}>\)\=/ contained contains=razorcsGeneric,razorcsKeywordError,razorExtraMemberOperator nextgroup=razorInjectDeclarator skipwhite 204 | syn match razorInjectDeclarator /\%#=1\K\k*/ contained contains=razorcsKeywordError 205 | 206 | syn keyword razorNamespace namespace contained nextgroup=razorIdentifier skipwhite 207 | 208 | syn keyword razorPage page contained nextgroup=razorString skipwhite 209 | syn region razorString matchgroup=razorcsStringStart start=/\%#=1"/ matchgroup=razorcsStringEnd end=/\%#=1"/ contained contains=razorcsEscapeSequence,razorcsEscapeSequenceError 210 | 211 | syn keyword razorLayout layout contained nextgroup=razorIdentifier skipwhite 212 | 213 | syn keyword razorPreservewhitespace preservewhitespace contained nextgroup=razorBoolean skipwhite 214 | syn keyword razorBoolean true false contained 215 | 216 | syn keyword razorSection section contained nextgroup=razorSectionName skipwhite 217 | syn match razorSectionName /\%#=1\K\k*/ contained nextgroup=razorBlock skipwhite skipempty contains=razorcsKeywordError 218 | 219 | syn keyword razorTypeparam typeparam contained nextgroup=razorTypeParameter skipwhite 220 | syn match razorTypeParameter /\%#=1\K\k*/ contained contains=razorcsKeywordError nextgroup=razorcsTypeConstraint skipwhite 221 | 222 | syn keyword razorAddTagHelper addTagHelper contained nextgroup=razorTagPattern,razorTagPatternWildcard skipwhite 223 | syn match razorTagPattern /\%#=1\K\k*/ contained nextgroup=razorTagPatternMemberOperator,razorTagPatternWildcard,razorTagPatternComma 224 | syn match razorTagPatternComma /\%#=1,/ contained nextgroup=razorTagPattern,razorTagPatternWildcard skipwhite 225 | syn match razorTagPatternWildcard /\%#=1\*/ contained nextgroup=razorTagPatternComma 226 | syn match razorTagPatternMemberOperator /\%#=1\./ contained nextgroup=razorTagPattern 227 | 228 | syn keyword razorRemoveTagHelper removeTagHelper contained nextgroup=razorTagPattern,razorTagPatternWildcard skipwhite 229 | 230 | syn keyword razorTagHelperPrefix tagHelperPrefix contained 231 | 232 | syn keyword razorRendermode rendermode contained nextgroup=razorRendermodeMode skipwhite 233 | syn keyword razorRendermodeMode InteractiveServer InteractiveWebAssembly InteractiveAuto contained 234 | 235 | " Miscellaneous 236 | syn keyword razorType contained 237 | \ sbyte short int long byte ushort uint ulong float double decimal nint nuint 238 | \ char bool object string 239 | 240 | " Highlighting 241 | hi def link razorDirective Statement 242 | hi def link razorIf razorDirective 243 | hi def link razorFor razorDirective 244 | hi def link razorForeach razorDirective 245 | hi def link razorAwait razorDirective 246 | hi def link razorWhile razorDirective 247 | hi def link razorElse razorDirective 248 | hi def link razorSwitch razorDirective 249 | hi def link razorDo razorDirective 250 | hi def link razorUsing razorDirective 251 | hi def link razorTry razorDirective 252 | hi def link razorCatch razorDirective 253 | hi def link razorFinally razorDirective 254 | hi def link razorLock razorDirective 255 | hi def link razorAttribute razorDirective 256 | hi def link razorCode razorDirective 257 | hi def link razorFunctions razorDirective 258 | hi def link razorImplements razorDirective 259 | hi def link razorInherits razorDirective 260 | hi def link razorModel razorDirective 261 | hi def link razorInject razorDirective 262 | hi def link razorNamespace razorDirective 263 | hi def link razorPage razorDirective 264 | hi def link razorLayout razorDirective 265 | hi def link razorPreservewhitespace razorDirective 266 | hi def link razorSection razorDirective 267 | hi def link razorTypeparam razorDirective 268 | hi def link razorAddTagHelper razorDirective 269 | hi def link razorRemoveTagHelper razorDirective 270 | hi def link razorTagHelperPrefix razorDirective 271 | hi def link razorRendermode razorDirective 272 | hi def link razorSemicolon razorcsDelimiter 273 | hi def link razorTypeIdentifier razorcsTypeIdentifier 274 | hi def link razorUsingIdentifier razorIdentifier 275 | hi def link razorUsingMemberOperator razorMemberOperator 276 | hi def link razorUsingOperator razorcsAssignmentOperator 277 | hi def link razorInjectIdentifier razorIdentifier 278 | hi def link razorInjectDeclarator razorcsDeclarator 279 | hi def link razorString razorcsString 280 | hi def link razorBoolean razorcsBoolean 281 | hi def link razorSectionName razorcsDeclarator 282 | hi def link razorTypeParameter razorcsDeclarator 283 | hi def link razorTagPattern razorIdentifier 284 | hi def link razorTagPatternMemberOperator razorMemberOperator 285 | hi def link razorTagPatternWildcard SpecialChar 286 | hi def link razorTagPatternComma Delimiter 287 | hi def link razorRendermodeMode Keyword 288 | hi def link razorExtraMemberOperator razorMemberOperator 289 | hi def link razorType razorcsType 290 | hi def link razorUsingStatic razorcsUsingStatic 291 | 292 | let b:current_syntax = "razor" 293 | 294 | " vim:fdm=marker 295 | --------------------------------------------------------------------------------