Skip to content

Make static completion context-aware#59

Merged
bbatsov merged 1 commit into
masterfrom
context-aware-completion
Jul 12, 2026
Merged

Make static completion context-aware#59
bbatsov merged 1 commit into
masterfrom
context-aware-completion

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 12, 2026

Copy link
Copy Markdown
Member

The static source discarded the completion context entirely, so it couldn't tell where in the form the cursor sat. It now parses the context once and uses it for two things compliment also does:

  • Inside a (:require [some.ns :refer [__prefix__]]) clause, it completes that namespace's public vars (scoped) instead of the usual grab-bag - so [clojure.string :refer [bl|]] offers blank?, not every bl* in scope.
  • Special forms are only offered at the head of a list, not in argument position.

The refer detection is ported from compliment's vars source but wired to the cljs analyzer for the actual var lookup. I left import-list completion out on purpose - unlike the JVM, cljs has no ready catalog of importable Closure classes to offer, so there's nothing clean to complete against there.

New tests for both, 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)

The source discarded the completion context, so it couldn't tell where in
the form the cursor was. It now parses the context once and uses it for
two things compliment also does:

- inside a (:require [some.ns :refer [__prefix__]]) clause it completes
  that namespace's public vars (scoped), instead of the usual grab-bag
- special forms are only offered at the head of a list, not in argument
  position

The require/refer detection is ported from compliment's vars source but
wired to the cljs analyzer for the actual var lookup. Import-list
completion is intentionally left out - cljs has no ready catalog of
importable Closure classes to offer.
@bbatsov bbatsov merged commit 30eec38 into master Jul 12, 2026
8 of 9 checks passed
@bbatsov bbatsov deleted the context-aware-completion branch July 12, 2026 10:51
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