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

slawek09806: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.

slawek09807:02:58

How do you navigate your code?

slawek09807:02:12

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

pez07:02:03

I mostly command click my way around.

slawek09807: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.

slawek09807: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.

slawek09807: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.

slawek09807: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).

slawek09807:02:02

OK, I will have a look. Thanks!

slawek09807:02:23

And how am I expected to use it?

slawek09807: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

slawek09807:02:25

I do not like java 1.8.0?

slawek09807:02:38

Jdk11 still fails, 56 vs 55

slawek09808: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 šŸ™‚

slack103808: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

pez08:02:02

@slawek098 try this VSIX instead. It uses the lsp jar from Releases in @snoeā€™s repo. https://4123-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.78-feat-lsp-client-01b7a2db.vsix

slack103808: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?

slack103808: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...

slack103808:02:56

šŸ˜® didnt know that this would work

slack103808:02:13

i will try this on my machine now

slack103808:02:40

oh nice it works šŸ˜„

slawek09808:02:03

@pez will try.

slawek09808:02:35

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

slawek09808:02:43

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

slawek09808: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

slawek09808: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!

slawek09809: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

slawek09817: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

slawek09817: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.

slawek09809:02:31

@foobar matches foo-bar

slawek09809:02:50

#foobar does not match foo-bar

slawek09809: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.

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 šŸ™‚

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?