#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"

namespace lsp::protocol
{
    // Document Formatting
    struct DocumentFormattingClientCapabilities
    {
        std::optional<boolean> dynamicRegistration;
    };

    struct DocumentFormattingOptions : WorkDoneProgressOptions
    {
    };

    struct DocumentFormattingRegistrationOptions : TextDocumentRegistrationOptions, DocumentFormattingOptions
    {
    };

    struct FormattingOptions
    {
        uinteger tabSize;
        boolean insertSpaces;
        std::optional<boolean> trimTrailingWhitespace;
        std::optional<boolean> insertFinalNewline;
        std::optional<boolean> trimFinalNewlines;
        std::map<string, std::variant<boolean, integer, string>> key;
    };

    struct DocumentFormattingParams : WorkDoneProgressParams
    {
        TextDocumentIdentifier textDocument;
        FormattingOptions options;
    };

    // Document Range Formatting
    struct DocumentRangeFormattingClientCapabilities
    {
        std::optional<boolean> dynamicRegistration;
        std::optional<boolean> rangesSupport;
    };

    struct DocumentRangeFormattingOptions : WorkDoneProgressOptions
    {
        std::optional<boolean> rangesSupport;
    };

    struct DocumentRangeFormattingRegistrationOptions : TextDocumentRegistrationOptions, DocumentRangeFormattingOptions
    {
    };

    struct DocumentRangeFormattingParams : WorkDoneProgressParams
    {
        TextDocumentIdentifier textDocument;
        Range range;
        FormattingOptions options;
    };

    // Document On Type Formatting
    struct DocumentOnTypeFormattingClientCapabilities
    {
        std::optional<boolean> dynamicRegistration;
    };

    struct DocumentOnTypeFormattingOptions : WorkDoneProgressOptions
    {
        string firstTriggerCharacter;
        std::optional<std::vector<string>> moreTriggerCharacter;
    };

    struct DocumentOnTypeFormattingRegistrationOptions : TextDocumentRegistrationOptions, DocumentOnTypeFormattingOptions
    {
    };

    struct DocumentOnTypeFormattingParams
    {
        TextDocumentIdentifier textDocument;
        Position position;
        string ch;
        FormattingOptions options;
    };
}
