Subject: bug#58790: Eglot URI parsing bug when using clojure-lsp server

From: Michael Albinus <[email-masked]>
Date: Thu, 08 Dec 2022 14:46:58 +0100

Danny Freeman <[email-masked]> writes:

Hi Danny,

>> Well, running the test together with your package looks fine. What I
>> don't understand is the following sequence:
>>
>> [client-request] (id:6) Fri Dec  2 17:04:01 2022:
>> (:jsonrpc "2.0" :id 6 :method "textDocument/definition" :params
>> 	  (:textDocument
>> 	   (:uri "file:///usr/local/src/eglot-xref-to-jar-repo/src/user.clj")
>> 	   :position
>> 	   (:line 3 :character 3)))
>> [server-reply] (id:6) Fri Dec  2 17:04:01 2022:
>> (:jsonrpc "2.0" :id 6 :result
>> 	  (:uri "jar:file:///home/albinus/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj" :range
>> 		(:start
>> 		 (:line 923 :character 6)
>> 		 :end
>> 		 (:line 923 :character 9))))
>>
>> That means, that the client (my local Emacs) has asked for
>> "textDocument/definition" on the file user.clj, as indicated by your
>> recipe. The remote server has returned as answer, that this definition is in
>> "jar:file:///home/albinus/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj". This
>> file must be located on the server, because the server cannot know
>> anything about my local configuration, right?
>
> The server should be running on your machine locally, and have access to
> everything Emacs does. It knows the location of that jar because it uses
> the clojure build tool to create a classpath for the project, which
> contains the full location of the clojure-1.10.3.jar file.

???

I'm speaking about a clojure file which is located on a remote machine,
accessed via Tramp. I thought that Eglot uses an LSP server on that
remote machine then.

> From what the clojure-lsp maintainers tell me, it will not run on a
> remote machine and be able to work with a project on your local machine.
> I'm not sure what it would return for a definition if it was able to run
> on a remote machine.

The LSP server shouldn't care. It returns a local file name, like
"jar:file:///home/albinus/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj". This
is because the file is local from the server's pov.

It is the client, Eglot, which must be able to access this file on the
remote machine. A task for your jarchive file name handler, I believe.

Or do I misunderstand the architecture?

Best regards, Michael.