[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 1.2 985ba0f 062/101: Improve signature help
From: |
Christian Johansson |
Subject: |
[elpa] 1.2 985ba0f 062/101: Improve signature help |
Date: |
Thu, 29 Apr 2021 15:09:01 -0400 (EDT) |
tag: 1.2
commit 985ba0f0bd76daa8b2d7b6a497a728f7a2be5adf
Author: Michał Krzywkowski <k.michal@zoho.com>
Commit: Michał Krzywkowski <k.michal@zoho.com>
Improve signature help
* eglot.el (eglot--sig-info): Don't lose existing information.
Attempt to highlight the active parameter by searching for it's
:label in signature's :label. Append to the result first sentence
of signature's :documentation, if present.
---
eglot.el | 52 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/eglot.el b/eglot.el
index 7e79b16..57d19b3 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1537,23 +1537,41 @@ is not active."
(defun eglot--sig-info (sigs active-sig active-param)
(cl-loop
for (sig . moresigs) on (append sigs nil) for i from 0
- concat (cl-destructuring-bind (&key label _documentation parameters) sig
- (let (active-doc)
- (concat
- (propertize (replace-regexp-in-string "(.*$" "(" label)
- 'face 'font-lock-function-name-face)
- (cl-loop
- for (param . moreparams) on (append parameters nil) for j from 0
- concat (cl-destructuring-bind (&key label documentation) param
- (when (and (eql j active-param) (eql i active-sig))
- (setq label (propertize
- label
- 'face
'eldoc-highlight-function-argument))
- (when documentation
- (setq active-doc (concat label ": "
documentation))))
- label)
- if moreparams concat ", " else concat ")")
- (when active-doc (concat "\n" active-doc)))))
+ concat (cl-destructuring-bind (&key label documentation parameters) sig
+ (with-temp-buffer
+ (save-excursion (insert label))
+ (when (looking-at "\\([^(]+\\)(")
+ (add-face-text-property (match-beginning 1) (match-end 1)
+ 'font-lock-function-name-face))
+
+ (when (and (stringp documentation) (eql i active-sig)
+ (string-match "[[:space:]]*\\([^.\r\n]+[.]?\\)"
+ documentation))
+ (setq documentation (match-string 1 documentation))
+ (unless (string-prefix-p (string-trim documentation) label)
+ (goto-char (point-max))
+ (insert ": " documentation)))
+ (when (and (eql i active-sig) active-param
+ (< -1 active-param (length parameters)))
+ (cl-destructuring-bind (&key label documentation)
+ (aref parameters active-param)
+ (goto-char (point-min))
+ (let ((case-fold-search nil))
+ (cl-loop for nmatches from 0
+ while (and (not (string-empty-p label))
+ (search-forward label nil t))
+ finally do
+ (when (= 1 nmatches)
+ (add-face-text-property
+ (- (point) (length label)) (point)
+ 'eldoc-highlight-function-argument))))
+ (when documentation
+ (goto-char (point-max))
+ (insert "\n"
+ (propertize
+ label 'face 'eldoc-highlight-function-argument)
+ ": " documentation))))
+ (buffer-string)))
when moresigs concat "\n"))
(defun eglot-help-at-point ()
- [elpa] 1.2 9cee9eb 086/101: Move constants to top instead of forward-declaring, (continued)
- [elpa] 1.2 9cee9eb 086/101: Move constants to top instead of forward-declaring, Christian Johansson, 2021/04/29
- [elpa] 1.2 fc9bbf7 096/101: Fix #160: Properly delete inserted text after completion, Christian Johansson, 2021/04/29
- [elpa] 1.2 b573d42 003/101: Close #44: Don't turn on flymake-mode any more than is needed, Christian Johansson, 2021/04/29
- [elpa] 1.2 13d8da4 039/101: Fix textDocument/hover responses where MarkedString is a plist (#72), Christian Johansson, 2021/04/29
- [elpa] 1.2 cf4881c 081/101: Simplify eglot-code-action. Fix compilation warning, Christian Johansson, 2021/04/29
- [elpa] 1.2 0f8091f 082/101: Fix a bug when response to definitions request is a single location, Christian Johansson, 2021/04/29
- [elpa] 1.2 a81bb01 091/101: Tweak solution to #125 with a hint from Fangrui Song, Christian Johansson, 2021/04/29
- [elpa] 1.2 ba41ed8 099/101: Fix #167: correctly insert TextEdit-less snippets, Christian Johansson, 2021/04/29
- [elpa] 1.2 aa3de04 021/101: Require jsonrpc.el 1.0.2 (GNU ELPA didn't build 1.0.1), Christian Johansson, 2021/04/29
- [elpa] 1.2 7342d88 054/101: Close #115: Don't block kill-buffer-hook if server somehow hangs, Christian Johansson, 2021/04/29
- [elpa] 1.2 985ba0f 062/101: Improve signature help,
Christian Johansson <=
- [elpa] 1.2 0509576 042/101: Improve snippet support, Christian Johansson, 2021/04/29
- [elpa] 1.2 97b9c06 065/101: Override eglot-execute-command for eclipse.jdt.ls server, Christian Johansson, 2021/04/29
- [elpa] 1.2 1aeeb45 085/101: Support ocaml-language-server out of the box (#149), Christian Johansson, 2021/04/29
- [elpa] 1.2 e5738ff 094/101: Per #144: Format documentation of signature parameters, Christian Johansson, 2021/04/29
- [elpa] 1.2 e70be91 101/101: * eglot.el (Version): Bump to 1.2, Christian Johansson, 2021/04/29