1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
filetype: "kvlang"
detect:
filename: "\\.kv$"
rules:
# layouts
- special: "\\b[a-z].+"
- identifier: "\\b(self|app|root)\\b"
- type: "\\b[A-Z].+"
- type: "\\b(AnchorLayout|BoxLayout|FloatLayout|RelativeLayout|GridLayout|PageLayout|StackLayout)\\b"
- type: "\\b(canvas)\\b"
# functions
- identifier.function: "[a-zA-Z_0-9]+\\("
# built-in functions
- type: "\\b(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes)\\b"
- type: "\\b(callable|chr|classmethod|compile|copyright|credits|oct)\\b"
- type: "\\b(delattr|dict|dir|display|divmod|enumerate|eval|filter)\\b"
- type: "\\b(float|format|frozenset|get_ipython|getattr|globals|type)\\b"
- type: "\\b(hash|help|hex|id|input|int|isinstance|issubclass|iter|len)\\b"
- type: "\\b(license|list|locals|map|max|memoryview|min|next|object)\\b"
- type: "\\b(open|ord|pow|print|property|range|repr|reversed|round|set)\\b"
- type: "\\b(setattr|slice|sorted|staticmethod|hasattr|super|tuple|str)\\b"
- type: "\\b(vars|zip|exec|sum|complex)\\b"
# keywords
- statement.built_in: "\\b(and|as|assert|async|await|break|class|continue|def)\\b"
- statement.built_in: "\\b(del|elif|else|except|finally|for|from|global|if)\\b"
- statement.built_in: "\\b(import|in|is|lambda|nonlocal|not|or|pass|raise)\\b"
- statement.built_in: "\\b(return|try|while|with|yield|match|case)\\b"
# operators
- symbol.operator: "([~^.:;,+*|=!\\%]|<|>|/|-|&)"
# parentheses
- symbol.brackets: "([(){}]|\\[|\\])"
# numbers
- constant.number: "\\b[0-9](_?[0-9])*(\\.([0-9](_?[0-9])*)?)?(e[0-9](_?[0-9])*)?\\b" # decimal
- constant.number: "\\b0b(_?[01])+\\b" # bin
- constant.number: "\\b0o(_?[0-7])+\\b" # oct
- constant.number: "\\b0x(_?[0-9a-f])+\\b" # hex
- constant.bool.none: "\\b(None)\\b"
- constant.bool.true: "\\b(True)\\b"
- constant.bool.false: "\\b(False)\\b"
# strings
- constant.string:
start: "\""
end: "(\"|$)"
skip: "\\\\."
rules: []
- constant.string:
start: "'"
end: "('|$)"
skip: "\\\\."
rules: []
- comment:
start: "#"
end: "$"
rules: []
|