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

From: Danny Freeman <[email-masked]>
Date: Sat, 10 Dec 2022 12:21:18 -0500

Michael Albinus <[email-masked]> writes:

> Yes, this is what it looks like. I don't believe it is an error in the
> LSP server.
>
> The eglot architecture, AFAIU, runs always the the LSP server on the
> same machine as the file under investigation is located on. For local
> files it is obvious: in eglot--connect, make-process is called, which
> connects to the LSP server on the local machine.
>
> If you have a remote file, say
> /ssh:user@host:/usr/local/src/emacs/src/dbusbind.c (in order to use a
> more simple LSP server like clangd), they same happens: make-process is
> called. *But* make-process realizes that default-directory is a remote
> one (/ssh:user@host:/usr/local/src/emacs/src//), and so it calls clangd
> on that remote host.
>
> That LSP server doesn't care where the client is called from. It still
> does
>
> [client-request] (id:20) Fri Dec  9 16:47:05 2022:
> (:jsonrpc "2.0" :id 20 :method "textDocument/definition" :params
> 	  (:textDocument
> 	   (:uri "file:///usr/local/src/emacs/src/dbusbind.c")
> 	   :position
> 	   (:line 171 :character 0)))
> [server-reply] (id:20) Fri Dec  9 16:47:05 2022:
> (:id 20 :jsonrpc "2.0" :result
>      [(:range
>        (:end
> 	(:character 22 :line 172)
> 	:start
> 	(:character 0 :line 172))
>        :uri "file:///usr/local/src/emacs/src/dbusbind.c")])
>
> So the client requests to get a definition in (the server local) file
> "file:///usr/local/src/emacs/src/dbusbind.c" at a given position, and
> the server replies with a pointer to the (server local) file
> "file:///usr/local/src/emacs/src/dbusbind.c". It is up to the client
> (eglot), to translate this information into remote file name syntax
> "/ssh:user@host:/usr/local/src/emacs/src/dbusbind.c".
>

>
> I suppose for clojure the same spplies. If the LSP server on that remote
> host returns something like a (server local) file
> "jar:file:///home/albinus/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj",
> it is up to the (eglot) client to recognize this as a pointer to the
> remote file at the given location. This problem is not tackled yet by
> your jarchive package.
>
> Best regards, Michael.

Thanks for taking the time to explain more. I understand now, and have
enough information to re-create this scenario myself. Once I do that
I'll see how I can account for this scenario in jarchive. When I do I
will post an update.

-- 
Danny Freeman