yi-core-0.17.0: Yi editor core library

LicenseGPL-2
Maintaineryi-devel@googlegroups.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010
ExtensionsOverloadedStrings

Yi.Mode.Common

Description

Common functions used by modes.

Synopsis

Documentation

type TokenBasedMode tok = Mode (Tree (Tok tok)) Source #

fundamentalMode :: Mode syntax Source #

The only built in mode of yi

anyExtension Source #

Arguments

:: [String]

List of extensions

-> FilePath

Path to compare against

-> a

File contents. Currently unused but see extensionOrContentsMatch.

-> Bool 

When applied to an extensions list, creates a modeApplies function.

extensionOrContentsMatch :: [String] -> Parser () -> FilePath -> YiString -> Bool Source #

When applied to an extensions list and regular expression pattern, creates a modeApplies function.

linearSyntaxMode Source #

Arguments

:: Show s 
=> s

Starting state

-> TokenLexer AlexState s (Tok t) AlexInput 
-> (t -> StyleName) 
-> TokenBasedMode t 

Specialised version of linearSyntaxMode' for the common case, wrapping up into a Lexer with commonLexer.

hookModes :: (AnyMode -> Bool) -> BufferM () -> [AnyMode] -> [AnyMode] Source #

Adds a hook to all matching hooks in a list

applyModeHooks :: [(AnyMode -> Bool, BufferM ())] -> [AnyMode] -> [AnyMode] Source #

Apply a list of mode hooks to a list of AnyModes

lookupMode :: AnyMode -> YiM AnyMode Source #

Check whether a mode of the same name is already in modeTable and returns the original mode, if it isn't the case.

styleMode :: Show (l s) => StyleLexer l s t i -> TokenBasedMode t Source #

extensionMatches :: [String] -> FilePath -> Bool Source #

Determines if the file's extension is one of the extensions in the list.

shebangParser :: Parser a -> Parser () Source #

Generate a parser for shebang patterns the generated parser will match only if the shebang is at the start of a line

Examples

shebangParser "runhaskell"

generates a parser that matches "#!/usr/bin/env runhaskell\n" (but also "djsjfaj\n\n\n\r\n#! /usr/bin/env runhaskell \ndkasfkda\n\r\nkasfaj")

Note: You can get ("runhaskell" :: Parser String) by using the OverloadedStrings extension

shebangParser "python"

generates a parser that matches "#!/usr/bin/env python\n"

Note: it doesn't match "#!/usr/bin/env python2\n" (that's why the newline is required)

It is also possible to use more complex parsers:

shebangParser ("python" *> ("2" <|> "3" <|> ""))

generates a parser that matches any of:

  • "#!/usr/bin/env python\n"
  • "#!/usr/bin/env python2\n"
  • "#!/usr/bin/env python3\n"