    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE PackageImports    #-}
    {-# OPTIONS_HADDOCK show-extensions #-}

    -- |
    -- Module      :  Yi.Modes
    -- License     :  GPL-2
    -- Maintainer  :  yi-devel@googlegroups.com
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- Definitions for the bulk of modes shipped with Yi.

    module Yi.Modes (cMode, objectiveCMode, cppMode, cabalMode,  clojureMode,
                     srmcMode, ocamlMode, ottMode, gnuMakeMode,
                     perlMode, pythonMode, javaMode, jsonMode, anyExtension,
                     svnCommitMode, whitespaceMode,
                     gitCommitMode, rubyMode
                    ) where

    import           Lens.Micro.Platform          ((%~), (&), (.~))
    import           Data.List           (isPrefixOf)
    import           System.FilePath     (takeDirectory, takeFileName)

    import           Yi.Buffer
    --import           Yi.Lexer.Alex
    import qualified Yi.Lexer.C           as C (lexer)
    import qualified Yi.Lexer.Cabal       as Cabal (lexer)
    import qualified Yi.Lexer.Clojure     as Clojure (lexer)
    import qualified Yi.Lexer.Cplusplus   as Cplusplus (lexer)
    import qualified Yi.Lexer.GitCommit   as GitCommit (Token, lexer)
    import qualified Yi.Lexer.GNUMake     as GNUMake (lexer)
    import qualified Yi.Lexer.Java        as Java (lexer)
    import qualified Yi.Lexer.JSON        as JSON (lexer)
    import qualified Yi.Lexer.ObjectiveC  as ObjectiveC (lexer)
    import qualified Yi.Lexer.OCaml       as OCaml (Token, lexer)
    import qualified Yi.Lexer.Ott         as Ott (lexer)
    import qualified Yi.Lexer.Perl        as Perl (lexer)
    import qualified Yi.Lexer.Python      as Python (lexer)
    import qualified Yi.Lexer.Ruby        as Ruby (lexer)
    import qualified Yi.Lexer.Srmc        as Srmc (lexer)
    import qualified Yi.Lexer.SVNCommit   as SVNCommit (lexer)
    import qualified Yi.Lexer.Whitespace  as Whitespace (lexer)
    import           Yi.Mode.Common
    import           Yi.Style             (StyleName)

    cMode :: TokenBasedMode StyleName
    cMode :: TokenBasedMode StyleName
    cMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    C.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "c"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "c", String
    "h" ]

    objectiveCMode :: TokenBasedMode StyleName
    objectiveCMode :: TokenBasedMode StyleName
    objectiveCMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    ObjectiveC.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "objective-c"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "m", String
    "mm" ]

    cppMode :: TokenBasedMode StyleName
    cppMode :: TokenBasedMode StyleName
    cppMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Cplusplus.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "cxx", String
    "cpp", String
    "hxx" ]
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "c++"

    cabalMode :: TokenBasedMode StyleName
    cabalMode :: TokenBasedMode StyleName
    cabalMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Cabal.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "cabal"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "cabal" ]
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Maybe (BufferM HlState) -> Identity (Maybe (BufferM HlState)))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Maybe (BufferM HlState) -> f (Maybe (BufferM HlState)))
    -> Mode syntax -> f (Mode syntax)
    modeToggleCommentSelectionA ((Maybe (BufferM HlState) -> Identity (Maybe (BufferM HlState)))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Maybe (BufferM HlState)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ BufferM HlState -> Maybe (BufferM HlState)
    forall a. a -> Maybe a
    Just (YiString -> BufferM HlState
    toggleCommentB YiString
    "--")

    clojureMode :: TokenBasedMode StyleName
    clojureMode :: TokenBasedMode StyleName
    clojureMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Clojure.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "clojure"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "clj", String
    "edn" ]

    srmcMode :: TokenBasedMode StyleName
    srmcMode :: TokenBasedMode StyleName
    srmcMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Srmc.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "srmc"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "pepa", String
    "srmc" ] -- pepa is a subset of srmc

    gitCommitMode :: TokenBasedMode GitCommit.Token
    gitCommitMode :: TokenBasedMode StyleName
    gitCommitMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    GitCommit.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "git-commit"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ String -> YiString -> Bool
    forall {p}. String -> p -> Bool
    isCommit
      where
        isCommit :: String -> p -> Bool
    isCommit String
    p p
    _ = case (String -> String
    takeFileName String
    p, String -> String
    takeFileName (String -> String) -> String -> String
    forall a b. (a -> b) -> a -> b
    $ String -> String
    takeDirectory String
    p) of
          (String
    "COMMIT_EDITMSG", String
    ".git") -> Bool
    True
          (String, String)
    _ -> Bool
    False

    svnCommitMode :: TokenBasedMode StyleName
    svnCommitMode :: TokenBasedMode StyleName
    svnCommitMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    SVNCommit.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "svn-commit"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ String -> YiString -> Bool
    forall {p}. String -> p -> Bool
    isCommit
      where
        isCommit :: String -> p -> Bool
    isCommit String
    p p
    _ = String
    "svn-commit" String -> String -> Bool
    forall a. Eq a => [a] -> [a] -> Bool
    `isPrefixOf` String
    p Bool -> Bool -> Bool
    && [String] -> String -> Bool
    extensionMatches [String
    "tmp"] String
    p

    ocamlMode :: TokenBasedMode OCaml.Token
    ocamlMode :: TokenBasedMode Token
    ocamlMode = StyleLexer AlexState HlState Token AlexInput
    -> TokenBasedMode Token
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState Token AlexInput
    OCaml.lexer
      TokenBasedMode Token
    -> (TokenBasedMode Token -> TokenBasedMode Token)
    -> TokenBasedMode Token
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode Token -> Identity (TokenBasedMode Token)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode Token -> Identity (TokenBasedMode Token))
    -> Text -> TokenBasedMode Token -> TokenBasedMode Token
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "ocaml"
      TokenBasedMode Token
    -> (TokenBasedMode Token -> TokenBasedMode Token)
    -> TokenBasedMode Token
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode Token -> Identity (TokenBasedMode Token)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode Token -> Identity (TokenBasedMode Token))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode Token
    -> TokenBasedMode Token
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "ml", String
    "mli", String
    "mly" , String
    "mll", String
    "ml4", String
    "mlp4" ]

    perlMode :: TokenBasedMode StyleName
    perlMode :: TokenBasedMode StyleName
    perlMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Perl.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "perl"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "t", String
    "pl", String
    "pm" ]

    rubyMode :: TokenBasedMode StyleName
    rubyMode :: TokenBasedMode StyleName
    rubyMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Ruby.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "ruby"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "rb", String
    "ru" ]

    pythonMode :: TokenBasedMode StyleName
    pythonMode :: TokenBasedMode StyleName
    pythonMode = TokenBasedMode StyleName
    base
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "python"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "py" ]
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Maybe (BufferM HlState) -> Identity (Maybe (BufferM HlState)))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Maybe (BufferM HlState) -> f (Maybe (BufferM HlState)))
    -> Mode syntax -> f (Mode syntax)
    modeToggleCommentSelectionA ((Maybe (BufferM HlState) -> Identity (Maybe (BufferM HlState)))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Maybe (BufferM HlState)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ BufferM HlState -> Maybe (BufferM HlState)
    forall a. a -> Maybe a
    Just (YiString -> BufferM HlState
    toggleCommentB YiString
    "#")
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (IndentSettings -> Identity IndentSettings)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (IndentSettings -> f IndentSettings)
    -> Mode syntax -> f (Mode syntax)
    modeIndentSettingsA ((IndentSettings -> Identity IndentSettings)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (IndentSettings -> IndentSettings)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
    %~ (\IndentSettings
    x -> IndentSettings
    x { expandTabs = True, tabSize = 4 })
      where
        base :: TokenBasedMode StyleName
    base = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Python.lexer

    javaMode :: TokenBasedMode StyleName
    javaMode :: TokenBasedMode StyleName
    javaMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Java.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "java"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "java" ]

    jsonMode :: TokenBasedMode StyleName
    jsonMode :: TokenBasedMode StyleName
    jsonMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    JSON.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "json"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "json" ]

    gnuMakeMode :: TokenBasedMode StyleName
    gnuMakeMode :: TokenBasedMode StyleName
    gnuMakeMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    GNUMake.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "Makefile"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ String -> YiString -> Bool
    forall {p}. String -> p -> Bool
    isMakefile
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (IndentSettings -> Identity IndentSettings)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (IndentSettings -> f IndentSettings)
    -> Mode syntax -> f (Mode syntax)
    modeIndentSettingsA ((IndentSettings -> Identity IndentSettings)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (IndentSettings -> IndentSettings)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
    %~ (\IndentSettings
    x -> IndentSettings
    x { expandTabs = False, shiftWidth = 8 })
      where
        isMakefile :: FilePath -> a -> Bool
        isMakefile :: forall {p}. String -> p -> Bool
    isMakefile String
    path a
    _contents = String -> Bool
    matches (String -> Bool) -> String -> Bool
    forall a b. (a -> b) -> a -> b
    $ String -> String
    takeFileName String
    path
            where matches :: String -> Bool
    matches String
    "Makefile"    = Bool
    True
                  matches String
    "makefile"    = Bool
    True
                  matches String
    "GNUmakefile" = Bool
    True
                  matches String
    filename      = [String] -> String -> Bool
    extensionMatches [ String
    "mk" ] String
    filename

    ottMode :: TokenBasedMode StyleName
    ottMode :: TokenBasedMode StyleName
    ottMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Ott.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "ott"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "ott" ]

    whitespaceMode :: TokenBasedMode StyleName
    whitespaceMode :: TokenBasedMode StyleName
    whitespaceMode = StyleLexer AlexState HlState StyleName AlexInput
    -> TokenBasedMode StyleName
    forall (l :: * -> *) s t i.
    Show (l s) =>
    StyleLexer l s t i -> TokenBasedMode t
    styleMode StyleLexer AlexState HlState StyleName AlexInput
    Whitespace.lexer
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & (Text -> Identity Text)
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    (Text -> f Text) -> Mode syntax -> f (Mode syntax)
    modeNameA ((Text -> Identity Text)
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> Text -> TokenBasedMode StyleName -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ Text
    "whitespace"
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((String -> YiString -> Bool)
     -> Identity (String -> YiString -> Bool))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((String -> YiString -> Bool) -> f (String -> YiString -> Bool))
    -> Mode syntax -> f (Mode syntax)
    modeAppliesA (((String -> YiString -> Bool)
      -> Identity (String -> YiString -> Bool))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (String -> YiString -> Bool)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ [String] -> String -> YiString -> Bool
    forall a. [String] -> String -> a -> Bool
    anyExtension [ String
    "ws" ]
      TokenBasedMode StyleName
    -> (TokenBasedMode StyleName -> TokenBasedMode StyleName)
    -> TokenBasedMode StyleName
    forall a b. a -> (a -> b) -> b
    & ((Tree (Tok StyleName) -> IndentBehaviour -> BufferM HlState)
     -> Identity
          (Tree (Tok StyleName) -> IndentBehaviour -> BufferM HlState))
    -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName)
    forall syntax (f :: * -> *).
    Functor f =>
    ((syntax -> IndentBehaviour -> BufferM HlState)
     -> f (syntax -> IndentBehaviour -> BufferM HlState))
    -> Mode syntax -> f (Mode syntax)
    modeIndentA (((Tree (Tok StyleName) -> IndentBehaviour -> BufferM HlState)
      -> Identity
           (Tree (Tok StyleName) -> IndentBehaviour -> BufferM HlState))
     -> TokenBasedMode StyleName -> Identity (TokenBasedMode StyleName))
    -> (Tree (Tok StyleName) -> IndentBehaviour -> BufferM HlState)
    -> TokenBasedMode StyleName
    -> TokenBasedMode StyleName
    forall s t a b. ASetter s t a b -> b -> s -> t
    .~ (\Tree (Tok StyleName)
    _ IndentBehaviour
    _ -> Char -> BufferM HlState
    insertB Char
    '\t')