aboutsummaryrefslogtreecommitdiff
path: root/editors/emacs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-12 11:12:45 +0100
committerAleksey Kladov <[email protected]>2019-08-12 11:49:28 +0100
commit13eddd7c499388e956e47aae6a7210e43eb40d55 (patch)
tree07e031193619aaee5b691e22f9e82361fdbbd1b7 /editors/emacs
parentcce31580e1ec1770b7a5bf4e6fd3441df2c74533 (diff)
Drop support for old extendSelection API
Emacs now handles this via native LSP request https://github.com/emacs-lsp/lsp-mode/commit/dc86bbb227147aa8141e690ad5648fdbd2ebdb9f
Diffstat (limited to 'editors/emacs')
-rw-r--r--editors/emacs/ra-emacs-lsp.el32
1 files changed, 3 insertions, 29 deletions
diff --git a/editors/emacs/ra-emacs-lsp.el b/editors/emacs/ra-emacs-lsp.el
index 075cbd82d..79822c8ce 100644
--- a/editors/emacs/ra-emacs-lsp.el
+++ b/editors/emacs/ra-emacs-lsp.el
@@ -14,7 +14,7 @@
14;; - 'hover' type information & documentation (with lsp-ui) 14;; - 'hover' type information & documentation (with lsp-ui)
15;; - implements source changes (for code actions etc.), except for file system changes 15;; - implements source changes (for code actions etc.), except for file system changes
16;; - implements joinLines (you need to bind rust-analyzer-join-lines to a key) 16;; - implements joinLines (you need to bind rust-analyzer-join-lines to a key)
17;; - implements extendSelection (either bind rust-analyzer-extend-selection to a key, or use expand-region) 17;; - implements selectionRanges (either bind lsp-extend-selection to a key, or use expand-region)
18;; - provides rust-analyzer-inlay-hints-mode for inline type hints 18;; - provides rust-analyzer-inlay-hints-mode for inline type hints
19 19
20;; What's missing: 20;; What's missing:
@@ -103,39 +103,13 @@
103 (rust-analyzer--join-lines-params))) 103 (rust-analyzer--join-lines-params)))
104 (rust-analyzer--apply-source-change))) 104 (rust-analyzer--apply-source-change)))
105 105
106;; extend selection 106;; selection ranges
107
108(defun rust-analyzer-extend-selection ()
109 (interactive)
110 (-let (((&hash "start" "end") (rust-analyzer--extend-selection)))
111 (rust-analyzer--goto-lsp-loc start)
112 (set-mark (point))
113 (rust-analyzer--goto-lsp-loc end)
114 (exchange-point-and-mark)))
115
116(defun rust-analyzer--extend-selection-params ()
117 "Extend selection params."
118 (list :textDocument (lsp--text-document-identifier)
119 :selections
120 (vector
121 (if (use-region-p)
122 (lsp--region-to-range (region-beginning) (region-end))
123 (lsp--region-to-range (point) (point))))))
124
125(defun rust-analyzer--extend-selection ()
126 (->
127 (lsp-send-request
128 (lsp-make-request
129 "rust-analyzer/extendSelection"
130 (rust-analyzer--extend-selection-params)))
131 (ht-get "selections")
132 (seq-first)))
133 107
134(defun rust-analyzer--add-er-expansion () 108(defun rust-analyzer--add-er-expansion ()
135 (make-variable-buffer-local 'er/try-expand-list) 109 (make-variable-buffer-local 'er/try-expand-list)
136 (setq er/try-expand-list (append 110 (setq er/try-expand-list (append
137 er/try-expand-list 111 er/try-expand-list
138 '(rust-analyzer-extend-selection)))) 112 '(lsp-extend-selection))))
139 113
140(with-eval-after-load 'expand-region 114(with-eval-after-load 'expand-region
141 ;; add the expansion for all existing rust-mode buffers. If expand-region is 115 ;; add the expansion for all existing rust-mode buffers. If expand-region is