[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 1.2 8ed2524 038/101: Close #50: Support snippet completions
From: |
Christian Johansson |
Subject: |
[elpa] 1.2 8ed2524 038/101: Close #50: Support snippet completions |
Date: |
Thu, 29 Apr 2021 15:08:56 -0400 (EDT) |
tag: 1.2
commit 8ed25241925e48da1890cae5b448b586cbf62ecf
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Close #50: Support snippet completions
* eglot.el (eglot-client-capabilities): Declare support for
snippet-based completions.
(eglot-completion-at-point): Expand snippet completions with
YASnippet if that is found.
(eglot-note, eglot-warning, eglot-error): Diagnostic
overlay priorities have to be slightly lower than yasnippet's,
which must be reasonably high.
---
eglot.el | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/eglot.el b/eglot.el
index 63fbce2..13c72ab 100644
--- a/eglot.el
+++ b/eglot.el
@@ -202,7 +202,8 @@ let the buffer grow forever."
:synchronization (list
:dynamicRegistration :json-false
:willSave t :willSaveWaitUntil t :didSave t)
- :completion `(:dynamicRegistration :json-false)
+ :completion (list :dynamicRegistration :json-false
+ :completionItem `(:snippetSupport t))
:hover `(:dynamicRegistration :json-false)
:signatureHelp `(:dynamicRegistration :json-false)
:references `(:dynamicRegistration :json-false)
@@ -956,13 +957,15 @@ Uses THING, FACE, DEFS and PREPEND."
(defalias 'eglot--make-diag 'flymake-make-diagnostic)
(defalias 'eglot--diag-data 'flymake-diagnostic-data)
-(dolist (type '(eglot-error eglot-warning eglot-note))
- (put type 'flymake-overlay-control
- `((mouse-face . highlight)
- (keymap . ,(let ((map (make-sparse-keymap)))
- (define-key map [mouse-1]
- (eglot--mouse-call 'eglot-code-actions))
- map)))))
+(cl-loop for i from 1
+ for type in '(eglot-note eglot-warning eglot-error )
+ do (put type 'flymake-overlay-control
+ `((mouse-face . highlight)
+ (priority . ,(+ 50 i))
+ (keymap . ,(let ((map (make-sparse-keymap)))
+ (define-key map [mouse-1]
+ (eglot--mouse-call 'eglot-code-actions))
+ map)))))
;;; Protocol implementation (Requests, notifications, etc)
@@ -1384,7 +1387,7 @@ is not active."
(items (if (vectorp resp) resp (plist-get resp :items))))
(mapcar
(jsonrpc-lambda (&rest all &key label insertText
&allow-other-keys)
- (let ((insert (or insertText label)))
+ (let ((insert (or insertText (string-trim-left label))))
(add-text-properties 0 1 all insert)
(put-text-property 0 1 'eglot--lsp-completion all insert)
insert))
@@ -1425,9 +1428,17 @@ is not active."
(erase-buffer)
(insert (eglot--format-markup documentation))
(current-buffer)))))
- :exit-function (lambda (_string _status)
- (eglot--signal-textDocument/didChange)
- (eglot-eldoc-function))))))
+ :exit-function (lambda (obj _status)
+ (cl-destructuring-bind (&key insertTextFormat
+ insertText
+ &allow-other-keys)
+ (text-properties-at 0 obj)
+ (when (and (eql insertTextFormat 2)
+ (fboundp 'yas-expand-snippet))
+ (delete-region (- (point) (length obj)) (point))
+ (funcall 'yas-expand-snippet insertText))
+ (eglot--signal-textDocument/didChange)
+ (eglot-eldoc-function)))))))
(defvar eglot--highlights nil "Overlays for textDocument/documentHighlight.")
- [elpa] 1.2 2971683 075/101: Rework test macros for hopefully more stable testing, (continued)
- [elpa] 1.2 2971683 075/101: Rework test macros for hopefully more stable testing, Christian Johansson, 2021/04/29
- [elpa] 1.2 3b3c1db 036/101: Close #73: Prompt for server in interactive eglot-shutdown, Christian Johansson, 2021/04/29
- [elpa] 1.2 a1cc0ad 043/101: * README.md (Obligatory animated gif section): Add snippet gif., Christian Johansson, 2021/04/29
- [elpa] 1.2 3532bd0 064/101: Per #63: Add support for eclipse.jdt.ls server, Christian Johansson, 2021/04/29
- [elpa] 1.2 0ef245f 051/101: Fix serious breakage introduced by #93, Christian Johansson, 2021/04/29
- [elpa] 1.2 71012bc 067/101: Add tests for eclipse.jdt.ls connection, Christian Johansson, 2021/04/29
- [elpa] 1.2 ea2fcc7 087/101: * eglot-tests.el (eclipse-connect): Increase connect timeout to 20., Christian Johansson, 2021/04/29
- [elpa] 1.2 7f1a0e3 100/101: * eglot.el (eglot-completion-at-point): Less chatter., Christian Johansson, 2021/04/29
- [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 <=
- [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, 2021/04/29
- [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