Skip to content

Fuzzy matching and compliment-style ranking#56

Closed
bbatsov wants to merge 3 commits into
run-static-completion-testsfrom
fuzzy-matching-and-ranking
Closed

Fuzzy matching and compliment-style ranking#56
bbatsov wants to merge 3 commits into
run-static-completion-testsfrom
fuzzy-matching-and-ranking

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 12, 2026

Copy link
Copy Markdown
Member

Stacked on #55 - review/merge that one first (the base retargets to master once it lands).

Two steps toward parity with compliment's Clojure completion:

Fuzzy matching. Completion was prefix-only; compliment matches fuzzily, so pr-fn completes print-function and cs completes clojure.string. Since compliment's core doesn't re-match what a source returns, our prefix filter was the hard ceiling. candidate-match? now uses compliment.utils/fuzzy-matches? with the same per-kind rules compliment uses: .-separated fuzzy for namespaces/classes, --separated fuzzy for vars/macros/etc., and plain prefix for keywords.

Ranking. compliment attaches a :priority to each candidate and sorts by it; ours had none, so everything tied at the bottom and only sorted by length. Candidates now carry the same priorities compliment uses - current-ns vars first, then cljs.core, then namespaces, then classes - with keywords and special forms left unranked.

Both are covered by new tests in the (now actually running, thanks to #55) static suite, green under CLJS 1.11 and 1.12.

  • The commits are consistent with the contribution guidelines
  • You've added tests to cover your change(s)
  • All tests are passing
  • The new code is not generating reflection warnings
  • You've updated the changelog (if adding/changing user-visible functionality)

bbatsov added 3 commits July 12, 2026 12:35
Completion was prefix-only, while compliment matches fuzzily: `pr-fn`
completes `print-function`, `cs` completes `clojure.string`. Since
compliment's core doesn't re-match what a source returns, our prefix
filter was the hard ceiling on this.

candidate-match? now mirrors compliment's per-kind rules via
compliment.utils/fuzzy-matches?: `.`-separated fuzzy for namespaces and
classes, `-`-separated fuzzy for everything var-like, and plain prefix
matching for keywords (which compliment also keeps prefix-only).
compliment attaches a :priority to each candidate (lower sorts first) and
its core sorts the pooled candidates by it; ours had none, so every
candidate landed in the same bottom bucket and only sorted by length.

Candidates now carry the same priorities compliment uses for Clojure: a
var in the current ns first (30), then cljs.core (31), then namespaces
(50 for cljs.*/clojure.*, 51 otherwise), then classes (60). Keywords and
special forms stay unranked, exactly like compliment.
@bbatsov bbatsov deleted the branch run-static-completion-tests July 12, 2026 09:42
@bbatsov bbatsov closed this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant