FuzzyCompletions provides fuzzy completions for a Julia runtime session.

Its API is totally compatible with the standard library module REPL.REPLCompletions; so this package can be used as a drop-in replacement for your completion provider.


You can make your REPL complete fuzzily with the following code:

using REPL
using REPL.LineEdit
using FuzzyCompletions

struct FuzzyCompletionProvider <: REPL.CompletionProvider

function LineEdit.complete_line(c::FuzzyCompletionProvider, s)
  partial = REPL.beforecursor(s.input_buffer)
  full = LineEdit.input_string(s)

  # module-aware repl backend completions
  comps, range, should_complete = completions(full, lastindex(partial), c.mod)
  filter!(c->score(c)0, comps)
  return unique!(FuzzyCompletions.completion_text.(comps)), partial[range], should_complete

Base.active_repl.interface.modes[1].complete = FuzzyCompletionProvider(Main) # or whatever module where you want to get completes from

Then, your REPL will work like

julia> sthing
isnothing something # fuzzy completions

julia> regex<tab>
Regex      RegexMatch # cases doesn't need to match

But I'm sure you will dislike this behavior; we usually want CLI to complete eagerly, not to be an indecisive boy.


Fuzzy completions can be useful within IDE or somewhere some richer UI for showing/selecting completion suggestions is available:


The original idea of the implementation came from this patch by @pfitzseb.


This package is under MIT License.