[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 714e5be 086/139: Half-baked textDocument/hover sup
From: |
João Távora |
Subject: |
[elpa] externals/elpa 714e5be 086/139: Half-baked textDocument/hover support |
Date: |
Mon, 14 May 2018 09:53:41 -0400 (EDT) |
branch: externals/elpa
commit 714e5be3080d5bef55e5b3143d3d1d3dd593a508
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Half-baked textDocument/hover support
* eglot.el (eglot--format-markup): New helper.
(eglot--managed-mode): Handle eldoc-documentation-function.
(eglot-eldoc-function): New function.
* README.md: update
---
README.md | 2 +-
eglot.el | 42 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index f70d15f..611839b 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ server. To skip the guess and always be prompted use `C-u M-x
eglot`.
- [ ] textDocument/documentSymbol
- [ ] textDocument/executeCommand
- [ ] textDocument/format
-- [ ] textDocument/hover
+- [x] textDocument/hover
- [ ] textDocument/rename
- [x] textDocument/references
- [ ] textDocument/signatureHelp
diff --git a/eglot.el b/eglot.el
index 3bed8d9..2c97f2f 100644
--- a/eglot.el
+++ b/eglot.el
@@ -772,6 +772,23 @@ Meaning only return locally if successful, otherwise exit
non-locally."
(13 . "Enum") (14 . "Keyword") (15 . "Snippet") (16 . "Color")
(17 . "File") (18 . "Reference")))
+(defun eglot--format-markup (markup)
+ "Format MARKUP according to LSP's spec."
+ (cond ((stringp markup)
+ (with-temp-buffer
+ (ignore-errors (funcall 'markdown-mode))
+ (font-lock-ensure)
+ (insert markup)
+ (string-trim (buffer-string))))
+ (t
+ (with-temp-buffer
+ (ignore-errors (funcall (intern (concat
+ (plist-get markup :language)
+ "-mode" ))))
+ (insert (plist-get markup :value))
+ (font-lock-ensure)
+ (buffer-string)))))
+
;;; Minor modes
;;;
@@ -796,7 +813,10 @@ Meaning only return locally if successful, otherwise exit
non-locally."
(add-hook 'after-save-hook 'eglot--signal-textDocument/didSave nil t)
(add-hook 'xref-backend-functions 'eglot-xref-backend nil t)
(add-hook 'completion-at-point-functions #'eglot-completion-at-point nil t)
- (flymake-mode 1))
+ (add-function :before-until (local 'eldoc-documentation-function)
+ #'eglot-eldoc-function)
+ (flymake-mode 1)
+ (eldoc-mode 1))
(t
(remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
(remove-hook 'after-change-functions 'eglot--after-change t)
@@ -806,7 +826,9 @@ Meaning only return locally if successful, otherwise exit
non-locally."
(remove-hook 'before-save-hook 'eglot--signal-textDocument/willSave t)
(remove-hook 'after-save-hook 'eglot--signal-textDocument/didSave t)
(remove-hook 'xref-backend-functions 'eglot-xref-backend t)
- (remove-hook 'completion-at-point-functions #'eglot-completion-at-point
t))))
+ (remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
+ (remove-function (local 'eldoc-documentation-function)
+ #'eglot-eldoc-function))))
(define-minor-mode eglot-mode
"Minor mode for all buffers managed by EGLOT in some way." nil
@@ -1410,6 +1432,22 @@ DUMMY is ignored"
(get-text-property 0 :sortText a)
(get-text-property 0 :sortText b)))))))))
+(defun eglot-eldoc-function ()
+ "EGLOT's `eldoc-documentation-function' function."
+ (eglot--request (eglot--current-process-or-lose)
+ :textDocument/hover
+ (eglot--obj
+ :textDocument (eglot--current-buffer-TextDocumentIdentifier)
+ :position (eglot--pos-to-lsp-position))
+ :success-fn (eglot--lambda (&key contents _range)
+ (eldoc-message
+ (mapconcat #'eglot--format
+ (if (vectorp contents)
+ contents
+ (list contents))
+ "\n"))))
+ nil)
+
;;; Dynamic registration
;;;
- [elpa] externals/elpa 418412b 131/139: Fix copyright header. Obviously not since 2003, (continued)
- [elpa] externals/elpa 418412b 131/139: Fix copyright header. Obviously not since 2003, João Távora, 2018/05/14
- [elpa] externals/elpa 54fc885 113/139: More RLS-specifics: update Flymake diags when indexing done, João Távora, 2018/05/14
- [elpa] externals/elpa 8a80fb7 105/139: Simplify `eglot-shutdown`, João Távora, 2018/05/14
- [elpa] externals/elpa d40f9ac 094/139: Half-decent imenu support via textDocument/documentSymbol, João Távora, 2018/05/14
- [elpa] externals/elpa 42177d0 107/139: New "deferred requests" that wait until server is ready, João Távora, 2018/05/14
- [elpa] externals/elpa ef80455 121/139: Support :completionItem/resolve, João Távora, 2018/05/14
- [elpa] externals/elpa 77856c2 130/139: Reinstate the catch/loop/throw idiom in eglot-request, João Távora, 2018/05/14
- [elpa] externals/elpa d1cdcf1 119/139: Friendlier M-x eglot, João Távora, 2018/05/14
- [elpa] externals/elpa 4c0bfc3 139/139: Support didChangeWatchedFiles with dynamic registration, João Távora, 2018/05/14
- [elpa] externals/elpa fceb6bb 090/139: Get rid of eglot--special-buffer-process, João Távora, 2018/05/14
- [elpa] externals/elpa 714e5be 086/139: Half-baked textDocument/hover support,
João Távora <=
- [elpa] externals/elpa e9b5e54 077/139: ETOOMANYLAMBDAS, João Távora, 2018/05/14
- [elpa] externals/elpa f257d63 089/139: * eglot.el: Reformat to shave off some lines., João Távora, 2018/05/14
- [elpa] externals/elpa 5ce9ab0 106/139: Call eglot-eldoc-function after completion finishes, João Távora, 2018/05/14
- [elpa] externals/elpa d431d41 088/139: Fix bug in hover support, João Távora, 2018/05/14
- [elpa] externals/elpa d0b7773 117/139: Reduce log chatter, João Távora, 2018/05/14
- [elpa] externals/elpa 9af84a2 124/139: Prepare to sumbit to GNU ELPA, João Távora, 2018/05/14
- [elpa] externals/elpa 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/elpa 6e76b08 100/139: Support workspace/applyEdit, João Távora, 2018/05/14
- [elpa] externals/elpa 3e0f1c3 122/139: Misc little adjustments for readability, João Távora, 2018/05/14
- [elpa] externals/elpa 9bf3166 136/139: Don't define a menu if nothing to show there for now, João Távora, 2018/05/14