Fork me on GitHub
#lsp
<
2024-01-15
>
vemv10:01:45

Does clojure-lsp have an option to use Sierra style imports?

-   [org.eclipse.jetty.server Server]
+   (org.eclipse.jetty.server Server)

delaguardo10:01:47

"Change coll to list" code action?

vemv10:01:01

I mean, on ns form cleaning, it shouldn't require much user effort

delaguardo10:01:12

afaik there is no such option. but it should be easy to add one for clean-ns https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/feature/clean_ns.clj#L432 btw, why do you prefer lists over vectors here?

šŸ‘ 1
vemv10:01:45

It's classic https://stuartsierra.com/2016/clojure-how-to-ns.html style and a variety of tools have support for it

ericdallo11:01:41

We had some thread on this channel discussing that, would be nice if we could follow some standard instead of supporting both, and in the thread we discussed about [ would be preferable over ( , I can't find it tho

delaguardo11:01:48

I also remember seeing Alex Miller talk about his personal preferences to [ but it wasn't in the form of "standard"

vemv11:01:01

However there's that Sierra standard that many teams have chosen to follow, and compatible tooling. Allow me to say, its it really tools' choice to change the course of what is considered prefered? Especially when other tools favor something else - it seems to me that having choice doesn't hurt anyone and avoids any possible form of tension, so to speak.

ericdallo11:01:47

Yeah, I prefer to have a standard, but I agree it's something not easy to enforce or our responsibility

vemv11:01:19

Ironically, I cannot enforce either what clojure-lsp should do šŸ˜„ Suffice to say it would solve day-to-day problems at work - I'd greatly appreciate it And of course anything we can do cider-side to make life easier to you folks, would be done as well

vemv11:01:41

(Speaking of, I'm reworking our cljfmt integration - should be 1:1 compatible with clojure-lsp)

ericdallo11:01:24

Cool, glad to know :) Feel free to post a issue about supporting the sierra standard optionally

šŸ™Œ 1
armed12:01:09

Hello, I think I found a bug related to code actions when java imports are involved. Steps to reproduce: ā€¢ assume following ns declaration:

(ns my.namespace
  (:import [java.awt.event ActionEvent]))
ā€¢ write down Robot. constructor:
(def robot (Robot.))
ā€¢ execute code action which suggests importing java.awt.Robot, the resulting namespace declaration becomes broken:
(ns my.namespace
  (:import [[java.awt Robot event] ActionEvent]))
Shall I create gh issue for that?

armed12:01:23

Or it might be only related to my environment: custom neovim config. Not sure.

ericdallo13:01:33

yeah, it seems to happen on some classes only :thinking_face: , but please open a issue, I can repro that

šŸ‘ 1
armed13:01:52

I discovered that it happens when the path is already reused by another import declaratin, e.g. java.awt.event and we are importing new class with a subpath java.awt so it drops event

Mateusz Mazurczak13:01:02

Hi, I've tested new lsp build: https://github.com/clojure-lsp/clojure-lsp-dev-builds/releases/download/2024.01.15-12.02.49-nightly/clojure-lsp-native-macos-aarch64.zip for mac aarch I've found a new issue (regression that when I rename the fn with lsp-rename it doesn't refresh it's state, so the highlight stay on the previous length of the name and references are kept on old name (so rename results in 0 references) and to refresh the state lsp-restart-workspace is needed Described here in more detail: https://github.com/clojure-lsp/clojure-lsp/issues/1755#issue-2082066732

Mateusz Mazurczak13:01:42

But the good news is @UKFSJSM38 that your update on renaming namespaces is working well!

ericdallo14:01:58

@U0281QDFE1X thanks, is that only related to code lens, or find-references become a problem as well?

Mateusz Mazurczak14:01:31

So for lsp-find-references Directly after lsp-rename it works, but after I run "lsp" it doesn't. Previously it was opposite way, so if I've run lsp-rename, find-refences won't work unless I would run "lsp" So hard to answer directly with yes/no because I have this case with lsp-rename that it won't take effect if I don't do "lsp" in that namespace, e.g. if I do lsp-rename namespace, it works correctly in terms of rename, but for lsp to not highilight me it on red or to find references I need to run lsp. And it was a case for some other commands/workflow with lsp, so now I have muscle memory to often run "lsp". I'm not sure if that's intended part of workflow with clojure-lsp or if it should be reported

ericdallo14:01:56

That's odd, I'll try to repro what you mentioned later today, but it's supposed to work without any extra lsp command

šŸ‘ 1
Mateusz Mazurczak14:01:54

So in that case, running lsp-rename on namespace requires lsp afterwards to find refernces, running lsp-rename on function don't require it, but after running lsp it won't find references anymore

ericdallo14:01:41

that is sounding like a lsp-mode bug, one easy way to confirm that is try to repro on Calva vscode

ag22:01:00

Can someone tell me how to set up initializationOptions: for a given server? I think I did learn this before, but I can't figure it out anymore. Basically, I want to set up options for fennel-ls server, like explained here: https://sr.ht/~xerool/fennel-ls. Ideally, I want to be able to use different settings for each project.

ericdallo22:01:01

Set up where? If you wanna understand how and where in the protocol you should pass it, the clojure-lsp integration tests help a lot understand that

ag22:01:36

Oh, I think it's just a key in make-lsp-client... right?

ericdallo22:01:15

I think so, is that from emacs lsp-mode?

ag22:01:27

yes, so I set up lsp client for Fennel, it works, but now, I want to be able to change its settings. See, here https://sr.ht/~xerool/fennel-ls/#default-settings I want to set "extra-globals"

ag22:01:51

Would be nice if I could do it per project, but if it's global, well, for now it would be fine

ericdallo22:01:31

Yeah, I think is not possible per project

ag22:01:53

Yup, now I remember. Thank you Eric!

šŸ‘ 1
ag22:01:13

What do you mean it's not possible? We're talking about Emacs here. Everything is possible. It's just the matter of how crazy you are, that's all šŸ™‚

ericdallo22:01:49

Ah yeah, that's true haha, I meant without changing lsp-mode :)

ericdallo22:01:21

But, you can even extend lsp-mode functions via elisp so it's possible as well but maybe not a good idea haha

ag22:01:05

I dunno, sounds pretty straightforward. In theory that is, at least. You'd just eval some shit in .dir-locals.el, that calls (lsp-register-client on some hook, I dunno. Good... bad.. if it works... who cares, right?

šŸ˜‚ 1
ag22:01:13

And hey, :initialization-options is actually a function... I can slurp some fennel-ls.cfg, or something from the project root.

ag22:01:57

Goddammit... I just wanted seemingly simple fokkin ting... and now I have this whole yak to shave... I hate myself sometimes...

šŸ˜… 1
ericdallo22:01:45

Good luck!

1
ag23:01:26

Here you go (if anyone needs it):

(defun fennel-ls-init-options ()
      (let* ((lsp-cfg-dir (concat (projectile-project-root) "/.lsp/"))
             (cfg-file (expand-file-name "fennel-ls.json" lsp-cfg-dir))
             (json-object-type 'plist))
        (when (file-exists-p cfg-file)
          (json-read-file cfg-file))))

    (lsp-register-client
     (make-lsp-client
      :new-connection (lsp-stdio-connection "fennel-ls")
      :activation-fn (lsp-activate-on "fennel")
      :server-id 'fennel-ls
      :initialization-options #'fennel-ls-init-options))
and in the project root: .lsp/fennel-ls.json:
{
    "fennel-ls": {
        "checks": {
            "unused-definition": true,
            "unknown-module-field": true
        },
        "extra-globals": "awesome mapcat"
    }
}

šŸ‘ 1