[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 764347d 128/139: New command eglot-help-at-point
From: |
João Távora |
Subject: |
[elpa] externals/eglot 764347d 128/139: New command eglot-help-at-point and a README update |
Date: |
Mon, 14 May 2018 09:55:09 -0400 (EDT) |
branch: externals/eglot
commit 764347d24c9894b0de3a7aca2a7ea5b2d691c4e2
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
New command eglot-help-at-point and a README update
* README.md (Commands and keybindings): New section.
* eglot.el (eglot-eldoc-function): Use eglot--hover-info.
Don't care about kind in highlightSymbol
(eglot--hover-info): New helper.
(eglot-help-at-point): New command.
---
README.md | 25 +++++++++++++++++++++++++
eglot.el | 41 ++++++++++++++++++++++++++++-------------
2 files changed, 53 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 8a94466..a3789a4 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,31 @@ Let me know how well it works and I'll add it to the list,
or submit a
PR. You can also enter a `server:port` pattern to connect to an LSP
server. To skip the guess and always be prompted use `C-u M-x eglot`.
+# Commands and keybindings
+
+Here's a summary of available commands:
+
+- `M-x eglot-reconnect` reconnects to the server
+
+- `M-x eglot-rename` asks the server to rename the symbol at point
+
+- `M-x eglot-help-at-point` asks the server for help for symbol at
+ point. Currently this is what `eldoc-mode` displays in the echo
+ area.
+
+- `M-x eglot-events-buffer` jumps to the events buffer for debugging
+ communication with the server.
+
+There are *no keybindings* specific to Eglot, but you can bind stuff
+in `eglot-mode-map`, which is active as long as Eglot is managing a
+file in your project. The commands don't need to be eglot-specific,
+either:
+
+```
+(define-key eglot-mode-map (kbd "C-c h") 'eglot-help-at-point)
+(define-key eglot-mode-map (kbd "<f6>") 'xref-find-definitions)
+```
+
# Supported Protocol features
## General
diff --git a/eglot.el b/eglot.el
index c8612cf..13f6f61 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1314,6 +1314,28 @@ DUMMY is ignored"
(defvar eglot--highlights nil "Overlays for textDocument/documentHighlight.")
+(defun eglot--hover-info (contents &optional range)
+ (concat (and range
+ (eglot--with-lsp-range (beg end) range
+ (concat (buffer-substring beg end) ": ")))
+ (mapconcat #'eglot--format-markup
+ (append
+ (cond ((vectorp contents)
+ contents)
+ (contents
+ (list contents)))) "\n")))
+
+(defun eglot-help-at-point ()
+ "Request \"hover\" information for the thing at point."
+ (interactive)
+ (cl-destructuring-bind (&key contents range)
+ (eglot--request (eglot--current-process-or-lose) :textDocument/hover
+ (eglot--TextDocumentPositionParams))
+ (when (seq-empty-p contents) (eglot--error "No hover info here"))
+ (with-help-window "*eglot help*"
+ (with-current-buffer standard-output
+ (insert (eglot--hover-info contents range))))))
+
(defun eglot-eldoc-function ()
"EGLOT's `eldoc-documentation-function' function."
(let ((buffer (current-buffer))
@@ -1325,17 +1347,7 @@ DUMMY is ignored"
:success-fn (eglot--lambda (&key contents range)
(when (get-buffer-window buffer)
(with-current-buffer buffer
- (eldoc-message
- (concat
- (and range
- (eglot--with-lsp-range (beg end) range
- (concat (buffer-substring beg end) ": ")))
- (mapconcat #'eglot--format-markup
- (append
- (cond ((vectorp contents)
- contents)
- (contents
- (list contents)))) "\n"))))))
+ (eldoc-message (eglot--hover-info contents range)))))
:deferred :textDocument/hover))
(when (eglot--server-capable :documentHighlightProvider)
(eglot--async-request
@@ -1346,12 +1358,11 @@ DUMMY is ignored"
(when (get-buffer-window buffer)
(with-current-buffer buffer
(eglot--mapply
- (eglot--lambda (&key range kind)
+ (eglot--lambda (&key range _kind)
(eglot--with-lsp-range (beg end) range
(let ((ov (make-overlay beg end)))
(overlay-put ov 'face 'highlight)
(overlay-put ov 'evaporate t)
- (overlay-put ov :kind kind)
ov)))
highlights)))))
:deferred :textDocument/documentHighlight)))
@@ -1482,3 +1493,7 @@ Proceed? "
(provide 'eglot)
;;; eglot.el ends here
+
+;; Local Variables:
+;; checkdoc-force-docstrings-flag: nil
+;; End:
- [elpa] externals/eglot c4ffabc 083/139: Half-decent completion support, (continued)
- [elpa] externals/eglot c4ffabc 083/139: Half-decent completion support, João Távora, 2018/05/14
- [elpa] externals/eglot d431d41 088/139: Fix bug in hover support, João Távora, 2018/05/14
- [elpa] externals/eglot 1356844 097/139: Fix odd bugs, João Távora, 2018/05/14
- [elpa] externals/eglot 6e76b08 100/139: Support workspace/applyEdit, João Távora, 2018/05/14
- [elpa] externals/eglot 5ce9ab0 106/139: Call eglot-eldoc-function after completion finishes, João Távora, 2018/05/14
- [elpa] externals/eglot ecd334f 101/139: Update README, João Távora, 2018/05/14
- [elpa] externals/eglot 39e8b9e 081/139: Add (dummy) tests and Travis CI integration, João Távora, 2018/05/14
- [elpa] externals/eglot 23b79e0 111/139: Shorten summary line to appease package-lint.el, João Távora, 2018/05/14
- [elpa] externals/eglot 37b7329 098/139: Reasonable textDocument/documentHighlight support, João Távora, 2018/05/14
- [elpa] externals/eglot d1cdcf1 119/139: Friendlier M-x eglot, João Távora, 2018/05/14
- [elpa] externals/eglot 764347d 128/139: New command eglot-help-at-point and a README update,
João Távora <=
- [elpa] externals/eglot 9bf3166 136/139: Don't define a menu if nothing to show there for now, João Távora, 2018/05/14
- [elpa] externals/eglot 54fc885 113/139: More RLS-specifics: update Flymake diags when indexing done, João Távora, 2018/05/14
- [elpa] externals/eglot 56c2e1d 104/139: Get rid of eglot-mode, João Távora, 2018/05/14
- [elpa] externals/eglot 9577dfc 125/139: Duh, json.el is in Emacs, and json-mode.el is useless here, João Távora, 2018/05/14
- [elpa] externals/eglot d33a9b5 103/139: Simplify eglot--signal-textDocument/didChange, João Távora, 2018/05/14
- [elpa] externals/eglot ef80455 121/139: Support :completionItem/resolve, João Távora, 2018/05/14
- [elpa] externals/eglot f89f859 114/139: Simplify mode-line updating logic, João Távora, 2018/05/14
- [elpa] externals/eglot 3a6c637 099/139: Support textDocument/rename, João Távora, 2018/05/14
- [elpa] externals/eglot 581608f 115/139: Resist server failure during synchronous requests, João Távora, 2018/05/14
- [elpa] externals/eglot 56cf02d 126/139: Rework autoreconnection logic, João Távora, 2018/05/14