# http://python.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](py) %{ set buffer filetype python } # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -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*#\h* y jgh P } # indent after line ending with : try %{ exec -draft k x :$ j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group python-highlight global WinSetOption filetype=python %{ add-highlighter 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 } } } hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter python } hook global WinSetOption filetype=(?!python).* %{ remove-hooks window python-indent }