mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-25 10:32:19 +03:00
ec16969609
Automatic reparsing of %sh{...}, while convenient in many cases, can be surprising as well, and can lead to security problems: 'echo %sh{ printf "foo\necho bar" }' runs 'echo foo', then 'echo bar'. we make this danger explicit, and we fix the 'nop %sh{...}' pattern. To reparse %sh{...} strings, they can be passed to evaluate-commands, which has been fixed to work in every cases where %sh{...} reparsing was used..
59 lines
1.8 KiB
Plaintext
59 lines
1.8 KiB
Plaintext
# http://ocaml.org
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
# require ocp-indent
|
|
|
|
# Detection
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
hook global BufCreate .*\.mli? %{
|
|
set-option buffer filetype ocaml
|
|
}
|
|
|
|
# Highlighters
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
add-highlighter shared/ regions -default code ocaml \
|
|
string '"' (?<!\\)(\\\\)*" '' \
|
|
comment \Q(* \Q*) '' \
|
|
|
|
add-highlighter shared/ocaml/string fill string
|
|
add-highlighter shared/ocaml/comment fill comment
|
|
|
|
# Commands
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
define-command -hidden ocaml-indent-on-char %{
|
|
evaluate-commands -no-hooks -draft -itersel %{
|
|
execute-keys ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>"
|
|
}
|
|
}
|
|
|
|
# Initialization
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ add-highlighter window ref ocaml }
|
|
|
|
hook global WinSetOption filetype=ocaml %{
|
|
hook window InsertChar [|\n] -group ocaml-indent ocaml-indent-on-char
|
|
}
|
|
|
|
hook -group ocaml-highlight global WinSetOption filetype=(?!ocaml).* %{ remove-highlighter window/ocaml }
|
|
|
|
hook global WinSetOption filetype=(?!ocaml).* %{
|
|
remove-hooks window ocaml-indent
|
|
}
|
|
|
|
# Macro
|
|
# ‾‾‾‾‾
|
|
|
|
evaluate-commands %sh{
|
|
keywords=and:as:asr:assert:begin:class:constraint:do:done:downto:else:end:exception:external:false:for:fun:function:functor:if:in:include:inherit:initializer:land:lazy:let:lor:lsl:lsr:lxor:match:method:mod:module:mutable:new:nonrec:object:of:open:or:private:rec:sig:struct:then:to:true:try:type:val:virtual:when:while:with
|
|
echo "
|
|
add-highlighter shared/ocaml/code regex \b($(printf $keywords | tr : '|'))\b 0:keyword
|
|
hook global WinSetOption filetype=ocaml %{
|
|
set-option window static_words $keywords
|
|
}
|
|
"
|
|
}
|