Merge remote-tracking branch 'krobelus/embrace-menu-2'
This commit is contained in:
commit
e83dbdcd2c
|
@ -143,7 +143,7 @@ If no client is passed then the current one is used' \
|
|||
fi
|
||||
}
|
||||
}
|
||||
complete-command iterm-focus client
|
||||
complete-command -menu iterm-focus client
|
||||
|
||||
alias global focus iterm-focus
|
||||
alias global terminal iterm-terminal-vertical
|
||||
|
|
|
@ -72,7 +72,7 @@ If no client is passed then the current one is used' \
|
|||
fi
|
||||
}
|
||||
}
|
||||
complete-command kitty-focus client
|
||||
complete-command -menu kitty-focus client
|
||||
|
||||
alias global terminal kitty-terminal
|
||||
alias global terminal-tab kitty-terminal-tab
|
||||
|
|
|
@ -6,4 +6,4 @@ The optional arguments are passed as commands to the new client' \
|
|||
terminal kak -c %val{session} -e "%arg{@}"
|
||||
}
|
||||
|
||||
complete-command new command
|
||||
complete-command -menu new command
|
||||
|
|
|
@ -72,7 +72,7 @@ If no client is passed then the current one is used' \
|
|||
fi
|
||||
}
|
||||
}
|
||||
complete-command screen-focus client
|
||||
complete-command -menu screen-focus client
|
||||
|
||||
alias global focus screen-focus
|
||||
alias global terminal screen-terminal-vertical
|
||||
|
|
|
@ -43,7 +43,7 @@ If no client is passed, then the current client is used' \
|
|||
fi
|
||||
}
|
||||
}
|
||||
complete-command sway-focus client
|
||||
complete-command -menu sway-focus client
|
||||
|
||||
unalias global focus
|
||||
alias global focus sway-focus
|
||||
|
|
|
@ -71,7 +71,7 @@ If no client is passed then the current one is used' \
|
|||
fi
|
||||
}
|
||||
}
|
||||
complete-command tmux-focus client
|
||||
complete-command -menu tmux-focus client
|
||||
|
||||
## The default behaviour for the `new` command is to open an horizontal pane in a tmux session
|
||||
alias global focus tmux-focus
|
||||
|
|
|
@ -51,7 +51,7 @@ If no client is passed, then the current client is used' \
|
|||
%{
|
||||
fail 'Focusing specific windows in most Wayland window managers is unsupported'
|
||||
}
|
||||
complete-command wayland-focus client
|
||||
complete-command -menu wayland-focus client
|
||||
|
||||
alias global focus wayland-focus
|
||||
alias global terminal wayland-terminal
|
||||
|
|
|
@ -63,7 +63,7 @@ If no client is passed, then the current client is used' \
|
|||
fi
|
||||
}
|
||||
}
|
||||
complete-command x11-focus client
|
||||
complete-command -menu x11-focus client
|
||||
|
||||
alias global focus x11-focus
|
||||
alias global terminal x11-terminal
|
||||
|
|
|
@ -811,9 +811,12 @@ Completions CommandManager::complete(const Context& context,
|
|||
if (is_switch(token.content))
|
||||
{
|
||||
auto switches = Kakoune::complete(token.content.substr(1_byte), pos_in_token,
|
||||
command.param_desc.switches |
|
||||
transform(&SwitchMap::Item::key));
|
||||
return switches.empty() ? Completions{} : Completions{start+1, cursor_pos, std::move(switches)};
|
||||
concatenated(command.param_desc.switches
|
||||
| transform(&SwitchMap::Item::key),
|
||||
ConstArrayView<String>{"-"}));
|
||||
return switches.empty()
|
||||
? Completions{}
|
||||
: Completions{start+1, cursor_pos, std::move(switches), Completions::Flags::Menu};
|
||||
}
|
||||
if (not command.completer)
|
||||
return Completions{};
|
||||
|
|
|
@ -106,7 +106,7 @@ template<typename Completer>
|
|||
auto add_flags(Completer completer, Completions::Flags completions_flags)
|
||||
{
|
||||
return [completer=std::move(completer), completions_flags]
|
||||
(const Context& context, CompletionFlags flags, const String& prefix, ByteCount cursor_pos) {
|
||||
(const Context& context, CompletionFlags flags, StringView prefix, ByteCount cursor_pos) {
|
||||
Completions res = completer(context, flags, prefix, cursor_pos);
|
||||
res.flags |= completions_flags;
|
||||
return res;
|
||||
|
@ -121,7 +121,7 @@ auto menu(Completer completer)
|
|||
|
||||
template<bool menu>
|
||||
auto filename_completer = make_completer(
|
||||
[](const Context& context, CompletionFlags flags, const String& prefix, ByteCount cursor_pos)
|
||||
[](const Context& context, CompletionFlags flags, StringView prefix, ByteCount cursor_pos)
|
||||
{ return Completions{ 0_byte, cursor_pos,
|
||||
complete_filename(prefix,
|
||||
context.options()["ignored_files"].get<Regex>(),
|
||||
|
@ -180,7 +180,7 @@ auto make_single_word_completer(Func&& func)
|
|||
{
|
||||
return make_completer(
|
||||
[func = std::move(func)](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||
StringView prefix, ByteCount cursor_pos) -> Completions {
|
||||
auto candidate = { func(context) };
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, candidate) }; });
|
||||
}
|
||||
|
@ -193,27 +193,19 @@ const ParameterDesc double_params{ {}, ParameterDesc::Flags::None, 2, 2 };
|
|||
static constexpr auto scopes = { "global", "buffer", "window" };
|
||||
|
||||
static Completions complete_scope(const Context&, CompletionFlags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
StringView prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, scopes) };
|
||||
}
|
||||
|
||||
|
||||
static Completions complete_command_name(const Context& context, CompletionFlags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
StringView prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return CommandManager::instance().complete_command_name(
|
||||
context, prefix.substr(0, cursor_pos));
|
||||
}
|
||||
|
||||
static Completions complete_alias_name(const Context& context, CompletionFlags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos,
|
||||
context.aliases().flatten_aliases()
|
||||
| transform(&HashItem<String, String>::key)) };
|
||||
}
|
||||
|
||||
struct ShellScriptCompleter
|
||||
{
|
||||
ShellScriptCompleter(String shell_script,
|
||||
|
@ -896,7 +888,8 @@ Completions highlighter_cmd_completer(
|
|||
StringView path = params[0];
|
||||
auto sep_it = find(path, '/');
|
||||
if (sep_it == path.end())
|
||||
return { 0_byte, pos_in_token, complete(path, pos_in_token, highlighter_scopes) };
|
||||
return { 0_byte, pos_in_token, complete(path, pos_in_token, highlighter_scopes),
|
||||
Completions::Flags::Menu };
|
||||
|
||||
StringView scope{path.begin(), sep_it};
|
||||
HighlighterGroup* root = nullptr;
|
||||
|
@ -913,7 +906,8 @@ Completions highlighter_cmd_completer(
|
|||
else if (add and token_to_complete == 1)
|
||||
{
|
||||
StringView name = params[1];
|
||||
return { 0_byte, name.length(), complete(name, pos_in_token, HighlighterRegistry::instance() | transform(&HighlighterRegistry::Item::key)) };
|
||||
return { 0_byte, name.length(), complete(name, pos_in_token, HighlighterRegistry::instance() | transform(&HighlighterRegistry::Item::key)),
|
||||
Completions::Flags::Menu };
|
||||
}
|
||||
else
|
||||
return {};
|
||||
|
@ -1064,7 +1058,7 @@ const CommandDesc remove_highlighter_cmd = {
|
|||
};
|
||||
|
||||
static Completions complete_hooks(const Context&, CompletionFlags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
StringView prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, enum_desc(Meta::Type<Hook>{}) | transform(&EnumDesc<Hook>::name)) };
|
||||
}
|
||||
|
@ -1089,7 +1083,7 @@ const CommandDesc add_hook_cmd = {
|
|||
CommandHelper{},
|
||||
make_completer(complete_scope, complete_hooks, complete_nothing,
|
||||
[](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
StringView prefix, ByteCount cursor_pos)
|
||||
{ return CommandManager::instance().complete(
|
||||
context, flags, prefix, cursor_pos); }),
|
||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||
|
@ -1340,6 +1334,14 @@ const CommandDesc define_command_cmd = {
|
|||
define_command
|
||||
};
|
||||
|
||||
static Completions complete_alias_name(const Context& context, CompletionFlags,
|
||||
StringView prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos,
|
||||
context.aliases().flatten_aliases()
|
||||
| transform(&HashItem<String, String>::key))};
|
||||
}
|
||||
|
||||
const CommandDesc alias_cmd = {
|
||||
"alias",
|
||||
nullptr,
|
||||
|
@ -1358,14 +1360,6 @@ const CommandDesc alias_cmd = {
|
|||
}
|
||||
};
|
||||
|
||||
static Completions complete_alias(const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return {0_byte, cursor_pos,
|
||||
complete(prefix, cursor_pos, context.aliases().flatten_aliases() |
|
||||
transform([](auto& entry) -> const String& { return entry.key; }))};
|
||||
}
|
||||
|
||||
const CommandDesc unalias_cmd = {
|
||||
"unalias",
|
||||
nullptr,
|
||||
|
@ -1374,7 +1368,7 @@ const CommandDesc unalias_cmd = {
|
|||
ParameterDesc{{}, ParameterDesc::Flags::None, 2, 3},
|
||||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
make_completer(complete_scope, complete_alias, complete_command_name),
|
||||
make_completer(complete_scope, complete_alias_name, complete_command_name),
|
||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||
{
|
||||
AliasRegistry& aliases = get_scope(parser[0], context).aliases();
|
||||
|
@ -1469,7 +1463,7 @@ const CommandDesc debug_cmd = {
|
|||
CommandHelper{},
|
||||
make_completer(
|
||||
[](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||
StringView prefix, ByteCount cursor_pos) -> Completions {
|
||||
auto c = {"info", "buffers", "options", "memory", "shared-strings",
|
||||
"profile-hash-maps", "faces", "mappings", "regex", "registers"};
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) };
|
||||
|
@ -1787,7 +1781,7 @@ const CommandDesc declare_option_cmd = {
|
|||
CommandHelper{},
|
||||
make_completer(
|
||||
[](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||
StringView prefix, ByteCount cursor_pos) -> Completions {
|
||||
auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-specs", "range-specs", "str-to-str-map"};
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) };
|
||||
}),
|
||||
|
@ -2412,7 +2406,7 @@ const CommandDesc try_catch_cmd = {
|
|||
};
|
||||
|
||||
static Completions complete_face(const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos)
|
||||
StringView prefix, ByteCount cursor_pos)
|
||||
{
|
||||
return {0_byte, cursor_pos,
|
||||
complete(prefix, cursor_pos, context.faces().flatten_faces() |
|
||||
|
@ -2506,7 +2500,7 @@ const CommandDesc set_register_cmd = {
|
|||
CommandHelper{},
|
||||
make_completer(
|
||||
[](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||
StringView prefix, ByteCount cursor_pos) -> Completions {
|
||||
return { 0_byte, cursor_pos,
|
||||
RegisterManager::instance().complete_register_name(prefix, cursor_pos) };
|
||||
}),
|
||||
|
@ -2555,7 +2549,7 @@ const CommandDesc change_directory_cmd = {
|
|||
CommandHelper{},
|
||||
make_completer(
|
||||
[](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||
StringView prefix, ByteCount cursor_pos) -> Completions {
|
||||
return { 0_byte, cursor_pos,
|
||||
complete_filename(prefix,
|
||||
context.options()["ignored_files"].get<Regex>(),
|
||||
|
@ -2702,7 +2696,7 @@ const CommandDesc require_module_cmd = {
|
|||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
make_completer(
|
||||
[](const Context&, CompletionFlags, const String& prefix, ByteCount cursor_pos) {
|
||||
[](const Context&, CompletionFlags, StringView prefix, ByteCount cursor_pos) {
|
||||
return CommandManager::instance().complete_module_name(prefix.substr(0, cursor_pos));
|
||||
}),
|
||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||
|
|
|
@ -75,7 +75,8 @@ Completions HighlighterGroup::complete_child(StringView path, ByteCount cursor_p
|
|||
| transform([](auto& hl) { return hl.value->has_children() ? hl.key + "/" : hl.key; })
|
||||
| gather<Vector<String>>());
|
||||
|
||||
return { 0, 0, std::move(candidates) };
|
||||
auto completions_flags = group ? Completions::Flags::None : Completions::Flags::Menu;
|
||||
return { 0, 0, std::move(candidates), completions_flags };
|
||||
}
|
||||
|
||||
void Highlighters::highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range)
|
||||
|
|
|
@ -2089,7 +2089,8 @@ public:
|
|||
}
|
||||
|
||||
auto container = m_regions | transform(&decltype(m_regions)::Item::key);
|
||||
return { 0, 0, complete(path, cursor_pos, container) };
|
||||
auto completions_flags = group ? Completions::Flags::None : Completions::Flags::Menu;
|
||||
return { 0, 0, complete(path, cursor_pos, container), completions_flags };
|
||||
}
|
||||
|
||||
static std::unique_ptr<Highlighter> create(HighlighterParameters params, Highlighter*)
|
||||
|
|
Loading…
Reference in New Issue
Block a user