Merge remote-tracking branch '4hnme/master'

This commit is contained in:
Maxime Coste 2024-02-10 21:53:17 +11:00
commit dbefadeb0f

View File

@ -15,6 +15,8 @@ hook global WinSetOption filetype=ocaml %{
require-module ocaml require-module ocaml
set-option window static_words %opt{ocaml_static_words} set-option window static_words %opt{ocaml_static_words}
hook window InsertChar -group ocaml-insert '\*' ocaml-insert-closing-comment-bracket hook window InsertChar -group ocaml-insert '\*' ocaml-insert-closing-comment-bracket
hook window InsertChar \n -group ocaml-insert ocaml-insert-on-new-line
hook window ModeChange pop:insert:.* -group ocaml-trim-indent ocaml-trim-indent
} }
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ hook -group ocaml-highlight global WinSetOption filetype=ocaml %{
@ -99,6 +101,23 @@ define-command ocaml-alternative-file -docstring 'Switch between .ml and .mli fi
} }
# Remove trailing whitespaces
define-command -hidden ocaml-trim-indent %{
evaluate-commands -no-hooks -draft -itersel %{
try %{ execute-keys -draft x s \h+$ <ret> d }
}
}
# Preserve indentation when creating new line
define-command -hidden ocaml-insert-on-new-line %{
evaluate-commands -draft -itersel %{
# copy white spaces at the beginnig of the previous line
try %{ execute-keys -draft k x s ^\h+ <ret> y jgh P x s \h+$ <a-d> }
# increase indentation if the previous line ended with either '=' sign or do keyword
try %{ execute-keys -draft k x s (=|\bdo)$ <ret> j <a-gt> }
}
}
# The OCaml comment is `(* Some comment *)`. Like the C-family this can be a multiline comment. # The OCaml comment is `(* Some comment *)`. Like the C-family this can be a multiline comment.
# #
# Recognize when the user is trying to commence a comment when they type `(*` and # Recognize when the user is trying to commence a comment when they type `(*` and