-- |Data types for the Neovim syntax API.
module Ribosome.Data.Syntax where

-- |Different kinds of syntax items.
data SyntaxItemDetail =
  Keyword {
    SyntaxItemDetail -> Text
kwGroup :: Text,
    SyntaxItemDetail -> Text
kwKeyword :: Text,
    SyntaxItemDetail -> [Text]
kwOptions :: [Text]
  }
  |
  Match {
    SyntaxItemDetail -> Text
matchGroup :: Text,
    SyntaxItemDetail -> Text
matchPattern :: Text
  }
  |
  Region {
    SyntaxItemDetail -> Text
regionGroup :: Text,
    SyntaxItemDetail -> Text
regionStart :: Text,
    SyntaxItemDetail -> Text
regionEnd :: Text,
    SyntaxItemDetail -> Maybe Text
regionSkip :: Maybe Text,
    SyntaxItemDetail -> Text
regionStartOffset :: Text,
    SyntaxItemDetail -> Text
regionEndOffset :: Text
  }
  |
  Verbatim {
    SyntaxItemDetail -> Text
verbatimCommand :: Text
  }
  deriving stock (SyntaxItemDetail -> SyntaxItemDetail -> Bool
(SyntaxItemDetail -> SyntaxItemDetail -> Bool)
-> (SyntaxItemDetail -> SyntaxItemDetail -> Bool)
-> Eq SyntaxItemDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SyntaxItemDetail -> SyntaxItemDetail -> Bool
$c/= :: SyntaxItemDetail -> SyntaxItemDetail -> Bool
== :: SyntaxItemDetail -> SyntaxItemDetail -> Bool
$c== :: SyntaxItemDetail -> SyntaxItemDetail -> Bool
Eq, Int -> SyntaxItemDetail -> ShowS
[SyntaxItemDetail] -> ShowS
SyntaxItemDetail -> String
(Int -> SyntaxItemDetail -> ShowS)
-> (SyntaxItemDetail -> String)
-> ([SyntaxItemDetail] -> ShowS)
-> Show SyntaxItemDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SyntaxItemDetail] -> ShowS
$cshowList :: [SyntaxItemDetail] -> ShowS
show :: SyntaxItemDetail -> String
$cshow :: SyntaxItemDetail -> String
showsPrec :: Int -> SyntaxItemDetail -> ShowS
$cshowsPrec :: Int -> SyntaxItemDetail -> ShowS
Show)

-- |A syntax item like @keyword@ or @match@, bundled with options for the @:syntax@ command.
data SyntaxItem =
  SyntaxItem {
    SyntaxItem -> SyntaxItemDetail
siDetail :: SyntaxItemDetail,
    SyntaxItem -> [Text]
siOptions :: [Text],
    SyntaxItem -> Map Text Text
siParams :: Map Text Text
  }
  deriving stock (SyntaxItem -> SyntaxItem -> Bool
(SyntaxItem -> SyntaxItem -> Bool)
-> (SyntaxItem -> SyntaxItem -> Bool) -> Eq SyntaxItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SyntaxItem -> SyntaxItem -> Bool
$c/= :: SyntaxItem -> SyntaxItem -> Bool
== :: SyntaxItem -> SyntaxItem -> Bool
$c== :: SyntaxItem -> SyntaxItem -> Bool
Eq, Int -> SyntaxItem -> ShowS
[SyntaxItem] -> ShowS
SyntaxItem -> String
(Int -> SyntaxItem -> ShowS)
-> (SyntaxItem -> String)
-> ([SyntaxItem] -> ShowS)
-> Show SyntaxItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SyntaxItem] -> ShowS
$cshowList :: [SyntaxItem] -> ShowS
show :: SyntaxItem -> String
$cshow :: SyntaxItem -> String
showsPrec :: Int -> SyntaxItem -> ShowS
$cshowsPrec :: Int -> SyntaxItem -> ShowS
Show)

-- |Options for a highlight group.
data Highlight =
  Highlight {
    Highlight -> Text
hiGroup :: Text,
    Highlight -> Map Text Text
hiValues :: Map Text Text
  }
  deriving stock (Highlight -> Highlight -> Bool
(Highlight -> Highlight -> Bool)
-> (Highlight -> Highlight -> Bool) -> Eq Highlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Highlight -> Highlight -> Bool
$c/= :: Highlight -> Highlight -> Bool
== :: Highlight -> Highlight -> Bool
$c== :: Highlight -> Highlight -> Bool
Eq, Int -> Highlight -> ShowS
[Highlight] -> ShowS
Highlight -> String
(Int -> Highlight -> ShowS)
-> (Highlight -> String)
-> ([Highlight] -> ShowS)
-> Show Highlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Highlight] -> ShowS
$cshowList :: [Highlight] -> ShowS
show :: Highlight -> String
$cshow :: Highlight -> String
showsPrec :: Int -> Highlight -> ShowS
$cshowsPrec :: Int -> Highlight -> ShowS
Show)

-- |Options for a @:highlight link@ command.
data HiLink =
  HiLink {
    HiLink -> Text
hlGroup :: Text,
    HiLink -> Text
hlTarget :: Text
  }
  deriving stock (HiLink -> HiLink -> Bool
(HiLink -> HiLink -> Bool)
-> (HiLink -> HiLink -> Bool) -> Eq HiLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HiLink -> HiLink -> Bool
$c/= :: HiLink -> HiLink -> Bool
== :: HiLink -> HiLink -> Bool
$c== :: HiLink -> HiLink -> Bool
Eq, Int -> HiLink -> ShowS
[HiLink] -> ShowS
HiLink -> String
(Int -> HiLink -> ShowS)
-> (HiLink -> String) -> ([HiLink] -> ShowS) -> Show HiLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HiLink] -> ShowS
$cshowList :: [HiLink] -> ShowS
show :: HiLink -> String
$cshow :: HiLink -> String
showsPrec :: Int -> HiLink -> ShowS
$cshowsPrec :: Int -> HiLink -> ShowS
Show)

-- |A set of syntax settings, consisting of syntax items like @keyword@ and @match@, highlights and highlight links.
data Syntax =
  Syntax {
     Syntax -> [SyntaxItem]
syntaxItems :: [SyntaxItem],
     Syntax -> [Highlight]
syntaxHighlights :: [Highlight],
     Syntax -> [HiLink]
syntaxHiLinks :: [HiLink]
  }
  deriving stock (Syntax -> Syntax -> Bool
(Syntax -> Syntax -> Bool)
-> (Syntax -> Syntax -> Bool) -> Eq Syntax
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Syntax -> Syntax -> Bool
$c/= :: Syntax -> Syntax -> Bool
== :: Syntax -> Syntax -> Bool
$c== :: Syntax -> Syntax -> Bool
Eq, Int -> Syntax -> ShowS
[Syntax] -> ShowS
Syntax -> String
(Int -> Syntax -> ShowS)
-> (Syntax -> String) -> ([Syntax] -> ShowS) -> Show Syntax
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Syntax] -> ShowS
$cshowList :: [Syntax] -> ShowS
show :: Syntax -> String
$cshow :: Syntax -> String
showsPrec :: Int -> Syntax -> ShowS
$cshowsPrec :: Int -> Syntax -> ShowS
Show, (forall x. Syntax -> Rep Syntax x)
-> (forall x. Rep Syntax x -> Syntax) -> Generic Syntax
forall x. Rep Syntax x -> Syntax
forall x. Syntax -> Rep Syntax x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Syntax x -> Syntax
$cfrom :: forall x. Syntax -> Rep Syntax x
Generic)
  deriving anyclass (Syntax
Syntax -> Default Syntax
forall a. a -> Default a
def :: Syntax
$cdef :: Syntax
Default)