emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding support for xref jumping to headers/interfaces


From: João Távora
Subject: Re: Adding support for xref jumping to headers/interfaces
Date: Mon, 6 Mar 2023 13:38:20 +0000

On Mon, Mar 6, 2023 at 1:24 PM Dmitry Gutov <dgutov@yandex.ru> wrote:
>
> On 06/03/2023 15:15, João Távora wrote:
> > On Mon, Mar 6, 2023 at 12:23 PM Felician Nemeth
> > <felician.nemeth@gmail.com>  wrote:
> >> Can you, please, consider adding more than just one new xref command?
> >> The Language Server Protocol defines jump-to-declaration,
> >> jump-to-implementation, and jump-to-typeDefinition commands as well.
> >>
> >> ----
> >>
> >> I can image a new xref-find-extra command that provides a
> >> `tmm-menubar'-like single key selection for the specific jump type.  The
> >> list of jump-types could be filled up by Eglot or major-modes (ada-mode
> >> would add "specifications", ocaml-mode would add "interface").  If C-M-?
> >> is bound to this new xref-find-extra, then "C-M-? i" would jump to the
> >> interface definition in ada-mode, and "C-M-? d" would ask the LSP server
> >> for declarations in case of Eglot.
> >>
> >> (Users who find "C-M-?" awkward can rebind xref-find-extra to "s-.")
> >>
> >> What do you think?
> > To me, the "find extra" trampoline idea sounds nice too.  It doesn't
> > suffer from the drawback of adding "interface", "implementation",
> > "typeDefinition", "superSpecificLanguageConstruct" concepts to xref.el
> > in poorly-scalable fashion.
>
> Could Eglot dynamically report on which of these operations are
> supported in the current buffer?

I think that is doable, yes.  The question is whether to use the LSP
names for them or our "own" names.  I think I prefer the former, to
avoid concept creep.  So M-x xref-find-extra would offer
"textDocument/findImplementation", "textDocument/findDeclaration",
etc when backend reports these operation names (which in turn it does
if the server has the associated LSP capability).

Other non-Eglot backends would report other operation names,
but that's fine as long as whoever reports them also knows
how to handle them.

The consistency would be in the single xref-find-extra binding.
The LSP names are clear enough and we can even decamelify them
automatically to be nicer to the camelically disinclined like
myself.

João



reply via email to

[Prev in Thread] Current Thread [Next in Thread]