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

From: Danny Freeman <[email-masked]>
Date: Wed, 16 Nov 2022 17:59:08 -0500

João Távora <[email-masked]> writes:

Michael writes:
> url-handlers.el supports already non-canonical schemes, see
> `url-tramp-protocols'. We could add "jar" and "zipfile" to another user
> option, `url-archive-protocols', and let tramp-archive.el do the job.

I think this could be a nice thing to include in emacs itself.
I have already implemented this funcitonality in a package on elpa:
https://elpa.gnu.org/packages/jarchive.html if you want to look. 

João writes:
> I think you're right. Let's not do this patch
> It's not Eglot's responsibility, or at least there's nothing Eglot can reasonably do about the problem that a later system
> can't, except maybe informing that it was the LSP server who is the source of the unknown URL scheme. I'm not sure it
> is worth the trouble, but let others speak their mind.

This seems reasonable to me.

> > Do you (or Danny) have a recipe I could follow?
> Danny would, probably, but the recipe would involve a particular LSP server and clojure toolchain, i think.

Indeed I do :)

>From emacs master branch. The only extra package that needs to be
installed is clojure-mode.

I have a repository here that should be cloned
https://git.sr.ht/~dannyfreeman/eglot-xref-to-jar-repo

It contains a nixos shell to install everything automatically if you use
that kind of thing.

If not, you need to have a recent version of openjdk installed, anything
over version 11 will do.  

The clojure command line tool needs to be installed:
https://clojure.org/guides/install_clojure (it's also in most linux
distro package managers)

Clojure-lsp needs to be installed: https://clojure-lsp.io/installation/

Even if you use the nixos shell, this following step is required:
Running the `clojure -Stree` command in that git repo to install clojure
dependencies.

>From there, opening the repository in emacs to this line:
https://git.sr.ht/~dannyfreeman/eglot-xref-to-jar-repo/tree/main/item/src/user.clj#L4

Running `M-x eglot`
Then `M-x xref-find-definitions` over the symbol `inc` should reproduce
the error.

I have not found any other lsp servers that do this kind of thing,
besides a java one that has even more problems than clojure-lsp. So
apologies for the complicated recipe.

-- 
Danny Freeman