GNU bug report logs - #58790
Eglot URI parsing bug when using clojure-lsp server

Previous Next

Package: emacs;

Reported by: Danny Freeman <danny <at> dfreeman.email>

Date: Wed, 26 Oct 2022 05:08:04 UTC

Severity: normal

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Danny Freeman <danny <at> dfreeman.email>
To: 58790 <at> debbugs.gnu.org
Subject: bug#58790: Eglot URI parsing bug when using clojure-lsp server
Date: Tue, 25 Oct 2022 17:44:22 -0400
[Message part 1 (text/plain, inline)]
Hello,

I am submitting 2 patches that were discussed over on eglot's github
issue tracker: https://github.com/joaotavora/eglot/issues/661

Only one of the patches is needed to solve the issue, but I wanted to
present both options.

The problem occurs when using `xref-find-defintions` while eglot is
managing a clojure buffer with clojure-lsp. If the symbol that
xref-find-definitions is activated on is defined in a jar file,
clojure-lsp by default will provide a location with a response like the 
following

(:jsonrpc "2.0" :id 14 :result
  (:uri 
"zipfile:///Users/andreperictavares/.m2/repository/org/clojure/tools.namespace/0.3.1/tools.namespace-0.3.1.jar::clojure/tools/namespace/find.clj" 
... ))

However, there is a clojure-lsp setting that the maintainers of 
clojure-lsp would like to make default that changes the URI format to 
send a response like this

(:jsonrpc "2.0" :id 14 :result
  (:uri 
"jar:file:///Users/andreperictavares/.m2/repository/org/clojure/tools.namespace/0.3.1/tools.namespace-0.3.1.jar!clojure/tools/namespace/find.clj" 
... )).

This jar format URI is a common thing used in the JVM world apparently. 
It is a URI that contains a nested URI. If eglot is provided this kind 
of URI it needs to parse it TWICE before eglot dispatches the path. If 
it's only parsed once then emacs ends up trying to navigate using 
something roughly equivalent to `(find-file "file:///path/to/jar")` 
which does not work. That is what the patch titled 
`0001-Parse-jar-scheme-URIs-in-eglot-correctly.patch` fixes.

The other patch forces clojure-lsp to use the `zipfile` scheme and 
avoids the need to parse the URI twice. I prefer the double parsing 
patch though, as I believe if other language servers for JVM languages 
use this jar URI scheme, they would also be able to benefit from the patch.

I have a very simple repository here that can be used to test the 
problem here: 
https://git.sr.ht/~dannyfreeman/eglot-xref-to-jar-repo/tree/main/item/src/user.clj#L4

With clojure and clojure-lsp installed, eglot activated in a buffer 
visiting that `user.clj` file, the issue can be recreated.

This is my first time attempting to contribute to emacs. I am actively 
going through the process of copyright assignment right now in case it 
is necessary.

Thank you,
Danny Freeman
[0001-Initialize-clojure-lsp-with-the-zipfile-dependency-s.patch (text/x-patch, attachment)]
[0001-Parse-jar-scheme-URIs-in-eglot-correctly.patch (text/x-patch, attachment)]
[OpenPGP_0x369D556E204D19D6.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

This bug report was last modified 2 years and 166 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.