Skip to content

Commit fd34321

Browse files
committed
Implement support for textDocument/linkedEditingRange
Fixes #2449
1 parent 1ece3b8 commit fd34321

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

CHANGELOG.org

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
* Changelog
22
** Unreleased 8.0.1
3+
* Added support for ~textDocument/linkedEditingRange~ via
4+
~lsp-iedit-linked-ranges~ and ~lsp-evil-multiedit-ranges~ (see [[https://github.com/emacs-lsp/lsp-mode/pull/3166][#3166]])
35
* Add [[https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli#readme][GraphQL Language Server]] for autocomplete graphql query
46
* Added ~lsp-auto-touch-files~. When it is non-nil it will auto-create the
57
file on the disk before sending ~textDocument/didOpen~.

clients/lsp-xml.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Newlines and excess whitespace are removed."
189189
("xml.catalogs" lsp-xml-catalogs)
190190
("xml.trace.server" lsp-xml-trace-server)))
191191

192-
(defconst lsp-xml-jar-version "0.13.1")
192+
(defconst lsp-xml-jar-version "0.18.0")
193193

194194
(defconst lsp-xml-jar-name (format "org.eclipse.lemminx-%s-uber.jar" lsp-xml-jar-version))
195195

lsp-iedit.el

+24-3
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,23 @@ See also `lsp-enable-symbol-highlighting'."
7676
(let ((highlights (lsp-request "textDocument/documentHighlight"
7777
(lsp--text-document-position-params)))
7878
(-compare-fn (-lambda ((&Location :range (&Range :start l-start :end l-end))
79-
(&Location :range (&Range :start r-start :end r-end)))
80-
(and (lsp--position-equal l-start r-start)
81-
(lsp--position-equal l-end r-end)))))
79+
(&Location :range (&Range :start r-start :end r-end)))
80+
(and (lsp--position-equal l-start r-start)
81+
(lsp--position-equal l-end r-end)))))
8282
(lsp-iedit--on-ranges (mapcar #'lsp:document-highlight-range (-distinct highlights)))))
8383

84+
;;;###autoload
85+
(defun lsp-iedit-linked-ranges ()
86+
"Start an `iedit' for `textDocument/linkedEditingRange'"
87+
(interactive)
88+
(unless (lsp-feature? "textDocument/linkedEditingRange")
89+
(user-error "`textDocument/linkedEditingRange' is not supported by current server"))
90+
91+
(->> (lsp--text-document-position-params)
92+
(lsp-request "textDocument/linkedEditingRange")
93+
(lsp:linked-editing-ranges-ranges)
94+
(lsp-iedit--on-ranges)))
95+
8496
;;;###autoload
8597
(defun lsp-evil-multiedit-highlights ()
8698
"Start an `evil-multiedit' operation on the documentHighlights at point.
@@ -95,6 +107,15 @@ See also `lsp-enable-symbol-highlighting'."
95107
(lsp-iedit-highlights)
96108
(evil-multiedit-state))
97109

110+
(defun lsp-evil-multiedit-ranges ()
111+
"Start an `evil-multiedit' for `textDocument/linkedEditingRange'"
112+
(interactive)
113+
(require 'evil-multiedit)
114+
(when (fboundp 'ahs-clear) (ahs-clear))
115+
(setq evil-multiedit--dont-recall t)
116+
(lsp-iedit-linked-ranges)
117+
(evil-multiedit-state))
118+
98119
(lsp-consistency-check lsp-iedit)
99120

100121
(provide 'lsp-iedit)

lsp-mode.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ directory")
835835
("textDocument/formatting" :capability :documentFormattingProvider)
836836
("textDocument/hover" :capability :hoverProvider)
837837
("textDocument/implementation" :capability :implementationProvider)
838+
("textDocument/linkedEditingRange" :capability :linkedEditingRangeProvider)
838839
("textDocument/onTypeFormatting" :capability :documentOnTypeFormattingProvider)
839840
("textDocument/prepareRename"
840841
:check-command (lambda (workspace)
@@ -3451,8 +3452,7 @@ disappearing, unset all the variables related to it."
34513452
(publishDiagnostics . ((relatedInformation . t)
34523453
(tagSupport . ((valueSet . [1 2])))
34533454
(versionSupport . t)))
3454-
(moniker . nil)
3455-
(linkedEditingRange . nil)))
3455+
(linkedEditingRange . ((dynamicRegistration . t)))))
34563456
(window . ((workDoneProgress . t)
34573457
(showMessage . nil)
34583458
(showDocument . nil))))

lsp-protocol.el

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ See `-let' for a description of the destructuring mechanism."
604604
(FormattingOptions (:tabSize :insertSpaces) (:trimTrailingWhitespace :insertFinalNewline :trimFinalNewlines))
605605
(HoverCapabilities nil (:contentFormat :dynamicRegistration))
606606
(ImplementationCapabilities nil (:dynamicRegistration :linkSupport))
607+
(LinkedEditingRanges (:ranges) (:wordPattern))
607608
(Location (:range :uri) nil)
608609
(MarkedString (:language :value) nil)
609610
(MarkupContent (:kind :value) nil)

0 commit comments

Comments
 (0)