Fork me on GitHub
#calva
<
2020-02-26
>
sogaiu00:02:40

i also have an alternative implementation that matches on a regular expression:

(when-let [^js tree (get @trees uri)]
        (let [q (.query @clj-lang
                  (str "((list "
                       "   (symbol) @head "
                       "   (symbol) @name) "
                       " (match? @head \"^def[a-zA-Z]*\"))"))
              ms (.matches q (.-rootNode tree))]
but this is also a hack -- i'm not so sure there is going to be a practical method that can identify everything. at least statically, it seems unlikely unless there is a naming convention everyone follows.

pez05:02:09

In the tmLanguage grammar, that Calva shares with vscode default Clojure extension, and also Atom. There is a similar hack/assumption. In Calva we have adapted it slightly to allow for symbols starting with default: https://github.com/BetterThanTomorrow/calva/blob/master/src/calva-fmt/clojure.tmLanguage.json#L293

otwieracz06:02:41

@sogaiu sorry for lack of understanding, but does it mean you created vscode extension for clojure outline?

pez07:02:36

@slawek098, I happen to be able to answer that. 😃 @sogaiu made a proof of concept for a way to do Clojure grammar in vscode, and as part of that used it to make an outline. So, no, there is no such extension really. Yet.

otwieracz07:02:58

How do you navigate your code?

otwieracz07:02:12

I mean, that's complicated issue in my case.

pez07:02:03

I mostly command click my way around.

otwieracz07:02:53

One, Calva does not support outline (and Ctrl+Shift+O). Second, there are no per-workspace tags (Ctrl+T). Third, only vim keybinding I am able to use without huge perfromance impact is SimpleVim which does not even support / search - useful as last resort for navigation within a file.

otwieracz07:02:07

So I end up opening file an scrolling through it, looking for symbols.

pez07:02:08

Sounds awful. You mean that cmd+f doesn't work?

pez07:02:52

I would love an outline. It will eventually be added. We just need to decide on what tooling we should use, and free some time for it.

otwieracz07:02:22

Actually it does not work by default, because it's conflicting with Ctrl+F from SimpleVim - I had to rebind it to Ctrl+Alt+F.

pez07:02:39

I'm currently testing a thing that @slack1038 baked together, using clojure-lsp, that gives me outline, symbol lookup and workspace wide tags in Calva. It is currently in the POC phase of things, but anyway, there's hope! Let me know if you want to run this build.

otwieracz07:02:21

I believe I can try!

pez07:02:09

Here: https://4103-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.78-feat-lsp-client-73a73615.vsix Things are a bit crazy with nrepl and lsp competing on serving features, but mostly things still work. See Installing VSIX Packages here, if you're not familiar with how its done: https://github.com/BetterThanTomorrow/calva/wiki/Testing-VSIX-Packages#installing-a-vsix-package (It is super easy).

otwieracz07:02:02

OK, I will have a look. Thanks!

otwieracz07:02:23

And how am I expected to use it?

otwieracz07:02:59

Exception in thread "main" java.lang.UnsupportedClassVersionError: clojure_lsp/ClojureExtensions has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 52.0

otwieracz07:02:25

I do not like java 1.8.0?

otwieracz07:02:38

Jdk11 still fails, 56 vs 55

otwieracz08:02:13

But there is no openjdk-12 in Ubuntu.

pez08:02:49

Ah, we should probably compile that jar using Java 1.8... I'll see if I can figure it out.

snoe15:02:41

@pez beware of this if you are compiling yourself on java > 8 https://github.com/snoe/clojure-lsp/pull/89

pez15:02:26

Thanks! I picked your latest release for now. But good to know this!

pez09:02:38

It will take me a while to get the lsp in w/o causing chaos in Calva (mainly because of Calva providing many of the same features). But it is mindblowing how much power you have provided to Clojure coding with this project!

pez09:02:27

There is an issue that you might know something about. With the lsp I get a fix-lightbulb everywhere I place the cursor. The fix it offers is add-missing-libspec, and it doesn't seem to do anything at all.

pez09:02:36

I'll be more than happy to provide a PR. Hooking Calva on lsp will mean much of my dev work will be in the lsp instead of in Calva directly, so I will need to learn how to hack there. 😃

sogaiu08:02:19

@slawek098 pez's summary is accurate -- it's a poc, here is what it looks like

sogaiu08:02:28

depending on what level of accuracy one wants, how much work it might be in calva (or other extension) will likely vary. if you're happy with finding most things then i don't think it should be that much work.

sogaiu08:02:55

the poc also can do jump-to-definition (statically, no repl use) within the file.

sogaiu08:02:20

for jumping to definitions in other files, i use this: https://github.com/sogaiu/alc.index-defs

sogaiu08:02:50

that requires building the index manually but allows one to navigate among things even in one's dependencies (though it doesn't handle interop)

sogaiu08:02:48

this last one uses clj-kondo internally as a library to identify things and has been pretty accurate in my use

sogaiu08:02:14

sorry, if this is off-topic

pez08:02:30

It certainly isn't off topic in this channel.

sogaiu08:02:40

that's nice to hear 🙂

kstehn08:02:28

@pez @slawek098 oh sorry for that i compiled it with adopt openjdk 12 myself i just checkout the clojure-lsp repo and used lein uberjar to get the standalone jar

kstehn08:02:00

with that one there is a small problem with windows thats why i compiled it myself and used a jar instead 😉

pez08:02:31

Ah, what is the small problem?

kstehn08:02:01

that you need to rename the file to .bat at the end otherwise it wont start

pez08:02:26

I renamed it to .jar...

kstehn08:02:56

😮 didnt know that this would work

kstehn08:02:13

i will try this on my machine now

kstehn08:02:40

oh nice it works 😄

otwieracz08:02:35

Will this language server work when connecting to a repl and not starting it (connect vs jack-in)

otwieracz08:02:43

OK, seems like it's working! I will testi t.

otwieracz08:02:19

Do you know if it's possible for Ctrl+T to match common-foobar when typing #common foobar or #foobar common or #foo comm

otwieracz08:02:24

So it's more like fuzzy search

pez09:02:04

I would assume vscode's fuzzy searching is active.

pez09:02:08

Remember that this is just a test build. There will be dragons. It will be quite some work getting it to play nicely in Calva.

orestis09:02:59

Hello wonderful Calva people. I'm trying Calva every now and then and I'm super excited to see how far it progresses, seemingly every week 🙂

orestis09:02:42

One thing that I couldn't find how to do -- I'm used to using the CIDER inspector or most often, the ability to pretty-print the result of an evaluation in a new bugger. Is there a way for Calva to do that?

pez09:02:56

Thanks for those words, @orestis!

otwieracz09:02:58

@pez OK, so defnitely fuzzy search do work in Go to symbol in file but not in Go to symbol in workspace

snoe16:02:38

@slawek098 the code for workspace-symbols is pretty simplistic, fuzzy find there would be nice! https://github.com/snoe/clojure-lsp/blob/master/src/clojure_lsp/handlers.clj#L401

otwieracz17:02:40

@snoe @pez maybe I'd try to work on it - how I can test it? How's clojure-lsp integrated into calva?

snoe17:02:16

@slawek098 it looks like there isn't an existing unit test in clojure-lsp but it would be pretty straightforward, you add "code" to db/db then call (handlers/workspace-symbols "search") to exercise see: https://github.com/snoe/clojure-lsp/blob/b1a561e3b330d56a1c46cf0c737120a18613c715/test/clojure_lsp/handlers_test.clj#L12-L18

otwieracz17:02:42

@snoe I'm rather asking how to test it within VScode

snoe17:02:16

ah, that I'm unsure of.

pez17:02:48

It's probably best to develop it using unit tests. Then to test in Calva would be to follow the regular Calva dev workflow, but replace the clojure-lsp.jar in the root folder.

otwieracz09:02:31

@foobar matches foo-bar

otwieracz09:02:50

#foobar does not match foo-bar

otwieracz09:02:00

#foo-bar matches foo-bar

pez09:02:02

That might be something you can find or report as an issue on clojure-lsp, @slawek098.

pez09:02:07

@orestis, no inspector in Calva yet. I sometimes use the one in clojure. No pretty-print to buffer either. What I do is I hover on the inline result and click the Copy link (there is no visual feedback, but the result is indeed copied). Then paste in a new buffer and set that buffer to be of Clojure type.

👍 4
orestis12:02:53

Works nicely, thanks. The folding behaves interestingly in the case of a seq of maps: Since both the opening paren and the opening bracket are on the same line, you can't fold the first map...

Corneliu Hoffman13:02:22

While we are giving thanks, I am a convert form spacemacs and I love Calva 🙂

❤️ 4
calva 4
otwieracz17:02:40

@snoe @pez maybe I'd try to work on it - how I can test it? How's clojure-lsp integrated into calva?

pez20:02:05

@orestis, maybe try a different pretty printer setting? No clue if any of them do anything different for seqs of maps, but maybe?