# http://python.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufSetOption mimetype=text/x-python %{ set buffer filetype python } hook global BufCreate .*[.](py) %{ set buffer filetype python } # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ addhl -group / regions -default code python \ double_string '"""' '"""' '' \ single_string "'''" "'''" '' \ double_string '"' (?' 0:value addhl -group /python/code regex '\<(${meta//:/|})\>' 0:meta addhl -group /python/code regex '\<(${keywords//:/|})\>' 0:keyword " # Highlight types, when they are not used as constructors echo "addhl -group /python/code regex '\<(${types//:/|})\>[^(]' 1:type" } # Commands # ‾‾‾‾‾‾‾‾ def -hidden _python_indent_on_new_line %{ eval -draft -itersel %{ # preserve previous line indent try %{ exec -draft K } # filter previous line try %{ exec -draft k : _python_filter_around_selections } # copy '#' comment prefix and following white spaces try %{ exec -draft k x s ^\h*\K#\h* y j p } # indent after : try %{ exec -draft k x :$ j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=python %{ addhl ref python hook window InsertChar \n -group python-indent _python_indent_on_new_line set window formatcmd "autopep8 -" } hook global WinSetOption filetype=(?!python).* %{ rmhl python rmhooks window python-indent }