55{-# LANGUAGE FlexibleInstances #-}
66{-# LANGUAGE FunctionalDependencies #-}
77{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8- {-# LANGUAGE MultiParamTypeClasses #-}
98{-# LANGUAGE OverloadedStrings #-}
109{-# LANGUAGE TemplateHaskell #-}
1110{-# LANGUAGE TypeSynonymInstances #-}
@@ -18,14 +17,15 @@ import Data.Aeson.TH
1817import Data.Aeson.Types
1918import Data.Text (Text )
2019import qualified Data.Text as T
20+ import Language.Haskell.LSP.Types.ClientCapabilities
2121import Language.Haskell.LSP.Types.Command
2222import Language.Haskell.LSP.Types.Constants
23- import Language.Haskell.LSP.Types.ClientCapabilities
2423import Language.Haskell.LSP.Types.Diagnostic
2524import Language.Haskell.LSP.Types.DocumentFilter
2625import Language.Haskell.LSP.Types.List
27- import Language.Haskell.LSP.Types.Message
2826import Language.Haskell.LSP.Types.Location
27+ import Language.Haskell.LSP.Types.MarkupContent
28+ import Language.Haskell.LSP.Types.Message
2929import Language.Haskell.LSP.Types.Symbol
3030import Language.Haskell.LSP.Types.TextDocument
3131import Language.Haskell.LSP.Types.Uri
@@ -499,7 +499,7 @@ interface ServerCapabilities {
499499 *
500500 * Since 3.10.0
501501 */
502- foldingRangeProvider?: boolean | FoldingRangeProviderOptions | (FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
502+ foldingRangeProvider?: boolean | FoldingRangeProviderOptions | (FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
503503 /**
504504 * The server provides execute command support.
505505 */
@@ -544,7 +544,7 @@ data TDS = TDSOptions TextDocumentSyncOptions
544544
545545instance FromJSON TDS where
546546 parseJSON x = TDSOptions <$> parseJSON x <|> TDSKind <$> parseJSON x
547-
547+
548548instance ToJSON TDS where
549549 toJSON (TDSOptions x) = toJSON x
550550 toJSON (TDSKind x) = toJSON x
@@ -553,7 +553,7 @@ data GotoOptions = GotoOptionsStatic Bool
553553 | GotoOptionsDynamic
554554 { -- | A document selector to identify the scope of the registration. If set to null
555555 -- the document selector provided on the client side will be used.
556- _documentSelector :: Maybe DocumentSelector
556+ _documentSelector :: Maybe DocumentSelector
557557 -- | The id used to register the request. The id can be used to deregister
558558 -- the request again. See also Registration#id.
559559 , _id :: Maybe Text
@@ -624,7 +624,7 @@ data WorkspaceOptions =
624624 deriving (Show , Read , Eq )
625625
626626deriveJSON lspOptions ''WorkspaceOptions
627-
627+
628628data InitializeResponseCapabilitiesInner =
629629 InitializeResponseCapabilitiesInner
630630 { -- | Defines how text documents are synced. Is either a detailed structure
@@ -1232,19 +1232,19 @@ Request:
12321232method: ‘workspace/configuration’
12331233params: ConfigurationParams defined as follows
12341234export interface ConfigurationParams {
1235- items: ConfigurationItem[];
1235+ items: ConfigurationItem[];
12361236}
12371237
12381238export interface ConfigurationItem {
1239- /**
1240- * The scope to get the configuration section for.
1241- */
1242- scopeUri?: string;
1243-
1244- /**
1245- * The configuration section asked for.
1246- */
1247- section?: string;
1239+ /**
1240+ * The scope to get the configuration section for.
1241+ */
1242+ scopeUri?: string;
1243+
1244+ /**
1245+ * The configuration section asked for.
1246+ */
1247+ section?: string;
12481248}
12491249Response:
12501250
@@ -1731,26 +1731,28 @@ Response
17311731
17321732 result: Hover | null defined as follows:
17331733
1734+
17341735/**
1735- * The result of a hove request.
1736+ * The result of a hover request.
17361737 */
17371738interface Hover {
1738- /**
1739- * The hover's content
1740- */
1741- contents: MarkedString | MarkedString[];
1739+ /**
1740+ * The hover's content
1741+ */
1742+ contents: MarkedString | MarkedString[] | MarkupContent ;
17421743
1743- /**
1744- * An optional range
1745- */
1746- range?: Range;
1744+ /**
1745+ * An optional range is a range inside a text document
1746+ * that is used to visualize a hover, e.g. by changing the background color.
1747+ */
1748+ range?: Range;
17471749}
17481750
1749- Where MarkedString is defined as follows:
1751+
17501752/**
17511753 * MarkedString can be used to render human readable text. It is either a markdown string
17521754 * or a code-block that provides a language and a code snippet. The language identifier
1753- * is sematically equal to the optional language identifier in fenced code blocks in GitHub
1755+ * is semantically equal to the optional language identifier in fenced code blocks in GitHub
17541756 * issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
17551757 *
17561758 * The pair of a language and a value is an equivalent to markdown:
@@ -1759,7 +1761,8 @@ Where MarkedString is defined as follows:
17591761 * ```
17601762 *
17611763 * Note that markdown strings will be sanitized - that means html will be escaped.
1762- */
1764+ * @deprecated use MarkupContent instead.
1765+ */
17631766type MarkedString = string | { language: string; value: string };
17641767
17651768 error: code and message set in case an exception happens during the hover
@@ -1777,6 +1780,7 @@ data LanguageString =
17771780
17781781deriveJSON lspOptions ''LanguageString
17791782
1783+ {-# DEPRECATED MarkedString, PlainString, CodeString "Use MarkupContent instead, since 3.3.0 (11/24/2017)" #-}
17801784data MarkedString =
17811785 PlainString T. Text
17821786 | CodeString LanguageString
@@ -1789,9 +1793,52 @@ instance FromJSON MarkedString where
17891793 parseJSON (A. String t) = pure $ PlainString t
17901794 parseJSON o = CodeString <$> parseJSON o
17911795
1796+ -- -------------------------------------
1797+
1798+ data HoverContents =
1799+ HoverContentsMS (List MarkedString )
1800+ | HoverContents MarkupContent
1801+ | HoverContentsEmpty
1802+ deriving (Read ,Show ,Eq )
1803+
1804+ instance ToJSON HoverContents where
1805+ toJSON (HoverContentsMS x) = toJSON x
1806+ toJSON (HoverContents x) = toJSON x
1807+ toJSON (HoverContentsEmpty ) = A. Null
1808+ instance FromJSON HoverContents where
1809+ parseJSON v@ (A. String _) = HoverContentsMS <$> parseJSON v
1810+ parseJSON (A. Null ) = pure HoverContentsEmpty
1811+ parseJSON v@ (A. Array _) = HoverContentsMS <$> parseJSON v
1812+ parseJSON v@ (A. Object _) = HoverContents <$> parseJSON v
1813+ <|> HoverContentsMS <$> parseJSON v
1814+ parseJSON _ = mempty
1815+
1816+ -- -------------------------------------
1817+
1818+ #if __GLASGOW_HASKELL__ >= 804
1819+ instance Semigroup HoverContents where
1820+ (<>) = mappend
1821+ #endif
1822+
1823+ instance Monoid HoverContents where
1824+ mempty = HoverContentsEmpty
1825+
1826+ HoverContentsEmpty `mappend` hc = hc
1827+ hc `mappend` HoverContentsEmpty = hc
1828+ HoverContents h1 `mappend` HoverContents h2 = HoverContents (h1 `mappend` h2)
1829+ HoverContents h1 `mappend` HoverContentsMS (List h2s) = HoverContents (mconcat (h1: (map toMarkupContent h2s)))
1830+ HoverContentsMS (List h1s) `mappend` HoverContents h2 = HoverContents (mconcat ((map toMarkupContent h1s) ++ [h2]))
1831+ HoverContentsMS (List h1s) `mappend` HoverContentsMS (List h2s) = HoverContentsMS (List (h1s `mappend` h2s))
1832+
1833+ toMarkupContent :: MarkedString -> MarkupContent
1834+ toMarkupContent (PlainString s) = unmarkedUpContent s
1835+ toMarkupContent (CodeString (LanguageString lang s)) = markedUpContent lang s
1836+
1837+ -- -------------------------------------
1838+
17921839data Hover =
17931840 Hover
1794- { _contents :: List MarkedString
1841+ { _contents :: HoverContents
17951842 , _range :: Maybe Range
17961843 } deriving (Read ,Show ,Eq )
17971844
@@ -2852,4 +2899,3 @@ data TraceNotification =
28522899 } deriving (Show , Read , Eq )
28532900
28542901deriveJSON lspOptions ''TraceNotification
2855-
0 commit comments