[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 3ffea45 44/62: Close #50: Support snippet complet
From: |
Stefan Monnier |
Subject: |
[elpa] externals/eglot 3ffea45 44/62: Close #50: Support snippet completions |
Date: |
Sat, 29 Sep 2018 17:13:35 -0400 (EDT) |
branch: externals/eglot
commit 3ffea45f29b97ab89a9d2444731c6378ab4daa47
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
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] externals/eglot 5808c0d 11/62: Add entry for haskell-ide-engine in eglot-server-programs (#49), (continued)
- [elpa] externals/eglot 5808c0d 11/62: Add entry for haskell-ide-engine in eglot-server-programs (#49), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot ec02ffa 14/62: Work around Emacs bugs 32237, 32278 (#53), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot e476411 19/62: Close #58: Erase company-doc buffer in between doc requests, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot dfaa389 12/62: * README.md (Installation and usage): Add haskell-ide-engine, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot a6cad6b 15/62: Fix typo in willSaveWaitUntil RPC request (#51), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 2728e12 22/62: Per #59: eglot-workspace-configuration's keys needn't be keywords, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot fd7e587 27/62: Require jsonrpc.el 1.0.2 (GNU ELPA didn't build 1.0.1), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 99fd6a4 30/62: * eglot.el (eglot-cquery): Capitalize docstring., Stefan Monnier, 2018/09/29
- [elpa] externals/eglot fdd021c 26/62: Close #61: Snappier completions that don't hinder typing, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 22b0c89 41/62: Add kotlin-language-server (#70), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 3ffea45 44/62: Close #50: Support snippet completions,
Stefan Monnier <=
- [elpa] externals/eglot e711bdb 47/62: Add go-langserver (#74), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 83d7025 36/62: Close #68: Implement asynchronous server connection, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 2355e17 23/62: Per #63: Accept functions as entries in eglot-server-programs, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot c0f9db7 46/62: Per #74: Don't error if server replies with empty hover message, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot be15bb1 43/62: Per #74: Fix eglot-capabilities when querying for multiple features, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 15040a6 48/62: Improve snippet support, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot d88f6aa 54/62: Close #86: Handle case when :textDocumentSync isn't a number, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 42fffa5 16/62: Close #54: Correctly make LSP positions in narrowed buffers, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot e935718 20/62: Fix placement of diagnostics with same start and end positions, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 88ebed6 17/62: Implement TextDocument/rangeFormatting, Stefan Monnier, 2018/09/29