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.
Hum, maybe it's a clojure-lsp bug, let me check
I cannot repro that, it adds one ns correctly for cljs files
I updated clojure-lsp and lsp-mode and it seems to be working right!
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
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
}
I don't know if it's okay, but there are a lot of clojure-lsp processes running
No that's absolutely odd multiple process running. Could you try killing all process and start the project again?
Also check lsp-sessions to list all sessions
what's lsp-sessions?
I think it is lsp-describe-session
That opens a buffer with multiple paths to projects
Are there multiple process alive yet?
Sorry I was afk! Yes, there are multiple processes alive. In the lsp-describe-session buffer everything seems fine.
That's odd, who many projects you have opened at same time?
it should has only one clojure-lsp process for workspace active
Hi @ericdallo, Iโm seeing the same symptom (multiple ns
forms inserted by LSP):
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
I donโt have multiple LSP processes running, however.
that's probably not a clojure-lsp issue, but a lsp-mode one, you have probably multiple project roots or something like that running...
please, create a issue with minimal code as minimal as you can that repro the issue
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
).
Is there a way to ascertain โmultiple project rootsโ.
I think that's enough, that's why a minimal repro could help understand if it's some bug or some wrong configuration
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
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
)
you can start on clojure-lsp, if we prove is not a bug on the server, then you can open on lsp-mode
but we need to know if the issue is reproducible with lsp-start-plain.el
Thanks @ericdallo
You can disable it on clj-refactor or via clojure-lsp config let me get that
(setq cljr-add-ns-to-blank-clj-files nil)
Or: {:auto-add-ns-to-new-files? false}
in .lsp/config.edn
I found this (setq cljr-add-ns-to-blank-clj-files nil)
in my config
I don't remember having the namespace problem in clojure files.
I'm having it in clojurescript though.
Hum, maybe there is another one specific for cljs?
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)))))
and the variable is nil.
I'll try disabling it in lsp and enabling it in clj-refactor.
Hum, yeah, it should work for cljr
For clojure-lsp, you need to restart the server
If I enable clj refactor:
(ns app.components.aaaa.pepe)
(ns app.components.aaaa.pepe)(ns app.components.aaaa.pepe)
Try closing the buffer and reopenning
Still havent disabled it in clojure-lsp
Yeah, I would disable on cljr since I know how clojure-lsp handles it, but it's your choice
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
(ns app.fd)(ns app.fd)
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?
I just disabled the lsp-ui-doc-mode ๐
I think they (doom) removed some defaults
eg
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.
that's odd, it seems related with lsp-mode/lsp-ui
it seems you are using lsp-ui-doc right?
yeah it looks like it was on in a buffer
hmm I guess I will take a look at my config
I also updated doom maybe I blamed the wrong thing for it
thanks Eric, figured it out ๐
What was the issue?