[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 0e5e08d 51/69: Support goto-{declaration, impleme
From: |
João Távora |
Subject: |
[elpa] externals/eglot 0e5e08d 51/69: Support goto-{declaration, implementation, typeDefinition} |
Date: |
Sun, 20 Oct 2019 08:21:51 -0400 (EDT) |
branch: externals/eglot
commit 0e5e08d29899b7724a78c70a90a17a1c3ac6444b
Author: Felicián Németh <address@hidden>
Commit: João Távora <address@hidden>
Support goto-{declaration, implementation, typeDefinition}
Closes #302.
* eglot.el (eglot--xref-definitions-method): New variable.
(xref-backend-definitions): Use it.
(eglot-find-declaration, eglot-find-implementation,
eglot-find-typeDefinition): New functions.
* README.md (Language features): Add new capabilities.
* eglot.el (eglot-client-capabilities): Add new capabilities.
(eglot-ignored-server-capabilites): Add new capability.
---
README.md | 7 ++++---
eglot.el | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 0987c40..820deee 100644
--- a/README.md
+++ b/README.md
@@ -241,7 +241,7 @@ provide enhanced code analysis via `xref-find-definitions`,
To "unmanage" these buffers, shutdown the server with `M-x
eglot-shutdown`.
-# Supported Protocol features (3.6)
+# Supported Protocol features
## General
- [x] initialize
@@ -288,8 +288,9 @@ eglot-shutdown`.
- [x] textDocument/hover
- [x] textDocument/signatureHelp (fancy stuff with Python's [pyls][pyls])
- [x] textDocument/definition
-- [ ] textDocument/typeDefinition (3.6.0)
-- [ ] textDocument/implementation (3.6.0)
+- [x] textDocument/typeDefinition (3.6.0)
+- [x] textDocument/implementation (3.6.0)
+- [x] textDocument/declaration (3.14)
- [x] textDocument/references
- [x] textDocument/documentHighlight
- [x] textDocument/documentSymbol
diff --git a/eglot.el b/eglot.el
index 1dc5711..e3ead96 100644
--- a/eglot.el
+++ b/eglot.el
@@ -491,6 +491,9 @@ treated as in `eglot-dbind'."
(:labelOffsetSupport t)))
:references `(:dynamicRegistration :json-false)
:definition `(:dynamicRegistration :json-false)
+ :declaration `(:dynamicRegistration :json-false)
+ :implementation `(:dynamicRegistration :json-false)
+ :typeDefinition `(:dynamicRegistration :json-false)
:documentSymbol (list
:dynamicRegistration :json-false
:symbolKind `(:valueSet
@@ -1090,6 +1093,7 @@ under cursor."
(const :tag "Go to definition" :definitionProvider)
(const :tag "Go to type definition" :typeDefinitionProvider)
(const :tag "Go to implementation" :implementationProvider)
+ (const :tag "Go to declaration" :implementationProvider)
(const :tag "Find references" :referencesProvider)
(const :tag "Highlight symbols automatically"
:documentHighlightProvider)
(const :tag "List symbols in buffer" :documentSymbolProvider)
@@ -1796,6 +1800,36 @@ Try to visit the target file for a richer summary line."
:textDocumentPositionParams
(eglot--TextDocumentPositionParams))))
+(defvar eglot--xref-definitions-method :textDocument/definition
+ "The LSP method to map xref-find-definitions call.")
+
+(defun eglot-find-declaration ()
+ "Find the declaration for the identifier at point.
+See `xref-find-definitions' and `xref-prompt-for-identifier'."
+ (interactive)
+ (eglot--find-location 'declaration))
+
+(defun eglot-find-implementation ()
+ "Find the implementation for the identifier at point.
+See `xref-find-definitions' and `xref-prompt-for-identifier'."
+ (interactive)
+ (eglot--find-location 'implementation))
+
+(defun eglot-find-typeDefinition ()
+ "Find the type definition for the identifier at point.
+See `xref-find-definitions' and `xref-prompt-for-identifier'."
+ (interactive)
+ (eglot--find-location 'typeDefinition))
+
+(defun eglot--find-location (kind)
+ (let* ((method-name (symbol-name kind))
+ (method (intern (concat ":textDocument/" method-name)))
+ (capability (intern (concat ":" method-name "Provider"))))
+ (if (eglot--server-capable capability)
+ (let ((eglot--xref-definitions-method method))
+ (call-interactively #'xref-find-definitions))
+ (eglot--error "Server is not a %sProvider" method-name))))
+
(cl-defmethod xref-backend-definitions ((_backend (eql eglot)) identifier)
(let* ((rich-identifier
(car (member identifier eglot--xref-known-symbols)))
@@ -1803,7 +1837,7 @@ Try to visit the target file for a richer summary line."
(if rich-identifier
(get-text-property 0 :locations rich-identifier)
(jsonrpc-request (eglot--current-server-or-lose)
- :textDocument/definition
+ eglot--xref-definitions-method
(get-text-property
0 :textDocumentPositionParams identifier))))
(locations
- [elpa] externals/eglot 059ea59 43/69: Optionally shutdown after killing last buffer of managed project (#309), (continued)
- [elpa] externals/eglot 059ea59 43/69: Optionally shutdown after killing last buffer of managed project (#309), João Távora, 2019/10/20
- [elpa] externals/eglot 59ba0b1 39/69: New README section on how to best report bugs to Eglot, João Távora, 2019/10/20
- [elpa] externals/eglot ce983d1 47/69: Revert "Treat null/nil server capabilities as false", João Távora, 2019/10/20
- [elpa] externals/eglot 4693abf 50/69: Fix #258: Allow user to set idle time to wait before processing changes, João Távora, 2019/10/20
- [elpa] externals/eglot 14ab804 54/69: Fix #318: unbreak xref-find-definitions, João Távora, 2019/10/20
- [elpa] externals/eglot dbb5dd4 57/69: Slightly more robust completion tests, João Távora, 2019/10/20
- [elpa] externals/eglot 3604173 64/69: Unbreak eglot--setq-saving if symbol is unbound, João Távora, 2019/10/20
- [elpa] externals/eglot a11a41b 63/69: Use of company-capf backend in eglot-managed buffers, João Távora, 2019/10/20
- [elpa] externals/eglot 6e93622 27/69: Fix #273: leniently handle invalid positions sent by some servers, João Távora, 2019/10/20
- [elpa] externals/eglot 254fee0 46/69: Use more pyls and less rls in tests, João Távora, 2019/10/20
- [elpa] externals/eglot 0e5e08d 51/69: Support goto-{declaration, implementation, typeDefinition},
João Távora <=
- [elpa] externals/eglot 5a21670 59/69: Fix bug in workspace/didChangeWatchedfiles, João Távora, 2019/10/20
- [elpa] externals/eglot 9359c15 58/69: Close #316: add support for the Ada Language Server, João Távora, 2019/10/20
- [elpa] externals/eglot d6508e0 29/69: Fix #273: fix a typo, João Távora, 2019/10/20
- [elpa] externals/eglot 28ecd5d 34/69: Change the default of eglot-move-to-column-function, João Távora, 2019/10/20
- [elpa] externals/eglot 7a70c97 33/69: Require array package to use current-line (#294), João Távora, 2019/10/20
- [elpa] externals/eglot f7a1bf6 49/69: Fix #236: much less noisy mode line, João Távora, 2019/10/20
- [elpa] externals/eglot 4c5d0d4 53/69: Misc improvements to the xref glue code, João Távora, 2019/10/20
- [elpa] externals/eglot 5ea4049 68/69: Fix #324: let user keep control of some variables during Eglot sessions, João Távora, 2019/10/20
- [elpa] externals/eglot 33a4f86 69/69: * eglot.el (Version): Bump to 1.5, João Távora, 2019/10/20
- [elpa] externals/eglot cf161b0 41/69: Test with emacs master on Travis, João Távora, 2019/10/20