Fork me on GitHub
#lsp
<
2021-05-18
>
nmkip00:05:03

Hi! In Emacs when I create a clojurescript file some_name.cljs, cider and lsp are adding the namespace like this: (ns some-name)(ns some-name) if I recall correctly there was an option to prevent this from happening but I can't find it, anyone remembers which was it? I'll keep searching in the meantime.

ericdallo00:05:25

You can disable it on clj-refactor or via clojure-lsp config let me get that

ericdallo00:05:12

(setq cljr-add-ns-to-blank-clj-files nil)

ericdallo00:05:45

Or: {:auto-add-ns-to-new-files? false} in .lsp/config.edn

nmkip00:05:58

I found this (setq cljr-add-ns-to-blank-clj-files nil) in my config

nmkip00:05:18

I don't remember having the namespace problem in clojure files.

nmkip00:05:32

I'm having it in clojurescript though.

ericdallo00:05:15

Hum, maybe there is another one specific for cljs?

nmkip00:05:26

Doesn't seem so. This is the code:

(defun cljr--clojure-ish-filename-p (file-name)
  (or (string-suffix-p ".clj" file-name)
      (string-suffix-p ".cljs" file-name)
      (string-suffix-p ".cljx" file-name)
      (string-suffix-p ".cljc" file-name)))

(defun cljr--add-ns-if-blank-clj-file ()
  (ignore-errors
    (when (and cljr-add-ns-to-blank-clj-files
               (cljr--clojure-ish-filename-p (buffer-file-name))
               (= (point-min) (point-max)))
      (insert (format "(ns %s)\n\n" (cider-expected-ns)))
      (when (cljr--in-tests-p)
        (cljr--add-test-declarations)))))

nmkip00:05:57

and the variable is nil.

nmkip00:05:10

I'll try disabling it in lsp and enabling it in clj-refactor.

ericdallo00:05:21

Hum, yeah, it should work for cljr

ericdallo00:05:49

For clojure-lsp, you need to restart the server

nmkip00:05:26

If I enable clj refactor:

(ns app.components.aaaa.pepe)

(ns app.components.aaaa.pepe)(ns app.components.aaaa.pepe)

ericdallo00:05:34

Try closing the buffer and reopenning

nmkip00:05:52

Still havent disabled it in clojure-lsp

ericdallo00:05:44

Yeah, I would disable on cljr since I know how clojure-lsp handles it, but it's your choice

nmkip01:05:27

Can you check if this problem happens in cljs files? In the buffer message I see:

LSP :: Connected to [clojure-lsp:405252]. [2 times]
LSP :: Applying 1 edits to `fd.cljs' ...
Applying 1 edits to `fd.cljs' ...done
LSP :: Applying 1 edits to `fd.cljs' ...
Applying 1 edits to `fd.cljs' ...done

nmkip01:05:05

(ns app.fd)(ns app.fd)

ericdallo13:05:09

Hum, maybe it's a clojure-lsp bug, let me check

ericdallo13:05:38

I cannot repro that, it adds one ns correctly for cljs files

nmkip18:05:17

I updated clojure-lsp and lsp-mode and it seems to be working right!

nice 4
nmkip17:05:49

I was wrong, the problem still persists. I created a project using npx create-cljs-app , then I ran cider-jack-in-cljs -> shadow -> :app Then I created a file reagent_components.cljs The result was:

(ns reagent-component)(ns reagent-component)(ns reagent-component)(ns reagent-component)
This was in m *Messages* buffer
(New file)
LSP :: Connected to [clojure-lsp:24277]. [2 times]
LSP :: Applying 1 edits to `reagent_components.cljs' ...
Applying 1 edits to `reagent_components.cljs' ...done
LSP :: Applying 1 edits to `reagent_components.cljs' ...
Applying 1 edits to `reagent_components.cljs' ...done
LSP :: Applying 1 edits to `reagent_components.cljs' ...
Applying 1 edits to `reagent_components.cljs' ...done
LSP :: Applying 1 edits to `reagent_components.cljs' ...
Applying 1 edits to `reagent_components.cljs' ...done

nmkip17:05:21

cljr-add-ns-to-blank-clj-files is nil and this is my ~/.lsp/config.edn

{
 :auto-add-ns-to-new-files? true
 :semantic-tokens? false
} 

nmkip17:05:16

I don't know if it's okay, but there are a lot of clojure-lsp processes running

ericdallo17:05:23

No that's absolutely odd multiple process running. Could you try killing all process and start the project again?

ericdallo17:05:44

Also check lsp-sessions to list all sessions

nmkip18:05:33

what's lsp-sessions?

ericdallo18:05:14

I think it is lsp-describe-session

nmkip18:05:25

That opens a buffer with multiple paths to projects

ericdallo18:05:27

Are there multiple process alive yet?

nmkip04:05:49

Sorry I was afk! Yes, there are multiple processes alive. In the lsp-describe-session buffer everything seems fine.

ericdallo14:05:46

That's odd, who many projects you have opened at same time?

ericdallo14:05:01

it should has only one clojure-lsp process for workspace active

Affan Salman21:05:57

Hi @UKFSJSM38, I’m seeing the same symptom (multiple ns forms inserted by LSP):

Affan Salman21:05:05

LSP :: Connected to [clojure-lsp:99779].
LSP :: Applying 1 edits to `scratch.clj' ...
Applying 1 edits to `scratch.clj' ...done
LSP :: Applying 1 edits to `scratch.clj' ...
Applying 1 edits to `scratch.clj' ...done

Affan Salman21:05:53

I don’t have multiple LSP processes running, however.

ericdallo21:05:09

that's probably not a clojure-lsp issue, but a lsp-mode one, you have probably multiple project roots or something like that running...

ericdallo21:05:00

please, create a issue with minimal code as minimal as you can that repro the issue

Affan Salman21:05:46

Hm, I have a single clojure-lsp process; not multiple. 🙂 I have a single project active and the root for that is correct (from lsp-describe-session).

Affan Salman21:05:59

Is there a way to ascertain “multiple project roots”.

ericdallo21:05:24

I think that's enough, that's why a minimal repro could help understand if it's some bug or some wrong configuration

ericdallo21:05:04

also, please test it with https://github.com/emacs-lsp/lsp-mode/blob/master/scripts/lsp-start-plain.el to make sure it s not a issue with your emacs

Affan Salman21:05:52

Sure; I can try creating an issue but I’m hoping that we can determine which repo to create it under. (`lsp-mode` or clojure-lsp)

ericdallo21:05:56

you can start on clojure-lsp, if we prove is not a bug on the server, then you can open on lsp-mode

ericdallo21:05:19

but we need to know if the issue is reproducible with lsp-start-plain.el

👍 3
Dmytro Bunin12:05:49

With newest update I started to notice on hover a popup with docstring. And Im failing to find a way to disable that. Am I missing a setting to do so?

ericdallo13:05:30

that's odd, it seems related with lsp-mode/lsp-ui

ericdallo13:05:44

it seems you are using lsp-ui-doc right?

Dmytro Bunin13:05:26

yeah it looks like it was on in a buffer

Dmytro Bunin13:05:35

hmm I guess I will take a look at my config

Dmytro Bunin13:05:31

I also updated doom maybe I blamed the wrong thing for it

Dmytro Bunin13:05:14

thanks Eric, figured it out 🙂

ericdallo13:05:07

What was the issue?

Dmytro Bunin07:05:02

I just disabled the lsp-ui-doc-mode 🙂

Dmytro Bunin07:05:27

I think they (doom) removed some defaults

👍 3
borkdude13:05:14

There is currently an experimental setup possible for getting clojure-lsp support in babashka scripts: https://github.com/babashka/babashka/issues/733#issue-811939787 Feel free to give it a try and suggest improvements.

🎉 6