module Language.Haskell.LSP.Types.Capabilities
(
module Language.Haskell.LSP.Types.ClientCapabilities
, fullCaps
, LSPVersion(..)
, capsForVersion
) where
import Prelude hiding (min)
import Language.Haskell.LSP.Types.ClientCapabilities
import Language.Haskell.LSP.Types
fullCaps :: ClientCapabilities
fullCaps = capsForVersion (LSPVersion maxBound maxBound)
data LSPVersion = LSPVersion Int Int
capsForVersion :: LSPVersion -> ClientCapabilities
capsForVersion (LSPVersion maj min) = ClientCapabilities (Just w) (Just td) Nothing Nothing
where
w = WorkspaceClientCapabilities
(Just True)
(Just (WorkspaceEditClientCapabilities (Just True)))
(Just (DidChangeConfigurationClientCapabilities dynamicReg))
(Just (DidChangeWatchedFilesClientCapabilities dynamicReg))
(Just symbolCapabilities)
(Just (ExecuteClientCapabilities dynamicReg))
(since 3 6 True)
(since 3 6 True)
symbolCapabilities = SymbolClientCapabilities
dynamicReg
(since 3 4 symbolKindCapabilities)
symbolKindCapabilities =
SymbolKindClientCapabilities (Just sKs)
sKs
| maj >= 3 && min >= 4 = List (oldSKs ++ newSKs)
| otherwise = List oldSKs
oldSKs = [ SkFile
, SkModule
, SkNamespace
, SkPackage
, SkClass
, SkMethod
, SkProperty
, SkField
, SkConstructor
, SkEnum
, SkInterface
, SkFunction
, SkVariable
, SkConstant
, SkString
, SkNumber
, SkBoolean
, SkArray
]
newSKs = [ SkObject
, SkKey
, SkNull
, SkEnumMember
, SkStruct
, SkEvent
, SkOperator
, SkTypeParameter
]
td = TextDocumentClientCapabilities
(Just sync)
(Just completionCapability)
(Just hoverCapability)
(Just signatureHelpCapability)
(Just (ReferencesClientCapabilities dynamicReg))
(Just (DocumentHighlightClientCapabilities dynamicReg))
(Just documentSymbolCapability)
(Just (FormattingClientCapabilities (Just True)))
(Just (RangeFormattingClientCapabilities dynamicReg))
(Just (OnTypeFormattingClientCapabilities dynamicReg))
(Just (DefinitionClientCapabilities dynamicReg))
(since 3 6 (TypeDefinitionClientCapabilities dynamicReg))
(since 3 6 (ImplementationClientCapabilities dynamicReg))
(Just codeActionCapability)
(Just (CodeLensClientCapabilities dynamicReg))
(Just (DocumentLinkClientCapabilities dynamicReg))
(since 3 6 (ColorProviderClientCapabilities dynamicReg))
(Just (RenameClientCapabilities dynamicReg (since 3 12 True)))
(Just publishDiagnosticsCapabilities)
(since 3 10 foldingRangeCapability)
sync =
SynchronizationTextDocumentClientCapabilities
dynamicReg
(Just True)
(Just True)
(Just True)
completionCapability =
CompletionClientCapabilities
dynamicReg
(Just completionItemCapabilities)
(since 3 4 completionItemKindCapabilities)
(since 3 3 True)
completionItemCapabilities = CompletionItemClientCapabilities
(Just True)
(Just True)
(since 3 3 (List [MkPlainText, MkMarkdown]))
(Just True)
(since 3 9 True)
(since 3 15 completionItemTagsCapabilities)
completionItemKindCapabilities =
CompletionItemKindClientCapabilities (Just ciKs)
completionItemTagsCapabilities =
CompletionItemTagsClientCapabilities (List [ CtDeprecated ])
ciKs
| maj >= 3 && min >= 4 = List (oldCiKs ++ newCiKs)
| otherwise = List oldCiKs
oldCiKs = [ CiText
, CiMethod
, CiFunction
, CiConstructor
, CiField
, CiVariable
, CiClass
, CiInterface
, CiModule
, CiProperty
, CiUnit
, CiValue
, CiEnum
, CiKeyword
, CiSnippet
, CiColor
, CiFile
, CiReference
]
newCiKs = [ CiFolder
, CiEnumMember
, CiConstant
, CiStruct
, CiEvent
, CiOperator
, CiTypeParameter
]
hoverCapability =
HoverClientCapabilities
dynamicReg
(since 3 3 (List [MkPlainText, MkMarkdown]))
codeActionCapability
= CodeActionClientCapabilities
dynamicReg
(since 3 8 (CodeActionLiteralSupport caKs))
caKs = CodeActionKindClientCapabilities
(List [ CodeActionQuickFix
, CodeActionRefactor
, CodeActionRefactorExtract
, CodeActionRefactorInline
, CodeActionRefactorRewrite
, CodeActionSource
, CodeActionSourceOrganizeImports
])
signatureHelpCapability =
SignatureHelpClientCapabilities
dynamicReg
(Just signatureInformationCapability)
signatureInformationCapability =
SignatureInformationClientCapabilities
(Just (List [MkPlainText, MkMarkdown]))
documentSymbolCapability =
DocumentSymbolClientCapabilities
dynamicReg
(since 3 4 documentSymbolKind)
(since 3 10 True)
documentSymbolKind =
DocumentSymbolKindClientCapabilities
(Just sKs)
foldingRangeCapability =
FoldingRangeClientCapabilities
dynamicReg
Nothing
(Just False)
publishDiagnosticsCapabilities =
PublishDiagnosticsClientCapabilities
(since 3 7 True)
(since 3 15 publishDiagnosticsTagsCapabilities)
publishDiagnosticsTagsCapabilities =
PublishDiagnosticsTagsClientCapabilities
(List [ DtUnnecessary, DtDeprecated ])
dynamicReg
| maj >= 3 = Just True
| otherwise = Nothing
since x y a
| maj >= x && min >= y = Just a
| otherwise = Nothing