Fork me on GitHub
#lsp
<
2021-10-20
>
Joshua Suskalo01:10:40

how do I disable the unused-public-var linter?

Joshua Suskalo01:10:52

yeah, thanks!

👍 2
simonkatz09:10:26

Is there something I can read that will give me an understanding of sessions and workspaces? One thing in particular I’m wondering about is the file .emacs.d/.lsp-session-v1 and how things work with multiple Emacs instances.

ericdallo12:10:24

Not sure there is something to read about that, this is a particularity in lsp-mode

ericdallo12:10:01

Maybe a section on lsp-mode explaining it would be good

ericdallo13:10:46

I suggest you request that on emacs-lsp discord channel https://discord.gg/swuxy5AAgT

simonkatz13:10:25

OK; thanks Eric.

andrea.crotti13:10:30

I was trying to speed up the lsp reformatting and this time I knew exactly the namespaces (just 5-6)

andrea.crotti13:10:54

the initial clj-kondo analysis phase seems to take as long as without specifying the namespaces, is that normal?

ericdallo13:10:14

yes, because we need to scan the whole project

ericdallo13:10:51

even if you pass one or 2 namespaces, it could be something on classpath that may change the diagnostics or something else for those namespaces

ericdallo13:10:31

@U0524T275 after fixing the unknown namespaces, it should be faster

andrea.crotti13:10:02

ah yeah sure makes sense

andrea.crotti13:10:22

unfortunately inside the work network I can't build clojure-lsp

andrea.crotti13:10:28

so still e to use the older version

ericdallo13:10:37

I just released a new version with your fix :)

andrea.crotti13:10:52

nice I'll get it then

mpenet13:10:20

is there a way to see the clojure-lsp version in use from emacs?

mpenet13:10:01

lsp-clojure-server-info

☝️ 1
andrea.crotti13:10:12

Ah well I juit call clojure-lsp --version

ericdallo13:10:21

It works too ☝️

andrea.crotti13:10:23

I guess if there only one executable available it will use that one

ericdallo13:10:18

clojure-lsp Released clojure-lsp 2021.10.20-13.04.11 with more fixes, performance improvements and new features! • General ◦ Improve intialization feedback report messages. ◦ Consider `dev` and `test` alias for deps.edn projects as project-specs during classpath lookup. https://github.com/clojure-lsp/clojure-lsp/issues/586 ◦ Avoid scanning source-paths twice, as it was being considered as part of external classpath as well. ◦ Change cache db from sqlite to datalevin for faster startup + better graalvm compatibility. ◦ Make the cache analysis save async to make startup faster. ◦ Support Auto refresh settings memoizing with a ttl of 1 second avoiding the need of restarting server when changing configs. https://github.com/clojure-lsp/clojure-lsp/issues/502 ◦ Bump clj-kondo adding new `gen-class` linter and other fixes/improvements. Fixes https://github.com/clojure-lsp/clojure-lsp/issues/589 ◦ Remove unused duplicate require if any. https://github.com/clojure-lsp/clojure-lsp/issues/527 ◦ Fix crash on clean-ns when ns contains comments. ◦ Improve project analysis filter to check source-paths. https://github.com/clojure-lsp/clojure-lsp/issues/597 • Editor ◦ Add reference code lens for ns forms. https://github.com/clojure-lsp/clojure-lsp/issues/578 ◦ Fix expand-let bug that occurs when a list form precedes let. https://github.com/clojure-lsp/clojure-lsp/pull/590 ◦ Add new command to create test for function at point. https://github.com/clojure-lsp/clojure-lsp/issues/582 ◦ Add new code action to create test for current function/var ◦ Add `private` to documentSymbol to make clear that a var or function is `private`. ◦ Add new code action `Suppress xxx diagnostic`, adding clj-kondo comment code to ignore the diagnostic. https://github.com/clojure-lsp/clojure-lsp/issues/591 ◦ Add more semantic tokens: aliases for macros, variable and function definitions. ◦ Add https://clojuredocs.org/ information during symbol hover. https://github.com/clojure-lsp/clojure-lsp/issues/571 Probably one of the major changes is the replace of sqlite with #datalevin as the analysis cache db implementation, improving the clojure-lsp startup, thank you @huahaiy for the huge help on this! 🚀 Also, we have https://clojuredocs.org/ integration 🎉 showing docs, examples, notes and see-alsos of symbols directly on your editor when hovering a symbol! Have a great code ;)

aw_yeah 2
catjam 2
borkdude14:10:12

@ericdallo How does one get the clojuredocs on hover?

ericdallo14:10:57

when clojure-lsp starts it requests and cache clojuredocs, so when you hover it tries to find the symbol on that cache

borkdude14:10:25

yes, but how? I don't see this

borkdude14:10:32

do I need some emacs plugin?

ericdallo14:10:48

Oh, got it, there are some ways to get documentation on lsp-mode:

ericdallo14:10:24

via the most common lsp-ui-doc-show

ericdallo14:10:11

but there is a better way IMO which show in a buffer

ericdallo14:10:33

I'm trying to remember the emacs command, I use all the time but on doom-emacs which is just K 😂

borkdude14:10:47

you can request the help for this keybinding

ericdallo14:10:06

yeah, but it calls a doom function which down there will call this lsp-mode command

ericdallo14:10:33

it's a eldoc integration

borkdude14:10:08

I'll just use Calva :P

😂 1
ericdallo14:10:49

this is the eldoc hover:

borkdude14:10:17

but how do I get this?

ericdallo14:10:49

yeah, I'm searching, I think lsp-mode just add a hook to eldoc, so you just need to call eldoc, let me check

borkdude14:10:19

I'm also always having trouble with lsp thinking that it needs to index my entire /tmp folder when I'm testing things in /tmp/test-project, even when I have a /tmp/test-project/.clj-kondo

ericdallo14:10:45

you can ignore that folder or remove it lsp-workspace-folders-remove

borkdude14:10:53

yes I did :)

borkdude14:10:09

but it still won't think that /tmp/test-project is the project root

borkdude14:10:18

isn't there something like: choose project root?

ericdallo14:10:25

you can type I to choose interactively

ericdallo14:10:35

you first remove the project root

borkdude14:10:43

I where and when?

ericdallo14:10:52

then next time lsp kicks in, it should prompt a message to choose the project root

ericdallo14:10:59

you type I and then choose the root

borkdude14:10:46

ok that worked

ericdallo14:10:31

about the hover, doom seems to do a lot of magic, I really don't know how to do that on emacs vanilla :(

ericdallo14:10:48

I suspect it calls eldoc and then open a buffer with its content

borkdude14:10:30

it still asks me to import a project every time I visit another file in this project

borkdude14:10:37

it happens to me every time I have a project in /tmp

borkdude14:10:02

with lsp-ui I now see the docs, but not anything from clojuredocs I think

ericdallo14:10:57

yeah it's fallbacking to the one without clojruedocs

ericdallo14:10:27

hum, maybe the request to get the cache failed when starting clojure-lsp?

anonimitoraf14:10:35

I don't see clojuredocs in doom's +lookup/documentation either (the eldoc thing)

ericdallo14:10:39

even so, it should do a async request the next time

ericdallo14:10:03

oh, it could be a missing reflect config on graalvm, let me check

borkdude14:10:20

*warn-on-reflection* perhaps?

ericdallo14:10:33

I didn't have time to create a integration test for that yet 😔

ericdallo14:10:49

Yeah, maybe I missed add *warn-on-reflection* on the new ns

ericdallo14:10:01

Yeah I missed facepalm

borkdude14:10:40

you can also do it like this: -e "(set! *warn-on-reflection true)" -m "clojure-lsp.main"

ericdallo14:10:41

no warnings though after adding it :thinking_face:

borkdude14:10:47

then it will be globally on I think

ericdallo14:10:57

I'll test the native image, 1 sec

ericdallo14:10:25

damm need of adding extra-protocols

borkdude14:10:59

oh yes, that

lread14:10:11

Also: unimportant typo in the screenshot? "Error refreshing clojruedocs"

ericdallo14:10:31

yeah 😂 tks

👍 1
❤️ 2
ericdallo14:10:25

I'm testing the image and should release soon a fix

pez20:10:40

> I’ll just use Calva 😛 😃 This will only work while the REPL is not connected. I’m working on it!

👍 1
pez15:10:35

Trying to run the clojure-lsp server in some kind of development mode. development.md says I can do this, but I can’t:

% clj -X:debug-jar && clj -X:bin
Compiling clojure-lsp.main ...
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:436).
clojure_lsp.ClojureExtensions

Full report at:
/var/folders/t5/gqxhj8pd6p9_tnvy6sbtmy480000gn/T/clojure-14345845008648981829.edn

Compilation failed!
Execution error (ExceptionInfo) at hf.depstar.uberjar/build-jar-as-exec (uberjar.clj:554).
AOT compilation failed

Full report at:
/var/folders/t5/gqxhj8pd6p9_tnvy6sbtmy480000gn/T/clojure-13972972892988954623.edn

ericdallo15:10:02

Probably the docs are missing say you need to clojure -X:javac

pez15:10:28

I have also tried some variants on

% clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.8.3"},cider/cider-nrepl {:mvn/version,"0.26.0"}}}' -A:debug:bin -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
WARNING: Implicit use of clojure.main with options is deprecated, use -M
nREPL server started on port 63367 on host localhost - 
And connect the REPL and load main.clj. But that gives:
; Evaluating file: main.clj
; Syntax error (FileNotFoundException) compiling at (src/clojure_lsp/main.clj:1:1).
; Could not locate borkdude/dynaload__init.class, borkdude/dynaload.clj or borkdude/dynaload.cljc on classpath.
; Evaluation of file main.clj failed: class clojure.lang.Compiler$CompilerException

ericdallo15:10:58

I need to update the docs, but could you try just running make ?

pez15:10:49

Trying with javac now, but make next, for sure.

ericdallo15:10:54

Updated the docs to run make

pez15:10:01

Both doing it manually and running make gave me an executable. Running it, but then unsure what to do. There is no /tmp/clojure-lsp.*.out.

ericdallo15:10:47

this folder is generated by JVM, but I think for some macos it generates in another folder

pez15:10:37

There is no way I can just run it with clojure like I tried above?

ericdallo15:10:40

• get the generated folder by running the serverInfo command and checking log-path • Just set a clojure-lsp config {:log-path "/tmp/clojure-lsp.out"}

ericdallo15:10:54

yes, there is you can clojure -X:run

ericdallo15:10:12

but it will happen the same with the log

pez15:10:24

Will that give me a REPL?

ericdallo15:10:58

yes, every time we run on JVM it shoud start nrepl in background and log the port/make available on serverInfo command

ericdallo15:10:30

it will not print on stdout because stdout is reserved for LSP requests/responses

pez15:10:39

And which port do I talk to the lsp server with?

pez15:10:00

Could it print on stderr maybe?

ericdallo15:10:11

it's not a error :)

pez15:10:41

Well, stderr is not just for errors. It is a channel to communicate on out of stdout band also.

pez15:10:22

So in a unix command line pipeline you might want to say stuff, while stdout is piped.

ericdallo15:10:24

clojure-lsp logs a lot of useful information on its log, I don't know why logging to stderr is necessary

pez15:10:39

Because I would see it easily?

ericdallo15:10:29

lsp clients already use the stderr for other err/warning issues, we would add info that is not a error/warning and maybe confuse those things

pez15:10:40

Now I am in a bit of a Catch 22. I want to know which port to communicate with clojure-lsp on, and need to talkk to clojure-lsp to find out what log file I can find that port in.

ericdallo15:10:51

I don't get it why you can't just set log-path and tail the file

pez15:10:07

I didn’t know about log-path

pez15:10:28

Now see that you’ve mentioned. I’ll try with that!

👍 1
ericdallo15:10:17

we had issues in the past we permission on the log path, that's why we leave to jdk create the log file on its default location, but we allow user override that as well

pez15:10:48

% clojure -X:run
No function found on command line or in :exec-fn

ericdallo15:10:00

oh, I meant clojure -M:run , sorry

ericdallo15:10:05

I usually don't use that

ericdallo15:10:12

I just make and use the executable

ericdallo15:10:21

and connect nrepl to the executable

pez15:10:36

Does it let you modify the running program?

pez15:10:31

I don’t get any log file even if I set it to log in the current directory

pez15:10:51

Also:

% clojure -M:run
Execution error (NullPointerException) at clojure-lsp.main/exit (main.clj:116).
null
After quite a while. 😃

ericdallo15:10:44

that's odd, well, generate the binary with make , which will just generate an embedded jar in a executable file

ericdallo15:10:52

then you can configure the log-path

ericdallo15:10:01

and during start it should log to that path

pez15:10:09

Yes, so that’s what I have done. I tried the clojure -M:run option after that.

ericdallo15:10:17

I have mine log-path configured on my ~/.lsp/config.edn if it helps: https://github.com/ericdallo/dotfiles/blob/master/.lsp/config.edn#L1

pez15:10:06

I’ll try that.

ericdallo15:10:49

BTW check if you have write permissions on /tmp/ as you use Macos, maybe try log to home or somewhere else

pez15:10:49

I’ve tried logging to the current directory as well.

pez15:10:01

No log file for me.

ericdallo15:10:16

weird, never faced this issue

ericdallo15:10:30

how you are starting clojure-lsp?

pez15:10:46

./clojure-lsp

ericdallo15:10:04

the log-path check only happens when server is starting :)

ericdallo15:10:19

you need to send the first request initialize

ericdallo15:10:31

that's why I suggest you test it with an editor

ericdallo15:10:46

or use clojure-lsp API, like ./clojure-lsp clean-ns or something like that

pez15:10:50

And on witch port do i talk to clojure-lsp?

pez15:10:55

Hmmm, I could let calva start it …

ericdallo15:10:16

let me try to explain it better: • you generate the dev binary running make as you did. • you tell your editor to use the binary when starting clojure-lsp, for Calva for example there is a setting to specify the clojure-lsp path • during a specific moment when clojure-lsp is starting, it should start printing to the log-path

pez16:10:57

> you tell your editor to use the binary when starting clojure-lsp, for Calva for example there is a setting to specify the clojure-lsp path So that what I just tried. 😃 I just copied it over the one that Calva has downloaded for itself. Works. Now let’s see where I find the logpath.

ericdallo16:10:43

Good, you can set the clojure-lsp path calva setting to avoid overwriting to the one calva downloads

pez16:10:31

Yeah, this is just easier.

pez16:10:06

Not finding any repl port message.

ericdallo16:10:18

did you call serverInfo ?

ericdallo16:10:24

it prints a :port

ericdallo16:10:45

since you are running on an editor now, calling serverInfo is just easier

ericdallo16:10:04

I tested semantic tokens on calva this way :)

pez16:10:32

Yeah, forgot about you saying I should use that. Looked for it in the log. 😃 I have the REPL connected. Missed what you answered about me being able to modify clojure-lsp now.

pez16:10:32

Hmmm, wait, I tested it in a stupid way.

pez16:10:26

No, doesn’t seem to be able to REPL the program into a new shape. So I edit->recompile->test the old fashion way?

ericdallo16:10:20

it should work via nrepl :thinking_face:

ericdallo16:10:26

I do this all the time

ericdallo16:10:33

but yeah, recompiling should work as well

pez16:10:03

Well, if you say it works via the REPL I want that. It’s the reason I do Clojure in the first place. 😃

ericdallo16:10:44

what didn't work exactly, did the connection to nrepl work?

pez16:10:27

What I tried was adding a key to serverInfo, reevaluated that form and then ran serverInfo command again. Don’t see my new key there.

ericdallo16:10:30

I even use this https://github.com/ericdallo/dotfiles/blob/master/.doom.d/config.el#L28-L37 in my emacs that connect to the nrepl on clojure-lsp automatically haha

ericdallo16:10:03

hum, that should work indeed :thinking_face:

pez16:10:23

I’ll try it from start then.

ericdallo16:10:42

try adding a log/info

ericdallo16:10:53

and check if it prints on log-path

pez16:10:31

Yes!!!! Awesomeness.

pez16:10:58

No idea why it didn’t work with the first try, but I had tried a lot of things then.

pez16:10:26

make -> reload the vs code window (to make clojure-lsp reconnect) -> serverInfo, copy port -> calva connect, paste port -> load file -> edit server-info function -> serverInfo -> success.

ericdallo16:10:01

yeah, that's the way

pez16:10:27

I can try describe the process “Hack clojure-lsp with Calva” in the development.md file, if you like?

ericdallo16:10:04

sure, could it be agnostic of the editor? that should help other editors as well

pez16:10:21

It is quite a mind-fuck to experience this. I am modifying the clojure-lsp server backing my session.

ericdallo16:10:41

yeah, i know that feel the first time I did that hahah

pez16:10:51

It can be agnostic, with a short section about the calva specifics. (Like clojure-lsp path).

pez16:10:17

It seems I need to evaluate more than just the server-info function for it to kick in. Do you have an idea what more it is? I’d like to avoid to instruct to reload the whole file, which works, but it brute.

pez16:10:51

The ns form then the function isn’t enough.

pez17:10:19

Found it. (def server-info-raw server-info)

pez17:10:30

If we make that (def server-info-raw #'server-info) then we only need to re-eval server-info. WDYT?

ericdallo17:10:16

yes, LGTM :)

dmegas17:10:47

I can’t seem to be able to make lsp-find-references return all references of a var - it only returns references from namespaces that I have already open. The same for lenses. Do I need to configure any special settings for it to work (I’m on Emacs)?

ericdallo17:10:34

not actually, this sounds like wrong source-paths configured

ericdallo17:10:47

could you provide a repro?

dmegas18:10:32

thank you, I’ll try to put sth together

seancorfield17:10:11

Can LSP easily determine that a function call is to a private Var rather than a public Var? Now that we have semantic tokens, that would seem like a useful distinction to surface in color-coding function calls perhaps?

ericdallo17:10:44

yeah, I think we can and then add a modifier to that token saying it's private

ericdallo17:10:37

maybe readonly

seancorfield18:10:44

Hmm, that sounds a bit hokey... I'm surprised they don't have standard tokens/modifiers for access levels...

seancorfield18:10:38

They show tokenModifiers as an array with things like private and static below that...

ericdallo18:10:53

yeah, I'm not sure if the modifiers need to follow that list or we could include custom ones, but each client handle that extra modifier

pez18:10:57

Hokey is ok, I'd say. It's up to the theme to style it anyway so it's quite arbitrary either way.

👍 1
Karol Wójcik19:10:01

Two issues I found with lsp. 1. Macros are listed in company as a Variable + Function. 2. Some of the functions are listed as variables, but they're functions

ericdallo19:10:56

thanks! Probably because there is the var-definition and the var-usage of that function, is this project opensource so I can try later?

Karol Wójcik19:10:07

Yeah. This is holy-lambda 😄

ericdallo19:10:29

I can try it later, thanks for the feedback!

Karol Wójcik19:10:39

You're very welcome 🙂

Karol Wójcik19:10:59

Also I see great performance improvements in this release.

ericdallo19:10:15

Good, glad to hear it!

ericdallo13:10:32

I made a commit on master fixing the 2. the first one I need to debug a little more

Karol Wójcik13:10:36

Much appreciated!