mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 14:40:20 +09:00
Fix python decorator syntax. (#2827)
1. Python decorators begin a compound statement, so they only appear at the start of a line. So match at the line start to avoid giving decorator colors to matrix multiplication (@) expressions. Source: https://docs.python.org/3/reference/compound_stmts.html#function-definitions 2. Python decorators go to the end of the line and might not include parentheses (for example @functools.cache). So instead of matching everything until an `(`, just match as many non-`(` characters as possible---which both catches the @functools.cache example and allows decorator parameters to fall back to the default color. 3. Instead of hardcoding `brightgreen` (which railscast.micro also complains about), color decorators as `preproc` (otherwise unused by the python syntax files, and arguably the right colorscheme group to be using for syntactic sugars anyway). Note this will change decorator colors---for example from bright green to kinda brown on monokai, and from yellow to more of a light orange on railscast.
This commit is contained in:
@@ -20,7 +20,7 @@ rules:
|
||||
# keywords
|
||||
- statement: "\\b(and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b"
|
||||
# decorators
|
||||
- brightgreen: "@.*[(]"
|
||||
- preproc: "^\\s*@[^(]*"
|
||||
# operators
|
||||
- symbol.operator: "([~^.:;,+*|=!\\%@]|<|>|/|-|&)"
|
||||
# parentheses
|
||||
|
||||
Reference in New Issue
Block a user