rc filetype: add trim-indent hooks to all languages that have indent hooks
An indent hook automatically adds whitespace, so it seems prudent to add the hook to remove unwanted whitespace again. This is what we do in most languages already.
This commit is contained in:
parent
19806a4b4c
commit
6f28178b91
|
@ -11,6 +11,7 @@ hook global BufCreate .*\.v %{
|
||||||
|
|
||||||
hook global WinSetOption filetype=coq %{
|
hook global WinSetOption filetype=coq %{
|
||||||
require-module coq
|
require-module coq
|
||||||
|
hook window ModeChange pop:insert:.* -group coq-trim-indent coq-trim-indent
|
||||||
hook window InsertChar \n -group coq-indent coq-copy-indent-on-newline
|
hook window InsertChar \n -group coq-indent coq-copy-indent-on-newline
|
||||||
|
|
||||||
set-option window static_words %opt{coq_static_words}
|
set-option window static_words %opt{coq_static_words}
|
||||||
|
@ -115,4 +116,12 @@ define-command -hidden coq-copy-indent-on-newline %{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define-command -hidden coq-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ hook global BufCreate .*\.elv %{
|
||||||
hook global WinSetOption filetype=elvish %<
|
hook global WinSetOption filetype=elvish %<
|
||||||
require-module elvish
|
require-module elvish
|
||||||
|
|
||||||
|
hook window ModeChange pop:insert:.* -group elvish-trim-indent elvish-trim-indent
|
||||||
hook window InsertChar \n -group elvish-insert elvish-indent
|
hook window InsertChar \n -group elvish-insert elvish-indent
|
||||||
hook window InsertChar [\]})] -group elvish-insert elvish-deindent
|
hook window InsertChar [\]})] -group elvish-insert elvish-deindent
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elvish-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elvish-.+ }
|
||||||
|
@ -36,6 +37,14 @@ add-highlighter shared/elvish/code/keyword_block regex \}\h+(elif|else|except|fi
|
||||||
|
|
||||||
add-highlighter shared/elvish/code/metachar regex [*?|&\;<>()[\]{}] 0:operator
|
add-highlighter shared/elvish/code/metachar regex [*?|&\;<>()[\]{}] 0:operator
|
||||||
|
|
||||||
|
define-command -hidden elvish-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden elvish-indent %< evaluate-commands -draft -itersel %<
|
define-command -hidden elvish-indent %< evaluate-commands -draft -itersel %<
|
||||||
execute-keys <semicolon>
|
execute-keys <semicolon>
|
||||||
try %<
|
try %<
|
||||||
|
|
|
@ -15,6 +15,7 @@ hook global WinSetOption filetype=fsharp %{
|
||||||
require-module fsharp
|
require-module fsharp
|
||||||
|
|
||||||
# indent on newline
|
# indent on newline
|
||||||
|
hook window ModeChange pop:insert:.* -group fsharp-trim-indent fsharp-trim-indent
|
||||||
hook window InsertChar \n -group fsharp-insert fsharp-insert-on-new-line
|
hook window InsertChar \n -group fsharp-insert fsharp-insert-on-new-line
|
||||||
hook window InsertChar \n -group fsharp-indent fsharp-indent-on-new-line
|
hook window InsertChar \n -group fsharp-indent fsharp-indent-on-new-line
|
||||||
|
|
||||||
|
@ -125,6 +126,14 @@ add-highlighter shared/fsharp/code/ regex "\B(\(\))\B" 0:value
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
define-command -hidden fsharp-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden fsharp-insert-on-new-line %{
|
define-command -hidden fsharp-insert-on-new-line %{
|
||||||
evaluate-commands -draft -itersel %{
|
evaluate-commands -draft -itersel %{
|
||||||
# copy // comments prefix and following white spaces
|
# copy // comments prefix and following white spaces
|
||||||
|
|
|
@ -8,6 +8,7 @@ hook global BufCreate .*/?[jJ]ustfile %{
|
||||||
hook global WinSetOption filetype=justfile %{
|
hook global WinSetOption filetype=justfile %{
|
||||||
require-module justfile
|
require-module justfile
|
||||||
|
|
||||||
|
hook window ModeChange pop:insert:.* -group justfile-trim-indent justfile-trim-indent
|
||||||
hook window InsertChar \n -group justfile-indent just-indent-on-new-line
|
hook window InsertChar \n -group justfile-indent just-indent-on-new-line
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ }
|
||||||
}
|
}
|
||||||
|
@ -23,6 +24,14 @@ provide-module justfile %{
|
||||||
# Indentation
|
# Indentation
|
||||||
# ‾‾‾‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
define-command -hidden justfile-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden just-indent-on-new-line %{
|
define-command -hidden just-indent-on-new-line %{
|
||||||
evaluate-commands -draft -itersel %{
|
evaluate-commands -draft -itersel %{
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
|
|
|
@ -13,6 +13,7 @@ hook global WinSetOption filetype=makefile %{
|
||||||
|
|
||||||
set-option window static_words %opt{makefile_static_words}
|
set-option window static_words %opt{makefile_static_words}
|
||||||
|
|
||||||
|
hook window ModeChange pop:insert:.* -group makefile-trim-indent makefile-trim-indent
|
||||||
hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line
|
hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ }
|
||||||
}
|
}
|
||||||
|
@ -50,6 +51,14 @@ evaluate-commands %sh{
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
define-command -hidden makefile-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden makefile-indent-on-new-line %{
|
define-command -hidden makefile-indent-on-new-line %{
|
||||||
evaluate-commands -draft -itersel %{
|
evaluate-commands -draft -itersel %{
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
|
|
|
@ -14,6 +14,7 @@ hook global BufCreate .*[.](markdown|md|mkd) %{
|
||||||
hook global WinSetOption filetype=markdown %{
|
hook global WinSetOption filetype=markdown %{
|
||||||
require-module markdown
|
require-module markdown
|
||||||
|
|
||||||
|
hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent
|
||||||
hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line
|
hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line
|
||||||
hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line
|
hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ }
|
||||||
|
@ -99,6 +100,14 @@ add-highlighter shared/markdown/inline/text/ regex "\H( {2,})$" 1:+r@meta
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
define-command -hidden markdown-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden markdown-insert-on-new-line %{
|
define-command -hidden markdown-insert-on-new-line %{
|
||||||
try %{ execute-keys -draft -itersel k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
|
try %{ execute-keys -draft -itersel k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ hook global BufCreate .*\.(lpr|lfm)$ %{
|
||||||
|
|
||||||
hook global WinSetOption filetype=((free|object)?pascal|delphi) %[
|
hook global WinSetOption filetype=((free|object)?pascal|delphi) %[
|
||||||
require-module pascal
|
require-module pascal
|
||||||
|
hook window ModeChange pop:insert:.* -group pascal-trim-indent pascal-trim-indent
|
||||||
hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line
|
hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ }
|
||||||
set-option window static_words %opt{static_words}
|
set-option window static_words %opt{static_words}
|
||||||
|
@ -189,6 +190,14 @@ EOF
|
||||||
done
|
done
|
||||||
¶
|
¶
|
||||||
|
|
||||||
|
define-command -hidden pascal-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden pascal-indent-on-new-line %{
|
define-command -hidden pascal-indent-on-new-line %{
|
||||||
evaluate-commands -no-hooks -draft -itersel %{
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
|
|
|
@ -15,6 +15,7 @@ hook global WinSetOption filetype=protobuf %[
|
||||||
|
|
||||||
set-option window static_words %opt{protobuf_static_words}
|
set-option window static_words %opt{protobuf_static_words}
|
||||||
|
|
||||||
|
hook window ModeChange pop:insert:.* -group protobuf-trim-indent protobuf-trim-indent
|
||||||
hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline
|
hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline
|
||||||
hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace
|
hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace
|
||||||
hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace
|
hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace
|
||||||
|
@ -66,6 +67,14 @@ evaluate-commands %sh{
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
define-command -hidden protobuf-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden protobuf-indent-on-newline %~
|
define-command -hidden protobuf-indent-on-newline %~
|
||||||
evaluate-commands -draft -itersel %[
|
evaluate-commands -draft -itersel %[
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
|
|
|
@ -14,6 +14,7 @@ hook global BufCreate .*\.taskpaper %{
|
||||||
hook global WinSetOption filetype=taskpaper %{
|
hook global WinSetOption filetype=taskpaper %{
|
||||||
require-module taskpaper
|
require-module taskpaper
|
||||||
|
|
||||||
|
hook window ModeChange pop:insert:.* -group taskpaper-trim-indent taskpaper-trim-indent
|
||||||
hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line
|
hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ }
|
||||||
}
|
}
|
||||||
|
@ -40,6 +41,14 @@ add-highlighter shared/taskpaper/ regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+))
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
define-command -hidden taskpaper-trim-indent %{
|
||||||
|
evaluate-commands -no-hooks -draft -itersel %{
|
||||||
|
execute-keys <a-x>
|
||||||
|
# remove trailing white spaces
|
||||||
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
define-command -hidden taskpaper-indent-on-new-line %{
|
define-command -hidden taskpaper-indent-on-new-line %{
|
||||||
evaluate-commands -draft -itersel %{
|
evaluate-commands -draft -itersel %{
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user