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

import qualified Data.Aeson                    as A
import           Data.Aeson.TH
import           Data.Scientific                ( Scientific )
import           Data.Text                      ( Text )
import           Language.LSP.Types.Command
import           Language.LSP.Types.Common
import           Language.LSP.Types.MarkupContent
import           Language.LSP.Types.Progress
import           Language.LSP.Types.TextDocument
import           Language.LSP.Types.Utils
import           Language.LSP.Types.WorkspaceEdit
import           Language.LSP.Types.Location (Range)

data CompletionItemKind = CiText
                        | CiMethod
                        | CiFunction
                        | CiConstructor
                        | CiField
                        | CiVariable
                        | CiClass
                        | CiInterface
                        | CiModule
                        | CiProperty
                        | CiUnit
                        | CiValue
                        | CiEnum
                        | CiKeyword
                        | CiSnippet
                        | CiColor
                        | CiFile
                        | CiReference
                        | CiFolder
                        | CiEnumMember
                        | CiConstant
                        | CiStruct
                        | CiEvent
                        | CiOperator
                        | CiTypeParameter
         deriving (ReadPrec [CompletionItemKind]
ReadPrec CompletionItemKind
Int -> ReadS CompletionItemKind
ReadS [CompletionItemKind]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemKind]
$creadListPrec :: ReadPrec [CompletionItemKind]
readPrec :: ReadPrec CompletionItemKind
$creadPrec :: ReadPrec CompletionItemKind
readList :: ReadS [CompletionItemKind]
$creadList :: ReadS [CompletionItemKind]
readsPrec :: Int -> ReadS CompletionItemKind
$creadsPrec :: Int -> ReadS CompletionItemKind
Read,Int -> CompletionItemKind -> ShowS
[CompletionItemKind] -> ShowS
CompletionItemKind -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemKind] -> ShowS
$cshowList :: [CompletionItemKind] -> ShowS
show :: CompletionItemKind -> String
$cshow :: CompletionItemKind -> String
showsPrec :: Int -> CompletionItemKind -> ShowS
$cshowsPrec :: Int -> CompletionItemKind -> ShowS
Show,CompletionItemKind -> CompletionItemKind -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemKind -> CompletionItemKind -> Bool
$c/= :: CompletionItemKind -> CompletionItemKind -> Bool
== :: CompletionItemKind -> CompletionItemKind -> Bool
$c== :: CompletionItemKind -> CompletionItemKind -> Bool
Eq,Eq CompletionItemKind
CompletionItemKind -> CompletionItemKind -> Bool
CompletionItemKind -> CompletionItemKind -> Ordering
CompletionItemKind -> CompletionItemKind -> CompletionItemKind
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CompletionItemKind -> CompletionItemKind -> CompletionItemKind
$cmin :: CompletionItemKind -> CompletionItemKind -> CompletionItemKind
max :: CompletionItemKind -> CompletionItemKind -> CompletionItemKind
$cmax :: CompletionItemKind -> CompletionItemKind -> CompletionItemKind
>= :: CompletionItemKind -> CompletionItemKind -> Bool
$c>= :: CompletionItemKind -> CompletionItemKind -> Bool
> :: CompletionItemKind -> CompletionItemKind -> Bool
$c> :: CompletionItemKind -> CompletionItemKind -> Bool
<= :: CompletionItemKind -> CompletionItemKind -> Bool
$c<= :: CompletionItemKind -> CompletionItemKind -> Bool
< :: CompletionItemKind -> CompletionItemKind -> Bool
$c< :: CompletionItemKind -> CompletionItemKind -> Bool
compare :: CompletionItemKind -> CompletionItemKind -> Ordering
$ccompare :: CompletionItemKind -> CompletionItemKind -> Ordering
Ord)

instance A.ToJSON CompletionItemKind where
  toJSON :: CompletionItemKind -> Value
toJSON CompletionItemKind
CiText          = Scientific -> Value
A.Number Scientific
1
  toJSON CompletionItemKind
CiMethod        = Scientific -> Value
A.Number Scientific
2
  toJSON CompletionItemKind
CiFunction      = Scientific -> Value
A.Number Scientific
3
  toJSON CompletionItemKind
CiConstructor   = Scientific -> Value
A.Number Scientific
4
  toJSON CompletionItemKind
CiField         = Scientific -> Value
A.Number Scientific
5
  toJSON CompletionItemKind
CiVariable      = Scientific -> Value
A.Number Scientific
6
  toJSON CompletionItemKind
CiClass         = Scientific -> Value
A.Number Scientific
7
  toJSON CompletionItemKind
CiInterface     = Scientific -> Value
A.Number Scientific
8
  toJSON CompletionItemKind
CiModule        = Scientific -> Value
A.Number Scientific
9
  toJSON CompletionItemKind
CiProperty      = Scientific -> Value
A.Number Scientific
10
  toJSON CompletionItemKind
CiUnit          = Scientific -> Value
A.Number Scientific
11
  toJSON CompletionItemKind
CiValue         = Scientific -> Value
A.Number Scientific
12
  toJSON CompletionItemKind
CiEnum          = Scientific -> Value
A.Number Scientific
13
  toJSON CompletionItemKind
CiKeyword       = Scientific -> Value
A.Number Scientific
14
  toJSON CompletionItemKind
CiSnippet       = Scientific -> Value
A.Number Scientific
15
  toJSON CompletionItemKind
CiColor         = Scientific -> Value
A.Number Scientific
16
  toJSON CompletionItemKind
CiFile          = Scientific -> Value
A.Number Scientific
17
  toJSON CompletionItemKind
CiReference     = Scientific -> Value
A.Number Scientific
18
  toJSON CompletionItemKind
CiFolder        = Scientific -> Value
A.Number Scientific
19
  toJSON CompletionItemKind
CiEnumMember    = Scientific -> Value
A.Number Scientific
20
  toJSON CompletionItemKind
CiConstant      = Scientific -> Value
A.Number Scientific
21
  toJSON CompletionItemKind
CiStruct        = Scientific -> Value
A.Number Scientific
22
  toJSON CompletionItemKind
CiEvent         = Scientific -> Value
A.Number Scientific
23
  toJSON CompletionItemKind
CiOperator      = Scientific -> Value
A.Number Scientific
24
  toJSON CompletionItemKind
CiTypeParameter = Scientific -> Value
A.Number Scientific
25

instance A.FromJSON CompletionItemKind where
  parseJSON :: Value -> Parser CompletionItemKind
parseJSON (A.Number  Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiText
  parseJSON (A.Number  Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiMethod
  parseJSON (A.Number  Scientific
3) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiFunction
  parseJSON (A.Number  Scientific
4) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiConstructor
  parseJSON (A.Number  Scientific
5) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiField
  parseJSON (A.Number  Scientific
6) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiVariable
  parseJSON (A.Number  Scientific
7) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiClass
  parseJSON (A.Number  Scientific
8) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiInterface
  parseJSON (A.Number  Scientific
9) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiModule
  parseJSON (A.Number Scientific
10) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiProperty
  parseJSON (A.Number Scientific
11) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiUnit
  parseJSON (A.Number Scientific
12) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiValue
  parseJSON (A.Number Scientific
13) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiEnum
  parseJSON (A.Number Scientific
14) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiKeyword
  parseJSON (A.Number Scientific
15) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiSnippet
  parseJSON (A.Number Scientific
16) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiColor
  parseJSON (A.Number Scientific
17) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiFile
  parseJSON (A.Number Scientific
18) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiReference
  parseJSON (A.Number Scientific
19) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiFolder
  parseJSON (A.Number Scientific
20) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiEnumMember
  parseJSON (A.Number Scientific
21) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiConstant
  parseJSON (A.Number Scientific
22) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiStruct
  parseJSON (A.Number Scientific
23) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiEvent
  parseJSON (A.Number Scientific
24) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiOperator
  parseJSON (A.Number Scientific
25) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemKind
CiTypeParameter
  parseJSON Value
_             = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"CompletionItemKind"

data CompletionItemTag
  -- | Render a completion as obsolete, usually using a strike-out.
  = CitDeprecated
  | CitUnknown Scientific
  deriving (CompletionItemTag -> CompletionItemTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemTag -> CompletionItemTag -> Bool
$c/= :: CompletionItemTag -> CompletionItemTag -> Bool
== :: CompletionItemTag -> CompletionItemTag -> Bool
$c== :: CompletionItemTag -> CompletionItemTag -> Bool
Eq, Eq CompletionItemTag
CompletionItemTag -> CompletionItemTag -> Bool
CompletionItemTag -> CompletionItemTag -> Ordering
CompletionItemTag -> CompletionItemTag -> CompletionItemTag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CompletionItemTag -> CompletionItemTag -> CompletionItemTag
$cmin :: CompletionItemTag -> CompletionItemTag -> CompletionItemTag
max :: CompletionItemTag -> CompletionItemTag -> CompletionItemTag
$cmax :: CompletionItemTag -> CompletionItemTag -> CompletionItemTag
>= :: CompletionItemTag -> CompletionItemTag -> Bool
$c>= :: CompletionItemTag -> CompletionItemTag -> Bool
> :: CompletionItemTag -> CompletionItemTag -> Bool
$c> :: CompletionItemTag -> CompletionItemTag -> Bool
<= :: CompletionItemTag -> CompletionItemTag -> Bool
$c<= :: CompletionItemTag -> CompletionItemTag -> Bool
< :: CompletionItemTag -> CompletionItemTag -> Bool
$c< :: CompletionItemTag -> CompletionItemTag -> Bool
compare :: CompletionItemTag -> CompletionItemTag -> Ordering
$ccompare :: CompletionItemTag -> CompletionItemTag -> Ordering
Ord, Int -> CompletionItemTag -> ShowS
[CompletionItemTag] -> ShowS
CompletionItemTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemTag] -> ShowS
$cshowList :: [CompletionItemTag] -> ShowS
show :: CompletionItemTag -> String
$cshow :: CompletionItemTag -> String
showsPrec :: Int -> CompletionItemTag -> ShowS
$cshowsPrec :: Int -> CompletionItemTag -> ShowS
Show, ReadPrec [CompletionItemTag]
ReadPrec CompletionItemTag
Int -> ReadS CompletionItemTag
ReadS [CompletionItemTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemTag]
$creadListPrec :: ReadPrec [CompletionItemTag]
readPrec :: ReadPrec CompletionItemTag
$creadPrec :: ReadPrec CompletionItemTag
readList :: ReadS [CompletionItemTag]
$creadList :: ReadS [CompletionItemTag]
readsPrec :: Int -> ReadS CompletionItemTag
$creadsPrec :: Int -> ReadS CompletionItemTag
Read)

instance A.ToJSON CompletionItemTag where
  toJSON :: CompletionItemTag -> Value
toJSON CompletionItemTag
CitDeprecated  = Scientific -> Value
A.Number Scientific
1
  toJSON (CitUnknown Scientific
i) = Scientific -> Value
A.Number Scientific
i

instance A.FromJSON CompletionItemTag where
  parseJSON :: Value -> Parser CompletionItemTag
parseJSON (A.Number Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionItemTag
CitDeprecated
  parseJSON Value
_            = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"CompletionItemTag"

data CompletionItemTagsClientCapabilities =
  CompletionItemTagsClientCapabilities
    { -- | The tag supported by the client.
      CompletionItemTagsClientCapabilities -> List CompletionItemTag
_valueSet :: List CompletionItemTag
    } deriving (Int -> CompletionItemTagsClientCapabilities -> ShowS
[CompletionItemTagsClientCapabilities] -> ShowS
CompletionItemTagsClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemTagsClientCapabilities] -> ShowS
$cshowList :: [CompletionItemTagsClientCapabilities] -> ShowS
show :: CompletionItemTagsClientCapabilities -> String
$cshow :: CompletionItemTagsClientCapabilities -> String
showsPrec :: Int -> CompletionItemTagsClientCapabilities -> ShowS
$cshowsPrec :: Int -> CompletionItemTagsClientCapabilities -> ShowS
Show, ReadPrec [CompletionItemTagsClientCapabilities]
ReadPrec CompletionItemTagsClientCapabilities
Int -> ReadS CompletionItemTagsClientCapabilities
ReadS [CompletionItemTagsClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemTagsClientCapabilities]
$creadListPrec :: ReadPrec [CompletionItemTagsClientCapabilities]
readPrec :: ReadPrec CompletionItemTagsClientCapabilities
$creadPrec :: ReadPrec CompletionItemTagsClientCapabilities
readList :: ReadS [CompletionItemTagsClientCapabilities]
$creadList :: ReadS [CompletionItemTagsClientCapabilities]
readsPrec :: Int -> ReadS CompletionItemTagsClientCapabilities
$creadsPrec :: Int -> ReadS CompletionItemTagsClientCapabilities
Read, CompletionItemTagsClientCapabilities
-> CompletionItemTagsClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemTagsClientCapabilities
-> CompletionItemTagsClientCapabilities -> Bool
$c/= :: CompletionItemTagsClientCapabilities
-> CompletionItemTagsClientCapabilities -> Bool
== :: CompletionItemTagsClientCapabilities
-> CompletionItemTagsClientCapabilities -> Bool
$c== :: CompletionItemTagsClientCapabilities
-> CompletionItemTagsClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CompletionItemTagsClientCapabilities

data CompletionItemResolveClientCapabilities =
  CompletionItemResolveClientCapabilities
    { -- | The properties that a client can resolve lazily.
      CompletionItemResolveClientCapabilities -> List Text
_properties :: List Text
    } deriving (Int -> CompletionItemResolveClientCapabilities -> ShowS
[CompletionItemResolveClientCapabilities] -> ShowS
CompletionItemResolveClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemResolveClientCapabilities] -> ShowS
$cshowList :: [CompletionItemResolveClientCapabilities] -> ShowS
show :: CompletionItemResolveClientCapabilities -> String
$cshow :: CompletionItemResolveClientCapabilities -> String
showsPrec :: Int -> CompletionItemResolveClientCapabilities -> ShowS
$cshowsPrec :: Int -> CompletionItemResolveClientCapabilities -> ShowS
Show, ReadPrec [CompletionItemResolveClientCapabilities]
ReadPrec CompletionItemResolveClientCapabilities
Int -> ReadS CompletionItemResolveClientCapabilities
ReadS [CompletionItemResolveClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemResolveClientCapabilities]
$creadListPrec :: ReadPrec [CompletionItemResolveClientCapabilities]
readPrec :: ReadPrec CompletionItemResolveClientCapabilities
$creadPrec :: ReadPrec CompletionItemResolveClientCapabilities
readList :: ReadS [CompletionItemResolveClientCapabilities]
$creadList :: ReadS [CompletionItemResolveClientCapabilities]
readsPrec :: Int -> ReadS CompletionItemResolveClientCapabilities
$creadsPrec :: Int -> ReadS CompletionItemResolveClientCapabilities
Read, CompletionItemResolveClientCapabilities
-> CompletionItemResolveClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemResolveClientCapabilities
-> CompletionItemResolveClientCapabilities -> Bool
$c/= :: CompletionItemResolveClientCapabilities
-> CompletionItemResolveClientCapabilities -> Bool
== :: CompletionItemResolveClientCapabilities
-> CompletionItemResolveClientCapabilities -> Bool
$c== :: CompletionItemResolveClientCapabilities
-> CompletionItemResolveClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CompletionItemResolveClientCapabilities

{-|
How whitespace and indentation is handled during completion
item insertion.

@since 3.16.0
-}
data InsertTextMode =
  -- | The insertion or replace strings is taken as it is. If the
  -- value is multi line the lines below the cursor will be
  -- inserted using the indentation defined in the string value.
  -- The client will not apply any kind of adjustments to the
  -- string.
  AsIs
  -- | The editor adjusts leading whitespace of new lines so that
  -- they match the indentation up to the cursor of the line for
  -- which the item is accepted.
  --
  -- Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
  -- multi line completion item is indented using 2 tabs and all
  -- following lines inserted will be indented using 2 tabs as well.
  | AdjustIndentation
  deriving (ReadPrec [InsertTextMode]
ReadPrec InsertTextMode
Int -> ReadS InsertTextMode
ReadS [InsertTextMode]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsertTextMode]
$creadListPrec :: ReadPrec [InsertTextMode]
readPrec :: ReadPrec InsertTextMode
$creadPrec :: ReadPrec InsertTextMode
readList :: ReadS [InsertTextMode]
$creadList :: ReadS [InsertTextMode]
readsPrec :: Int -> ReadS InsertTextMode
$creadsPrec :: Int -> ReadS InsertTextMode
Read,Int -> InsertTextMode -> ShowS
[InsertTextMode] -> ShowS
InsertTextMode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsertTextMode] -> ShowS
$cshowList :: [InsertTextMode] -> ShowS
show :: InsertTextMode -> String
$cshow :: InsertTextMode -> String
showsPrec :: Int -> InsertTextMode -> ShowS
$cshowsPrec :: Int -> InsertTextMode -> ShowS
Show,InsertTextMode -> InsertTextMode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsertTextMode -> InsertTextMode -> Bool
$c/= :: InsertTextMode -> InsertTextMode -> Bool
== :: InsertTextMode -> InsertTextMode -> Bool
$c== :: InsertTextMode -> InsertTextMode -> Bool
Eq)

instance A.ToJSON InsertTextMode where
  toJSON :: InsertTextMode -> Value
toJSON InsertTextMode
AsIs              = Scientific -> Value
A.Number Scientific
1
  toJSON InsertTextMode
AdjustIndentation = Scientific -> Value
A.Number Scientific
2

instance A.FromJSON InsertTextMode where
  parseJSON :: Value -> Parser InsertTextMode
parseJSON (A.Number Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure InsertTextMode
AsIs
  parseJSON (A.Number Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure InsertTextMode
AdjustIndentation
  parseJSON Value
_            = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"InsertTextMode"

data CompletionItemInsertTextModeClientCapabilities =
  CompletionItemInsertTextModeClientCapabilities
    { CompletionItemInsertTextModeClientCapabilities
-> List InsertTextMode
_valueSet :: List InsertTextMode
    } deriving (Int -> CompletionItemInsertTextModeClientCapabilities -> ShowS
[CompletionItemInsertTextModeClientCapabilities] -> ShowS
CompletionItemInsertTextModeClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemInsertTextModeClientCapabilities] -> ShowS
$cshowList :: [CompletionItemInsertTextModeClientCapabilities] -> ShowS
show :: CompletionItemInsertTextModeClientCapabilities -> String
$cshow :: CompletionItemInsertTextModeClientCapabilities -> String
showsPrec :: Int -> CompletionItemInsertTextModeClientCapabilities -> ShowS
$cshowsPrec :: Int -> CompletionItemInsertTextModeClientCapabilities -> ShowS
Show, ReadPrec [CompletionItemInsertTextModeClientCapabilities]
ReadPrec CompletionItemInsertTextModeClientCapabilities
Int -> ReadS CompletionItemInsertTextModeClientCapabilities
ReadS [CompletionItemInsertTextModeClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemInsertTextModeClientCapabilities]
$creadListPrec :: ReadPrec [CompletionItemInsertTextModeClientCapabilities]
readPrec :: ReadPrec CompletionItemInsertTextModeClientCapabilities
$creadPrec :: ReadPrec CompletionItemInsertTextModeClientCapabilities
readList :: ReadS [CompletionItemInsertTextModeClientCapabilities]
$creadList :: ReadS [CompletionItemInsertTextModeClientCapabilities]
readsPrec :: Int -> ReadS CompletionItemInsertTextModeClientCapabilities
$creadsPrec :: Int -> ReadS CompletionItemInsertTextModeClientCapabilities
Read, CompletionItemInsertTextModeClientCapabilities
-> CompletionItemInsertTextModeClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemInsertTextModeClientCapabilities
-> CompletionItemInsertTextModeClientCapabilities -> Bool
$c/= :: CompletionItemInsertTextModeClientCapabilities
-> CompletionItemInsertTextModeClientCapabilities -> Bool
== :: CompletionItemInsertTextModeClientCapabilities
-> CompletionItemInsertTextModeClientCapabilities -> Bool
$c== :: CompletionItemInsertTextModeClientCapabilities
-> CompletionItemInsertTextModeClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CompletionItemInsertTextModeClientCapabilities

data CompletionItemClientCapabilities =
  CompletionItemClientCapabilities
    { -- | Client supports snippets as insert text.
      --
      -- A snippet can define tab stops and placeholders with `$1`, `$2` and
      -- `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of
      -- the snippet. Placeholders with equal identifiers are linked, that is
      -- typing in one will update others too.
      CompletionItemClientCapabilities -> Maybe Bool
_snippetSupport :: Maybe Bool

      -- | Client supports commit characters on a completion item.
    , CompletionItemClientCapabilities -> Maybe Bool
_commitCharactersSupport :: Maybe Bool

      -- | Client supports the follow content formats for the documentation
      -- property. The order describes the preferred format of the client.
    , CompletionItemClientCapabilities -> Maybe (List MarkupKind)
_documentationFormat :: Maybe (List MarkupKind)

      -- | Client supports the deprecated property on a completion item.
    , CompletionItemClientCapabilities -> Maybe Bool
_deprecatedSupport :: Maybe Bool

      -- | Client supports the preselect property on a completion item.
    , CompletionItemClientCapabilities -> Maybe Bool
_preselectSupport :: Maybe Bool

      -- | Client supports the tag property on a completion item. Clients
      -- supporting tags have to handle unknown tags gracefully. Clients
      -- especially need to preserve unknown tags when sending a
      -- completion item back to the server in a resolve call.
      --
      -- @since 3.15.0
    , CompletionItemClientCapabilities
-> Maybe CompletionItemTagsClientCapabilities
_tagSupport :: Maybe CompletionItemTagsClientCapabilities
      -- | Client supports insert replace edit to control different behavior if
      -- completion item is inserted in the text or should replace text.
      --
      -- @since 3.16.0
    , CompletionItemClientCapabilities -> Maybe Bool
_insertReplaceSupport :: Maybe Bool
      -- | Indicates which properties a client can resolve lazily on a
      -- completion item. Before version 3.16.0 only the predefined properties
      -- `documentation` and `details` could be resolved lazily.
      --
      -- @since 3.16.0
    , CompletionItemClientCapabilities
-> Maybe CompletionItemResolveClientCapabilities
_resolveSupport :: Maybe CompletionItemResolveClientCapabilities
      -- | The client supports the `insertTextMode` property on
      -- a completion item to override the whitespace handling mode
      -- as defined by the client (see `insertTextMode`).
      --
      -- @since 3.16.0
    , CompletionItemClientCapabilities
-> Maybe CompletionItemInsertTextModeClientCapabilities
_insertTextModeSupport :: Maybe CompletionItemInsertTextModeClientCapabilities
    } deriving (Int -> CompletionItemClientCapabilities -> ShowS
[CompletionItemClientCapabilities] -> ShowS
CompletionItemClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemClientCapabilities] -> ShowS
$cshowList :: [CompletionItemClientCapabilities] -> ShowS
show :: CompletionItemClientCapabilities -> String
$cshow :: CompletionItemClientCapabilities -> String
showsPrec :: Int -> CompletionItemClientCapabilities -> ShowS
$cshowsPrec :: Int -> CompletionItemClientCapabilities -> ShowS
Show, ReadPrec [CompletionItemClientCapabilities]
ReadPrec CompletionItemClientCapabilities
Int -> ReadS CompletionItemClientCapabilities
ReadS [CompletionItemClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemClientCapabilities]
$creadListPrec :: ReadPrec [CompletionItemClientCapabilities]
readPrec :: ReadPrec CompletionItemClientCapabilities
$creadPrec :: ReadPrec CompletionItemClientCapabilities
readList :: ReadS [CompletionItemClientCapabilities]
$creadList :: ReadS [CompletionItemClientCapabilities]
readsPrec :: Int -> ReadS CompletionItemClientCapabilities
$creadsPrec :: Int -> ReadS CompletionItemClientCapabilities
Read, CompletionItemClientCapabilities
-> CompletionItemClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemClientCapabilities
-> CompletionItemClientCapabilities -> Bool
$c/= :: CompletionItemClientCapabilities
-> CompletionItemClientCapabilities -> Bool
== :: CompletionItemClientCapabilities
-> CompletionItemClientCapabilities -> Bool
$c== :: CompletionItemClientCapabilities
-> CompletionItemClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CompletionItemClientCapabilities

data CompletionItemKindClientCapabilities =
  CompletionItemKindClientCapabilities
    { -- | The completion item kind values the client supports. When this
      -- property exists the client also guarantees that it will
      --  handle values outside its set gracefully and falls back
      --  to a default value when unknown.
      CompletionItemKindClientCapabilities
-> Maybe (List CompletionItemKind)
_valueSet :: Maybe (List CompletionItemKind)
    }
  deriving (Int -> CompletionItemKindClientCapabilities -> ShowS
[CompletionItemKindClientCapabilities] -> ShowS
CompletionItemKindClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItemKindClientCapabilities] -> ShowS
$cshowList :: [CompletionItemKindClientCapabilities] -> ShowS
show :: CompletionItemKindClientCapabilities -> String
$cshow :: CompletionItemKindClientCapabilities -> String
showsPrec :: Int -> CompletionItemKindClientCapabilities -> ShowS
$cshowsPrec :: Int -> CompletionItemKindClientCapabilities -> ShowS
Show, ReadPrec [CompletionItemKindClientCapabilities]
ReadPrec CompletionItemKindClientCapabilities
Int -> ReadS CompletionItemKindClientCapabilities
ReadS [CompletionItemKindClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItemKindClientCapabilities]
$creadListPrec :: ReadPrec [CompletionItemKindClientCapabilities]
readPrec :: ReadPrec CompletionItemKindClientCapabilities
$creadPrec :: ReadPrec CompletionItemKindClientCapabilities
readList :: ReadS [CompletionItemKindClientCapabilities]
$creadList :: ReadS [CompletionItemKindClientCapabilities]
readsPrec :: Int -> ReadS CompletionItemKindClientCapabilities
$creadsPrec :: Int -> ReadS CompletionItemKindClientCapabilities
Read, CompletionItemKindClientCapabilities
-> CompletionItemKindClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItemKindClientCapabilities
-> CompletionItemKindClientCapabilities -> Bool
$c/= :: CompletionItemKindClientCapabilities
-> CompletionItemKindClientCapabilities -> Bool
== :: CompletionItemKindClientCapabilities
-> CompletionItemKindClientCapabilities -> Bool
$c== :: CompletionItemKindClientCapabilities
-> CompletionItemKindClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CompletionItemKindClientCapabilities

data CompletionClientCapabilities =
  CompletionClientCapabilities
    { CompletionClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool -- ^ Whether completion supports dynamic
                                         -- registration.
    , CompletionClientCapabilities
-> Maybe CompletionItemClientCapabilities
_completionItem :: Maybe CompletionItemClientCapabilities
    , CompletionClientCapabilities
-> Maybe CompletionItemKindClientCapabilities
_completionItemKind :: Maybe CompletionItemKindClientCapabilities
    , CompletionClientCapabilities -> Maybe Bool
_contextSupport :: Maybe Bool
    } deriving (Int -> CompletionClientCapabilities -> ShowS
[CompletionClientCapabilities] -> ShowS
CompletionClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionClientCapabilities] -> ShowS
$cshowList :: [CompletionClientCapabilities] -> ShowS
show :: CompletionClientCapabilities -> String
$cshow :: CompletionClientCapabilities -> String
showsPrec :: Int -> CompletionClientCapabilities -> ShowS
$cshowsPrec :: Int -> CompletionClientCapabilities -> ShowS
Show, ReadPrec [CompletionClientCapabilities]
ReadPrec CompletionClientCapabilities
Int -> ReadS CompletionClientCapabilities
ReadS [CompletionClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionClientCapabilities]
$creadListPrec :: ReadPrec [CompletionClientCapabilities]
readPrec :: ReadPrec CompletionClientCapabilities
$creadPrec :: ReadPrec CompletionClientCapabilities
readList :: ReadS [CompletionClientCapabilities]
$creadList :: ReadS [CompletionClientCapabilities]
readsPrec :: Int -> ReadS CompletionClientCapabilities
$creadsPrec :: Int -> ReadS CompletionClientCapabilities
Read, CompletionClientCapabilities
-> CompletionClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionClientCapabilities
-> CompletionClientCapabilities -> Bool
$c/= :: CompletionClientCapabilities
-> CompletionClientCapabilities -> Bool
== :: CompletionClientCapabilities
-> CompletionClientCapabilities -> Bool
$c== :: CompletionClientCapabilities
-> CompletionClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CompletionClientCapabilities

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

data InsertTextFormat
  = PlainText -- ^The primary text to be inserted is treated as a plain string.
  | Snippet
      -- ^ The primary text to be inserted is treated as a snippet.
      --
      -- A snippet can define tab stops and placeholders with `$1`, `$2`
      -- and `${3:foo}`. `$0` defines the final tab stop, it defaults to
      -- the end of the snippet. Placeholders with equal identifiers are linked,
      -- that is typing in one will update others too.
      --
      -- See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
    deriving (Int -> InsertTextFormat -> ShowS
[InsertTextFormat] -> ShowS
InsertTextFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsertTextFormat] -> ShowS
$cshowList :: [InsertTextFormat] -> ShowS
show :: InsertTextFormat -> String
$cshow :: InsertTextFormat -> String
showsPrec :: Int -> InsertTextFormat -> ShowS
$cshowsPrec :: Int -> InsertTextFormat -> ShowS
Show, ReadPrec [InsertTextFormat]
ReadPrec InsertTextFormat
Int -> ReadS InsertTextFormat
ReadS [InsertTextFormat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsertTextFormat]
$creadListPrec :: ReadPrec [InsertTextFormat]
readPrec :: ReadPrec InsertTextFormat
$creadPrec :: ReadPrec InsertTextFormat
readList :: ReadS [InsertTextFormat]
$creadList :: ReadS [InsertTextFormat]
readsPrec :: Int -> ReadS InsertTextFormat
$creadsPrec :: Int -> ReadS InsertTextFormat
Read, InsertTextFormat -> InsertTextFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsertTextFormat -> InsertTextFormat -> Bool
$c/= :: InsertTextFormat -> InsertTextFormat -> Bool
== :: InsertTextFormat -> InsertTextFormat -> Bool
$c== :: InsertTextFormat -> InsertTextFormat -> Bool
Eq)

instance A.ToJSON InsertTextFormat where
  toJSON :: InsertTextFormat -> Value
toJSON InsertTextFormat
PlainText = Scientific -> Value
A.Number Scientific
1
  toJSON InsertTextFormat
Snippet   = Scientific -> Value
A.Number Scientific
2

instance A.FromJSON InsertTextFormat where
  parseJSON :: Value -> Parser InsertTextFormat
parseJSON (A.Number  Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure InsertTextFormat
PlainText
  parseJSON (A.Number  Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure InsertTextFormat
Snippet
  parseJSON Value
_             = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"InsertTextFormat"

data CompletionDoc = CompletionDocString Text
                   | CompletionDocMarkup MarkupContent
  deriving (Int -> CompletionDoc -> ShowS
[CompletionDoc] -> ShowS
CompletionDoc -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionDoc] -> ShowS
$cshowList :: [CompletionDoc] -> ShowS
show :: CompletionDoc -> String
$cshow :: CompletionDoc -> String
showsPrec :: Int -> CompletionDoc -> ShowS
$cshowsPrec :: Int -> CompletionDoc -> ShowS
Show, ReadPrec [CompletionDoc]
ReadPrec CompletionDoc
Int -> ReadS CompletionDoc
ReadS [CompletionDoc]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionDoc]
$creadListPrec :: ReadPrec [CompletionDoc]
readPrec :: ReadPrec CompletionDoc
$creadPrec :: ReadPrec CompletionDoc
readList :: ReadS [CompletionDoc]
$creadList :: ReadS [CompletionDoc]
readsPrec :: Int -> ReadS CompletionDoc
$creadsPrec :: Int -> ReadS CompletionDoc
Read, CompletionDoc -> CompletionDoc -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionDoc -> CompletionDoc -> Bool
$c/= :: CompletionDoc -> CompletionDoc -> Bool
== :: CompletionDoc -> CompletionDoc -> Bool
$c== :: CompletionDoc -> CompletionDoc -> Bool
Eq)

deriveJSON lspOptionsUntagged ''CompletionDoc

data InsertReplaceEdit =
  InsertReplaceEdit
    { InsertReplaceEdit -> Text
_newText :: Text -- ^ The string to be inserted.
    , InsertReplaceEdit -> Range
_insert  :: Range -- ^ The range if the insert is requested
    , InsertReplaceEdit -> Range
_repalce :: Range -- ^ The range if the replace is requested.
    }
  deriving (ReadPrec [InsertReplaceEdit]
ReadPrec InsertReplaceEdit
Int -> ReadS InsertReplaceEdit
ReadS [InsertReplaceEdit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsertReplaceEdit]
$creadListPrec :: ReadPrec [InsertReplaceEdit]
readPrec :: ReadPrec InsertReplaceEdit
$creadPrec :: ReadPrec InsertReplaceEdit
readList :: ReadS [InsertReplaceEdit]
$creadList :: ReadS [InsertReplaceEdit]
readsPrec :: Int -> ReadS InsertReplaceEdit
$creadsPrec :: Int -> ReadS InsertReplaceEdit
Read,Int -> InsertReplaceEdit -> ShowS
[InsertReplaceEdit] -> ShowS
InsertReplaceEdit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsertReplaceEdit] -> ShowS
$cshowList :: [InsertReplaceEdit] -> ShowS
show :: InsertReplaceEdit -> String
$cshow :: InsertReplaceEdit -> String
showsPrec :: Int -> InsertReplaceEdit -> ShowS
$cshowsPrec :: Int -> InsertReplaceEdit -> ShowS
Show,InsertReplaceEdit -> InsertReplaceEdit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsertReplaceEdit -> InsertReplaceEdit -> Bool
$c/= :: InsertReplaceEdit -> InsertReplaceEdit -> Bool
== :: InsertReplaceEdit -> InsertReplaceEdit -> Bool
$c== :: InsertReplaceEdit -> InsertReplaceEdit -> Bool
Eq)
deriveJSON lspOptions ''InsertReplaceEdit

data CompletionEdit = CompletionEditText TextEdit | CompletionEditInsertReplace InsertReplaceEdit
  deriving (ReadPrec [CompletionEdit]
ReadPrec CompletionEdit
Int -> ReadS CompletionEdit
ReadS [CompletionEdit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionEdit]
$creadListPrec :: ReadPrec [CompletionEdit]
readPrec :: ReadPrec CompletionEdit
$creadPrec :: ReadPrec CompletionEdit
readList :: ReadS [CompletionEdit]
$creadList :: ReadS [CompletionEdit]
readsPrec :: Int -> ReadS CompletionEdit
$creadsPrec :: Int -> ReadS CompletionEdit
Read,Int -> CompletionEdit -> ShowS
[CompletionEdit] -> ShowS
CompletionEdit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionEdit] -> ShowS
$cshowList :: [CompletionEdit] -> ShowS
show :: CompletionEdit -> String
$cshow :: CompletionEdit -> String
showsPrec :: Int -> CompletionEdit -> ShowS
$cshowsPrec :: Int -> CompletionEdit -> ShowS
Show,CompletionEdit -> CompletionEdit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionEdit -> CompletionEdit -> Bool
$c/= :: CompletionEdit -> CompletionEdit -> Bool
== :: CompletionEdit -> CompletionEdit -> Bool
$c== :: CompletionEdit -> CompletionEdit -> Bool
Eq)

deriveJSON lspOptionsUntagged ''CompletionEdit

data CompletionItem =
  CompletionItem
    { CompletionItem -> Text
_label               :: Text -- ^ The label of this completion item. By default also
                       -- the text that is inserted when selecting this
                       -- completion.
    , CompletionItem -> Maybe CompletionItemKind
_kind                :: Maybe CompletionItemKind
    , CompletionItem -> Maybe (List CompletionItemTag)
_tags                :: Maybe (List CompletionItemTag) -- ^ Tags for this completion item.
    , CompletionItem -> Maybe Text
_detail              :: Maybe Text -- ^ A human-readable string with additional
                              -- information about this item, like type or
                              -- symbol information.
    , CompletionItem -> Maybe CompletionDoc
_documentation       :: Maybe CompletionDoc -- ^ A human-readable string that represents
                                                  -- a doc-comment.
    , CompletionItem -> Maybe Bool
_deprecated          :: Maybe Bool -- ^ Indicates if this item is deprecated.
    , CompletionItem -> Maybe Bool
_preselect           :: Maybe Bool
         -- ^ Select this item when showing.
         -- *Note* that only one completion item can be selected and that the
         -- tool / client decides which item that is. The rule is that the *first*
         -- item of those that match best is selected.
    , CompletionItem -> Maybe Text
_sortText            :: Maybe Text -- ^ A string that should be used when filtering
                                -- a set of completion items. When `falsy` the
                                -- label is used.
    , CompletionItem -> Maybe Text
_filterText          :: Maybe Text -- ^ A string that should be used when
                                  -- filtering a set of completion items. When
                                  -- `falsy` the label is used.
    , CompletionItem -> Maybe Text
_insertText          :: Maybe Text -- ^ A string that should be inserted a
                                  -- document when selecting this completion.
                                  -- When `falsy` the label is used.
    , CompletionItem -> Maybe InsertTextFormat
_insertTextFormat    :: Maybe InsertTextFormat
         -- ^ The format of the insert text. The format applies to both the
         -- `insertText` property and the `newText` property of a provided
         -- `textEdit`.
    , CompletionItem -> Maybe InsertTextMode
_insertTextMode      :: Maybe InsertTextMode
         -- ^ How whitespace and indentation is handled during completion
         -- item insertion. If not provided the client's default value depends on
         -- the @textDocument.completion.insertTextMode@ client capability.
    , CompletionItem -> Maybe CompletionEdit
_textEdit            :: Maybe CompletionEdit
         -- ^ An edit which is applied to a document when selecting this
         -- completion. When an edit is provided the value of `insertText` is
         -- ignored.
         --
         -- *Note:* The range of the edit must be a single line range and it
         -- must contain the position at which completion has been requested.
    , CompletionItem -> Maybe (List TextEdit)
_additionalTextEdits :: Maybe (List TextEdit)
         -- ^ An optional array of additional text edits that are applied when
         -- selecting this completion. Edits must not overlap with the main edit
         -- nor with themselves.
    , CompletionItem -> Maybe (List Text)
_commitCharacters    :: Maybe (List Text)
         -- ^ An optional set of characters that when pressed while this completion
         -- is active will accept it first and then type that character. *Note*
         -- that all commit characters should have `length=1` and that superfluous
         -- characters will be ignored.
    , CompletionItem -> Maybe Command
_command             :: Maybe Command
        -- ^ An optional command that is executed *after* inserting this
        -- completion. *Note* that additional modifications to the current
        -- document should be described with the additionalTextEdits-property.
    , CompletionItem -> Maybe Value
_xdata               :: Maybe A.Value -- ^ An data entry field that is preserved on a
                              -- completion item between a completion and a
                              -- completion resolve request.
    } deriving (ReadPrec [CompletionItem]
ReadPrec CompletionItem
Int -> ReadS CompletionItem
ReadS [CompletionItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionItem]
$creadListPrec :: ReadPrec [CompletionItem]
readPrec :: ReadPrec CompletionItem
$creadPrec :: ReadPrec CompletionItem
readList :: ReadS [CompletionItem]
$creadList :: ReadS [CompletionItem]
readsPrec :: Int -> ReadS CompletionItem
$creadsPrec :: Int -> ReadS CompletionItem
Read,Int -> CompletionItem -> ShowS
[CompletionItem] -> ShowS
CompletionItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionItem] -> ShowS
$cshowList :: [CompletionItem] -> ShowS
show :: CompletionItem -> String
$cshow :: CompletionItem -> String
showsPrec :: Int -> CompletionItem -> ShowS
$cshowsPrec :: Int -> CompletionItem -> ShowS
Show,CompletionItem -> CompletionItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionItem -> CompletionItem -> Bool
$c/= :: CompletionItem -> CompletionItem -> Bool
== :: CompletionItem -> CompletionItem -> Bool
$c== :: CompletionItem -> CompletionItem -> Bool
Eq)

deriveJSON lspOptions ''CompletionItem

-- | Represents a collection of 'CompletionItem's to be presented in the editor.
data CompletionList =
  CompletionList
    { CompletionList -> Bool
_isIncomplete :: Bool -- ^ This list it not complete. Further typing
                            -- should result in recomputing this list.
    , CompletionList -> List CompletionItem
_items        :: List CompletionItem -- ^ The completion items.
    } deriving (ReadPrec [CompletionList]
ReadPrec CompletionList
Int -> ReadS CompletionList
ReadS [CompletionList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionList]
$creadListPrec :: ReadPrec [CompletionList]
readPrec :: ReadPrec CompletionList
$creadPrec :: ReadPrec CompletionList
readList :: ReadS [CompletionList]
$creadList :: ReadS [CompletionList]
readsPrec :: Int -> ReadS CompletionList
$creadsPrec :: Int -> ReadS CompletionList
Read,Int -> CompletionList -> ShowS
[CompletionList] -> ShowS
CompletionList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionList] -> ShowS
$cshowList :: [CompletionList] -> ShowS
show :: CompletionList -> String
$cshow :: CompletionList -> String
showsPrec :: Int -> CompletionList -> ShowS
$cshowsPrec :: Int -> CompletionList -> ShowS
Show,CompletionList -> CompletionList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionList -> CompletionList -> Bool
$c/= :: CompletionList -> CompletionList -> Bool
== :: CompletionList -> CompletionList -> Bool
$c== :: CompletionList -> CompletionList -> Bool
Eq)

deriveJSON lspOptions ''CompletionList

-- | How a completion was triggered
data CompletionTriggerKind = -- | Completion was triggered by typing an identifier (24x7 code
                             -- complete), manual invocation (e.g Ctrl+Space) or via API.
                             CtInvoked
                             -- | Completion was triggered by a trigger character specified by
                             -- the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
                           | CtTriggerCharacter
                             -- | Completion was re-triggered as the current completion list is incomplete.
                           | CtTriggerForIncompleteCompletions
                             -- | An unknown 'CompletionTriggerKind' not yet supported in haskell-lsp.
                           | CtUnknown Scientific
  deriving (ReadPrec [CompletionTriggerKind]
ReadPrec CompletionTriggerKind
Int -> ReadS CompletionTriggerKind
ReadS [CompletionTriggerKind]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionTriggerKind]
$creadListPrec :: ReadPrec [CompletionTriggerKind]
readPrec :: ReadPrec CompletionTriggerKind
$creadPrec :: ReadPrec CompletionTriggerKind
readList :: ReadS [CompletionTriggerKind]
$creadList :: ReadS [CompletionTriggerKind]
readsPrec :: Int -> ReadS CompletionTriggerKind
$creadsPrec :: Int -> ReadS CompletionTriggerKind
Read, Int -> CompletionTriggerKind -> ShowS
[CompletionTriggerKind] -> ShowS
CompletionTriggerKind -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionTriggerKind] -> ShowS
$cshowList :: [CompletionTriggerKind] -> ShowS
show :: CompletionTriggerKind -> String
$cshow :: CompletionTriggerKind -> String
showsPrec :: Int -> CompletionTriggerKind -> ShowS
$cshowsPrec :: Int -> CompletionTriggerKind -> ShowS
Show, CompletionTriggerKind -> CompletionTriggerKind -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionTriggerKind -> CompletionTriggerKind -> Bool
$c/= :: CompletionTriggerKind -> CompletionTriggerKind -> Bool
== :: CompletionTriggerKind -> CompletionTriggerKind -> Bool
$c== :: CompletionTriggerKind -> CompletionTriggerKind -> Bool
Eq)

instance A.ToJSON CompletionTriggerKind where
  toJSON :: CompletionTriggerKind -> Value
toJSON CompletionTriggerKind
CtInvoked                         = Scientific -> Value
A.Number Scientific
1
  toJSON CompletionTriggerKind
CtTriggerCharacter                = Scientific -> Value
A.Number Scientific
2
  toJSON CompletionTriggerKind
CtTriggerForIncompleteCompletions = Scientific -> Value
A.Number Scientific
3
  toJSON (CtUnknown Scientific
x)                     = Scientific -> Value
A.Number Scientific
x

instance A.FromJSON CompletionTriggerKind where
  parseJSON :: Value -> Parser CompletionTriggerKind
parseJSON (A.Number Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionTriggerKind
CtInvoked
  parseJSON (A.Number Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionTriggerKind
CtTriggerCharacter
  parseJSON (A.Number Scientific
3) = forall (f :: * -> *) a. Applicative f => a -> f a
pure CompletionTriggerKind
CtTriggerForIncompleteCompletions
  parseJSON (A.Number Scientific
x) = forall (f :: * -> *) a. Applicative f => a -> f a
pure (Scientific -> CompletionTriggerKind
CtUnknown Scientific
x)
  parseJSON Value
_            = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"CompletionTriggerKind"

makeExtendingDatatype "CompletionOptions" [''WorkDoneProgressOptions]
  [ ("_triggerCharacters", [t| Maybe [Text] |])
  , ("_allCommitCharacters", [t| Maybe [Text] |])
  , ("_resolveProvider", [t| Maybe Bool|])
  ]
deriveJSON lspOptions ''CompletionOptions

makeExtendingDatatype "CompletionRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''CompletionOptions
  ]
  []
deriveJSON lspOptions ''CompletionRegistrationOptions

data CompletionContext =
  CompletionContext
    { CompletionContext -> CompletionTriggerKind
_triggerKind      :: CompletionTriggerKind -- ^ How the completion was triggered.
    , CompletionContext -> Maybe Text
_triggerCharacter :: Maybe Text
      -- ^ The trigger character (a single character) that has trigger code complete.
      -- Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
    }
  deriving (ReadPrec [CompletionContext]
ReadPrec CompletionContext
Int -> ReadS CompletionContext
ReadS [CompletionContext]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionContext]
$creadListPrec :: ReadPrec [CompletionContext]
readPrec :: ReadPrec CompletionContext
$creadPrec :: ReadPrec CompletionContext
readList :: ReadS [CompletionContext]
$creadList :: ReadS [CompletionContext]
readsPrec :: Int -> ReadS CompletionContext
$creadsPrec :: Int -> ReadS CompletionContext
Read, Int -> CompletionContext -> ShowS
[CompletionContext] -> ShowS
CompletionContext -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionContext] -> ShowS
$cshowList :: [CompletionContext] -> ShowS
show :: CompletionContext -> String
$cshow :: CompletionContext -> String
showsPrec :: Int -> CompletionContext -> ShowS
$cshowsPrec :: Int -> CompletionContext -> ShowS
Show, CompletionContext -> CompletionContext -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionContext -> CompletionContext -> Bool
$c/= :: CompletionContext -> CompletionContext -> Bool
== :: CompletionContext -> CompletionContext -> Bool
$c== :: CompletionContext -> CompletionContext -> Bool
Eq)

deriveJSON lspOptions ''CompletionContext

makeExtendingDatatype "CompletionParams"
  [ ''TextDocumentPositionParams
  , ''WorkDoneProgressParams
  , ''PartialResultParams
  ]
  [ ("_context", [t| Maybe CompletionContext |]) ]
deriveJSON lspOptions ''CompletionParams