Skip to content

Commit

Permalink
Make snippet work with dart_analysis_server (#105)
Browse files Browse the repository at this point in the history
* Make snippet work with dart_analysis_server

* Fix auto import

Co-authored-by: johngong <johngong@johngong.local>
  • Loading branch information
50ways2sayhard and johngong committed May 18, 2022
1 parent b91c722 commit 132d5d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 10 additions & 1 deletion langserver/dart-analysis-server.json
Expand Up @@ -2,5 +2,14 @@
"name": "dart-analysis-server",
"languageId": "dart",
"command": ["dart", "language-server", "--client-id", "emacs.lsp-bridge"],
"settings": {}
"settings": {},
"capabilities": {
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true
}
}
}
}
}
16 changes: 4 additions & 12 deletions lsp-bridge.el
Expand Up @@ -547,20 +547,12 @@ Then LSP-Bridge will start by gdb, please send new issue with `*lsp-bridge*' buf
(if (minibufferp) (window-buffer (minibuffer-selected-window))
(current-buffer))

(let ((snippet-fn (and (string= kind "Snippet")
(lsp-bridge--snippet-expansion-fn))))
(cond
;; Expand snippet.
(snippet-fn
(let ((snippet-fn (lsp-bridge--snippet-expansion-fn)))
(when insert-text
(delete-region (- (point) (length candidate)) (point))
(funcall snippet-fn insert-text))
;; Insert `insertText' and try to apply `additionalTextEdits'.
(insert-text
(delete-region (- (point) (length candidate)) (point))
(insert insert-text)

(funcall (or snippet-fn #'insert) insert-text)
(when (cl-plusp (length additionalTextEdits))
(lsp-bridge--apply-text-edits additionalTextEdits))))))
(lsp-bridge--apply-text-edits additionalTextEdits)))))
))))))

;; Copy from eglot
Expand Down

0 comments on commit 132d5d9

Please sign in to comment.