unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Danny Freeman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: 58790@debbugs.gnu.org, felician.nemeth@gmail.com,
	Stefan Kangas <stefankangas@gmail.com>,
	Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#58790: Eglot URI parsing bug when using clojure-lsp server
Date: Wed, 02 Nov 2022 09:15:36 -0400	[thread overview]
Message-ID: <877d0do5sp.fsf@dfreeman.email> (raw)
In-Reply-To: <87v8nxsrq6.fsf@gmail.com>


João Távora <joaotavora@gmail.com> writes:

> Yes, a patch is in order.  Comments below:
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index c587061837..b8f50e3cd8 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -231,7 +231,7 @@ eglot-server-programs
>                                  (html-mode . ,(eglot-alternatives '(("vscode-html-language-server" "--stdio") ("html-languageserver" "--stdio"))))
>                                  (dockerfile-mode . ("docker-langserver" "--stdio"))
>                                  ((clojure-mode clojurescript-mode clojurec-mode)
> -                                 . ("clojure-lsp"))
> +                                 . ("clojure-lsp" :initializationOptions (:dependency-scheme "jar")))
>                                  (csharp-mode . ("omnisharp" "-lsp"))
>                                  (purescript-mode . ("purescript-language-server" "--stdio"))
>                                  (perl-mode . ("perl"
>                                  "-MPerl::LanguageServer" "-e"
>                                  "Perl::LanguageServer::run"))
>
> Didn't you say that "jar" is already the default for clojure-lsp?  Do we
> really need to force it?  What can happen if we don't?

"jar" is not the default, "zipfile" is. The clojure-lsp maintainers want
to make jar the default but have not pulled the trigger on that yet.
Other lsp clients seem to be forcing "jar" in the initialization options
as well.

If we don't force it then I would be getting zipfile URIs, which is not
the end of the world, but I would prefer to only deal with the scheme
that the clojure-lsp devs want to use going forward. I could either set
the jar initialization option myself, tell the user to, or also support
the zipfile scheme. Setting it here is seems to be the easiest thing.

Including it does not have any downsides that I know of. Either way,
without some special file-name-handler dependencies in jars returned by
clojure-lsp cannot be opened. The end result is the same empty buffer.

> +(defvar eglot-preserve-jar-uri nil
> +  "If non-nil, jar: type URIs will not be converted to paths.
> +This means they will be provided to xref as URIs and not file paths.")
>
> We don't need this variable.  Eglot should no nothing about jars (except
> perhaps in only place where "clojure" is mentioned, which is in
> eglot-server-programs).
>
> I think it's better to patch eglot--uri-to-path so that if X looks
> anything other than file://, Eglot leaves it untouched.  After all, it's
> the only safe translation Eglot can make.
>
> And in eglot--path-to-uri, we do likewise.  If the PATH argument already
> looks vaguely URIish (say, it makes something like "^[[:alnum:]]+://")
> we leave it unchanged.
>
> Let me know if that makes sense and you can implement it, else I'll try
> it myself.

This makes sense and seems very reasonable to me. I will send an updated
patch that tries to do this.

One question I have is, does it make sense to still parse the escape
sequences (via url-unhex-string) in the full URI? Or do we continue
to leave it as is? In my local testing I've left it as is but don't have
any jars that I can navigate to with special characters in the path.

> Felicián also suggested that Eglot warns the user when it doesn't know
> an URI scheme.  I think that can make sense in some situations, for now
> let's assume it isn't as important as getting your new Jar
> file-name-handler to integrate with Eglot.  Maybe in some later patch
> Eglot can somehow predict if there is a file-name-handler entry for a
> given URI and only warn if there isn't.

I think it would be pretty straight forward to see if something like
`find-file-name-handler` would pick up an unaltered URI for a common
operation that we know eglot will be using, like `expand-file-name`. If
it doesn't then a warning can be issued.





  reply	other threads:[~2022-11-02 13:15 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 21:44 bug#58790: Eglot URI parsing bug when using clojure-lsp server Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-26  6:22 ` Stefan Kangas
2022-10-26 19:50   ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-27 15:09     ` João Távora
2022-10-29  1:22       ` Dmitry Gutov
2022-10-29  2:02         ` João Távora
2022-10-29 14:54           ` Dmitry Gutov
2022-10-29 19:35             ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-31 14:40               ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-02  8:09                 ` João Távora
2022-11-02 13:15                   ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-11-03 17:10                   ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10  9:49                     ` Eli Zaretskii
2022-11-10 11:00                       ` João Távora
2022-11-10 13:47                         ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 15:38                         ` Eli Zaretskii
2022-11-10 21:45                           ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 21:59                             ` João Távora
2022-11-10 22:22                               ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 22:30                                 ` João Távora
2022-11-10 22:48                                   ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 22:48                                 ` João Távora
2022-11-10 22:57                                   ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-11  7:29                                   ` Eli Zaretskii
2022-11-12 17:03                                     ` Michael Albinus
2022-11-13 21:04                                       ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-15 19:04                                         ` Michael Albinus
2022-11-15 22:28                                           ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-16  7:53                                             ` Michael Albinus
2022-11-16 10:21                                               ` João Távora
2022-11-16 15:45                                                 ` Michael Albinus
2022-11-16 16:20                                                   ` João Távora
2022-11-16 22:59                                                     ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-02 16:14                                                       ` Michael Albinus
2022-12-07 18:56                                                         ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08 13:46                                                           ` Michael Albinus
2022-12-08 19:07                                                             ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-09 16:04                                                               ` Michael Albinus
2022-12-10 17:21                                                                 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-10 17:45                                                                   ` Michael Albinus
2022-11-22 14:30                                                     ` Michael Albinus
2022-11-23 11:55                                                       ` Richard Copley
2022-11-23 12:36                                                         ` João Távora
2022-11-23 12:42                                                           ` Arash Esbati
2022-11-23 12:49                                                             ` Richard Copley
2022-11-23 12:54                                                               ` João Távora
2022-11-23 13:33                                                           ` Eli Zaretskii
2022-11-23 13:44                                                             ` João Távora
2022-11-23 14:03                                                               ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23 19:53                                                                 ` João Távora
2022-11-11  8:30                               ` Eli Zaretskii
2022-11-11  9:45                                 ` João Távora
2022-11-11 12:01                                   ` Eli Zaretskii
2022-11-11 14:02                                     ` João Távora
2022-11-11 14:45                                       ` Eli Zaretskii
2022-11-12  9:04                                         ` João Távora
2022-11-11  7:16                             ` Eli Zaretskii
2022-11-01 17:25         ` Juri Linkov
2022-10-29 15:36 ` Felician Nemeth
2022-10-29 17:09   ` João Távora
2022-11-09  0:59 ` bug#58790: Robert Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877d0do5sp.fsf@dfreeman.email \
    --to=bug-gnu-emacs@gnu.org \
    --cc=58790@debbugs.gnu.org \
    --cc=danny@dfreeman.email \
    --cc=dgutov@yandex.ru \
    --cc=felician.nemeth@gmail.com \
    --cc=joaotavora@gmail.com \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).