Skip to content

Commit

Permalink
Implement support for textDocument/linkedEditingRange
Browse files Browse the repository at this point in the history
Fixes #2449
  • Loading branch information
yyoncho committed Oct 23, 2021
1 parent 1ece3b8 commit 4982564
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
* Changelog
** Unreleased 8.0.1
* Added support for ~textDocument/linkedEditingRange~ via
~lsp-iedit-linked-ranges~ and ~lsp-evil-multiedit-ranges~ (see [[https://github.com/emacs-lsp/lsp-mode/pull/3166][#3166]])
* Add [[https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli#readme][GraphQL Language Server]] for autocomplete graphql query
* Added ~lsp-auto-touch-files~. When it is non-nil it will auto-create the
file on the disk before sending ~textDocument/didOpen~.
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-xml.el
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Newlines and excess whitespace are removed."
("xml.catalogs" lsp-xml-catalogs)
("xml.trace.server" lsp-xml-trace-server)))

(defconst lsp-xml-jar-version "0.13.1")
(defconst lsp-xml-jar-version "0.18.0")

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

Expand Down
27 changes: 24 additions & 3 deletions lsp-iedit.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,23 @@ See also `lsp-enable-symbol-highlighting'."
(let ((highlights (lsp-request "textDocument/documentHighlight"
(lsp--text-document-position-params)))
(-compare-fn (-lambda ((&Location :range (&Range :start l-start :end l-end))
(&Location :range (&Range :start r-start :end r-end)))
(and (lsp--position-equal l-start r-start)
(lsp--position-equal l-end r-end)))))
(&Location :range (&Range :start r-start :end r-end)))
(and (lsp--position-equal l-start r-start)
(lsp--position-equal l-end r-end)))))
(lsp-iedit--on-ranges (mapcar #'lsp:document-highlight-range (-distinct highlights)))))

;;;###autoload
(defun lsp-iedit-linked-ranges ()
"Start an `iedit' for `textDocument/linkedEditingRange'"
(interactive)
(unless (lsp-feature? "textDocument/linkedEditingRange")
(user-error "`textDocument/linkedEditingRange' is not supported by current server"))

(-> (lsp-request "textDocument/linkedEditingRange" (lsp--text-document-position-params))
(lsp:linked-editing-ranges-ranges)
(or (user-error "No editing ranges found"))
(lsp-iedit--on-ranges)))

;;;###autoload
(defun lsp-evil-multiedit-highlights ()
"Start an `evil-multiedit' operation on the documentHighlights at point.
Expand All @@ -95,6 +107,15 @@ See also `lsp-enable-symbol-highlighting'."
(lsp-iedit-highlights)
(evil-multiedit-state))

(defun lsp-evil-multiedit-ranges ()
"Start an `evil-multiedit' for `textDocument/linkedEditingRange'"
(interactive)
(require 'evil-multiedit)
(when (fboundp 'ahs-clear) (ahs-clear))
(setq evil-multiedit--dont-recall t)
(lsp-iedit-linked-ranges)
(evil-multiedit-state))

(lsp-consistency-check lsp-iedit)

(provide 'lsp-iedit)
Expand Down
4 changes: 2 additions & 2 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ directory")
("textDocument/formatting" :capability :documentFormattingProvider)
("textDocument/hover" :capability :hoverProvider)
("textDocument/implementation" :capability :implementationProvider)
("textDocument/linkedEditingRange" :capability :linkedEditingRangeProvider)
("textDocument/onTypeFormatting" :capability :documentOnTypeFormattingProvider)
("textDocument/prepareRename"
:check-command (lambda (workspace)
Expand Down Expand Up @@ -3451,8 +3452,7 @@ disappearing, unset all the variables related to it."
(publishDiagnostics . ((relatedInformation . t)
(tagSupport . ((valueSet . [1 2])))
(versionSupport . t)))
(moniker . nil)
(linkedEditingRange . nil)))
(linkedEditingRange . ((dynamicRegistration . t)))))
(window . ((workDoneProgress . t)
(showMessage . nil)
(showDocument . nil))))
Expand Down
1 change: 1 addition & 0 deletions lsp-protocol.el
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ See `-let' for a description of the destructuring mechanism."
(FormattingOptions (:tabSize :insertSpaces) (:trimTrailingWhitespace :insertFinalNewline :trimFinalNewlines))
(HoverCapabilities nil (:contentFormat :dynamicRegistration))
(ImplementationCapabilities nil (:dynamicRegistration :linkSupport))
(LinkedEditingRanges (:ranges) (:wordPattern))
(Location (:range :uri) nil)
(MarkedString (:language :value) nil)
(MarkupContent (:kind :value) nil)
Expand Down

0 comments on commit 4982564

Please sign in to comment.