diff options
| author | Maxime Coste <mawww@kakoune.org> | 2020-05-19 17:16:05 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2020-05-19 17:16:05 +1000 |
| commit | 5933ab1e780f8f2a51f6580e6fad249beea31698 (patch) | |
| tree | 75a80a0435689f3f06bd8cd9b0d1b6afc044a593 /rc/filetype/python.kak | |
| parent | 5fd548d5cfa9a96a247319398654c944eb52a671 (diff) | |
Split python auto-insert hooks from auto-indent
Diffstat (limited to 'rc/filetype/python.kak')
| -rw-r--r-- | rc/filetype/python.kak | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak index 58854638..0f754a1d 100644 --- a/rc/filetype/python.kak +++ b/rc/filetype/python.kak @@ -16,6 +16,7 @@ hook global WinSetOption filetype=python %{ set-option window static_words %opt{python_static_words} + hook window InsertChar \n -group python-insert python-insert-on-new-line hook window InsertChar \n -group python-indent python-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft <semicolon> <a-x> s ^\h+$ <ret> d } } @@ -142,10 +143,14 @@ add-highlighter shared/python/code/ regex ^\h*(?:from|import)\h+(\S+) 1:module # Commands # ‾‾‾‾‾‾‾‾ -define-command -hidden python-indent-on-new-line %{ +define-command -hidden python-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P } + } +} +define-command -hidden python-indent-on-new-line %{ + evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft <semicolon> K <a-&> } # cleanup trailing whitespaces from previous line |
