lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
nmkip 2021-05-18T00:38:03.003300Z

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.

ericdallo 2021-05-18T13:02:09.009800Z

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

ericdallo 2021-05-18T13:02:38.010Z

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

nmkip 2021-05-21T18:14:17.019500Z

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

2
nmkip 2021-05-22T17:29:49.033100Z

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

nmkip 2021-05-22T17:35:21.033300Z

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
} 

nmkip 2021-05-22T17:37:16.033500Z

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

ericdallo 2021-05-22T17:59:23.033900Z

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

ericdallo 2021-05-22T17:59:44.034100Z

Also check lsp-sessions to list all sessions

nmkip 2021-05-22T18:14:33.034300Z

what's lsp-sessions?

ericdallo 2021-05-22T18:15:14.034500Z

I think it is lsp-describe-session

nmkip 2021-05-22T18:16:25.034700Z

That opens a buffer with multiple paths to projects

ericdallo 2021-05-22T18:31:27.034900Z

Are there multiple process alive yet?

nmkip 2021-05-23T04:00:49.050200Z

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

ericdallo 2021-05-23T14:28:46.050700Z

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

ericdallo 2021-05-23T14:29:01.050900Z

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

2021-05-25T21:10:57.058300Z

Hi @ericdallo, Iโ€™m seeing the same symptom (multiple ns forms inserted by LSP):

2021-05-25T21:11:05.058500Z

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

2021-05-25T21:11:53.058700Z

I donโ€™t have multiple LSP processes running, however.

ericdallo 2021-05-25T21:12:09.058900Z

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

ericdallo 2021-05-25T21:13:00.059100Z

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

2021-05-25T21:24:46.059300Z

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).

2021-05-25T21:24:59.059500Z

Is there a way to ascertain โ€œmultiple project rootsโ€.

ericdallo 2021-05-25T21:26:24.059700Z

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

ericdallo 2021-05-25T21:27:04.059900Z

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

2021-05-25T21:27:52.060200Z

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)

ericdallo 2021-05-25T21:28:56.060500Z

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

ericdallo 2021-05-25T21:29:19.060700Z

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

1๐Ÿ‘
2021-05-25T21:34:48.061Z

Thanks @ericdallo

1๐Ÿ‘
ericdallo 2021-05-18T00:39:25.003500Z

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

ericdallo 2021-05-18T00:40:12.003700Z

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

ericdallo 2021-05-18T00:40:45.003900Z

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

nmkip 2021-05-18T00:42:58.004100Z

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

nmkip 2021-05-18T00:43:18.004300Z

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

nmkip 2021-05-18T00:43:32.004500Z

I'm having it in clojurescript though.

ericdallo 2021-05-18T00:48:15.004700Z

Hum, maybe there is another one specific for cljs?

nmkip 2021-05-18T00:50:26.004900Z

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)))))

nmkip 2021-05-18T00:50:57.005100Z

and the variable is nil.

nmkip 2021-05-18T00:51:10.005300Z

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

ericdallo 2021-05-18T00:52:21.005500Z

Hum, yeah, it should work for cljr

ericdallo 2021-05-18T00:52:49.005700Z

For clojure-lsp, you need to restart the server

nmkip 2021-05-18T00:55:26.005900Z

If I enable clj refactor:

(ns app.components.aaaa.pepe)

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

ericdallo 2021-05-18T00:56:34.006100Z

Try closing the buffer and reopenning

nmkip 2021-05-18T00:56:52.006300Z

Still havent disabled it in clojure-lsp

ericdallo 2021-05-18T00:57:44.006500Z

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

nmkip 2021-05-18T01:08:27.006700Z

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

nmkip 2021-05-18T01:09:05.006900Z

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

2021-05-18T12:52:49.008600Z

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?

2021-05-19T07:58:02.011800Z

I just disabled the lsp-ui-doc-mode ๐Ÿ™‚

2021-05-19T07:58:27.012Z

I think they (doom) removed some defaults

1๐Ÿ‘
2021-05-18T12:54:02.008700Z

eg

borkdude 2021-05-18T13:01:14.009700Z

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.

2๐ŸŽ‰
ericdallo 2021-05-18T13:02:09.009800Z

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

ericdallo 2021-05-18T13:02:38.010Z

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

ericdallo 2021-05-18T13:03:30.010200Z

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

ericdallo 2021-05-18T13:03:44.010400Z

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

2021-05-18T13:35:26.010800Z

yeah it looks like it was on in a buffer

2021-05-18T13:35:35.011Z

hmm I guess I will take a look at my config

2021-05-18T13:36:31.011200Z

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

2021-05-18T13:48:14.011400Z

thanks Eric, figured it out ๐Ÿ™‚

ericdallo 2021-05-18T13:58:07.011600Z

What was the issue?