This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-17
Channels
- # announcements (3)
- # babashka (3)
- # beginners (53)
- # biff (2)
- # calva (16)
- # cider (1)
- # clj-commons (1)
- # clj-kondo (97)
- # clj-on-windows (137)
- # clojure (49)
- # clojure-europe (63)
- # clojure-gamedev (1)
- # clojure-nl (2)
- # clojure-norway (50)
- # clojure-uk (4)
- # clojurescript (36)
- # core-async (28)
- # datomic (32)
- # emacs (22)
- # events (1)
- # graalvm (8)
- # honeysql (6)
- # jobs (2)
- # lambdaisland (5)
- # malli (6)
- # nbb (31)
- # off-topic (171)
- # pathom (14)
- # rdf (2)
- # reitit (4)
- # releases (2)
- # scittle (19)
- # shadow-cljs (46)
- # sql (6)
- # squint (6)
I’m trying to live-code a completion by finding the inlined compliment namespaces bundled with my cider and add a defsource
for it:
(cider.nrepl.inlined-deps.compliment.v0v3v12.compliment.sources/defsource ::my-source
:candidates #'candidates
:doc #'doc)
not seeing my candidates function being called though. Has anybody tried this before?fairly confident that it works. can retry myself if needed. @U0DJ4T5U1 was playing with this recently?
hmm, and should I be able to print from the candidates function or should that show up elsewhere (compared to my other print statements)?
sorry for the delay. This works perfectly for me:
(def calls (atom []))
(defn candidates [prefix ns context]
(swap! calls conj [prefix ns context])
[])
(defn doc [s ns]
(swap! calls conj [s ns])
nil)
(blah-blah.compliment/defsource ::foo
:candidates #'candidates
:doc #'doc)
...after hitting m<TAB>
, @calls
will have a "m"
in itso I'd suggest to start by that minimally viable snippet. build your way up iteratively - if it stops working, perhaps Compliment has some sort of try/catch
sorry, took me forever to get back to this. Still can’t get it to work using your snippet, here’s exactly what I have but the calls
atom stays empty. Anything I should be doing except typing in Emacs?
(ns my-custom.completion-source)
(defonce calls (atom []))
(defn candidates [prefix ns context]
(swap! calls conj [prefix ns context])
[])
(defn doc [s ns]
(swap! calls conj [s ns])
nil)
(filter #(clojure.string/includes? (str %) "compliment") (all-ns))
(cider.nrepl.inlined-deps.compliment.v0v3v12.compliment.sources/defsource ::foo
:candidates #'candidates
:doc #'doc)
I'd suggest starting by determining if the issue is client-side (elisp) or server-side. try triggering completions over the clojure repl (no elisp involved) after your source has been defined. Do you see the results you'd normally see in Emacs? After that, have the atoms changed?
the atom stays empty for me too after trying the same code as vemv linked.
would it be possible to do a quick huddle or something on this? I'm guessing there is something obvious i'm missing about getting the right feedback here.
i see completions for m<tab> but the atom doesn't change.
@U5H74UNSF did you get anywhere with this?
if i call the clojure code directly,
(candidates ....)
then obviously the atom gets mutated.
I'm guessing what i'm expecting is for m<tab> to work, but it doesn't because my emacs logic isn't hooked up to complement logic i cloned down. It's been a while sense i messed with this, maybe compliment starts a server and i can tell emacs to talk to it instead of the one created off the code from the official branch.
hey!
no, compliment doesn't create any servers. as indicated by the cider.nrepl.inlined-deps.compliment.v0v3v12
prefix, this namespace is 'inlined' by cider-nrepl. your emacs is only talking to cider-nrepl, through nrepl, through cider.el
> (candidates ....)
then obviously the atom gets mutated.
that's good news. one further experiment you can run is: instead of invoking candidates
(presumably from the Compliment library), invoke the cider-nrepl code that invokes the compliment library.
i.e simulate what cider-nrepl message does when receiving a completion nrepl "op"
(this code is fairly easy to navigate and comprehend - I'd encourage you to take a look since it's exactly what I'd do. I don't know it by heart!)
this is the ns https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/complete.clj , the only non-obvious thing is that the compliment
namespaces get the cider.nrepl.inlined-deps
prefix at CI release time.
was running into this issue today as well. Seems like cider-nrepl
has a strict set of compliment
sources it uses: https://github.com/clojure-emacs/cider-nrepl/blob/804eec7ae73ba2f0f098a57108359f68966a34c8/src/cider/nrepl/middleware/complete.clj#L25-L35
looks like it was included when clj-suitable
support was added (https://github.com/clojure-emacs/cider-nrepl/pull/641) to allow toggling between clj and cljs completion sources.
maybe the filtering could be done by having sources include the languages they work over. Or the :enabled
map entry could be set to false
(https://github.com/alexander-yakushev/compliment/blob/39d444f5d9f15d9ab8499c312e3639c9fc14489d/src/compliment/core.clj#L78)
I'm picking up this thread again. My confusion is about how to make nrepl accept my custom completion source. I tried adding defining a source and then calling init-source as https://github.com/alexander-yakushev/compliment/wiki/Custom-sources, and afterwards emacs isn't autocompleting using that source. It would make sense if the nprel server with the nrepl middleware was already running with the old version of compliment. But I'm probably not capturing the picture correctly here... Do i have to get that source into cider-nrepl inside this https://github.com/clojure-emacs/cider-nrepl/blob/804eec7ae73ba2f0f098a57108359f68966a34c8/src/cider/nrepl/middleware/complete.clj#L25-L35?