Predictive Text input for Kakoune

I love that Kakoune is so eager to provide completions in every situation, but the built-in completions that work so well for code (like completing words from other open buffers) don’t work well for prose. Meanwhile, when I have to type things on my phone… well, it’s not a great experience because of the tiny keyboard, but predictive text makes it much, much better than it otherwise would be. I tried straight-up loading the entire contents of /usr/share/dict/words into Kakoune’s completion engine, but that only made things worse - without frequency information, the majority of predictions are just distraction.

So, to get the predictive-text experience I wanted, I made a plugin:

You can enable it on a per-window basis, so you can keep it disabled for buffers where predictive text is not helpful. It also provides predictions on a per-filetype basis, so it won’t predict Python keywords in C++ files.

I just got it working and I’m going to use it for a while to see whether the predictions get more or less helpful over time. If they get less helpful, I might try tweaking it a bit.

Currently, there’s no attempt at dealing with upper-case or lower-case and no English-language assumptions like “the word after a period should start with a capital letter”, it’s all about the sequence of tokens you’d select by pressing b repeatedly.

If you’re not interested in predictive-text specifically, you might be interested in:

7 Likes

I’ve just released a slight update for this plugin that adds an index to the trigrams table. This should make it much more efficient to produce suggestions; my little laptop was beginning to chug if I typed quickly.

2 Likes