# 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 '"' (? K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # 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 -group python-highlight global WinSetOption filetype=python %{ addhl ref python } hook global WinSetOption filetype=python %{ hook window InsertChar \n -group python-indent _python_indent_on_new_line # cleanup trailing whitespaces on current line insert end hook window InsertEnd .* -group python-indent %{ try %{ exec -draft \; s ^\h+$ d } } set window formatcmd "autopep8 -" } hook global WinSetOption filetype=(?!python).* %{ rmhl python rmhooks window python-indent }