Fork me on GitHub
#calva
<
2018-12-06
>
iperdomo12:12:50

Last week at the ClojureBridge Bilbao (https://clojurebridge.org/events/2018-12-01-bilbao) I was trying to help some developer with her laptop to configure Calva (as she uses VS Code in her daily job)

iperdomo12:12:49

i followed the instructions, the nREPL server was running and everything but some how the UI was stuck while trying to connect ... 😒

iperdomo12:12:57

after some more debugging (~15min later) i found out that for some reasons she didn't have localhost as 127.0.0.1 in /etc/hosts .... really strange, don't ask me why ...

iperdomo12:12:42

which takes me to the the UI feeling of "Connecting..." and just waiting if something is happening or not ...

Whiskas12:12:04

I saw an extension for re-frame in Emacs

Whiskas12:12:15

maybe we can copy the way it’s done there

iperdomo12:12:24

after checking the Calva code, I noticed the usual pattern/problem of trying to open a connection without a timeout ...

Whiskas12:12:40

Oh, i saw this kind of stuff happening when asking the IDE to jump into a symbol without having a connection to nREPL first, @iperdomo

iperdomo12:12:17

this case was different, after fixing /etc/hosts everything worked just fine

iperdomo12:12:43

I made some changes and I was wondering if this is good enough to write an issue and open a PR - https://gist.github.com/iperdomo/5f24c8bcb5a47262d16847f3f3d74142

iperdomo12:12:11

a failure in connection could have helped me debugging the issue faster, instead of several attempts of enabling/disabling the extension

Whiskas12:12:54

The extension for emacs uses regex to find the keyword in a namespace and it needs that you specify a fully qualifyed keyword

Whiskas12:12:59

like ::login

Whiskas12:12:22

::events/login

pez13:12:33

@iperdomo: Thanks for sharing that information, and thanks for thinking about how Calva could have helped you to quicker pinpoint the problem, I’ll pull that PR right away, if you file it. I am right now looking at the connection scenario and figuring on what a better UI would be. I’d love to speak to others about that as it will be quite a rewrite of how it’s done today either way, because the current code is really hard to maintain.

pez13:12:10

@mateus.pimentel.w does that Emacs extension try to look at the context of the keyword, or does it try to see if any fully qualified keyword corresponds to a an effect etcetera?

Whiskas13:12:03

it kind of just gets the namespace of the keyword and searches for it there ( replacing the ::namespace/keyword by ::keyword )

Whiskas13:12:30

I think it would be better to have a extension that looks at the context tho

Whiskas13:12:59

in calva, the one responsible for finding the definition is cider?

pez13:12:09

Sounds like it could be something one could generalize to work with non-reframe things as well.

Whiskas13:12:26

yeah, that would be a good starting point

Whiskas13:12:42

the person would just need to use fully qualyfied keywords everywhere

pez13:12:13

Yeah, it is cider/nrepl that provides the info op, like @spacemods mentioned the other day.

pez13:12:43

How does that Emacs extension do it? Is it static analysis?

Whiskas13:12:05

:thinking_face:

Whiskas13:12:35

i would need to see the cider implementation to have a clue about how it does?

pez13:12:14

Cider uses nREPL so not static, it is evaluating the code and such.

pez13:12:39

I was asking about that re-frame mode for emacs.

pez13:12:57

(Of course, maybe it is using Cider, for all I know)

pez13:12:27

In the Calva context we can benefit from the fact that we can write stuff in ClojureScript so we can use libraries like rewrite-cljs and stuff to structurally find things in the code, and do not always have to resort to regexps.

iperdomo14:12:06

@pez ok, will open an issue and a PR ... i still need to make sure that i'm able to override those default values with a config ...

pez14:12:11

@iperdomo I don’t think it should be configurable. When things work the connection is instant, so the timeout should be something short.

iperdomo14:12:26

@pez then easier 🙂 ... 30s as default timeout should be enough?

pez14:12:52

Yes, ought to be enough for everyone 😃

iperdomo14:12:16

ok, thanks ...

pez14:12:04

(Don’t know if my paraphrasing of what Bill Gates never said was obvious.)

pez14:12:54

On settings and config: I generally try to avoid to add those whenever I can. It often opens up a can of cases and makes things harder to maintain, and there is always Emacs for people who love to tweak their editor.

👍 1
😀 1
emacs 2
pez14:12:55

(Of course there are also cases when settings make a lot of sense and then I add them.)

iperdomo14:12:05

I use Emacs, and I don't tweak it that much 😉

iperdomo14:12:30

just enough to get CIDER running

iperdomo14:12:54

anyway, I'll log an issue and the PR is comming

pez14:12:11

Yeah, Emacs has a lot going for it besides its immense tweakability.

iperdomo16:12:12

@pez what's the best to package and install my changes locally? I'm new to VS Code

pez16:12:29

@iperdomo assuming you have found the How to Contribute wiki page, and noticed that this piece of info is lacking. 😃 I’ll add it there, but for now. you’ll need the vcse packaging tool. npm install -g vsce, should do it. Then to package the extension run vsce package. It’ll produce a VSIX package that you can then install in VS Code. In the Extensions pane there is a small meatballs-menu with the option to install from local VSIX package. Version you package something “higher” than the current Calva extension and it will not be constantly replaced (In package.json).

iperdomo16:12:14

i found the wiki page, yes, and i managed to run all the steps ... so nothing is complaining

iperdomo16:12:07

many thanks, will try it out

pez16:12:57

One thing that is good to know is that my stupid build script for packaging wipes everything away from under the feet of the watchers, so you need to restart the watchers after a packaging.

iperdomo16:12:58

ok, no worries