syntax: kvlang: add syntax highlight code for .kv files (#3106)

This commit is contained in:
taconi 2024-03-13 15:00:29 -03:00 committed by GitHub
parent f0bc6281d4
commit fad4e449fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,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: []