summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-11-20 11:17:13 +0000
committerMaxime Coste <frrrwww@gmail.com>2016-11-20 11:17:13 +0000
commitbe03fdce2a963a4b3e350b4ddc229fffc4c36e6a (patch)
treea19630ce1d659d72fb1f0178381a1dc6cf099615 /src
parentcd8d51af3496ef7f82ab773e241de7168ab5c4b7 (diff)
Support completing hook names
Fixes #879
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 1b869b98..a1c028b4 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -746,11 +746,25 @@ const CommandDesc remove_highlighter_cmd = {
}
};
+static Completions complete_hooks(const Context&, CompletionFlags,
+ const String& prefix, ByteCount cursor_pos)
+{
+ static constexpr auto hooks = {
+ "BufWritePost", "BufWritePre", "FocusIn", "FocusOut",
+ "InsertBegin", "InsertChar", "InsertEnd", "InsertIdle",
+ "InsertKey", "InsertMove", "KakBegin", "KakEnd",
+ "InsertCompletionHide", "InsertCompletionShow",
+ "NormalBegin", "NormalEnd", "NormalIdle", "NormalKey",
+ "RuntimeError", "WinDisplay",
+ };
+ return { 0_byte, cursor_pos, complete(prefix, cursor_pos, hooks) };
+}
+
const CommandDesc add_hook_cmd = {
"hook",
nullptr,
- "hook <switches> <scope> <hook_name> <command>: add <command> in <scope> "
- "to be executed on hook <hook_name>\n"
+ "hook <switches> <scope> <hook_name> <filter> <command>: add <command> in <scope> "
+ "to be executed on hook <hook_name> when its parameter matches the <filter> regex\n"
"scope can be: \n"
" * global: hook is executed for any buffer or window\n"
" * buffer: hook is executed only for the current buffer\n"
@@ -762,7 +776,7 @@ const CommandDesc add_hook_cmd = {
},
CommandFlags::None,
CommandHelper{},
- make_completer(complete_scope, complete_nothing, complete_nothing,
+ make_completer(complete_scope, complete_hooks, complete_nothing,
[](const Context& context, CompletionFlags flags,
const String& prefix, ByteCount cursor_pos)
{ return CommandManager::instance().complete(