Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junolab/fuzzycompletions.jl
Fuzzy completion provider for Julia
https://github.com/junolab/fuzzycompletions.jl
Last synced: 15 days ago
JSON representation
Fuzzy completion provider for Julia
- Host: GitHub
- URL: https://github.com/junolab/fuzzycompletions.jl
- Owner: JunoLab
- License: mit
- Created: 2020-02-27T15:10:17.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T09:31:24.000Z (3 months ago)
- Last Synced: 2024-08-16T10:35:21.081Z (3 months ago)
- Language: Julia
- Homepage:
- Size: 80.1 KB
- Stars: 16
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FuzzyCompletions.jl
`FuzzyCompletions` provides fuzzy completions for a Julia runtime session.
Its API is totally compatible with the standard library module [`REPL.REPLCompletions`](https://github.com/JuliaLang/julia/blob/master/stdlib/REPL/src/REPLCompletions.jl);
so this package can be used as a drop-in replacement for your completion provider.## example
You can make your REPL complete fuzzily with the following code:
```julia
using REPL
using REPL.LineEdit
using FuzzyCompletionsstruct FuzzyCompletionProvider <: REPL.CompletionProvider
mod::Module
endfunction 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
endBase.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-repl
julia> sthing
isnothing something # fuzzy completionsjulia> regex
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.## consumers
Fuzzy completions can be useful within IDE or somewhere some richer UI for showing/selecting completion suggestions is available:
- [Juno](https://junolab.org/): https://github.com/JunoLab/Atom.jl/pull/308
- [Pluto](https://github.com/fonsp/Pluto.jl): https://github.com/fonsp/Pluto.jl/pull/689## acknowledgment
The original idea of the implementation came from [this patch by @pfitzseb](https://github.com/pfitzseb/julia/commit/740dd16843c16cb0b87264911f43abf8485652fe).
## license
This package is under [MIT License](LICENSE.md).