Fork me on GitHub
#emacs
<
2021-12-02
>
Drew Verlee00:12:02

i'm able to eval expressions in one file but not another in the same project. my emacs buffers says its connected in one but not the other. I can't imagine how this could be.

practicalli-johnny00:12:37

my only thought is that the file path that contains the non-working namespace is not in the Class Path when starting the REPL process. For example, if I have namespace files under the develop directory (usually user.clj) rather than src, then if I forget to add develop as a class path when starting a REPL I have to restart the REPL and add it.

Drew Verlee01:12:12

It works in intelliji, same ns, same repl.

Drew Verlee01:12:56

its now working after a cider update. [edit] it isn't working everywhere though .

practicalli-johnny06:12:06

Sorry to hear Cider is giving you these challenges.

Drew Verlee00:12:48

it's a shadow cljs project. I use spacemacs. I also live in chicago and i'm a Sagittarius.

😆 3
Drew Verlee00:12:51

My long standing belief was that emacs would have the clojure exp, being written in lisp and used by the most people in the community. I have lost any faith thats the case when working on larger projects.

vemv00:12:16

Clojure tooling projects are definitionally open-ended, have to constantly adapt to an ever changing (if not increasingly fragmented!) landscape. I'm not aware of any project that is, say, flawed by design, even the ones I don't use or like that much have a solid basis. Which is to say, if something doesn't work as it should, it simply needs more work, which happens to be unpaid, and to actually get quite in the way of one's day job :) We can always be the change we want to see in the world. That change can take many shapes: • create high-quality, reproducible issues over Github (which will always take a little more attention than over here) • fund work you are interested in, especially via your employer • contribute PRs fixing/strengthening any issues you may find. Emacs and Clojure are both hackers' tools - they are inspectable and modifiable at runtime. Getting started can be easier than it might seem.

v3ga00:12:54

How long have you been using emacs? I hate to be/sound this way but VS Code or IntelliJ may be the better fit. Emacs is for nerds, not everyone. I...AM A NERD. I'll tinker in emacs all day long, i'll tweak it until I force myself to stop. That brings me great pleasure. There are different types of developers and enthusiasts, those that take on a craft just to pay the bills and some interest and those that do what they like. Emacs is for those that do what they like and don't mind putting in ANY amount of hours towards it. My lord...i'm starting to sound like I belong to another certain lisp family. 👀

👀 1
❤️ 1
vemv00:12:09

Personally I'd be wary of a generalization, I've belonged to a few all-emacs teams and not everyone is necessarily a hardcore tinkerer. Nowadays the distros are "batteries-included" such that one can afford to just use things and focus in the actual work at hand. Sometimes I go whole months without committing a thing to my .emacs (which has existed for some 10y). Other seasons sure, I'll go on a nerdy spree :)

v3ga00:12:17

There's a season for all things, yes. I'll tone it down a bit but i'm very passionate about my email client!

Drew Verlee01:12:22

> create high-quality, reproducible issues over Github (which will always take a little more attention than over here) Here is as specific as i can get, auto completion across namespaces for variables doesn't work on my company project in both doom emacs and spacemacs. Finding references: I'm aware of cider-find-var and lsp. Both fail quite often. Intelliji + cursive and vs code both seem working way to find clojure var references. I have seen it working, at this point its worth the effort to spend hours testing them out to see if they do it constantly. Today i was unable to eval an expression one file/namespace but not a sibling. And i watched a co worker do it using Vscode. using the exact same steps i did. [edit] after updating cider now this is working again. haza?! (im tired)

Drew Verlee01:12:59

sometimes spacemacs just crashes when i move a window.

vemv01:12:01

I won't sugarcoat it, that wasn't specific at all, if you face an issue the best thing you can do is open it over GH detailing your stack, characteristics of your project, what data have you gathered to debug things, etc spacemacs and doom are a double-edged sword, they're powerful but also bit of a mud ball that not many really understand. Nowadays you can get quite far with a 100LOC .emacs which just installs a few core packages, tweaks defcustoms per your liking and that's it. Fewer moving pieces + importantly, less frequent updates (straight.el is interesting in this area - it offers true version pinning via Git. I've used a similar technique for 10y, can't imagine my life otherwise) > ] after updating cider now this is working again. haza?! :)

Drew Verlee01:12:45

But learning how to be specific will take me as much time as switching editors. This is a last ditch cry for help. As in, i need to hear that over some hill people dont live in fear and i can get there quickly.

vemv01:12:57

Who knows, if you create a GH issue, maintainers can help you iterate by asking you specific questions. (Which can theoretically also happen over here, but in practice sync support for free is rare)

Drew Verlee01:12:35

@vemv Where would i post this issue you think? Given my cursor is '*" i expect to see the vars in the re-frame namespace. That is auto-completion. currently i get no results. i'm connected to a repl and can eval expressions.

(ns admin.containers.curriculum.reports.learner
  (:require [re-frame.core :as re-frame]))

(re-frame/*)

Drew Verlee01:12:19

This works in other namespaces at times, in my emacs setup. And always seems to work in intelliji.

vemv01:12:42

the cider repo is fine > And always seems to work in intelliji. FYI it's comparing apples to oranges tbh. I understand the underlying stack is sort of hidden to the user, but completely different stacks are used in one and another IDE. Both have their strengths and weaknesses (as the open count hints here https://github.com/cursive-ide/cursive/issues)

Drew Verlee01:12:05

i'll try to make a ticket that conveys something useful, but to prove how hard that is. Now it works. tomorrow it wont, i would need to somehow capture whats changing.

Drew Verlee02:12:35

My larger point in discussing this was to hear feedback like "oh i work on lots of cljs projects and that never happens" or "yea me to". So i could get a sense of if i was trapped in some local minima. Say, i should ditch spaceamcs and jump on doom or trim evertyhing down to nothing.

vemv02:12:45

> Now it works. tomorrow it wont Yeah it can be hard when you use e.g. spacemacs and updates are sort of a coarse-grained thing AFAICT. Another usual suspect is mixing cider and clojure-lsp, it's not 'forbidden' so to speak but not something that is officially supported/documented either. If you create a GH meta-issue ("how to debug cljs autocompletion when it doesn't work") we can try to get the ball rolling. A good part is that completions can be debugged by evaling vanilla expressions in a normal JVM repl. i.e. it's all Clojure, all runtime-inspectable. You don't need cider.el or nrepl expertise to invoke said Clojure code.

Drew Verlee02:12:41

i would be happy to start with knowing what function is called thats supplying the auto complete. I might seem all whine, but i spent 2 hours trying to figure that out to no avail.

👀 1
vemv02:12:07

> My larger point in discussing this was to hear feedback like Fair enough. Personally I see shadow-cljs problems quite often here, but sadly no GH issues. Sometimes I try to foster that. If people don't follow that indication I'll assume the issue is not important enough for them to bother

vemv02:12:22

> i would be happy to start with knowing what function is called cider-nrepl provides completions. It does so by invoking Compliment which is a clj library. Compliment is based on "sources" i.e. a completion provider. There's a source specifically for cljs completions, provided by a library called clj-suitable cider-nrepl is a vanilla ns. so are Compliment and clj-suitable. However compliment and clj-suitable are prefixed with cider-nrepl-something-something (https://github.com/benedekfazekas/mranderson does that munging) If you invoke (all-ns) you should find cider-nrepl, and the 'munged' versions of compliment and clj-suitable. These are all JVM clojure libs. So jump-to-definition should work. You can take a look around their repos as well

Drew Verlee02:12:26

thanks a lot and for all your hard work. i see you have contributed to a couple of these very projects.

🍻 1
Drew Verlee03:12:24

I made a ticket here https://github.com/clojure-emacs/cider-nrepl/issues/732 The steps to reproduce aren't good. Again, that's part of the issue, these things dont seem to happen on small toy projects.

🙌 1
vemv03:12:18

Thanks much! Please specify over there if you are still perceiving this (given that you indicated that a cider upgrade fixed things). It's also OK to leave the issue open and add a comment whenever you experience flakiness again. But please in the meantime leave things clear for other maintainers to understand.

Drew Verlee03:12:14

The core issue remains, it works inconstantly. It worked in the specific ns. I tried 3 more and found another where it didn't. Here is my professional impression, cljs devs dont expect as much, they aren't reporting as many issues bc js and cljs is more chaotic in general. were basically used to things constantly falling out from underneath us at any time.

👍 1
🙂 1
vemv03:12:03

Is there any plausibly relevant difference between the namespaces where it works and where it doesn't? Do you use "string requires"? Do you have multiple source paths (as opposed to a single src path)? Is the inconsistency itself consistent? e.g. an Emacs buffer for a given .cljs will consistently always or never work, even when repeatedly closing/opening it. (Please answer over GH oc. Also feel free to take your time - definitely a thorough description matters more than 'latency')

👀 1
Drew Verlee03:12:59

> Is there any plausibly relevant difference between the namespaces where it works and where it doesn't? None that i see. No string requies. We do have multiple paths in our deps.edn, but i have an example where one completion works in one ns and not in another and they are in the same path.

Drew Verlee03:12:33

> Is the inconsistency itself consistent? e.g. an Emacs buffer for a given .cljs will consistently always or never work, even when repeatedly closing/opening it. When it doesn't work, it tends to never work in that namespace unless maybe i restart everything, update, etc... When it does work, it works 4/5 times. so there is some root difference between the contexts, it's not probability.

vemv03:12:21

cheers. Please move the last bits of info as part of the description, so that people can see a clear desc (vs. something that might look more like a chat dump)

vemv00:12:16

Clojure tooling projects are definitionally open-ended, have to constantly adapt to an ever changing (if not increasingly fragmented!) landscape. I'm not aware of any project that is, say, flawed by design, even the ones I don't use or like that much have a solid basis. Which is to say, if something doesn't work as it should, it simply needs more work, which happens to be unpaid, and to actually get quite in the way of one's day job :) We can always be the change we want to see in the world. That change can take many shapes: • create high-quality, reproducible issues over Github (which will always take a little more attention than over here) • fund work you are interested in, especially via your employer • contribute PRs fixing/strengthening any issues you may find. Emacs and Clojure are both hackers' tools - they are inspectable and modifiable at runtime. Getting started can be easier than it might seem.

v3ga00:12:54

How long have you been using emacs? I hate to be/sound this way but VS Code or IntelliJ may be the better fit. Emacs is for nerds, not everyone. I...AM A NERD. I'll tinker in emacs all day long, i'll tweak it until I force myself to stop. That brings me great pleasure. There are different types of developers and enthusiasts, those that take on a craft just to pay the bills and some interest and those that do what they like. Emacs is for those that do what they like and don't mind putting in ANY amount of hours towards it. My lord...i'm starting to sound like I belong to another certain lisp family. 👀

👀 1
❤️ 1
Drew Verlee01:12:22

> create high-quality, reproducible issues over Github (which will always take a little more attention than over here) Here is as specific as i can get, auto completion across namespaces for variables doesn't work on my company project in both doom emacs and spacemacs. Finding references: I'm aware of cider-find-var and lsp. Both fail quite often. Intelliji + cursive and vs code both seem working way to find clojure var references. I have seen it working, at this point its worth the effort to spend hours testing them out to see if they do it constantly. Today i was unable to eval an expression one file/namespace but not a sibling. And i watched a co worker do it using Vscode. using the exact same steps i did. [edit] after updating cider now this is working again. haza?! (im tired)

Drew Verlee01:12:11

I just loaded the name space where i can't eval expessions in emacs in intelliji and it just works. thats why i dont think i can use emacs anymore.

Charles Comstock02:12:14

Hey, definitely appreciate that that sounds like a really frustrating problem to have and well worth reporting as an error, but maybe not so constructive to frame it as "therefor I can't use emacs" anymore? If it's not working that is understandably frustrating, and if at the end of the day you decide to switch editors that is certainly a valid decision. However, in this context it comes across less of a request for help (which I presume was your intent), or a bug report and more of an attack on emacs/cider? It sounds like you have had a really tiring day, so appreciate if that wasn't the intent or if things are a feeling a little more dire. All that said, reading between the lines of your problem description, you mention that auto completion only works in some namespaces and that eval was working on some namespaces but not others. I'm not familiar with cursive or the plugin for vs code, but I do know that cider doesn't evaluate the entirety of your project unless you tell it to. So as example if you eval namespace A, but it doesn't require or reference namespace B, you may not have loaded B into the project so the autocomplete may not be aware of it. One way to verify is to load namespace B, eval it, and then go back to A and see if those vars are completing. Likewise, if you haven't evaluated the namespace to force the requires to happen, you often cannot eval individual forms in that namespace. It's quite possible that cursive and vs-code are not using runtime evaluation to reflect the available variables and are using some other mechanism. There are positives and negatives to this approach, but definitely something that can bite you if you are not aware. It's tricky to guess given your explanation but maybe this rings a bell somewhere?

Drew Verlee03:12:44

> One way to verify is to load namespace B, eval it, and then go back to A and see if those vars are completing. Thanks for the suggestion, i would love for this to be the problem. I tried this and it didnt' help. specifically ::file a (ns a (:require [ba :as b]) ;;file b (ns b) (defn blah...) eval file b eval file a b/* I expect b/blah to show up. it doesn't. This works when i try it in intelliji, and i have seen it work in vscode. It works maybe 1/5 times in emacs with cider nrepl. and mysetup.

Drew Verlee03:12:40

> more of an attack on emacs/cider? It isn't, i have and im giving money to the project to help support it because it helps support me. This is a cry for help, and way to voice that either i have a problem or the community does. If its the former then maybe someone can point me to where the grass is greener, if its the later maybe we can fix it together if we talk about it. If i dont' hear anything then i need to move on, i can't afford (literately) to have my tools not be competitive.

Charles Comstock03:12:15

Ok, I'm going to make a simple test project to see if I encounter anything like this

Charles Comstock03:12:46

Just to double check in your example above, did you actually require ba :as b or just b?

Drew Verlee03:12:23

i didn't actually setup something like that. I'm guessing if you make a toy shadow cljs project with something that simple it will work. My guess is that this happens at scale for some reason. If you have worked on large cljs projects and never run into this, that would be a useful data point for me.

Drew Verlee03:12:57

but in my description i did mean [ba :as b]

Charles Comstock03:12:06

Right but the other namespace listed is actually b, not ba, which means it wouldn't work in that case, so was just double checking that if you did ba :as b, the other namespace is ba, or that you require b :as b.

Drew Verlee03:12:27

(ns a (:require [ba :as b])) (b/*)

Charles Comstock03:12:53

is there a namespace ba defined?

Charles Comstock03:12:59

or a namespace b defined

Charles Comstock04:12:21

;; src/test_var_completion/core.clj
(ns test-var-completion.core
  (:require [test-var-completion.dependent :as depend]))

(println depend/a-value)
;; src/test_var_completion/dependent.clj
(ns test-var-completion.dependent)

(def a-value 1)

Drew Verlee04:12:06

i made a github ticket to add in the extra context. https://github.com/clojure-emacs/cider-nrepl/issues/732

Drew Verlee04:12:51

it's hard to say what the failure point is, but im guessing its related to cljs or shadow + emacs + nrepl.

Drew Verlee04:12:16

I never have this issue in a clojure project. But i also end up working more in large cljs codebases.

Charles Comstock04:12:30

Gotcha, yea I'm not familiar with using shadow-cljs. I do use figwheel-main quite frequently on a semi-large project (15kloc of cljs/cljc). There are definitely a few places where the clojurescript support is a little more finicky, but I haven't experienced the issue you are referring to.

Charles Comstock04:12:55

I do think trying to make a minimal shadow-cljs project demonstrating the problem that would really help in diagnosing the issue though!

Charles Comstock04:12:43

Oh one other thing that I noticed somewhere you described the problem as happening when one buffer said it was cider connected and the other did not? Did I understand that correctly?

Drew Verlee04:12:34

see https://github.com/clojure-emacs/cider-nrepl/issues/732 for a toy project where i (hopefully) re-created at least something close to the issue. I'm glad you pushed me to do that. I would also be shocked if it was that easy to trigger and no one else was crying about it. However, im worried ill wake up tomorrow, follow the same instructions, and it will work. no one else will exp it, then the ticket will be closed, and the issues i see constantly and daily will continue to haunt me. 😢

Drew Verlee04:12:36

> Oh one other thing that I noticed somewhere you described the problem as happening when one buffer said it was cider connected and the other did not? Did I understand that correctly? That's correct. I suspect there are a couple of things wonky at once unfortunately. That issue went away after i updated cider (i was on a very recent version though). I suspect it was more about restarting my repl for the 3rd time then the update.

Charles Comstock04:12:06

Yea I don't have any particular solution on the connected buffers issue, but I have experienced something funky there a couple of times, but have always been able to fix it by just forcing a reconnect. It's always really rare though and involved me doing something weird like update cider at the same time, swap between multiple projects. Haven't put my finger on what triggered it, but reconnecting from scratch always fixed it and then never had any issue after. It is frustrating when it happens but it was always weird enough I kinda assumed I got it confused in a wedged state.

Charles Comstock04:12:40

That said, I would definitely report that as a separate issue than the completion. If the buffer is not connected to cider, then all of the niceties will definitely not work.

Drew Verlee04:12:38

> If the buffer is not connected to cider, then all of the niceties will definitely not work. That was the first time that happened and ill consider it a one off unless it comes up again 🙂.

Charles Comstock04:12:07

(just for context I've encountered the cider connection confusion issue maybe every other month or so, and I use it daily so hence why I haven't submitted my own bug report)

Charles Comstock04:12:04

Anyway, I will check in on this later, but hopefully the bug report helps, and even if it does work cleanly tomorrow maybe that will help diagnose it

Drew Verlee01:12:52

• same project • same repl • different editor

Drew Verlee03:12:53

Thanks for the help, everyone. i started this conversation in hash_emacs because i wasn't sure where to go with it. Likely this is a cljs/shadow + cider issue and i have a github ticket for it. https://github.com/clojure-emacs/cider-nrepl/issues/732

Drew Verlee03:12:25

To add context, i'm currently at my third cljs job and in all three i feel constantly hamstrung by inconstant autocompletion and searching (find refs, declaration). The tools are constantly evolving (lsp, cider, etc..) and i have been very diligent in keeping up with those changes, but even now things are very inconsistent. But when i see my co workers use intelliji or vscode, these things just seem to work. Given a small sampling of Intelliji myself, it seems to be the case. Part of me voicing this here is so that we can learn from each other, if your experience has been drastically different please let me know. Share your setup and ill try it. Maybe ill learn its something specific to my project, or computer or whatever.

practicalli-johnny07:12:19

Cursive has been around for many years now and piggy-backed off the Intellij static analysis that had then been around for many more years. I think clojure-lsp has only been very actively worked on in the last year (and now has new releases every few weeks) So Cursive should give a highly polished results every time. I expect clojure-lsp, now that has significant funding from Clojurist Together to quickly catch up to Intellij For now, it you want to jump to definitions, references and all the static analysis based features, then cursive seems the safer choice (as would be paying for a licence to do commercial work with cursive)

Drew Verlee10:12:14

> I expect clojure-lsp, now that has significant funding from Clojurist Together to quickly catch up to Intellij If the analysis is better in LSP then cider, and it works cross platform (clj and cljs) then we should at least give emacs users the option for completion to come lsp right? Even via a function call? Maybe that already exists?

practicalli-johnny12:12:29

Completion does come from LSP if using an LSP client in Emacs along with the specific language server process for the language currently being used (and it's all set up correctly in Emacs + Doom and Spacemacs make this relatively easy)

practicalli-johnny12:12:57

Cider does not so any static analysis as far as I know. Cider understands all the expressions of the project that have been evaluated in a REPL started by Cider or correctly connected to from Cider.

practicalli-johnny12:12:07

For an unfamiliar codebase of noticeable size or complexity, LSP already adds effective navigation through references (and now unit test count). I have used these LSP features effectively for Clojure and basic ClojureScript, but never used shadow-cljs enough to make assessment. Other people are using the same features for other editors (neovim, calva). However the LSP project is relatively new compared to the work done by Intellij (and the developer of cursive) It's therefore much more likely that issues will arise with LSP and many people are contributing bugs and fixes.

Drew Verlee15:12:38

> Completion does come from LSP if using an LSP client in Emacs along with the specific language server process for the language currently being used (and it's all set up correctly in Emacs + Doom and Spacemacs make this relatively easy) I am running the emacs lsp client and Server. vemv suggested completion was coming from cider however. > Cider does not so any static analysis as far as I know. Cider understands all the expressions of the project that have been evaluated in a REPL started by Cider or correctly connected to from Cider. I linked a small example in the GH issue i posted on cider, it didn't matter if i evaled the var i expected to be autocompleted. > For an unfamiliar codebase of noticeable size or complexity, LSP already adds effective navigation through references (and now unit test count). LSP find definition or find reference currently works for me about 3/5 of the time. I can confirm at times it wont find references with a text search. I'll try to make some specific examples modeled around what i'm seeing. What i would be curious about is if it was working more often in VScode.

practicalli-johnny16:12:04

As you may know there is more than one way to do things in Emacs. Cider can generate data for the completions backend as well as an LSP implementation.There is a lot of cross-over between CIDER as an IDE and an LSP client ans server implementation. I suspect there always will be unless there is more investment in Cider. And of course there are also different completion backends. This is why I use Spacemacs, as someone else has worked this out for me. I'll dig out your example from #cider and give it a try.

ericdallo16:12:11

If you manage to reproduce references/definition not working for clojure-lsp, please open an issue with minimal repro

vemv19:12:52

> vemv suggested completion was coming from cider however. depends on whether you're using cider-nrepl + piggieback, or LSP. Both are different stacks. Are you running LSP at all? That would be great info to reflect in your GH issue.

vemv04:12:44

@drewverlee There are a few things that have never been implemented to begin with, as cljs is trickier. Others have been historically slow (e.g. clj-refactor's cljr-slash , which I believe is finally fast again). Around 2017 I was a full-time cljs dev using cider, clj-refactor and figwheel "classic". Nowadays shadow-cljs appears to be more common, and Sesman is part of the mix as well which AFAICT wasn't all that smooth. From that 2017 experience I recall essentially flawless autocompletion and other core features (go to definition, cljr-slash). Definitely enough to get the job done. Probably right now the landscape is a little more complex, but also the codebases are much stronger so a flawless experience as you seek seems definitely possible. A key ingredient is actually making those happen. If nobody contributes / reports issues etc things will naturally degrade.

pez11:12:18

It is not flawless in Calva either, just putting that in here. Agree with @vemv, we need reports about how it works out there and also info about expectations in order to bring things closer to flawlessness. (Contributions towards fixing things are of course also welcome, but the first step is always to know more about problems.)

Drew Verlee15:12:46

Im trying to get a sense of the field. how easy it is to do some common tasks. Git searching clojure evil mode movement etc... Emacs does this to my satisfaction in a lot of areas, which is why i haven't bit the bullet and moved.

pez15:12:21

I think @U07FP7QJ0 started collecting some info about this… Sorry if I miss-remember, Arne, I don’t want to spam you! 😃

plexus09:12:08

maybe you're thinking of this? https://docs.google.com/spreadsheets/d/1PjW5Vaz3-DSTx6fkfHVbwVV5J6cfKq3xttwnwgzNS8Q/edit#gid=0 doesn't quite fit the bill maybe but it can be a starting point

pez13:12:24

Yes, that was it. A piece in the puzzle, hopefully.

Drew Verlee15:12:38

> Completion does come from LSP if using an LSP client in Emacs along with the specific language server process for the language currently being used (and it's all set up correctly in Emacs + Doom and Spacemacs make this relatively easy) I am running the emacs lsp client and Server. vemv suggested completion was coming from cider however. > Cider does not so any static analysis as far as I know. Cider understands all the expressions of the project that have been evaluated in a REPL started by Cider or correctly connected to from Cider. I linked a small example in the GH issue i posted on cider, it didn't matter if i evaled the var i expected to be autocompleted. > For an unfamiliar codebase of noticeable size or complexity, LSP already adds effective navigation through references (and now unit test count). LSP find definition or find reference currently works for me about 3/5 of the time. I can confirm at times it wont find references with a text search. I'll try to make some specific examples modeled around what i'm seeing. What i would be curious about is if it was working more often in VScode.