2020-04-20 20:15:43 +03:00
|
|
|
## Syntax highlighting for Python.
|
2014-05-17 00:21:34 +04:00
|
|
|
|
2018-02-07 13:25:46 +03:00
|
|
|
syntax python "\.py$"
|
2018-08-28 20:47:40 +03:00
|
|
|
header "^#!.*python"
|
2017-11-19 13:10:53 +03:00
|
|
|
magic "Python script"
|
2016-05-25 23:13:50 +03:00
|
|
|
comment "#"
|
2014-05-12 20:01:57 +04:00
|
|
|
|
2019-11-04 21:52:35 +03:00
|
|
|
linter pyflakes
|
|
|
|
|
2014-05-12 20:01:57 +04:00
|
|
|
# Function definitions.
|
2019-08-17 18:01:19 +03:00
|
|
|
color brightblue "def [0-9A-Za-z_]+"
|
2014-05-12 20:01:57 +04:00
|
|
|
# Keywords.
|
2017-12-10 10:46:02 +03:00
|
|
|
color brightcyan "\<(and|as|assert|async|await|break|class|continue)\>"
|
2018-09-18 23:21:00 +03:00
|
|
|
color brightcyan "\<(def|del|elif|else|except|finally|for|from)\>"
|
2017-12-10 10:46:02 +03:00
|
|
|
color brightcyan "\<(global|if|import|in|is|lambda|nonlocal|not|or)\>"
|
2018-09-18 23:21:00 +03:00
|
|
|
color brightcyan "\<(pass|raise|return|try|while|with|yield)\>"
|
|
|
|
|
|
|
|
# These two are keywords in Python 2, but functions in Python 3,
|
|
|
|
# so only color them when they are followed by whitespace, assuming
|
|
|
|
# that print(x) is a function invocation and print (x) is a statement.
|
|
|
|
color brightcyan "\<(exec|print)([[:blank:]]|$)"
|
2014-05-12 22:10:08 +04:00
|
|
|
|
2018-08-16 20:55:03 +03:00
|
|
|
# Special values.
|
|
|
|
color brightmagenta "\<(False|None|True)\>"
|
|
|
|
|
2019-05-11 18:52:41 +03:00
|
|
|
# Mono-quoted strings.
|
2021-10-26 13:27:15 +03:00
|
|
|
color brightgreen "'([^'\]|\\.)*'|"([^"\]|\\.)*"|'''|""""
|
2019-05-11 18:52:41 +03:00
|
|
|
color normal "'''|""""
|
2015-03-25 16:50:12 +03:00
|
|
|
# Comments.
|
2018-11-03 23:12:44 +03:00
|
|
|
color brightred "(^|[[:blank:]])#.*"
|
2015-12-02 13:29:18 +03:00
|
|
|
# Triple-quoted strings.
|
2021-10-27 12:06:40 +03:00
|
|
|
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
|
|
|
|
color brightgreen start=""""([^"),]|$)" end="(^|[^(\])""""
|
2014-05-12 22:10:08 +04:00
|
|
|
|
|
|
|
# Reminders.
|
2020-04-21 13:47:08 +03:00
|
|
|
color brightwhite,yellow "\<(FIXME|TODO|XXX)\>"
|
2014-03-24 16:45:20 +04:00
|
|
|
|
2014-05-12 20:01:57 +04:00
|
|
|
# Trailing whitespace.
|
2014-03-24 16:45:20 +04:00
|
|
|
color ,green "[[:space:]]+$"
|