[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 1.2 cf4881c 081/101: Simplify eglot-code-action. Fix compilation
From: |
Christian Johansson |
Subject: |
[elpa] 1.2 cf4881c 081/101: Simplify eglot-code-action. Fix compilation warning |
Date: |
Thu, 29 Apr 2021 15:09:05 -0400 (EDT) |
tag: 1.2
commit cf4881c78ee1c5dbfc6cff151df4135358098b93
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Simplify eglot-code-action. Fix compilation warning
* eglot.el (eglot-code-actions): Simplify.
(eglot-client-capabilities): Mention supported codeActionKind's
directly.
(eglot--code-action-kinds): Remove.
---
eglot.el | 77 +++++++++++++++++++++++++++++++---------------------------------
1 file changed, 37 insertions(+), 40 deletions(-)
diff --git a/eglot.el b/eglot.el
index b2e88d8..2b683f8 100644
--- a/eglot.el
+++ b/eglot.el
@@ -226,9 +226,12 @@ let the buffer grow forever."
:codeAction (list
:dynamicRegistration :json-false
:codeActionLiteralSupport
- `(:codeActionKind
+ '(:codeActionKind
(:valueSet
- [,@eglot--code-action-kinds])))
+ ["quickfix"
+ "refactor" "refactor.extract"
+ "refactor.inline" "refactor.rewrite"
+ "source" "source.organizeImports"])))
:formatting `(:dynamicRegistration :json-false)
:rangeFormatting `(:dynamicRegistration :json-false)
:rename `(:dynamicRegistration :json-false)
@@ -745,11 +748,6 @@ Doubles as an indicator of snippet support."
(21 . "Null") (22 . "EnumMember") (23 . "Struct")
(24 . "Event") (25 . "Operator") (26 . "TypeParameter")))
-(defconst eglot--code-action-kinds
- '("quickfix" "refactor" "refactor.extract"
- "refactor.inline" "refactor.rewrite"
- "source" "source.organizeImports"))
-
(defun eglot--format-markup (markup)
"Format MARKUP according to LSP's spec."
(pcase-let ((`(,string ,mode)
@@ -1786,41 +1784,40 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(unless (eglot--server-capable :codeActionProvider)
(eglot--error "Server can't execute code actions!"))
(let* ((server (eglot--current-server-or-lose))
- (actions (jsonrpc-request
- server
- :textDocument/codeAction
- (list :textDocument (eglot--TextDocumentIdentifier)
- :range (list :start (eglot--pos-to-lsp-position beg)
- :end (eglot--pos-to-lsp-position end))
- :context
- `(:diagnostics
- [,@(mapcar (lambda (diag)
- (cdr (assoc 'eglot-lsp-diag
- (eglot--diag-data diag))))
- (flymake-diagnostics beg end))]))))
- (menu-items (mapcar (jsonrpc-lambda (&key title command arguments
- edit _kind _diagnostics)
- `(,title . (:command ,command :arguments
,arguments
- :edit ,edit)))
- actions))
- (menu (and menu-items `("Eglot code actions:" ("dummy"
,@menu-items))))
- (command-and-args
- (and menu
- (if (listp last-nonmenu-event)
- (x-popup-menu last-nonmenu-event menu)
- (let ((never-mind (gensym)) retval)
- (setcdr (cadr menu)
- (cons `("never mind..." . ,never-mind) (cdadr
menu)))
- (if (eq (setq retval (tmm-prompt menu)) never-mind)
- (keyboard-quit)
- retval))))))
- (cl-destructuring-bind (&key _title command arguments edit)
command-and-args
+ (actions
+ (jsonrpc-request
+ server
+ :textDocument/codeAction
+ (list :textDocument (eglot--TextDocumentIdentifier)
+ :range (list :start (eglot--pos-to-lsp-position beg)
+ :end (eglot--pos-to-lsp-position end))
+ :context
+ `(:diagnostics
+ [,@(mapcar (lambda (diag)
+ (cdr (assoc 'eglot-lsp-diag
+ (eglot--diag-data diag))))
+ (flymake-diagnostics beg end))]))))
+ (menu-items
+ (or (mapcar (jsonrpc-lambda (&key title command arguments
+ edit _kind _diagnostics)
+ `(,title . (:command ,command :arguments ,arguments
+ :edit ,edit)))
+ actions)
+ (eglot--error "No code actions here")))
+ (menu `("Eglot code actions:" ("dummy" ,@menu-items)))
+ (action (if (listp last-nonmenu-event)
+ (x-popup-menu last-nonmenu-event menu)
+ (let ((never-mind (gensym)) retval)
+ (setcdr (cadr menu)
+ (cons `("never mind..." . ,never-mind) (cdadr
menu)))
+ (if (eq (setq retval (tmm-prompt menu)) never-mind)
+ (keyboard-quit)
+ retval)))))
+ (cl-destructuring-bind (&key _title command arguments edit) action
(when edit
(eglot--apply-workspace-edit edit))
- (if command
- (eglot-execute-command server (intern command) arguments)
- (unless edit
- (eglot--message "No code actions here"))))))
+ (when command
+ (eglot-execute-command server (intern command) arguments)))))
- [elpa] 1.2 d52738f 095/101: Treat tab characters as 1 column wide in position conversion functions, (continued)
- [elpa] 1.2 d52738f 095/101: Treat tab characters as 1 column wide in position conversion functions, Christian Johansson, 2021/04/29
- [elpa] 1.2 7e9cc05 098/101: Fix #154: fix potential security issue fontifying LSP doc, Christian Johansson, 2021/04/29
- [elpa] 1.2 2bbf06e 097/101: Add support for R's languageserver (#161), Christian Johansson, 2021/04/29
- [elpa] 1.2 c667d79 093/101: Fix #125: add ability to report LSP-compliant columns, Christian Johansson, 2021/04/29
- [elpa] 1.2 a39a446 020/101: Close #61: Snappier completions that don't hinder typing, Christian Johansson, 2021/04/29
- [elpa] 1.2 2e21c12 084/101: * eglot.el (eglot-client-capabilities): Mention supported SymbolKinds., Christian Johansson, 2021/04/29
- [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 <=
- [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, 2021/04/29
- [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