Allow a null `rootUri` during initialization instead of crashing
neilyio opened this issue · comments
Describe the bug
I'm trying to get clojure-lsp working with Helix and Babashka. I'm finding that the language server crashes immediately when opening a .clj
file without a git repo.
Helix does not send rootUri
to language servers if you're not in a git repo, which causes the crash. One-off .clj
files seems to be a common workflow with Babashka, so I figure clojure-lsp
should support this.
To Reproduce
Steps to reproduce the behavior:
- Created an empty file
~/Desktop/bb.clj
- Start Helix with
hx ~/Desktop/bb.clj
clojure-lsp
crashes immediately.
Expected behavior
clojure-lsp
should work normally in Helix without a rootUri
.
Screenshots
2024-05-16T17:10:34.261Z INFO [clojure-lsp.server:627] - [SERVER] Starting server...
2024-05-16T17:10:34.308Z DEBUG [clojure-lsp.nrepl:21] - nrepl not found, skipping nrepl server start...
2024-05-16T17:10:34.321Z INFO [clojure-lsp.server:509] - Initializing...
2024-05-16T17:10:34.328Z ERROR [clojure-lsp.server:55] - Error receiving message: Internal error (-32603)
{:id 0, :method "initialize"}
com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine PosixPlatformThreads.java: 211
com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine PlatformThreads.java: 833
java.lang.Thread.run Thread.java: 1583
java.lang.Thread.runWith Thread.java: 1596
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 642
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1144
...
clojure.core.async/thread-call/fn async.clj: 486
lsp4clj.server/thread-loop/fn server.clj: 122
lsp4clj.server.ChanServer/fn server.clj: 260
lsp4clj.server.ChanServer/receive-request server.clj: 365
lsp4clj.server/pending-received-request server.clj: 181
...
clojure-lsp.server/fn server.clj: 520
clojure-lsp.shared/normalize-uri-from-client shared.clj: 546
clojure.string/starts-with? string.clj: 365
java.lang.NullPointerException:
User details (please complete the following information):
- OS: MacOS
- Editor: Helix
- Version: clojure-lsp 2024.04.22-11.58.08-nightly
@neilyio, in the meantime you can add (or just touch) a deps.edn
adjacent to your script.
You could also add a root to your .config/helix/languages.toml
(see https://github.com/helix-editor/helix/blob/master/languages.toml#L2258)