lsp

István Karaszi 2025-02-08T21:40:43.856429Z

Is there a feature in clojure-lsp like the cljr-magic-require-namespaces of clj-refactor?

✅ 1
István Karaszi 2025-02-11T13:42:17.735719Z

Somehow related to that. If I imported a wrong namespace (fat fingered), then I don’t have the option to import another one even after removing the require and reloading the namespace.

István Karaszi 2025-02-11T13:42:24.139109Z

Do you think that can be solved somehow?

ericdallo 2025-02-11T13:47:18.719589Z

removing the require would make the symbol unresolved again and re-show the option to add the require

ericdallo 2025-02-11T13:47:33.197309Z

Keep in mind LSP has nothing related with REPL or reloading things

István Karaszi 2025-02-11T13:48:53.736629Z

Well, I removed and saved the file, but the lsp-execute-code-action didn’t not pop it up, just the wrongly required one

ericdallo 2025-02-11T13:50:00.922889Z

after removing the require, you didn't receive a LSP diagnostics squiggle mentioning that symbol doesn't exist? I can't repro that, BTW it's something that happens all the time on my daily work, so I doubt there is a bug there

István Karaszi 2025-02-11T13:50:22.497999Z

I needed to restart clojure-lsp

István Karaszi 2025-02-11T13:50:37.918359Z

With “cached” state:

István Karaszi 2025-02-11T13:50:50.744049Z

After restart:

István Karaszi 2025-02-11T13:51:49.161959Z

It noticed that the symbol is missing, but it did not suggest me all the options, just one as you can see on the screenshot

ericdallo 2025-02-11T13:52:12.290929Z

there is no cache code-actions or diagnostics, that's weird

ericdallo 2025-02-11T13:52:27.812879Z

if you can make a consistent repro on https://github.com/ericdallo/clojure-sample, LMK

István Karaszi 2025-02-11T13:52:45.323099Z

I’ll try to do that

István Karaszi 2025-02-11T17:26:04.909289Z

It does work there so far, I’ll try to keep an eye when it happens

István Karaszi 2025-02-09T09:31:40.973399Z

For the meantime, this could work: https://clojurians.slack.com/archives/CPABC1H61/p1738272823070519?thread_ts=1738271979.090999&cid=CPABC1H61

István Karaszi 2025-02-08T21:43:49.601839Z

We have a debug namespace in our project that is only being used rarely in the development, therefore it is not loaded in any of the namespaces. When I try to lsp-clojure-add-missing-libspec, then it loads the incorrect namespace all the time.

ericdallo 2025-02-10T12:54:29.758509Z

Yeah, this is the most recommended way ☝️

István Karaszi 2025-02-10T12:55:56.482389Z

IIRC cljr-add-missing-libspec asks for the right library if there are multiple matches.

ericdallo 2025-02-10T12:56:13.527819Z

clojure-lsp as well

István Karaszi 2025-02-10T12:56:46.632129Z

I can see, that I need to select the right library when using lsp-execute-code-actions, but I am asking bout the lsp-clojure-add-missing-libspec function here

ericdallo 2025-02-10T12:57:22.046959Z

the lsp-execute-code-actions delegates to the add-missing-libspec + add-missing-import feature

ericdallo 2025-02-10T12:57:45.377409Z

the best lib to require is already sorted via code actions

István Karaszi 2025-02-10T12:59:23.872379Z

My question is about to make lsp-clojure-add-missing-libspec behave similar as cljr-add-missing-libspec and ask for the user input to select the right matches after lsp-clojure-add-missing-libspec has been called.

István Karaszi 2025-02-10T12:59:42.850899Z

I can live with the current solution, I am just curious about the design decision here

ericdallo 2025-02-10T13:06:13.645599Z

not easy, because those are commands and they are generic, so the clients (editors) just know that they can spawn them, and server process and return edits to the editor apply. the code actions is a feature that can show available code changes in current line/col, and each code changes is related to a command

👍 1
ericdallo 2025-02-10T13:06:45.635109Z

changing this behavior would need to workaround the LSP protocol for each editor

ericdallo 2025-02-10T13:07:03.462199Z

or create a new command that asks user too, it's a option, although doesn't look like a priority

István Karaszi 2025-02-10T13:13:57.616019Z

That makes sense. Thank you!

👍 1