As default config I want word autocompletion OFF

Hi, everybody.

I work with text documents, MD and plain text regular everyday-language documents.

I want to start Kakoune without word completions.

According to this solution (Disable autocomplete - #2 by tototest99), I put that setting ( set-option global completers) in my .kakrc file.

But later on, on the same buffer and session, the <C-o> keybind to toggle word autocompletion in Insert mode was not operating as expected. It stops working at all.

In other words, I want to start autocompletion OFF, and activate it on demand.

What is the right way to do it?

It looks like completion defaults to enabled every time you enter Insert mode. If you want completion to be disabled every time you enter Insert mode, it’s pretty easy to make Kakoune press <c-o> for you every time you enter insert mode:

hook global ModeChange push:.*:insert %{
    execute-keys <c-o>
}
1 Like

Thanks, @Screwtapello!

In addition to get an elegant solution, I understand the syntax for hooks for Kakoune a bit more ;D

How do I mark the thread as SOLVED?

set-option global autocomplete prompt works quite well. It does not show any completions until you press C-n in insert mode.

The only thing I would like to tweak is how hide the autocomplete menu after I select which entry I want. Pressing <Esc> exits insert mode. C-o hides the menu but then turns on autocompletion thereafter.

My best option seems to be to keep on typing so that the menu goes away, and to get used to this.

I believe that as long as you’re typing ASCII alphanumeric characters, or characters that (perhaps implicitly) appear in the extra_word_chars option, you’re filtering items in the current completion list. As soon as you type a character outside that set, Kakoune considers that completion session over, and dismisses the menu.

yeah just keep typing. I don’t think it’s about word characters; doc options says this about completions:

Candidates are shown if the text typed by the user (between . and the cursor) is a subsequence of .

Of course most completions don’t have a space so typing a space should be enough.

Also

C-o hides the menu but then turns on autocompletion thereafter.

yeah that seems weird but it’s kinda consistent because <c-n> only requests a one-time completion. I believe you can work around this by pressing <c-o> twice, perhaps even automating this:

hook window InsertCompletionShow .* %{
	map window insert <c-o> <c-o><c-o>
}
hook window InsertCompletionHide .* %{
	unmap window insert <c-o> <c-o><c-o>
}

I guess there is an argument to making this behavior the default (if insert-autocomplete is off), not sure