summaryrefslogtreecommitdiff
path: root/rc/filetype/python.kak
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-05-19 17:16:05 +1000
committerMaxime Coste <mawww@kakoune.org>2020-05-19 17:16:05 +1000
commit5933ab1e780f8f2a51f6580e6fad249beea31698 (patch)
tree75a80a0435689f3f06bd8cd9b0d1b6afc044a593 /rc/filetype/python.kak
parent5fd548d5cfa9a96a247319398654c944eb52a671 (diff)
Split python auto-insert hooks from auto-indent
Diffstat (limited to 'rc/filetype/python.kak')
-rw-r--r--rc/filetype/python.kak7
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