Skip to content

Commit

Permalink
Merge pull request #460 from MaskRay/rename
Browse files Browse the repository at this point in the history
lsp-rename: change prompt
  • Loading branch information
yyoncho authored Oct 27, 2018
2 parents e2edc74 + 1924261 commit 08f5c0c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lsp-methods.el
Original file line number Diff line number Diff line change
Expand Up @@ -2306,26 +2306,17 @@ A reference is highlighted only if it is visible in a window."
`(:query ,pattern)))))
(seq-map #'lsp--symbol-information-to-xref symbols)))

(defun lsp--make-document-rename-params (newname)
"Make DocumentRangeFormattingParams for selected region.
interface RenameParams {
textDocument: TextDocumentIdentifier;
position: Position;
newName: string;
}"
`(:position ,(lsp--cur-position)
:textDocument ,(lsp--text-document-identifier)
:newName ,newname))

(defun lsp-rename (newname)
"Rename the symbol (and all references to it) under point to NEWNAME."
(interactive (list (read-string "Rename to: " (thing-at-point 'symbol))))
(interactive (list (read-string (format "Rename %s to: " (thing-at-point 'symbol t)))))
(lsp--cur-workspace-check)
(unless (lsp--capability "renameProvider")
(signal 'lsp-capability-not-supported (list "renameProvider")))
(let ((edits (lsp--send-request (lsp--make-request
"textDocument/rename"
(lsp--make-document-rename-params newname)))))
`(:textDocument ,(lsp--text-document-identifier)
:position ,(lsp--cur-position)
:newName ,newname)))))
(when edits
(lsp--apply-workspace-edit edits))))

Expand Down

0 comments on commit 08f5c0c

Please sign in to comment.