Warning, /frameworks/syntax-highlighting/data/syntax/nix.xml is written in an unsupported language. File is not indexed.

0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <!DOCTYPE language [
0003     <!ENTITY ident "[a-zA-Z_][a-zA-Z0-9_\-']*">
0004 ]>
0005 
0006 <!--
0007     SPDX-FileCopyrightText: 2021 Marco Rebhan <me@dblsaiko.net>
0008     SPDX-FileContributor: Tuan Le <webmaster@michivi.com>
0009 
0010     SPDX-License-Identifier: MIT
0011 -->
0012 
0013 <language
0014     name="Nix"
0015     version="2"
0016     kateversion="5.79"
0017     section="Scripts"
0018     extensions="*.nix"
0019     casesensitive="1"
0020     author="Marco Rebhan &lt;me@dblsaiko.net&gt;"
0021     license="MIT"
0022     priority="1"
0023 >
0024     <highlighting>
0025         <list name="keywords">
0026             <item>assert</item>
0027             <item>rec</item>
0028             <item>and</item>
0029             <item>or</item>
0030         </list>
0031         <list name="builtins">
0032             <item>abort</item>
0033             <item>baseNameOf</item>
0034             <item>builtins</item>
0035             <item>derivation</item>
0036             <item>dirOf</item>
0037             <item>fetchTarball</item>
0038             <item>import</item>
0039             <item>isNull</item>
0040             <item>map</item>
0041             <item>removeAttrs</item>
0042             <item>throw</item>
0043             <item>toString</item>
0044         </list>
0045         <contexts>
0046             <context name="Expression" attribute="Normal Text" lineEndContext="#stay">
0047                 <IncludeRules context="Single Expression" />
0048 
0049                 <keyword String="keywords" attribute="Keyword" />
0050                 <WordDetect String="let" attribute="Keyword" context="Let" />
0051                 <WordDetect String="if" attribute="Keyword" context="If" />
0052                 <WordDetect String="with" attribute="Keyword" context="With" />
0053                 <Detect2Chars char="/" char1="/" attribute="Operator" />
0054                 <Detect2Chars char="?" char1="?" attribute="Operator" />
0055                 <Detect2Chars char="+" char1="+" attribute="Operator" />
0056                 <Detect2Chars char="|" char1="|" attribute="Operator" />
0057                 <Detect2Chars char="&amp;" char1="&amp;" attribute="Operator" />
0058                 <AnyChar String="+-*/?!" attribute="Operator" />
0059                 <RegExpr String="\b&ident;(?=\s*:)" context="Function" attribute="Identifier" />
0060 
0061                 <DetectIdentifier />
0062             </context>
0063             <context name="Single Expression" attribute="Normal Text" lineEndContext="#stay">
0064                 <DetectSpaces />
0065                 <IncludeRules context="Comment Rules" />
0066 
0067                 <keyword String="builtins" attribute="Builtin" />
0068                 <DetectChar char="&quot;" attribute="String" context="String" />
0069                 <Detect2Chars char="'" char1="'" attribute="String" context="String2" />
0070                 <DetectChar char="{" attribute="Symbol" context="Any Brace" beginRegion="Set" />
0071                 <DetectChar char="[" attribute="Symbol" context="List" beginRegion="List" />
0072                 <DetectChar char="(" attribute="Symbol" context="Parentheses" />
0073                 <RegExpr String="[a-zA-Z0-9-_.]*(/[a-zA-Z0-9-_.]+)+" attribute="Path" />
0074                 <Float attribute="Float" />
0075                 <Int attribute="Int" />
0076                 <WordDetect String="true" attribute="Constant" />
0077                 <WordDetect String="false" attribute="Constant" />
0078                 <WordDetect String="null" attribute="Constant" />
0079             </context>
0080             <context name="Parentheses" attribute="Normal Text" lineEndContext="#stay">
0081                 <DetectChar char=")" attribute="Symbol" context="#pop" />
0082 
0083                 <IncludeRules context="Expression" />
0084             </context>
0085 
0086             <context name="Comment Rules" attribute="Normal Text" lineEndContext="#stay">
0087                 <DetectChar char="#" attribute="Comment" context="Comment" />
0088                 <Detect2Chars char="/" char1="*" attribute="Comment" context="Multi-Line Comment" beginRegion="Comment" />
0089             </context>
0090             <context name="Comment" attribute="Comment" lineEndContext="#pop">
0091                 <DetectSpaces attribute="Comment"/>
0092                 <IncludeRules context="##Comments"/>
0093                 <DetectIdentifier attribute="Comment" context="#stay" />
0094             </context>
0095             <context name="Multi-Line Comment" attribute="Comment" lineEndContext="#stay">
0096                 <Detect2Chars char="*" char1="/" attribute="Comment" context="#pop" endRegion="Comment" />
0097                 <IncludeRules context="Comment"/>
0098             </context>
0099 
0100             <context name="String" attribute="String" lineEndContext="#stay">
0101                 <RegExpr String="\\." attribute="Special Char" />
0102                 <DetectChar char="&quot;" attribute="String" context="#pop" />
0103 
0104                 <Detect2Chars char="$" char1="{" attribute="Special Char" context="Interpolated String" />
0105             </context>
0106             <context name="String2" attribute="String" lineEndContext="#stay">
0107                 <RegExpr String="''(?:['$]|\\.)" attribute="Special Char" />
0108                 <Detect2Chars char="'" char1="'" attribute="String" context="#pop" />
0109 
0110                 <Detect2Chars char="$" char1="{" attribute="Special Char" context="Interpolated String" />
0111             </context>
0112             <context name="Interpolated String" attribute="Normal Text" lineEndContext="#stay">
0113                 <DetectChar char="}" attribute="Special Char" context="#pop" />
0114 
0115                 <IncludeRules context="Expression" />
0116             </context>
0117 
0118             <!--
0119                 we don't know whether this is a set { k = v; k1 = v1; ... } or
0120                 the beginning of a function declaration { x1, x2, x3, ... }: ...
0121                 yet
0122             -->
0123             <context name="Any Brace" attribute="Normal Text" lineEndContext="#stay">
0124                 <DetectSpaces />
0125                 <DetectChar char="}" attribute="Symbol" context="#pop" endRegion="Set"/>
0126 
0127                 <WordDetect String="inherit" attribute="Keyword" context="Any Brace - Inherit" />
0128                 <DetectChar char=";" attribute="Symbol" context="#pop!Set" />
0129                 <DetectChar char="=" attribute="Operator" context="Any Brace - Set Value" />
0130                 <DetectChar char="&quot;" attribute="String" context="Any Brace - String" />
0131                 <Detect2Chars char="'" char1="'" attribute="String" context="Any Brace - String2" />
0132 
0133                 <DetectChar char="," attribute="Symbol" context="#pop!Set Expansion" />
0134                 <DetectChar char="?" attribute="Symbol" context="Any Brace - Default Value" />
0135                 <StringDetect String="..." attribute="Symbol" context="#pop!Set Expansion" />
0136 
0137                 <RegExpr String="&ident;" attribute="Identifier" />
0138 
0139                 <IncludeRules context="Comment Rules" />
0140             </context>
0141             <!--
0142                 can't push two contexts so we need separate ones specifically
0143                 for this
0144             -->
0145             <context name="Any Brace - Set Value" attribute="Normal Text" lineEndContext="#stay">
0146                 <DetectChar char=";" attribute="Symbol" context="#pop#pop!Set" />
0147                 <IncludeRules context="Set Value" />
0148             </context>
0149             <context name="Any Brace - String" attribute="Normal Text" lineEndContext="#stay">
0150                 <DetectChar char="&quot;" attribute="String" context="#pop#pop!Set" />
0151                 <IncludeRules context="String" />
0152             </context>
0153             <context name="Any Brace - String2" attribute="Normal Text" lineEndContext="#stay">
0154                 <Detect2Chars char="'" char1="'" attribute="String" context="#pop#pop!Set" />
0155                 <IncludeRules context="String" />
0156             </context>
0157             <context name="Any Brace - Inherit" attribute="Normal Text" lineEndContext="#stay">
0158                 <DetectChar char=";" attribute="Symbol" context="#pop#pop!Set" />
0159                 <IncludeRules context="Inherit" />
0160             </context>
0161             <context name="Any Brace - Default Value" attribute="Normal Text" lineEndContext="#stay">
0162                 <DetectChar char="," attribute="Symbol" context="#pop#pop!Set Expansion" />
0163                 <IncludeRules context="Default Value" />
0164             </context>
0165 
0166             <!-- include for sets and let expressions -->
0167             <context name="Set-Like" attribute="Normal Text" lineEndContext="#stay">
0168                 <DetectChar char="&quot;" attribute="String" context="String" />
0169                 <Detect2Chars char="'" char1="'" attribute="String" context="String2" />
0170                 <DetectChar char="=" attribute="Operator" context="Set Value" />
0171                 <RegExpr String="&ident;" attribute="Identifier" />
0172                 <IncludeRules context="Comment Rules" />
0173             </context>
0174             <context name="Inherit" attribute="Normal Text" lineEndContext="#stay">
0175                 <DetectChar char=";" attribute="Symbol" context="#pop" />
0176                 <IncludeRules context="Single Expression" />
0177             </context>
0178 
0179             <context name="Set" attribute="Normal Text" lineEndContext="#stay">
0180                 <DetectSpaces />
0181                 <DetectChar char="}" attribute="Symbol" context="#pop" endRegion="Set" />
0182                 <WordDetect String="inherit" attribute="Keyword" context="Inherit" />
0183 
0184                 <IncludeRules context="Set-Like" />
0185             </context>
0186             <context name="Set Value" attribute="Normal Text" lineEndContext="#stay">
0187                 <DetectChar char=";" attribute="Symbol" context="#pop" />
0188                 <DetectChar char="}" attribute="Error" context="#pop#pop" endRegion="Set" />
0189 
0190                 <IncludeRules context="Expression" />
0191             </context>
0192 
0193             <context name="Set Expansion" attribute="Normal Text" lineEndContext="#stay">
0194                 <DetectSpaces />
0195                 <DetectChar char="}" attribute="Symbol" context="#pop" endRegion="Set"/>
0196 
0197                 <DetectChar char="," attribute="Symbol" />
0198                 <DetectChar char="?" attribute="Symbol" context="Default Value" />
0199                 <StringDetect String="..." attribute="Symbol" />
0200                 <RegExpr String="&ident;" attribute="Identifier" />
0201                 <IncludeRules context="Comment Rules" />
0202             </context>
0203             <context name="Default Value" attribute="Normal Text" lineEndContext="#stay">
0204                 <DetectChar char="," attribute="Symbol" context="#pop" />
0205                 <DetectChar char="}" attribute="Symbol" context="#pop#pop" />
0206 
0207                 <IncludeRules context="Expression" />
0208             </context>
0209 
0210             <context name="List" attribute="Normal Text" lineEndContext="#stay">
0211                 <DetectChar char="]" attribute="Symbol" context="#pop" endRegion="List" />
0212 
0213                 <IncludeRules context="Single Expression" />
0214             </context>
0215 
0216             <context name="Function" attribute="Normal Text" lineEndContext="#stay">
0217                 <DetectChar char=":" attribute="Symbol" context="#pop" />
0218                 <DetectSpaces attribute="Normal Text" />
0219             </context>
0220 
0221             <context name="Let" attribute="Normal Text" lineEndContext="#stay">
0222                 <DetectSpaces />
0223                 <WordDetect String="in" attribute="Keyword" context="#pop" />
0224 
0225                 <IncludeRules context="Set-Like" />
0226             </context>
0227 
0228             <context name="If" attribute="Normal Text" lineEndContext="#stay">
0229                 <WordDetect String="then" attribute="Keyword" context="#pop!Then" />
0230 
0231                 <IncludeRules context="Expression" />
0232             </context>
0233             <context name="Then" attribute="Normal Text" lineEndContext="#stay">
0234                 <WordDetect String="else" attribute="Keyword" context="#pop" />
0235 
0236                 <IncludeRules context="Expression" />
0237             </context>
0238 
0239             <context name="With" attribute="Normal Text" lineEndContext="#stay">
0240                 <DetectChar char=";" attribute="Symbol" context="#pop" />
0241                 <IncludeRules context="Expression" />
0242             </context>
0243         </contexts>
0244         <itemDatas>
0245             <itemData name="Normal Text" defStyleNum="dsNormal" />
0246             <itemData name="Builtin" defStyleNum="dsBuiltIn" />
0247             <itemData name="Int" defStyleNum="dsDecVal" />
0248             <itemData name="Float" defStyleNum="dsFloat" />
0249             <itemData name="Constant" defStyleNum="dsConstant" />
0250             <itemData name="String" defStyleNum="dsString" />
0251             <itemData name="Special Char" defStyleNum="dsSpecialChar" />
0252             <itemData name="Path" defStyleNum="dsSpecialString" />
0253             <itemData name="Keyword" defStyleNum="dsKeyword" />
0254             <itemData name="Comment" defStyleNum="dsComment" />
0255             <itemData name="Symbol" defStyleNum="dsOperator" />
0256             <itemData name="Operator" defStyleNum="dsOperator" />
0257             <itemData name="Identifier" defStyleNum="dsVariable" />
0258             <itemData name="Error" defStyleNum="dsError" />
0259         </itemDatas>
0260     </highlighting>
0261     <general>
0262         <comments>
0263             <comment name="singleLine" start="#" />
0264             <comment name="multiLine" start="/*" end="*/" region="Comment" />
0265         </comments>
0266         <keywords casesensitive="1" />
0267     </general>
0268 </language>