Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lsp types to allow workspace/applyEdit to work #816

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ type FcsRange = FSharp.Compiler.Text.Range
module FcsPos = FSharp.Compiler.Text.Pos
type FcsPos = FSharp.Compiler.Text.Pos

module Result =
let ofCoreResponse (r: CoreResponse<'a>) =
match r with
| CoreResponse.Res a -> Ok a
| CoreResponse.ErrorRes msg
| CoreResponse.InfoRes msg -> Error (JsonRpc.Error.InternalErrorMessage msg)

module AsyncResult =
let ofCoreResponse (ar: Async<CoreResponse<'a>>) =
ar |> Async.map (function | CoreResponse.Res a -> Ok a | CoreResponse.ErrorRes msg | CoreResponse.InfoRes msg -> Error (JsonRpc.Error.InternalErrorMessage msg))
ar |> Async.map Result.ofCoreResponse

let ofStringErr (ar: Async<Result<'a, string>>) =
ar |> AsyncResult.mapError JsonRpc.Error.InternalErrorMessage
Expand Down
21 changes: 21 additions & 0 deletions src/LanguageServerProtocol/LanguageServerProtocol.fs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ module Types =
/// (the server has not received an open notification before) the server can send
/// `null` to indicate that the version is known and the content on disk is the
/// truth (as speced with document content ownership)
/// Explicitly include the null value here.
[<JsonProperty(NullValueHandling = NullValueHandling.Include)>]
Version: int option
}
interface ITextDocumentIdentifier with
Expand Down Expand Up @@ -321,10 +323,29 @@ module Types =
DynamicRegistration: bool option
}

type ResourceOperationKind = Create | Rename | Delete

type FailureHandlingKind = Abort | Transactional | Undo | TextOnlyTransactional

type ChangeAnnotationSupport = {
GroupsOnLabel: bool option
}

/// Capabilities specific to `WorkspaceEdit`s
type WorkspaceEditCapabilities = {
/// The client supports versioned document changes in `WorkspaceEdit`s
DocumentChanges: bool option
/// The resource operations the client supports. Clients should at least
/// support 'create', 'rename' and 'delete' files and folders.
ResourceOperations: ResourceOperationKind [] option
/// The failure handling strategy of a client if applying the workspace edit fails.
FailureHandling: FailureHandlingKind option
/// Whether the client normalizes line endings to the client specific setting.
/// If set to `true` the client will normalize line ending characters
/// in a workspace edit to the client specific new line character(s).
NormalizesLineEndings: bool option
/// Whether the client in general supports change annotations on text edits, create file, rename file and delete file changes.
ChangeAnnotationSupport: ChangeAnnotationSupport option
}

/// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request.
Expand Down
6 changes: 5 additions & 1 deletion test/FsAutoComplete.Tests.Lsp/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ let defaultConfigDto : FSharpConfigDto =
let clientCaps : ClientCapabilities =
let dynCaps : DynamicCapabilities = { DynamicRegistration = Some true}
let workspaceCaps : WorkspaceClientCapabilities =
let weCaps : WorkspaceEditCapabilities = { DocumentChanges = Some true}
let weCaps : WorkspaceEditCapabilities = { DocumentChanges = Some true
ResourceOperations = None
FailureHandling = None
NormalizesLineEndings = None
ChangeAnnotationSupport = None }
let symbolCaps: SymbolCapabilities = { DynamicRegistration = Some true
SymbolKind = None}
let semanticTokenCaps: SemanticTokensWorkspaceClientCapabilities = { RefreshSupport = Some true }
Expand Down