{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE DuplicateRecordFields #-}
module Language.LSP.Types.Formatting where

import Data.Aeson.TH
import Data.Text (Text)
import Language.LSP.Types.Common
import Language.LSP.Types.Location
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils

data DocumentFormattingClientCapabilities =
  DocumentFormattingClientCapabilities
    { -- | Whether formatting supports dynamic registration.
      DocumentFormattingClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> DocumentFormattingClientCapabilities -> ShowS
[DocumentFormattingClientCapabilities] -> ShowS
DocumentFormattingClientCapabilities -> String
(Int -> DocumentFormattingClientCapabilities -> ShowS)
-> (DocumentFormattingClientCapabilities -> String)
-> ([DocumentFormattingClientCapabilities] -> ShowS)
-> Show DocumentFormattingClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DocumentFormattingClientCapabilities -> ShowS
showsPrec :: Int -> DocumentFormattingClientCapabilities -> ShowS
$cshow :: DocumentFormattingClientCapabilities -> String
show :: DocumentFormattingClientCapabilities -> String
$cshowList :: [DocumentFormattingClientCapabilities] -> ShowS
showList :: [DocumentFormattingClientCapabilities] -> ShowS
Show, ReadPrec [DocumentFormattingClientCapabilities]
ReadPrec DocumentFormattingClientCapabilities
Int -> ReadS DocumentFormattingClientCapabilities
ReadS [DocumentFormattingClientCapabilities]
(Int -> ReadS DocumentFormattingClientCapabilities)
-> ReadS [DocumentFormattingClientCapabilities]
-> ReadPrec DocumentFormattingClientCapabilities
-> ReadPrec [DocumentFormattingClientCapabilities]
-> Read DocumentFormattingClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DocumentFormattingClientCapabilities
readsPrec :: Int -> ReadS DocumentFormattingClientCapabilities
$creadList :: ReadS [DocumentFormattingClientCapabilities]
readList :: ReadS [DocumentFormattingClientCapabilities]
$creadPrec :: ReadPrec DocumentFormattingClientCapabilities
readPrec :: ReadPrec DocumentFormattingClientCapabilities
$creadListPrec :: ReadPrec [DocumentFormattingClientCapabilities]
readListPrec :: ReadPrec [DocumentFormattingClientCapabilities]
Read, DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
(DocumentFormattingClientCapabilities
 -> DocumentFormattingClientCapabilities -> Bool)
-> (DocumentFormattingClientCapabilities
    -> DocumentFormattingClientCapabilities -> Bool)
-> Eq DocumentFormattingClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
== :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
$c/= :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
/= :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentFormattingClientCapabilities

makeExtendingDatatype "DocumentFormattingOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''DocumentFormattingOptions

makeExtendingDatatype "DocumentFormattingRegistrationOptions"
  [ ''TextDocumentRegistrationOptions,
    ''DocumentFormattingOptions
  ]
  []
deriveJSON lspOptions ''DocumentFormattingRegistrationOptions

-- | Value-object describing what options formatting should use.
data FormattingOptions = FormattingOptions
  { -- | Size of a tab in spaces.
    FormattingOptions -> UInt
_tabSize :: UInt,
    -- | Prefer spaces over tabs
    FormattingOptions -> Bool
_insertSpaces :: Bool,
    -- | Trim trailing whitespace on a line.
    --
    -- Since LSP 3.15.0
    FormattingOptions -> Maybe Bool
_trimTrailingWhitespace :: Maybe Bool,
    -- | Insert a newline character at the end of the file if one does not exist.
    --
    -- Since LSP 3.15.0
    FormattingOptions -> Maybe Bool
_insertFinalNewline :: Maybe Bool,
    -- | Trim all newlines after the final newline at the end of the file.
    -- 
    -- Since LSP 3.15.0
    FormattingOptions -> Maybe Bool
_trimFinalNewlines :: Maybe Bool
    -- Note: May be more properties
  }
  deriving (ReadPrec [FormattingOptions]
ReadPrec FormattingOptions
Int -> ReadS FormattingOptions
ReadS [FormattingOptions]
(Int -> ReadS FormattingOptions)
-> ReadS [FormattingOptions]
-> ReadPrec FormattingOptions
-> ReadPrec [FormattingOptions]
-> Read FormattingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS FormattingOptions
readsPrec :: Int -> ReadS FormattingOptions
$creadList :: ReadS [FormattingOptions]
readList :: ReadS [FormattingOptions]
$creadPrec :: ReadPrec FormattingOptions
readPrec :: ReadPrec FormattingOptions
$creadListPrec :: ReadPrec [FormattingOptions]
readListPrec :: ReadPrec [FormattingOptions]
Read, Int -> FormattingOptions -> ShowS
[FormattingOptions] -> ShowS
FormattingOptions -> String
(Int -> FormattingOptions -> ShowS)
-> (FormattingOptions -> String)
-> ([FormattingOptions] -> ShowS)
-> Show FormattingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FormattingOptions -> ShowS
showsPrec :: Int -> FormattingOptions -> ShowS
$cshow :: FormattingOptions -> String
show :: FormattingOptions -> String
$cshowList :: [FormattingOptions] -> ShowS
showList :: [FormattingOptions] -> ShowS
Show, FormattingOptions -> FormattingOptions -> Bool
(FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> Eq FormattingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FormattingOptions -> FormattingOptions -> Bool
== :: FormattingOptions -> FormattingOptions -> Bool
$c/= :: FormattingOptions -> FormattingOptions -> Bool
/= :: FormattingOptions -> FormattingOptions -> Bool
Eq)

deriveJSON lspOptions ''FormattingOptions
makeExtendingDatatype "DocumentFormattingParams" [''WorkDoneProgressParams]
  [ ("_textDocument", [t| TextDocumentIdentifier |])
  , ("_options", [t| FormattingOptions |])
  ]
deriveJSON lspOptions ''DocumentFormattingParams

-- -------------------------------------

data DocumentRangeFormattingClientCapabilities =
  DocumentRangeFormattingClientCapabilities
    { -- | Whether formatting supports dynamic registration.
      DocumentRangeFormattingClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> DocumentRangeFormattingClientCapabilities -> ShowS
[DocumentRangeFormattingClientCapabilities] -> ShowS
DocumentRangeFormattingClientCapabilities -> String
(Int -> DocumentRangeFormattingClientCapabilities -> ShowS)
-> (DocumentRangeFormattingClientCapabilities -> String)
-> ([DocumentRangeFormattingClientCapabilities] -> ShowS)
-> Show DocumentRangeFormattingClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DocumentRangeFormattingClientCapabilities -> ShowS
showsPrec :: Int -> DocumentRangeFormattingClientCapabilities -> ShowS
$cshow :: DocumentRangeFormattingClientCapabilities -> String
show :: DocumentRangeFormattingClientCapabilities -> String
$cshowList :: [DocumentRangeFormattingClientCapabilities] -> ShowS
showList :: [DocumentRangeFormattingClientCapabilities] -> ShowS
Show, ReadPrec [DocumentRangeFormattingClientCapabilities]
ReadPrec DocumentRangeFormattingClientCapabilities
Int -> ReadS DocumentRangeFormattingClientCapabilities
ReadS [DocumentRangeFormattingClientCapabilities]
(Int -> ReadS DocumentRangeFormattingClientCapabilities)
-> ReadS [DocumentRangeFormattingClientCapabilities]
-> ReadPrec DocumentRangeFormattingClientCapabilities
-> ReadPrec [DocumentRangeFormattingClientCapabilities]
-> Read DocumentRangeFormattingClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DocumentRangeFormattingClientCapabilities
readsPrec :: Int -> ReadS DocumentRangeFormattingClientCapabilities
$creadList :: ReadS [DocumentRangeFormattingClientCapabilities]
readList :: ReadS [DocumentRangeFormattingClientCapabilities]
$creadPrec :: ReadPrec DocumentRangeFormattingClientCapabilities
readPrec :: ReadPrec DocumentRangeFormattingClientCapabilities
$creadListPrec :: ReadPrec [DocumentRangeFormattingClientCapabilities]
readListPrec :: ReadPrec [DocumentRangeFormattingClientCapabilities]
Read, DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
(DocumentRangeFormattingClientCapabilities
 -> DocumentRangeFormattingClientCapabilities -> Bool)
-> (DocumentRangeFormattingClientCapabilities
    -> DocumentRangeFormattingClientCapabilities -> Bool)
-> Eq DocumentRangeFormattingClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
== :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
$c/= :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
/= :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentRangeFormattingClientCapabilities

makeExtendingDatatype "DocumentRangeFormattingOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''DocumentRangeFormattingOptions

makeExtendingDatatype "DocumentRangeFormattingRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''DocumentRangeFormattingOptions
  ]
  []
deriveJSON lspOptions ''DocumentRangeFormattingRegistrationOptions

makeExtendingDatatype "DocumentRangeFormattingParams" [''WorkDoneProgressParams]
  [ ("_textDocument", [t| TextDocumentIdentifier |])
  , ("_range", [t| Range |])
  , ("_options", [t| FormattingOptions |])
  ]
deriveJSON lspOptions ''DocumentRangeFormattingParams

-- -------------------------------------

data DocumentOnTypeFormattingClientCapabilities =
  DocumentOnTypeFormattingClientCapabilities
    { -- | Whether formatting supports dynamic registration.
      DocumentOnTypeFormattingClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS
[DocumentOnTypeFormattingClientCapabilities] -> ShowS
DocumentOnTypeFormattingClientCapabilities -> String
(Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS)
-> (DocumentOnTypeFormattingClientCapabilities -> String)
-> ([DocumentOnTypeFormattingClientCapabilities] -> ShowS)
-> Show DocumentOnTypeFormattingClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS
showsPrec :: Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS
$cshow :: DocumentOnTypeFormattingClientCapabilities -> String
show :: DocumentOnTypeFormattingClientCapabilities -> String
$cshowList :: [DocumentOnTypeFormattingClientCapabilities] -> ShowS
showList :: [DocumentOnTypeFormattingClientCapabilities] -> ShowS
Show, ReadPrec [DocumentOnTypeFormattingClientCapabilities]
ReadPrec DocumentOnTypeFormattingClientCapabilities
Int -> ReadS DocumentOnTypeFormattingClientCapabilities
ReadS [DocumentOnTypeFormattingClientCapabilities]
(Int -> ReadS DocumentOnTypeFormattingClientCapabilities)
-> ReadS [DocumentOnTypeFormattingClientCapabilities]
-> ReadPrec DocumentOnTypeFormattingClientCapabilities
-> ReadPrec [DocumentOnTypeFormattingClientCapabilities]
-> Read DocumentOnTypeFormattingClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DocumentOnTypeFormattingClientCapabilities
readsPrec :: Int -> ReadS DocumentOnTypeFormattingClientCapabilities
$creadList :: ReadS [DocumentOnTypeFormattingClientCapabilities]
readList :: ReadS [DocumentOnTypeFormattingClientCapabilities]
$creadPrec :: ReadPrec DocumentOnTypeFormattingClientCapabilities
readPrec :: ReadPrec DocumentOnTypeFormattingClientCapabilities
$creadListPrec :: ReadPrec [DocumentOnTypeFormattingClientCapabilities]
readListPrec :: ReadPrec [DocumentOnTypeFormattingClientCapabilities]
Read, DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
(DocumentOnTypeFormattingClientCapabilities
 -> DocumentOnTypeFormattingClientCapabilities -> Bool)
-> (DocumentOnTypeFormattingClientCapabilities
    -> DocumentOnTypeFormattingClientCapabilities -> Bool)
-> Eq DocumentOnTypeFormattingClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
== :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
$c/= :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
/= :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentOnTypeFormattingClientCapabilities

data DocumentOnTypeFormattingOptions =
  DocumentOnTypeFormattingOptions
    { -- | A character on which formatting should be triggered, like @}@.
      DocumentOnTypeFormattingOptions -> Text
_firstTriggerCharacter :: Text
    , -- | More trigger characters.
      DocumentOnTypeFormattingOptions -> Maybe [Text]
_moreTriggerCharacter  :: Maybe [Text]
    } deriving (ReadPrec [DocumentOnTypeFormattingOptions]
ReadPrec DocumentOnTypeFormattingOptions
Int -> ReadS DocumentOnTypeFormattingOptions
ReadS [DocumentOnTypeFormattingOptions]
(Int -> ReadS DocumentOnTypeFormattingOptions)
-> ReadS [DocumentOnTypeFormattingOptions]
-> ReadPrec DocumentOnTypeFormattingOptions
-> ReadPrec [DocumentOnTypeFormattingOptions]
-> Read DocumentOnTypeFormattingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DocumentOnTypeFormattingOptions
readsPrec :: Int -> ReadS DocumentOnTypeFormattingOptions
$creadList :: ReadS [DocumentOnTypeFormattingOptions]
readList :: ReadS [DocumentOnTypeFormattingOptions]
$creadPrec :: ReadPrec DocumentOnTypeFormattingOptions
readPrec :: ReadPrec DocumentOnTypeFormattingOptions
$creadListPrec :: ReadPrec [DocumentOnTypeFormattingOptions]
readListPrec :: ReadPrec [DocumentOnTypeFormattingOptions]
Read,Int -> DocumentOnTypeFormattingOptions -> ShowS
[DocumentOnTypeFormattingOptions] -> ShowS
DocumentOnTypeFormattingOptions -> String
(Int -> DocumentOnTypeFormattingOptions -> ShowS)
-> (DocumentOnTypeFormattingOptions -> String)
-> ([DocumentOnTypeFormattingOptions] -> ShowS)
-> Show DocumentOnTypeFormattingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DocumentOnTypeFormattingOptions -> ShowS
showsPrec :: Int -> DocumentOnTypeFormattingOptions -> ShowS
$cshow :: DocumentOnTypeFormattingOptions -> String
show :: DocumentOnTypeFormattingOptions -> String
$cshowList :: [DocumentOnTypeFormattingOptions] -> ShowS
showList :: [DocumentOnTypeFormattingOptions] -> ShowS
Show,DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
(DocumentOnTypeFormattingOptions
 -> DocumentOnTypeFormattingOptions -> Bool)
-> (DocumentOnTypeFormattingOptions
    -> DocumentOnTypeFormattingOptions -> Bool)
-> Eq DocumentOnTypeFormattingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
== :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
$c/= :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
/= :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
Eq)
deriveJSON lspOptions ''DocumentOnTypeFormattingOptions

makeExtendingDatatype "DocumentOnTypeFormattingRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''DocumentOnTypeFormattingOptions
  ]
  []
deriveJSON lspOptions ''DocumentOnTypeFormattingRegistrationOptions

makeExtendingDatatype "DocumentOnTypeFormattingParams" [''TextDocumentPositionParams]
  [ ("_ch", [t| Text |])
  , ("_options", [t| FormattingOptions |])
  ]
deriveJSON lspOptions ''DocumentOnTypeFormattingParams