File tree Expand file tree Collapse file tree 6 files changed +45
-0
lines changed
src/Language/LSP/Protocol Expand file tree Collapse file tree 6 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ library
71
71
, base >= 4.11 && < 5
72
72
, binary
73
73
, containers
74
+ , data-default
74
75
, deepseq
75
76
, Diff >= 0.2
76
77
, dlist
@@ -114,6 +115,7 @@ library
114
115
Language.LSP.Protocol.Message.Registration
115
116
Language.LSP.Protocol.Message.Types
116
117
Language.LSP.Protocol.Types.Common
118
+ Language.LSP.Protocol.Types.CustomInstances
117
119
Language.LSP.Protocol.Types.Edit
118
120
Language.LSP.Protocol.Types.Lens
119
121
Language.LSP.Protocol.Types.Location
Original file line number Diff line number Diff line change 1
1
{-#LANGUAGE TemplateHaskell #-}
2
+ {-# OPTIONS_GHC -Wno-orphans #-}
2
3
3
4
module Language.LSP.Protocol.Message.Lens where
4
5
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ module Language.LSP.Protocol.Types (
22
22
, module SemanticTokens
23
23
-- * Main LSP types and functions
24
24
, module Generated
25
+ -- ** Custom instances for the generated types
26
+ , module CustomInstances
25
27
) where
26
28
27
29
import Language.LSP.Protocol.Internal.Types as Generated
@@ -35,3 +37,4 @@ import Language.LSP.Protocol.Types.Singletons as Singletons
35
37
import Language.LSP.Protocol.Types.Uri as Uri
36
38
import Language.LSP.Protocol.Types.Uri.OsPath as Uri
37
39
import Language.LSP.Protocol.Types.Edit as Edits
40
+ import Language.LSP.Protocol.Types.CustomInstances as CustomInstances
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ module Language.LSP.Protocol.Types.Common (
18
18
, Null (.. )
19
19
, absorbNull
20
20
, nullToMaybe
21
+ , maybeToNull
21
22
, (.=?)
22
23
) where
23
24
@@ -123,6 +124,16 @@ nullToMaybe :: a |? Null -> Maybe a
123
124
nullToMaybe (InL a) = Just a
124
125
nullToMaybe (InR _) = Nothing
125
126
127
+ maybeToNull :: Maybe a -> a |? Null
128
+ maybeToNull (Just x) = InL x
129
+ maybeToNull Nothing = InR Null
130
+
131
+ instance Semigroup s => Semigroup (s |? Null ) where
132
+ InL x <> InL y = InL (x <> y)
133
+ InL x <> InR _ = InL x
134
+ InR _ <> InL x = InL x
135
+ InR _ <> InR y = InR y
136
+
126
137
-- We use String so we can use fromString on it to get a key that works
127
138
-- in both aeson-1 and aeson-2
128
139
-- | Include a value in an JSON object optionally, omitting it if it is 'Nothing'.
Original file line number Diff line number Diff line change
1
+ {-# OPTIONS_GHC -Wno-orphans #-}
2
+ module Language.LSP.Protocol.Types.CustomInstances where
3
+
4
+ import Language.LSP.Protocol.Internal.Types
5
+ import Data.Default
6
+ import Data.Hashable
7
+ import Data.Semigroup ()
8
+
9
+ instance Semigroup WorkspaceEdit where
10
+ (WorkspaceEdit a b c) <> (WorkspaceEdit a' b' c') = WorkspaceEdit (a <> a') (b <> b') (c <> c')
11
+ instance Monoid WorkspaceEdit where
12
+ mempty = WorkspaceEdit Nothing Nothing Nothing
13
+
14
+ instance Hashable Location
15
+ instance Hashable Range
16
+ instance Hashable Position
17
+
18
+ instance Default ClientCapabilities where
19
+ def = ClientCapabilities (Just def) (Just def) (Just def) (Just def) (Just def) Nothing
20
+
21
+ instance Default WorkspaceClientCapabilities
22
+ instance Default TextDocumentClientCapabilities
23
+ instance Default NotebookDocumentClientCapabilities where
24
+ def = NotebookDocumentClientCapabilities def
25
+ instance Default NotebookDocumentSyncClientCapabilities
26
+ instance Default WindowClientCapabilities
27
+ instance Default GeneralClientCapabilities
Original file line number Diff line number Diff line change 1
1
{-#LANGUAGE TemplateHaskell #-}
2
+ {-# OPTIONS_GHC -Wno-orphans #-}
2
3
3
4
module Language.LSP.Protocol.Types.Lens where
4
5
You can’t perform that action at this time.
0 commit comments