Skip to content

Commit 0670480

Browse files
authored
Add types and requests for workspace-level file events (#17)
1 parent a1afc22 commit 0670480

File tree

1 file changed

+88
-3
lines changed

1 file changed

+88
-3
lines changed

src/LanguageServerProtocol.fs

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,11 +2271,57 @@ module Types =
22712271
type SemanticTokensDelta = {
22722272
ResultId: string option
22732273

2274-
/// The semantic token edits to transform a previous result into a new
2275-
/// result.
2276-
Edits: SemanticTokensEdit[];
2274+
/// The semantic token edits to transform a previous result into a new result.
2275+
Edits: SemanticTokensEdit[]
2276+
}
2277+
2278+
/// Represents information on a file/folder create.
2279+
///@since 3.16.0
2280+
type FileCreate = {
2281+
/// A file:// URI for the location of the file/folder being created.
2282+
Uri: string
2283+
}
2284+
2285+
/// The parameters sent in notifications/requests for user-initiated creation of files.
2286+
/// @since 3.16.0
2287+
type CreateFilesParams = {
2288+
/// An array of all files/folders created in this operation.
2289+
Files: FileCreate[]
2290+
}
2291+
2292+
/// Represents information on a file/folder rename.
2293+
/// @since 3.16.0
2294+
type FileRename = {
2295+
/// A file:// URI for the original location of the file/folder being renamed.
2296+
OldUri: string
2297+
/// A file:// URI for the new location of the file/folder being renamed.
2298+
NewUri: string
2299+
}
2300+
2301+
/// The parameters sent in notifications/requests for user-initiated renames of files.
2302+
/// @since 3.16.0
2303+
type RenameFilesParams = {
2304+
/// An array of all files/folders renamed in this operation. When a folder is renamed,
2305+
/// only the folder will be included, and not its children.
2306+
Files: FileRename[]
2307+
}
2308+
2309+
/// Represents information on a file/folder create.
2310+
///@since 3.16.0
2311+
type FileDelete = {
2312+
/// A file:// URI for the location of the file/folder being deleted.
2313+
Uri: string
2314+
}
2315+
2316+
/// The parameters sent in notifications/requests for user-initiated deletes of files.
2317+
/// @since 3.16.0
2318+
type DeleteFilesParams = {
2319+
/// An array of all files/folders deleted in this operation.
2320+
Files: FileDelete[]
22772321
}
22782322

2323+
open Types
2324+
22792325
module LowLevel =
22802326
open System
22812327
open System.IO
@@ -2751,6 +2797,39 @@ type LspServer() =
27512797
/// A notification sent from the client to the server to signal the change of configuration settings.
27522798
abstract member WorkspaceDidChangeConfiguration: DidChangeConfigurationParams -> Async<unit>
27532799
default __.WorkspaceDidChangeConfiguration(_) = ignoreNotification
2800+
2801+
/// The will create files request is sent from the client to the server before files are actually created
2802+
/// as long as the creation is triggered from within the client either by a user action or by applying a
2803+
/// workspace edit
2804+
abstract member WorkspaceWillCreateFiles: CreateFilesParams -> AsyncLspResult<WorkspaceEdit option>
2805+
default __.WorkspaceWillCreateFiles(_) = notImplemented
2806+
2807+
/// The did create files notification is sent from the client to the server when files were created
2808+
/// from within the client.
2809+
abstract member WorkspaceDidCreateFiles: CreateFilesParams -> Async<unit>
2810+
default __.WorkspaceDidCreateFiles(_) = ignoreNotification
2811+
2812+
/// The will rename files request is sent from the client to the server before files are actually renamed
2813+
/// as long as the rename is triggered from within the client either by a user action or by applying a
2814+
/// workspace edit.
2815+
abstract member WorkspaceWillRenameFiles: RenameFilesParams -> AsyncLspResult<WorkspaceEdit option>
2816+
default __.WorkspaceWillRenameFiles(_) = notImplemented
2817+
2818+
/// The did rename files notification is sent from the client to the server when files were renamed from
2819+
/// within the client.
2820+
abstract member WorkspaceDidRenameFiles: RenameFilesParams -> Async<unit>
2821+
default __.WorkspaceDidRenameFiles(_) = ignoreNotification
2822+
2823+
/// The will delete files request is sent from the client to the server before files are actually deleted
2824+
/// as long as the deletion is triggered from within the client either by a user action or by applying a
2825+
/// workspace edit.
2826+
abstract member WorkspaceWillDeleteFiles: DeleteFilesParams -> AsyncLspResult<WorkspaceEdit option>
2827+
default __.WorkspaceWillDeleteFiles(_) = notImplemented
2828+
2829+
/// The did delete files notification is sent from the client to the server when files were deleted from
2830+
/// within the client.
2831+
abstract member WorkspaceDidDeleteFiles: DeleteFilesParams -> Async<unit>
2832+
default __.WorkspaceDidDeleteFiles(_) = ignoreNotification
27542833

27552834
/// The workspace symbol request is sent from the client to the server to list project-wide symbols matching
27562835
/// the query string.
@@ -2982,6 +3061,12 @@ module Server =
29823061
"workspace/didChangeWatchedFiles", requestHandling (fun s p -> s.WorkspaceDidChangeWatchedFiles(p) |> notificationSuccess)
29833062
"workspace/didChangeWorkspaceFolders", requestHandling (fun s p -> s.WorkspaceDidChangeWorkspaceFolders (p) |> notificationSuccess)
29843063
"workspace/didChangeConfiguration", requestHandling (fun s p -> s.WorkspaceDidChangeConfiguration (p) |> notificationSuccess)
3064+
"workspace/willCreateFiles", requestHandling (fun s p -> s.WorkspaceWillCreateFiles(p))
3065+
"workspace/didCreateFiles", requestHandling (fun s p -> s.WorkspaceDidCreateFiles(p) |> notificationSuccess)
3066+
"workspace/willRenameFiles", requestHandling (fun s p -> s.WorkspaceWillRenameFiles(p))
3067+
"workspace/didRenameFiles", requestHandling (fun s p -> s.WorkspaceDidRenameFiles(p) |> notificationSuccess)
3068+
"workspace/willDeleteFiles", requestHandling (fun s p -> s.WorkspaceWillDeleteFiles(p))
3069+
"workspace/didDeleteFiles", requestHandling (fun s p -> s.WorkspaceDidDeleteFiles(p) |> notificationSuccess)
29853070
"workspace/symbol", requestHandling (fun s p -> s.WorkspaceSymbol (p))
29863071
"workspace/executeCommand ", requestHandling (fun s p -> s.WorkspaceExecuteCommand (p))
29873072
"shutdown", requestHandling (fun s () -> s.Shutdown() |> notificationSuccess)

0 commit comments

Comments
 (0)