[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 1.2 065f71a 080/101: Add support for code action literals
From: |
Christian Johansson |
Subject: |
[elpa] 1.2 065f71a 080/101: Add support for code action literals |
Date: |
Thu, 29 Apr 2021 15:09:05 -0400 (EDT) |
tag: 1.2
commit 065f71aed8e2ae56bc6ca8fefb35682173725366
Author: MichaĆ Krzywkowski <k.michal@zoho.com>
Commit: mkcms <k.michal@zoho.com>
Add support for code action literals
Code action literals allow the server to simply return a WorkspaceEdit
for a code action, so the client does not have to execute a command.
* eglot.el (eglot-client-capabilities): Add :codeActionLiteralSupport.
(eglot--code-action-kinds): New variable.
(eglot-code-actions): Apply provided WorkspaceEdit.
---
eglot.el | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/eglot.el b/eglot.el
index e151704..b2e88d8 100644
--- a/eglot.el
+++ b/eglot.el
@@ -223,7 +223,12 @@ let the buffer grow forever."
:definition `(:dynamicRegistration :json-false)
:documentSymbol `(:dynamicRegistration :json-false)
:documentHighlight `(:dynamicRegistration :json-false)
- :codeAction `(:dynamicRegistration :json-false)
+ :codeAction (list
+ :dynamicRegistration :json-false
+ :codeActionLiteralSupport
+ `(:codeActionKind
+ (:valueSet
+ [,@eglot--code-action-kinds])))
:formatting `(:dynamicRegistration :json-false)
:rangeFormatting `(:dynamicRegistration :json-false)
:rename `(:dynamicRegistration :json-false)
@@ -740,6 +745,11 @@ 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)
@@ -1788,8 +1798,10 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(cdr (assoc 'eglot-lsp-diag
(eglot--diag-data diag))))
(flymake-diagnostics beg end))]))))
- (menu-items (mapcar (jsonrpc-lambda (&key title command arguments)
- `(,title . (:command ,command :arguments
,arguments)))
+ (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
@@ -1802,10 +1814,13 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(if (eq (setq retval (tmm-prompt menu)) never-mind)
(keyboard-quit)
retval))))))
- (cl-destructuring-bind (&key _title command arguments) command-and-args
+ (cl-destructuring-bind (&key _title command arguments edit)
command-and-args
+ (when edit
+ (eglot--apply-workspace-edit edit))
(if command
(eglot-execute-command server (intern command) arguments)
- (eglot--message "No code actions here")))))
+ (unless edit
+ (eglot--message "No code actions here"))))))
- [elpa] 1.2 477e15d 018/101: * eglot.el (eglot-initialization-options): Fix spurious typo., (continued)
- [elpa] 1.2 477e15d 018/101: * eglot.el (eglot-initialization-options): Fix spurious typo., Christian Johansson, 2021/04/29
- [elpa] 1.2 802dea3 033/101: Close #41: Control the size of the events buffer, Christian Johansson, 2021/04/29
- [elpa] 1.2 8ed2524 038/101: Close #50: Support snippet completions, Christian Johansson, 2021/04/29
- [elpa] 1.2 7583849 058/101: eglot-ignored-server-capabilites: Prefer all choices over "Other", Christian Johansson, 2021/04/29
- [elpa] 1.2 240f88c 050/101: Don't warn on implementation-specific notifications (#93), Christian Johansson, 2021/04/29
- [elpa] 1.2 ba9877f 048/101: Close #86: Handle case when :textDocumentSync isn't a number, Christian Johansson, 2021/04/29
- [elpa] 1.2 6788dbc 074/101: Don't ignore unknown SymbolKinds in imenu, Christian Johansson, 2021/04/29
- [elpa] 1.2 9bf41be 076/101: Larger margin for printing test failure backtraces, Christian Johansson, 2021/04/29
- [elpa] 1.2 4550c08 077/101: Re-enable eclipse-jdt tests, Christian Johansson, 2021/04/29
- [elpa] 1.2 e866ca5 079/101: Use the container name of a symbol in imenu, Christian Johansson, 2021/04/29
- [elpa] 1.2 065f71a 080/101: Add support for code action literals,
Christian Johansson <=
- [elpa] 1.2 7f8465c 025/101: Add a generic eglot-execute-command API, Christian Johansson, 2021/04/29
- [elpa] 1.2 d0ec044 041/101: Add go-langserver (#74), Christian Johansson, 2021/04/29
- [elpa] 1.2 6cbfdda 057/101: Make eglot-ignored-server-capabilites more user-friendly (#126), Christian Johansson, 2021/04/29
- [elpa] 1.2 d54e494 046/101: Ignore extra keys in textDocument/publishDiagnostics (#81), Christian Johansson, 2021/04/29
- [elpa] 1.2 2d3c391 007/101: Close #48: be less verbose when using eglot-ensure, Christian Johansson, 2021/04/29
- [elpa] 1.2 9c2fd8c 002/101: Close #44: Robustify in the face of manual mode changes, Christian Johansson, 2021/04/29
- [elpa] 1.2 4d80eeb 015/101: Default eglot-handle-notifictiona|request must &allow-other-keys, Christian Johansson, 2021/04/29
- [elpa] 1.2 d2faf6d 001/101: Close #29: Implement workspace/didChangeConfiguration (#40), Christian Johansson, 2021/04/29
- [elpa] 1.2 5aea589 013/101: Close #58: Erase company-doc buffer in between doc requests, Christian Johansson, 2021/04/29
- [elpa] 1.2 5707785 024/101: * eglot.el (eglot-cquery): Capitalize docstring., Christian Johansson, 2021/04/29