1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 23:34:12 +03:00

Change autoshowcompl to auto_complete with insert|prompt possible values

This commit is contained in:
Maxime Coste 2018-07-15 09:45:17 +10:00
parent 58c7b06e1d
commit bde726d034
6 changed files with 36 additions and 15 deletions

View File

@ -78,6 +78,11 @@ change to make Kakoune command model cleaner and more robust.
inserting on the next character, which will be the first character
of the next line.
- `autoshowcompl` options has been renames `auto_complete` and is
now a `flags(insert|prompt)` option, allowing more granular
configuration of when the completions should be displayed
automatically.
== Kakoune 2018.04.13
First official Kakoune release.

View File

@ -166,9 +166,9 @@ are exclusively available to built-in options.
_default_ command|onkey +
display automatic information box in the enabled contexts
*autoshowcompl* `bool`::
_default_ true +
automatically display possible completions when editing a prompt
*auto_complete* `flags(insert|prompt)`::
_default_ insert|prompt +
automatically display possible completions in the enabled modes.
*ignored_files* `regex`::
filenames matching this regex won't be considered as candidates

View File

@ -709,10 +709,10 @@ public:
: InputMode(input_handler), m_prompt(prompt.str()), m_prompt_face(face),
m_empty_text{std::move(emptystr)},
m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)),
m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()},
m_auto_complete{context().options()["auto_complete"].get<AutoComplete>() & AutoComplete::Prompt},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) {
if (m_autoshowcompl and m_refresh_completion_pending)
if (m_auto_complete and m_refresh_completion_pending)
refresh_completions(CompletionFlags::Fast);
if (m_line_changed)
{
@ -880,7 +880,7 @@ public:
}
else if (key == ctrl('o'))
{
m_autoshowcompl = false;
m_auto_complete = false;
clear_completions();
if (context().has_client())
context().client().menu_hide();
@ -1019,7 +1019,7 @@ private:
LineEditor m_line_editor;
bool m_line_changed = false;
PromptFlags m_flags;
bool m_autoshowcompl;
bool m_auto_complete;
bool m_refresh_completion_pending = true;
Timer m_idle_timer;
@ -1078,11 +1078,11 @@ public:
m_restore_cursor(mode == InsertMode::Append),
m_edition(context()),
m_completer(context()),
m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()},
m_auto_complete{context().options()["auto_complete"].get<AutoComplete>() & AutoComplete::Insert},
m_disable_hooks{context().hooks_disabled(), context().hooks_disabled()},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) {
if (m_autoshowcompl)
if (m_auto_complete)
m_completer.update();
context().hooks().run_hook("InsertIdle", "", context());
}}
@ -1267,7 +1267,7 @@ public:
}
else if (key == ctrl('o'))
{
m_autoshowcompl = false;
m_auto_complete = false;
m_completer.reset();
}
else if (key == ctrl('u'))
@ -1433,7 +1433,7 @@ private:
ScopedEdition m_edition;
InsertCompleter m_completer;
const bool m_restore_cursor;
bool m_autoshowcompl;
bool m_auto_complete;
Timer m_idle_timer;
bool m_in_end = false;
MouseHandler m_mouse_handler;

View File

@ -152,6 +152,22 @@ constexpr auto enum_desc(Meta::Type<AutoInfo>)
});
}
enum class AutoComplete
{
None = 0,
Insert = 0b01,
Prompt = 0b10
};
constexpr bool with_bit_ops(Meta::Type<AutoComplete>) { return true; }
constexpr auto enum_desc(Meta::Type<AutoComplete>)
{
return make_array<EnumDesc<AutoComplete>, 3>({
{ AutoComplete::Insert, "insert"},
{ AutoComplete::Prompt, "prompt" }
});
}
bool show_auto_info_ifn(StringView title, StringView info, AutoInfo mask, const Context& context);
void hide_auto_info_ifn(const Context& context, bool hide);

View File

@ -350,9 +350,9 @@ void register_options()
reg.declare_option("autoinfo",
"automatically display contextual help",
AutoInfo::Command | AutoInfo::OnKey);
reg.declare_option("autoshowcompl",
"automatically display possible completions for prompts",
true);
reg.declare_option("auto_complete",
"automatically display possible completions",
AutoComplete::Insert | AutoComplete::Prompt);
reg.declare_option("aligntab",
"use tab characters when possible for alignment",
false);

View File

@ -9,7 +9,7 @@ main() {
kak_commands='
set global autoreload yes
set global autoinfo ""
set global autoshowcompl false
set global auto_complete ""
try %{
exec -save-regs / %{%s%\(\K[^)]+\)<ret>a<backspace><esc>i<backspace><backspace><c-u><esc><a-;>}
} catch %{ exec gg }