How to make custom REPL completion?

I would like to create a REPL with customised completion behaviour. Is there a tutorial, API documentations or similar about this somewhere?

A while ago I wanted to have case insensitive completions in the REPL, so I also went to look for how to do this. I could not find any real API for it, so the way I went about it was just to overwrite the existing methods with new ones that had the behaviour I was after. Not a very nice solution, but I got it to do pretty much what I wanted and I used it for a while. Not sure if it still works though with more recent julia versions, since internal things might change and I have not made sure it still aligns with the code I copied back then.

But if you are interested to see how I did that you can always have a look and maybe get some inspiration

1 Like

Have you come across FuzzyCompletions.jl already?


That looks much nicer that what I hacked together. Will give it a try :+1:

There is also an open issue to provide a better API to customize the REPL completions:

But I am not sure, whether anybody is currently working on that.

Maybe I needed something less complex than other people, but for simple cases I eventually worked my way to:

using ReplMaker 
import REPL
import REPL.LineEdit.complete_line
import REPL.LineEdit.CompletionProvider

struct GenericCompletionProvider <: CompletionProvider

function complete_line(x::GenericCompletionProvider, s)
    firstpart = String([1:s.input_buffer.ptr-1])
    return ([x.f(firstpart)], firstpart, true)

initrepl(println; mode_name=:upper, completion_provider=GenericCompletionProvider(uppercase))

If anyone sees any flaws in this, please point them out.

1 Like