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
7171 , base >= 4.11 && < 5
7272 , binary
7373 , containers
74+ , data-default
7475 , deepseq
7576 , Diff >= 0.2
7677 , dlist
@@ -114,6 +115,7 @@ library
114115 Language.LSP.Protocol.Message.Registration
115116 Language.LSP.Protocol.Message.Types
116117 Language.LSP.Protocol.Types.Common
118+ Language.LSP.Protocol.Types.CustomInstances
117119 Language.LSP.Protocol.Types.Edit
118120 Language.LSP.Protocol.Types.Lens
119121 Language.LSP.Protocol.Types.Location
Original file line number Diff line number Diff line change 11{-#LANGUAGE TemplateHaskell #-}
2+ {-# OPTIONS_GHC -Wno-orphans #-}
23
34module Language.LSP.Protocol.Message.Lens where
45
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ module Language.LSP.Protocol.Types (
2222 , module SemanticTokens
2323 -- * Main LSP types and functions
2424 , module Generated
25+ -- ** Custom instances for the generated types
26+ , module CustomInstances
2527 ) where
2628
2729import Language.LSP.Protocol.Internal.Types as Generated
@@ -35,3 +37,4 @@ import Language.LSP.Protocol.Types.Singletons as Singletons
3537import Language.LSP.Protocol.Types.Uri as Uri
3638import Language.LSP.Protocol.Types.Uri.OsPath as Uri
3739import 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 (
1818 , Null (.. )
1919 , absorbNull
2020 , nullToMaybe
21+ , maybeToNull
2122 , (.=?)
2223) where
2324
@@ -123,6 +124,16 @@ nullToMaybe :: a |? Null -> Maybe a
123124nullToMaybe (InL a) = Just a
124125nullToMaybe (InR _) = Nothing
125126
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+
126137 -- We use String so we can use fromString on it to get a key that works
127138 -- in both aeson-1 and aeson-2
128139-- | 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 11{-#LANGUAGE TemplateHaskell #-}
2+ {-# OPTIONS_GHC -Wno-orphans #-}
23
34module Language.LSP.Protocol.Types.Lens where
45
You can’t perform that action at this time.
0 commit comments