nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

python.nanorc (1462B)


      1 ## Syntax highlighting for Python.
      2 
      3 syntax python "\.py$"
      4 header "^#!.*python"
      5 magic "Python script"
      6 comment "#"
      7 
      8 # Alternative linter: pylint --exit-zero
      9 linter pyflakes
     10 
     11 # Function definitions.
     12 color brightblue "def [[:alnum:]_]+"
     13 # Keywords.
     14 color brightcyan "\<(and|as|assert|async|await|break|class|continue)\>"
     15 color brightcyan "\<(def|del|elif|else|except|finally|for|from)\>"
     16 color brightcyan "\<(global|if|import|in|is|lambda|nonlocal|not|or)\>"
     17 color brightcyan "\<(pass|raise|return|try|while|with|yield)\>"
     18 
     19 # These two are keywords in Python 2, but functions in Python 3,
     20 # so only color them when they are followed by whitespace, assuming
     21 # that print(x) is a function invocation and print (x) is a statement.
     22 color brightcyan "\<(exec|print)([[:blank:]]|$)"
     23 
     24 # Special values.
     25 color brightmagenta "\<(False|None|True)\>"
     26 
     27 # Decorators.
     28 color cyan "@[[:alpha:]_][[:alnum:]_.]*"
     29 
     30 # Mono-quoted strings.
     31 color brightgreen "'([^'\]|\\.)*'|"([^"\]|\\.)*"|'''|""""
     32 color normal "'''|""""
     33 # Comments.
     34 color brightred "(^|[[:blank:]])#.*"
     35 # Triple-quoted strings.
     36 color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
     37 color brightgreen start=""""([^"),]|$)" end="(^|[^(\])""""
     38 
     39 # Backslash escapes.
     40 color lime "\\($|[\'"abfnrtv]|[0-3]?[0-7]?[0-7]|x[[:xdigit:]]{2})"
     41 color lime "\\(N\{[[:alpha:]]+\}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8})"
     42 
     43 # Reminders.
     44 color brightwhite,yellow "\<(FIXME|TODO|XXX)\>"
     45 
     46 # Trailing whitespace.
     47 color ,green "[[:space:]]+$"