Skip to content

Commit 1a81bfc

Browse files
committed
Add support for prepareRename
If the server provides an STextDocumentPrepareRename handler, set RenameOptions during initialisation accordingly.
1 parent 52f6bf2 commit 1a81bfc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Language/LSP/Server/Processing.hs

+12-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ inferServerCapabilities clientCaps o h =
153153
, _documentFormattingProvider = supportedBool STextDocumentFormatting
154154
, _documentRangeFormattingProvider = supportedBool STextDocumentRangeFormatting
155155
, _documentOnTypeFormattingProvider = documentOnTypeFormattingProvider
156-
, _renameProvider = supportedBool STextDocumentRename
156+
, _renameProvider = renameProvider
157157
, _documentLinkProvider = supported' STextDocumentDocumentLink $ DocumentLinkOptions
158158
(Just False)
159159
(supported SDocumentLinkResolve)
@@ -233,6 +233,17 @@ inferServerCapabilities clientCaps o h =
233233
error "executeCommandCommands needs to be set if a executeCommandHandler is set"
234234
| otherwise = Nothing
235235

236+
clientSupportsPrepareRename = fromMaybe False $
237+
clientCaps ^? LSP.textDocument . _Just . LSP.rename . _Just . LSP.prepareSupport . _Just
238+
239+
renameProvider
240+
| clientSupportsPrepareRename
241+
, supported_b STextDocumentRename
242+
, supported_b STextDocumentPrepareRename = Just $
243+
InR . RenameOptions Nothing . Just $ True
244+
| supported_b STextDocumentRename = Just (InL True)
245+
| otherwise = Just (InL False)
246+
236247
sync = case textDocumentSync o of
237248
Just x -> Just (InL x)
238249
Nothing -> Nothing

0 commit comments

Comments
 (0)