babashka / babashka.nrepl

The nREPL server from babashka as a library, so it can be used from other SCI-based CLIs.
Eclipse Public License 1.0
52 stars 15 forks source link

Potentially: return known keywords (symbols?) in complete #55

Open benjamin-asdf opened 2 years ago

benjamin-asdf commented 2 years ago

with bb nrepl. Try to complete some keyword that you know sci already evalved. In jvm cider it gives you all keywords loaded. This behaviour is enjoyable in my opintion. It allows me to for example eval aws/ops once and then have complete for all the keys.

borkdude commented 2 years ago

Sounds good. @ericdallo: does clojure-lsp do a similar thing?

ericdallo commented 2 years ago

Yep, clojure-lsp completion return all known keywords on local buffer and if namespaced/aliased bring it corresponding namespace keywords as well

borkdude commented 2 years ago

Do you mean, if namespaced, then global completions instead of only local buffer?

ericdallo commented 2 years ago

Yes

benjamin-asdf commented 2 years ago

Also :require and such. I'm guessing this will be covered automatically but mentioning it.

benjamin-asdf commented 2 years ago

@borkdude do you have an idea how to go about implementing this?

borkdude commented 2 years ago

In jvm cider it gives you all keywords loaded

How does JVM cider do this?

benjamin-asdf commented 2 years ago

Turns out is depends on https://github.com/alexander-yakushev/compliment it has a namespace for keywords.

(import java.lang.reflect.Field)

(def keywords-table
  (memoize
   (fn []
     (let [^Field field (.getDeclaredField clojure.lang.Keyword "table")]
       (.setAccessible field true)
       (.get field nil)))))
borkdude commented 2 years ago

Oh.. what a gory hack! :)

benjamin-asdf commented 2 years ago

Maybe it is possible to use this compliment library. It seems to be advanced yet small.