Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete local bindings for ClojureScript files #766

Closed
iarenaza opened this issue Jan 30, 2023 · 0 comments · Fixed by #767
Closed

Complete local bindings for ClojureScript files #766

iarenaza opened this issue Jan 30, 2023 · 0 comments · Fixed by #767

Comments

@iarenaza
Copy link
Contributor

Expected behavior

When editing a ClojureScript file, CIDER-based completion offers local binding names (the function name and argument names if inside the function, the let-like block bindings if inside a let-like block, etc). Just like it happens when editing a Clojure file.

Actual behavior

It doesn't offer any local binding names as completion candidates. The root of the problem is that cider.nrepl.middleware.complete/cljs-sources only includes ::suitable-sources/cljs-source as a possible source. And suitable doesn't perform any local binding analysis.

But given that the local binding analysis done in compliment.sources.local-bindings namespace doesn't perform any evaluation or execution of the context form (thus it's independent of the actual host platform differences), we can use that same source for ClojureScript local bindings completion. I have tested it locally and it works as expected, without any side effects.

I have a pull request that I will attach in a few minutes implementing the suggested feature.

Steps to reproduce the problem

Create a ClojureScript REPL using you favorite technology (figwheel-main, shadow-cljs, etc), and connect to it. Enable completion in CIDER following the documentation. Make sure you don't have lsp completion enabled (this could mess with CIDER completion).

Once connected, open a .cljs (or .cljc) file and type the following form. Place the cursor where the '|' character is in the form below:

(let [foobar "foobar"
      foobaz "foobaz"]
  |
)

Start typing 'fooba'. The autocompletion feature should offer you both foobar and foobaz as completion candidates (and tell you their kind, that they are variables in this case). But it doesn't (it does in this is a .clj file, and you have an active Clojure REPL connection).

Environment & Version information

CIDER version

1.6.0

cider-nrepl version

0.29.0

nREPL version

1.0.0

Java version

openjdk version "17.0.4" 2022-07-19
OpenJDK Runtime Environment Temurin-17.0.4+8 (build 17.0.4+8)
OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (build 17.0.4+8, mixed mode, sharing)

Operating system

Debian GNU/Linux Bullseye

iarenaza added a commit to iarenaza/cider-nrepl that referenced this issue Jan 30, 2023
When editing a ClojureScript file, cider-nrepl doesn't offer any local
binding names (the function name and argument names if inside the
function, the let-like block bindings if inside a let-like block,
etc.) as completion candidates, like it does when editing a Clojure
file.

The root of the problem is that
`cider.nrepl.middleware.complete/cljs-sources` only includes
`::suitable-sources/cljs-source` as a possible source. And `suitable`
doesn't perform any local binding analysis.

Given that the local binding analysis done in
`compliment.sources.local-bindings` namespace doesn't perform any
evaluation or execution of the context form (thus, it is independent
of the actual host platform differences), we can use that same source
for ClojureScript local bindings completion.

[Closes: clojure-emacs#766]
iarenaza added a commit to iarenaza/cider-nrepl that referenced this issue Jan 31, 2023
When editing a ClojureScript file, cider-nrepl doesn't offer any local
binding names (the function name and argument names if inside the
function, the let-like block bindings if inside a let-like block,
etc.) as completion candidates, like it does when editing a Clojure
file.

The root of the problem is that
`cider.nrepl.middleware.complete/cljs-sources` only includes
`::suitable-sources/cljs-source` as a possible source. And `suitable`
doesn't perform any local binding analysis.

Given that the local binding analysis done in
`compliment.sources.local-bindings` namespace doesn't perform any
evaluation or execution of the context form (thus, it is independent
of the actual host platform differences), we can use that same source
for ClojureScript local bindings completion.

[Closes: clojure-emacs#766]
iarenaza added a commit to iarenaza/cider-nrepl that referenced this issue Jan 31, 2023
When editing a ClojureScript file, cider-nrepl doesn't offer any local
binding names (the function name and argument names if inside the
function, the let-like block bindings if inside a let-like block,
etc.) as completion candidates, like it does when editing a Clojure
file.

The root of the problem is that
`cider.nrepl.middleware.complete/cljs-sources` only includes
`::suitable-sources/cljs-source` as a possible source. And `suitable`
doesn't perform any local binding analysis.

Given that the local binding analysis done in
`compliment.sources.local-bindings` namespace doesn't perform any
evaluation or execution of the context form (thus, it is independent
of the actual host platform differences), we can use that same source
for ClojureScript local bindings completion.

[Closes: clojure-emacs#766]
iarenaza added a commit to iarenaza/cider-nrepl that referenced this issue Jan 31, 2023
When editing a ClojureScript file, cider-nrepl doesn't offer any local
binding names (the function name and argument names if inside the
function, the let-like block bindings if inside a let-like block,
etc.) as completion candidates, like it does when editing a Clojure
file.

The root of the problem is that
`cider.nrepl.middleware.complete/cljs-sources` only includes
`::suitable-sources/cljs-source` as a possible source. And `suitable`
doesn't perform any local binding analysis.

Given that the local binding analysis done in
`compliment.sources.local-bindings` namespace doesn't perform any
evaluation or execution of the context form (thus, it is independent
of the actual host platform differences), we can use that same source
for ClojureScript local bindings completion.

[Closes: clojure-emacs#766]
bbatsov pushed a commit that referenced this issue Jan 31, 2023
When editing a ClojureScript file, cider-nrepl doesn't offer any local
binding names (the function name and argument names if inside the
function, the let-like block bindings if inside a let-like block,
etc.) as completion candidates, like it does when editing a Clojure
file.

The root of the problem is that
`cider.nrepl.middleware.complete/cljs-sources` only includes
`::suitable-sources/cljs-source` as a possible source. And `suitable`
doesn't perform any local binding analysis.

Given that the local binding analysis done in
`compliment.sources.local-bindings` namespace doesn't perform any
evaluation or execution of the context form (thus, it is independent
of the actual host platform differences), we can use that same source
for ClojureScript local bindings completion.

[Closes: #766]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants