Fork me on GitHub
#lsp
<
2021-07-12
>
djm05:07:03

I’ve been getting that error too, and have been meaning to ask about it. Thank you for fixing it!

👍 2
ericdallo12:07:45

clojure-lsp Released https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.07.12-12.30.59 with a lot of fixes and improvements 🚀 Editor • Make semantic-tokens return no token for unknown symbols which has `:clj-kondo/unknown-namespace` on its analysis. • Fix file uri location when hovering a symbol. (c/c @brandon.ringe) • Add reference code lens to keyword definitions, e.g. `re-frame.core/reg-sub`. • Add `:semantic-tokens` debug information to `cursor-info` response. API/CLI • Fix corner case when ns form does not match filename. https://github.com/clojure-lsp/clojure-lsp/issues/466 • Fix errors with project-root on graalvm binary • Improve API usage avoiding exceptions and returning just data instead. • Improve analysis cache to multiple API calls. • Add new `--raw` option allowing to display only raw data. Useful to integrate with other tools like https://github.com/reviewdog/reviewdog

🚀 10
🤯 2
clojure-lsp 2
rafaeldelboni14:07:51

Hey I'm using the lsp library to execute format! and clean-ns! together as a deps.edn alias:

:lsp {:extra-paths ["test"]
                 :extra-deps {com.github.clojure-lsp/clojure-lsp {:mvn/version "2021.07.12-12.30.59"}}
                 :main-opts ["-e" "(require,'clojure-lsp.api),{:file-formats (count (:edits (clojure-lsp.api/format! {}))) :ns-cleaned (count (:edits (clojure-lsp.api/clean-ns! {})))}"]}
Is there a better/prettier way to do this?

ericdallo14:07:48

probably having two separate aliases and running like:

clojure -X:clean-ns
clojure -X:format

ericdallo14:07:24

you should use the dry? trueflag

rafaeldelboni14:07:46

in this case I want to replace my lint-fix alias

👍 2
ericdallo14:07:46

to not make changes, unless you really want to make changes hehe

ericdallo14:07:42

why you are counting the edits manually?

rafaeldelboni14:07:44

just to have a visual feedback of what happened, without this it will output all the files and the edits it made

ericdallo14:07:29

hum, maybe we should improve that

rafaeldelboni14:07:31

a helper fn, that does all the lints, or where I could pass what I want to be done via args would be cool 🙂

rafaeldelboni15:07:16

are you open to PRs for a fn like that?

ericdallo15:07:51

even so, the return of the functions may be different :thinking_face:

ericdallo15:07:27

myabe a clean api function that would call format, clean-ns and any other feature that would clean the project

borkdude15:07:44

The newest clojure CLI also supports running multiple functions in a threaded fashion

☝️ 2
ericdallo15:07:17

yeah, maybe that is a better way

borkdude15:07:33

the way to implement this is to receive and return maps

ericdallo15:07:33

even so, you would not be able to get the output of both, probably only one

ericdallo15:07:49

those functions already receive and return maps

borkdude15:07:55

and probably only add to the input map instead of returning a completely new map, so options are preserved for the next function

👍 2
ericdallo15:07:54

yeah, that'd need to be done ☝️

borkdude15:07:13

and use namespaced keywords to avoid conflicts between return values

rafaeldelboni15:07:18

> The newest clojure CLI also supports running multiple functions in a threaded fashion Do you have an example of this?

borkdude15:07:31

Best to ask in #tools-deps

borkdude15:07:36

I haven't used this much yet

ericdallo15:07:58

> and use namespaced keywords to avoid conflicts between return values agree would be better, but that'd make the input to verbose IMO

NoahTheDuke15:07:56

opened a new issue about extra line breaks in documentation hover: https://github.com/clojure-lsp/clojure-lsp/issues/473

ericdallo15:07:49

not sure it's a bug, in lsp-mode/emacs it seems to work:

ericdallo15:07:42

check client <-> server logs and check what is being returned from hover request

NoahTheDuke15:07:02

cool, i’ll do that

NoahTheDuke15:07:02

11:37:24 AM DEBUG [connection] - send to vim: [
  "call",
  "coc#api#call",
  [
    "call_function",
    [
      "coc#float#create_cursor_float",
      [
        0,
        0,
        [
          "web.auth/active-user?",
          "",
          "[user]",
          "---",
          "",
          "Returns the given user if it exists and is not banned",
          "",
          "---",
          "",
          "/Users/noah/Personal/netrunner/src/clj/web/auth.clj",
          "",
          "/Users/noah/Personal/netrunner/src/clj/web/auth.clj: file:///Users/noah/Personal/netrunner/src/clj/web/auth.clj"
        ],
        {
          "pumAlignTop": false,
          "preferTop": false,
          "offsetX": 0,
          "title": "",
          "close": 0,
          "codes": [
            {
              "filetype": "clojure",
              "startLine": 0,
              "endLine": 1
            },
            {
              "filetype": "clojure",
              "startLine": 2,
              "endLine": 3
            }
          ],
          "highlights": [
            {
              "hlGroup": "CocMarkdownLink",
              "lnum": 9,
              "colStart": 0,
              "colEnd": 51
            },
            {
              "hlGroup": "CocMarkdownLink",
              "lnum": 11,
              "colStart": 0,
              "colEnd": 51
            }
          ],
          "modes": [
            "n"
          ],
          "maxWidth": 80,
          "autohide": 1
        }
      ]
    ]
  ],
  -482
]

NoahTheDuke15:07:44

that’s what coc.nvim logs when I call the “hover” lsp command

ericdallo15:07:29

that seems correct, my guess is that coc.nvim is not handling the markdown entire correctly

ericdallo15:07:46

the --- has no \n

ericdallo15:07:08

that's why we add a blank line

ericdallo15:07:21

but nvim is adding a \n on the end of --- probably

ericdallo15:07:42

you can check that getting the markdown form clojure-lsp and pasting in some markdown preview like github

NoahTheDuke15:07:50

looks like it’s joining each string with a \n, which makes it look so awkward

ericdallo15:07:40

yeah, but that's is nvim output, we would need to check the json log between client and server

ericdallo15:07:55

there must be a way to check that on vim

NoahTheDuke15:07:29

ah okay, lemme see what i can pull out

NoahTheDuke15:07:57

well, this is the log from the node backend of coc.nvim i think

ericdallo15:07:15

let me try to check the logs from here

NoahTheDuke15:07:32

ah, this is between coc.nvim and vim, not between coc.vim and lsp, my apologies

👍 2
ericdallo16:07:34

this is what clojure-lsp returns to me:

clojure\nclojure-lsp.handlers/did-open [{:keys [textDocument]}]\n
\n----\n*[/home/greg/dev/clojure-lsp/src/clojure_lsp/handlers.clj](/home/greg/dev/clojure-lsp/src/clojure_lsp/handlers.clj)*

ericdallo16:07:08

Replacing \n with enter:

clojure clojure-lsp.handlers/did-open [{:keys [textDocument]}]
----
*[/home/greg/dev/clojure-lsp/src/clojure_lsp/handlers.clj](/home/greg/dev/clojure-lsp/src/clojure_lsp/handlers.clj)*

ericdallo16:07:14

looks correct to me , WDYT?

ericdallo16:07:33

with a docstring:

clojure clojure-lsp.handlers/did-open [{:keys [textDocument]}]
----
Some docstring here

----
*[/home/greg/dev/clojure-lsp/src/clojure_lsp/handlers.clj](/home/greg/dev/clojure-lsp/src/clojure_lsp/handlers.clj)*

ericdallo16:07:55

there is just one line break after the docstring which doesn seems to be a issue

NoahTheDuke16:07:04

Something funny is definitely happening cuz coc.nvim also strips the markdown links too

ericdallo16:07:46

oh, maybe it doesn have support for markdown?

ericdallo16:07:04

there is a flag that clients should send when they have support to markdown

ericdallo16:07:07

we can confirm that if you manage to get the json log

👍 2
NoahTheDuke16:07:24

Good idea, I’ll look into that. It supports highlighting of some kind cuz the typescript doc window has all sorts of highlighting and links

ericdallo17:07:19

yeah, seems right

ericdallo17:07:51

My guess is that vim is adding the new lines when returning to coc or something like that

NoahTheDuke18:07:50

okay, this took entirely too long because reasons

NoahTheDuke18:07:20

"
clojure\nweb.auth/active-user?\n
\n
clojure\n[user]\n
\n----\nReturns the given user if it exists and is not banned\n\n----\n*[/Users/noah/Personal/netrunner/src/clj/web/auth.clj](file:///Users/noah/Personal/netrunner/src/clj/web/auth.clj)*" 

NoahTheDuke18:07:34

“kind”: “markdown”

ericdallo18:07:01

seems correct to me, probably a issue how vim display the markdown

NoahTheDuke18:07:20

yeah, digging into that now. thanks so much for all the help so far, lol

NoahTheDuke19:07:22

seems it’s some sort of error with how coc.nvim handles markdown, turning it off makes the window a little uglier but much less intrusive

NoahTheDuke19:07:28

thanks for the help

ericdallo19:07:36

Nice, if you open an issue there, please link the clojure-lsp issue one, thanks!

Joshua Suskalo15:07:30

Hey @ericdallo, it's really cool to see you using americano in clojure-lsp! How have you liked it so far? Are there any features you'd like to be added to it to more fully support your usecase?

ericdallo15:07:44

I really liked 😄 it was something I was really missing from deps.edn, I need to confess it was on my personal backlog implement a lib that does that haha

ericdallo15:07:07

I used to use a external jar just for those classes, now I can have it in src-java folder on the same project 🙂

ericdallo15:07:42

I think it's supporting my use case really well, thank you for that!

borkdude15:07:55

ah the Java compilation thing, yeah, that's cool

borkdude15:07:02

it might soon be obsoleted by tools.build though?

Joshua Suskalo15:07:05

Yeah, I made it specifically because I had to do some java compilation for farolero and I saw that nobody had done a java-compilation-as-data library yet. I'm glad it's working out well for you!

👍 2
Joshua Suskalo15:07:26

No, tools.build is java compilation as program, just like badigeon etc. americano is build as data.

borkdude15:07:39

oooh right :)

Joshua Suskalo15:07:11

And the new update to the Clojure CLI actually helps americano even more because you can set up a prep alias, which means you can depend on stuff that compiles java as a source dependency.

Joshua Suskalo15:07:57

Which means once there's wide adoption of that update I can change farolero to do that prep on the user machine and not have a separate artifact for the java.lang.Error class.

borkdude15:07:27

it might even be possible to compile complete Java libraries with this prep thing right

borkdude15:07:41

I mean, why even bother with mvn anymore ;)

❤️ 2
ericdallo15:07:55

that sounds great

Joshua Suskalo15:07:12

Because you can use a RELEASE version in your personal config. ;)

borkdude15:07:36

clj-kondo will frown upon that 😆

Joshua Suskalo15:07:57

Sure, but it's my personal config, not a project dependency. It'd be to keep things like clj-new up to date. 😛

Joshua Suskalo15:07:20

Granted that also kinda goes out the window if we're moving to -T

borkdude15:07:37

yeah, I do this all the time ;)

Joshua Suskalo15:07:05

clj-kondo as a -T tool when? /s

borkdude15:07:12

no, the RELEASE hack ;)

Joshua Suskalo15:07:36

Yeah, I like that. Besides that the only reason I use maven is because it's easier than finding and copying the sha

Joshua Suskalo15:07:09

What I'd really like is a tool which allows me to "add dependency" with a tag version and it'd use rewrite-clj to add a new dependency to the deps.edn which copies the sha for that tag.

borkdude15:07:35

you could even do this with babashka since it has rewrite-clj included. rewrite-edn also works with this as a lib

borkdude15:07:06

and then put this script in your bin folder

borkdude15:07:11

and invoke it from the command line anywhere

ericdallo15:07:12

@U5NCUG8NR there is a clojure-lsp issue for that feature

Joshua Suskalo15:07:38

That's cool, but unfortunately I have never been able to get clojure-lsp to work on my nix machine 😅

Joshua Suskalo15:07:47

So I'd love to have it as a separate tool too.

ericdallo15:07:06

what issues you have with nix? I'm a nixos user as well 🙂

borkdude15:07:06

@ericdallo does clojure-lsp use muslc compilation?

borkdude15:07:09

as in, static?

borkdude15:07:17

then it should work with nix

ericdallo15:07:27

nope, static flag doesn't work yet because of sqlite lib that is not static

ericdallo15:07:43

but @U5NCUG8NR there is a nix derivation

Joshua Suskalo15:07:13

I can try that again and see if it works this time.

ericdallo15:07:43

Actually, I need to bump the derivation to lastest version to work, there was a bug on that release

Joshua Suskalo15:07:58

I love nix in concept but in practice it's given me nothing but pain (possibly because my hobbies include writing game engines, which rely super heavily on loading libraries at runtime)

borkdude15:07:20

> I love nix in concept but in practice it's given me nothing but pain I'm also afraid of this ;)

ericdallo15:07:38

yeah, I had a bad time setupping Unity + emacs on my nixos, but it works 🙂

Joshua Suskalo15:07:46

Oh yeah, I don't use unity. I write my own engines from scratch on top of opengl/vulkan+openal+assimp+several others, which means that for things like opengl/vulkan/openal the implementations have to be able to dynamically load the library from a fixed path on initialization

Joshua Suskalo15:07:20

I eventually got it working with help but it was no fun

ericdallo15:07:14

yeah, that sounds cool and a problem indeed haha

Joshua Suskalo16:07:34

That's not to say I've never used Unity, I have an I enjoyed it, including with Arcadia, but I like having a little more control over how game code is run so now I have my own Clojure game engine which uses its own ECS which uses reducers and other things to increase the concurrency of the engine to make up for some of the performance lost by being mostly purely functional and working in Clojure.

ericdallo16:07:40

yeah. that looks cool but too dificult to me I think 😛

Joshua Suskalo16:07:58

Lol, it's all perspective, I'd have no idea where to start on something like lsp.

Joshua Suskalo16:07:32

Or at the moment, a compiler. I'm trying to finally get my clojure->glsl compiler up to snuff and it's taking a lot of thought to even get started for version 2.

ericdallo16:07:26

hahaha LSP is easy compared to that, but yeah, everything depends on how much time you want spend to understand that thing

ericdallo16:07:55

I spent a lot of time making my dotfiles with nix where I can just change my notebook, run nix and everything is the smae 😛

borkdude16:07:19

I have macOS time-machine for that ;)

borkdude16:07:51

hehe, but I understand the point, nixos is really cool when you have it working

Joshua Suskalo16:07:27

Well to be fair I went to school for games development in C and C++

Joshua Suskalo17:07:37

Taking that knowledge over to Clojure, even with manual memory and resource management, isn't too hard. It's why I'm also planning on building out a library (tentatively named coffi) for using Project Panama to allow transparently calling C functions from Clojure, and passing Clojure functions as C function pointers.

😮 4
borkdude17:07:07

I hope this will work from babashka, that would be pretty cool

Joshua Suskalo17:07:24

As far as I know it should be fine as long as you mark the classes that Panama uses to be included in the graal image. There's a number of different classes needed. I can create an issue with all the classes needed once I get started on it.

Joshua Suskalo17:07:16

Although Graal itself may need to add some support for it, but that'll be a natural part of what happens once they add support for java 17