5
5
{-# LANGUAGE FlexibleInstances #-}
6
6
{-# LANGUAGE FunctionalDependencies #-}
7
7
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8
- {-# LANGUAGE MultiParamTypeClasses #-}
9
8
{-# LANGUAGE OverloadedStrings #-}
10
9
{-# LANGUAGE TemplateHaskell #-}
11
10
{-# LANGUAGE TypeSynonymInstances #-}
@@ -18,14 +17,15 @@ import Data.Aeson.TH
18
17
import Data.Aeson.Types
19
18
import Data.Text (Text )
20
19
import qualified Data.Text as T
20
+ import Language.Haskell.LSP.Types.ClientCapabilities
21
21
import Language.Haskell.LSP.Types.Command
22
22
import Language.Haskell.LSP.Types.Constants
23
- import Language.Haskell.LSP.Types.ClientCapabilities
24
23
import Language.Haskell.LSP.Types.Diagnostic
25
24
import Language.Haskell.LSP.Types.DocumentFilter
26
25
import Language.Haskell.LSP.Types.List
27
- import Language.Haskell.LSP.Types.Message
28
26
import Language.Haskell.LSP.Types.Location
27
+ import Language.Haskell.LSP.Types.MarkupContent
28
+ import Language.Haskell.LSP.Types.Message
29
29
import Language.Haskell.LSP.Types.Symbol
30
30
import Language.Haskell.LSP.Types.TextDocument
31
31
import Language.Haskell.LSP.Types.Uri
@@ -499,7 +499,7 @@ interface ServerCapabilities {
499
499
*
500
500
* Since 3.10.0
501
501
*/
502
- foldingRangeProvider?: boolean | FoldingRangeProviderOptions | (FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
502
+ foldingRangeProvider?: boolean | FoldingRangeProviderOptions | (FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
503
503
/**
504
504
* The server provides execute command support.
505
505
*/
@@ -544,7 +544,7 @@ data TDS = TDSOptions TextDocumentSyncOptions
544
544
545
545
instance FromJSON TDS where
546
546
parseJSON x = TDSOptions <$> parseJSON x <|> TDSKind <$> parseJSON x
547
-
547
+
548
548
instance ToJSON TDS where
549
549
toJSON (TDSOptions x) = toJSON x
550
550
toJSON (TDSKind x) = toJSON x
@@ -553,7 +553,7 @@ data GotoOptions = GotoOptionsStatic Bool
553
553
| GotoOptionsDynamic
554
554
{ -- | A document selector to identify the scope of the registration. If set to null
555
555
-- the document selector provided on the client side will be used.
556
- _documentSelector :: Maybe DocumentSelector
556
+ _documentSelector :: Maybe DocumentSelector
557
557
-- | The id used to register the request. The id can be used to deregister
558
558
-- the request again. See also Registration#id.
559
559
, _id :: Maybe Text
@@ -624,7 +624,7 @@ data WorkspaceOptions =
624
624
deriving (Show , Read , Eq )
625
625
626
626
deriveJSON lspOptions ''WorkspaceOptions
627
-
627
+
628
628
data InitializeResponseCapabilitiesInner =
629
629
InitializeResponseCapabilitiesInner
630
630
{ -- | Defines how text documents are synced. Is either a detailed structure
@@ -1232,19 +1232,19 @@ Request:
1232
1232
method: ‘workspace/configuration’
1233
1233
params: ConfigurationParams defined as follows
1234
1234
export interface ConfigurationParams {
1235
- items: ConfigurationItem[];
1235
+ items: ConfigurationItem[];
1236
1236
}
1237
1237
1238
1238
export 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;
1248
1248
}
1249
1249
Response:
1250
1250
@@ -1731,26 +1731,28 @@ Response
1731
1731
1732
1732
result: Hover | null defined as follows:
1733
1733
1734
+
1734
1735
/**
1735
- * The result of a hove request.
1736
+ * The result of a hover request.
1736
1737
*/
1737
1738
interface Hover {
1738
- /**
1739
- * The hover's content
1740
- */
1741
- contents: MarkedString | MarkedString[];
1739
+ /**
1740
+ * The hover's content
1741
+ */
1742
+ contents: MarkedString | MarkedString[] | MarkupContent ;
1742
1743
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;
1747
1749
}
1748
1750
1749
- Where MarkedString is defined as follows:
1751
+
1750
1752
/**
1751
1753
* MarkedString can be used to render human readable text. It is either a markdown string
1752
1754
* 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
1754
1756
* issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
1755
1757
*
1756
1758
* The pair of a language and a value is an equivalent to markdown:
@@ -1759,7 +1761,8 @@ Where MarkedString is defined as follows:
1759
1761
* ```
1760
1762
*
1761
1763
* Note that markdown strings will be sanitized - that means html will be escaped.
1762
- */
1764
+ * @deprecated use MarkupContent instead.
1765
+ */
1763
1766
type MarkedString = string | { language: string; value: string };
1764
1767
1765
1768
error: code and message set in case an exception happens during the hover
@@ -1777,6 +1780,7 @@ data LanguageString =
1777
1780
1778
1781
deriveJSON lspOptions ''LanguageString
1779
1782
1783
+ {-# DEPRECATED MarkedString, PlainString, CodeString "Use MarkupContent instead, since 3.3.0 (11/24/2017)" #-}
1780
1784
data MarkedString =
1781
1785
PlainString T. Text
1782
1786
| CodeString LanguageString
@@ -1789,9 +1793,52 @@ instance FromJSON MarkedString where
1789
1793
parseJSON (A. String t) = pure $ PlainString t
1790
1794
parseJSON o = CodeString <$> parseJSON o
1791
1795
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
+
1792
1839
data Hover =
1793
1840
Hover
1794
- { _contents :: List MarkedString
1841
+ { _contents :: HoverContents
1795
1842
, _range :: Maybe Range
1796
1843
} deriving (Read ,Show ,Eq )
1797
1844
@@ -2852,4 +2899,3 @@ data TraceNotification =
2852
2899
} deriving (Show , Read , Eq )
2853
2900
2854
2901
deriveJSON lspOptions ''TraceNotification
2855
-
0 commit comments