]> git.eshelyaron.com Git - emacs.git/commit
Rework and correct major part of xref glue code
authorJoão Távora <joaotavora@gmail.com>
Sun, 6 Oct 2019 15:10:33 +0000 (16:10 +0100)
committerJoão Távora <joaotavora@gmail.com>
Fri, 11 Oct 2019 10:11:47 +0000 (11:11 +0100)
commit9bb0331d04635002972b5208db6394ad931a4b86
tree151e5a8307e46169627bac9a6edb0ee68938162f
parent83ed46b6a30ae4067df1436f6aef6f539adf5e77
Rework and correct major part of xref glue code

See comments of https://github.com/joaotavora/eglot/pull/314.  Up to
now, xref-backend-indentifier-completion-table was a gross hack that
only worked sometimes.  It relied on some fugly gymnastics to cache a
response from :textDocument/documentSymbol and somehow used that
information to build a completion table.  But it doesn't work well.

Summarily, LSP doesn't lend itself well to the xref interface of
prompting for an arbitrary identifier and then go look for whichever
type of references of that identifier.  All the LSP
:textDocument/{definition,references,implementation,...} methods
expect to know the exact context of the search the user is about to
perform, in the form of a document location.  That conflicts with the
xref "arbitrary string" requirement.

Therefore, the slightly limited, but much more correct way, for Eglot
to function is to override the user's preference of
xref-prompt-for-identifier, temporarily setting it to nil in
eglot--managed-mode (ideally, though, xref-prompt-for-identifier
should be a function of the backend.)

Later on, a possibly better behaved identifier completion table can be
built on top of the :workspace/symbol LSP method.

* eglot.el (xref-backend-identifier-at-point): Rewrite.
(eglot--lsp-xrefs-for-method): New helper.
(eglot--lsp-xref-helper): Use eglot--lsp-xrefs-for-method.
(eglot--xref-definitions-method): Delete.
(eglot--lsp-xref-refs): New variable.
(xref-backend-references, xref-backend-definitions): Use
eglot--lsp-xrefs-for-method.
(eglot--managed-mode): Set xref-prompt-for-identifier
to nil.
(eglot--xref-reset-known-symbols, eglot--xref-known-symbols): Delete
(xref-backend-identifier-completion-table): Nullify.
(eglot-find-declaration, eglot-find-implementation)
(eglot-find-typeDefinition): Use eglot--lsp-xref-helper.
lisp/progmodes/eglot.el