Add new '_', 'case', and 'match' keywords to Python highlighter

This commit is contained in:
LXNN 2021-10-24 12:56:18 +01:00
parent b7b8dbe150
commit ebcb47e096

View File

@ -106,6 +106,9 @@ evaluate-commands %sh{
finally for global if in is lambda nonlocal not or pass print
raise return try while with yield"
# Collected from `keyword.softkwlist`
soft_keywords="_ case match"
types="bool buffer bytearray bytes complex dict file float frozenset int
list long memoryview object set str tuple unicode xrange"
@ -129,7 +132,7 @@ evaluate-commands %sh{
add-highlighter shared/python/code/ regex '\b($(join "${attributes}" '|'))\b' 0:attribute
add-highlighter shared/python/code/ regex '\bdef\s+($(join "${methods}" '|'))\b' 1:function
add-highlighter shared/python/code/ regex '\b($(join "${exceptions}" '|'))\b' 0:function
add-highlighter shared/python/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword
add-highlighter shared/python/code/ regex '\b($(join "${keywords} ${soft_keywords}" '|'))\b' 0:keyword
add-highlighter shared/python/code/ regex '\b($(join "${functions}" '|'))\b\(' 1:builtin
add-highlighter shared/python/code/ regex '\b($(join "${types}" '|'))\b' 0:type
add-highlighter shared/python/code/ regex '^\h*(@[\w_.]+))' 1:attribute