Creating a new `.clj` file in eglot takes a long time
pjsmith opened this issue · comments
Description
When I create a new .clj
file in Emacs, eglot
uses clojure-lsp
to populate the file with a (ns foo.bar.baz)
form. This should take a very short amount of time; instead it takes many seconds (around 10s for me, but I've seen up to 17s recently).
To Reproduce
Steps to reproduce the behavior:
- Create a new clj project with
lein new
- Open the
project.clj
file in Emacs - Use
C-x p f
to navigate to a new.clj
file in the project - When you get the
[eglot] Server wants to edit: <file.clj> Proceed?
message, enter [y]
Expected behavior
The new file will be created and opened, with a (ns foo.bar.baz)
form, in the current buffer in <1 second.
Actual behavior
The new file is created and opened in the current buffer, with the (ns foo.bar.baz)
form in place, but Emacs hangs and does not become responsive for ~10 seconds.
Log - client <-> server (from `M-x eglot-events-buffer`)
[client-notification] Tue Mar 26 19:13:45 2024: (:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///c%3A/lab/grue/src/clj/grue/money.clj" :version 0 :languageId "clojure" :text ""))) [server-request] (id:3) Tue Mar 26 19:13:45 2024: (:jsonrpc "2.0" :method "workspace/applyEdit" :params (:edit (:documentChanges [(:textDocument (:version 0 :uri "file:///c:/lab/grue/src/clj/grue/money.clj") :edits [(:range (:start (:line 0 :character 0) :end (:line 999998 :character 999998)) :newText "(ns grue.money)")])])) :id 3) [client-notification] Tue Mar 26 19:13:45 2024: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///c%3A/lab/grue/src/clj/grue/money.clj" :version 1) :contentChanges [(:text "(ns grue.money)\n\n")])) [client-notification] Tue Mar 26 19:13:50 2024: (:jsonrpc "2.0" :method "textDocument/didSave" :params (:text "(ns grue.money)\n\n" :textDocument (:uri "file:///c%3A/lab/grue/src/clj/grue/money.clj"))) [client-notification] Tue Mar 26 19:13:51 2024: (:jsonrpc "2.0" :method "workspace/didChangeWatchedFiles" :params (:changes [(:uri "file:///c%3A/lab/grue/src/clj/grue/money.clj" :type 1)])) [client-notification] Tue Mar 26 19:13:51 2024: (:jsonrpc "2.0" :method "workspace/didChangeWatchedFiles" :params (:changes [(:uri "file:///c%3A/lab/grue/src/clj/grue/money.clj" :type 2)])) [client-notification] Tue Mar 26 19:13:51 2024: (:jsonrpc "2.0" :method "workspace/didChangeWatchedFiles" :params (:changes [(:uri "file:///c%3A/lab/grue/src/clj/grue/.%23money.clj" :type 3)])) [client-reply] (id:3) ERROR Tue Mar 26 19:14:08 2024: (:jsonrpc "2.0" :id 3 :error (:code 32603 :message "Edits on ‘money.clj’ require version 0, you have 1")) [server-notification] Tue Mar 26 19:14:08 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///c:/lab/grue/src/clj/grue/money.clj" :diagnostics [])) [server-notification] Tue Mar 26 19:14:08 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///c:/lab/grue/src/clj/grue/money.clj" :diagnostics [])) [server-notification] Tue Mar 26 19:14:08 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///c:/lab/grue/src/clj/grue/.%23money.clj" :diagnostics [])) [server-notification] Tue Mar 26 19:14:08 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///c:/lab/grue/src/clj/grue/money.clj" :diagnostics [])) [server-notification] Tue Mar 26 19:14:08 2024: (:jsonrpc "2.0" :method "$/cancelRequest" :params (:id 3))
Log - clojure-lsp
2024-03-26T06:04:37.591Z INFO [clojure-lsp.handlers:443] - :signature-help 0ms 2024-03-26T06:13:45.023Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms 2024-03-26T06:13:45.030Z WARN [clojure-lsp.kondo:366] - Non-fatal error from clj-kondo: No configs copied.2024-03-26T06:13:45.031Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms
2024-03-26T06:13:45.032Z INFO [clojure-lsp.handlers:198] - :did-open 13ms
2024-03-26T06:13:45.066Z INFO [clojure-lsp.server:102] - :publish-diagnostics 0ms
2024-03-26T06:13:45.719Z INFO [clojure-lsp.feature.file-management:250] - changes analyzed by clj-depend took 0ms
2024-03-26T06:13:45.723Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms
2024-03-26T06:13:45.729Z WARN [clojure-lsp.kondo:366] - Non-fatal error from clj-kondo: No configs copied.2024-03-26T06:13:45.730Z INFO [clojure-lsp.feature.file-management:246] - changes analyzed by clj-kondo took 11ms
2024-03-26T06:13:45.730Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms
2024-03-26T06:13:45.730Z INFO [clojure-lsp.server:568] - :analyze-file 12ms
2024-03-26T06:13:45.736Z INFO [clojure-lsp.feature.file-management:139] - :reference-files/find 6ms
2024-03-26T06:13:45.737Z INFO [clojure-lsp.feature.file-management:137] - :notify-references 6ms
2024-03-26T06:13:45.766Z INFO [clojure-lsp.server:102] - :publish-diagnostics 0ms
2024-03-26T06:13:50.291Z INFO [clojure-lsp.handlers:207] - :did-save 0ms
2024-03-26T06:13:51.402Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms
2024-03-26T06:13:51.403Z INFO [clojure-lsp.feature.file-management:337] - :delete-watched-files 0ms
2024-03-26T06:13:51.442Z INFO [clojure-lsp.server:102] - :publish-diagnostics 0ms
2024-03-26T06:13:52.411Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms
2024-03-26T06:13:52.420Z INFO [clojure-lsp.kondo:245] - Linting whole project for unused-public-var took 9ms
2024-03-26T06:13:52.421Z WARN [clojure-lsp.kondo:366] - Non-fatal error from clj-kondo: No configs copied.2024-03-26T06:13:52.421Z INFO [clojure-lsp.feature.file-management:284] - Watched files analyzed, took 18ms
2024-03-26T06:13:52.422Z INFO [clojure-lsp.dep-graph:280] - :maintain-dep-graph 0ms
2024-03-26T06:13:52.423Z INFO [clojure-lsp.server:574] - :analyze-files-in-watched-dir 19ms
2024-03-26T06:13:52.450Z INFO [clojure-lsp.server:102] - :publish-diagnostics 0ms
2024-03-26T06:13:55.047Z ERROR [clojure-lsp.server:120] - No reponse from client after 10 seconds while applying workspace-edit.
User details (please complete the following information):
System
- OS: Windows 11
- Editor Emacs 29.1
- clojure-lsp version: clojure-lsp 2024.03.13-13.11.00
- clj-kondo version: clj-kondo 2024.03.13
@pjsmith You can see from the client<->server and server logs that clojure-lsp returns to clients immediately (few ms), so I don't think it's a server bug but an eglot or something in your editor causing that, I suggest you check with eglot maintainers.