packages feed

yi-contrib 0.8.2 → 0.10.0

raw patch · 12 files changed

+454/−509 lines, 12 filesdep +oo-prototypesdep +textdep +yi-languagedep ~yiPVP ok

version bump matches the API change (PVP)

Dependencies added: oo-prototypes, text, yi-language, yi-rope

Dependency ranges changed: yi

API changes (from Hackage documentation)

- Yi.Config.Users.Corey: config :: Config
- Yi.Config.Users.Ertai: config :: Config
- Yi.Config.Users.Jeff: myConfig :: Config
+ Yi.Config.Users.Anders: main :: IO ()
- Yi.Config.Users.Michal: myBindings :: (String -> EditorM ()) -> [VimBinding]
+ Yi.Config.Users.Michal: myBindings :: (EventString -> EditorM ()) -> [VimBinding]

Files

src/Yi/Config/Users/Amy.hs view
@@ -1,17 +1,25 @@+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Yi.Config.Users.Amy+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+ module Yi.Config.Users.Amy where  import Yi--import Prelude+import Yi.Keymap.Cua --- Import the desired UI as needed. +-- Import the desired UI as needed. -- Some are not complied in, so we import none here.  -- import Yi.UI.Vty (start) -- import Yi.UI.Pango (start) -import Yi.Keymap.Cua-+myConfig :: Config myConfig = defaultCuaConfig {     -- Keymap Configuration     defaultKm = extendedCuaKeymapSet,@@ -33,16 +41,15 @@       }   } +defaultUIConfig :: UIConfig defaultUIConfig = configUI myConfig  -- Add M-x (which is probably Alt-x on your system) to the default -- keyset, and have it launch our custom macro.+extendedCuaKeymapSet :: KeymapSet extendedCuaKeymapSet = customizedCuaKeymapSet $-  choice [-    metaCh 'x' ?>>! helloWorld-  ]+  choice [ metaCh 'x' ?>>! helloWorld ]  -- A custom macro helloWorld :: YiM ()-helloWorld = withBuffer $ insertN "Hello, world!"-+helloWorld = withCurrentBuffer $ insertN "Hello, world!"
src/Yi/Config/Users/Anders.hs view
@@ -1,11 +1,24 @@-module Yi.Config.Users.Anders (config) where+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-} -import Control.Lens-import Yi hiding (Block)+-- |+-- Module      :  Yi.Config.Users.Anders+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable++module Yi.Config.Users.Anders (config, main) where++import           Control.Lens+import           Data.Monoid+import           Yi hiding (Block)+import           Yi.Hoogle (hoogle)+import           Yi.Lexer.Haskell (TT) import qualified Yi.Mode.Haskell as H-import Yi.Hoogle (hoogle)-import Yi.String (mapLines)-import Yi.Modes (removeAnnots)+import qualified Yi.Rope as R+import           Yi.String (mapLines)+import           Yi.Syntax.Haskell (Tree)  config :: Config config = defaultEmacsConfig@@ -13,10 +26,10 @@ -- | Increase the indentation of the selection increaseIndent :: BufferM () increaseIndent = do-  r <- getSelectRegionB -  r' <- unitWiseRegion Yi.Line r +  r <- getSelectRegionB+  r' <- unitWiseRegion Yi.Line r      -- extend the region to full lines-  modifyRegionB (mapLines (' ':)) r'+  modifyRegionB (mapLines $ R.cons ' ') r'      -- prepend each line with a space  main :: IO ()@@ -32,10 +45,11 @@   }  -- | Set my hooks for nice features+haskellModeHooks :: Mode syntax -> Mode syntax haskellModeHooks mode =-   mode { modeName = "my " ++ modeName mode+   mode { modeName = "my " <> modeName mode         , modeKeymap =-            topKeymapA %~ ((ctrlCh 'c' ?>> +            topKeymapA %~ ((ctrlCh 'c' ?>>                             choice [ ctrlCh 'l' ?>>! H.ghciLoadBuffer                                    , ctrl (char 'z') ?>>! H.ghciGet                                    , ctrl (char 'h') ?>>! hoogle@@ -46,4 +60,5 @@                            <||) }  -- This is used in order to remove the unicode characters usually used.-noAnnots = removeAnnots (H.preciseMode {modeName = "preciseNoUnicode"})+noAnnots :: Mode (Tree TT)+noAnnots = H.preciseMode {modeName = "preciseNoUnicode"}
− src/Yi/Config/Users/Corey.hs
@@ -1,126 +0,0 @@-module Yi.Config.Users.Corey (config) where-{- An example yi.hs that uses the Vim keymap with these additions:-    - Always uses the VTY UI by default.-    - The color style is darkBlueTheme-    - The insert mode of the Vim keymap has been extended with a few additions-      I find useful.- -}-import Yi-import Yi.Keymap.Vim-import Yi.Buffer.Indent (indentAsPreviousB)-import Yi.Keymap.Keys-import Yi.Misc (adjBlock)---- import qualified Yi.UI.Vty--import Yi.Style.Library (darkBlueTheme)-import Data.List (isPrefixOf)-import Control.Monad (replicateM_)-import Control.Applicative---- Set soft tabs of 4 spaces in width.-prefIndent :: Mode s -> Mode s-prefIndent m = m {-        modeIndentSettings = IndentSettings-            {-                expandTabs = True,-                shiftWidth = 4,-                tabSize = 4-            }}--noHaskellAnnots m -    | modeName m == "haskell" = m { modeGetAnnotations = modeGetAnnotations emptyMode }-    | otherwise = m--config = defaultConfig -    {-        -- Use VTY as the default UI.-        -- startFrontEnd = Yi.UI.Vty.start,-        defaultKm = mkKeymap extendedVimKeymap,-        modeTable = fmap (onMode $ noHaskellAnnots . prefIndent) (modeTable defaultConfig),-        configUI = (configUI defaultConfig)-            {-                configTheme = darkBlueTheme-            }-    }--extendedVimKeymap = defKeymap `override` \super self -> super-    {-        v_top_level = -            (deprioritize >> v_top_level super)-            -- On 'o' in normal mode I always want to use the indent of the previous line.-            -- TODO: If the line where the newline is to be inserted is inside a-            -- block comment then the block comment should be "continued"-            -- TODO: Ends up I'm trying to replicate vim's "autoindent" feature. This -            -- should be made a function in Yi.-            <|> (char 'o' ?>> beginIns self $ do -                    moveToEol-                    insertB '\n'-                    indentAsPreviousB-                )-            -- On HLX (Haskell Language Extension) I want to go into insert mode such -            -- that the cursor position is correctly placed to start entering the name-            -- of an language extension in a LANGUAGE pragma.-            -- A language pragma will take either the form-            -- {-# LANGUAGE Foo #-}-            -- or-            -- >{-# LANGUAGE Foo #-}-            -- The form should be chosen based on the current mode.-            <|> ( pString "HXL" >> startExtesnionNameInsert self ),-        v_ins_char = -            (deprioritize >> v_ins_char super) -            -- On enter I always want to use the indent of previous line-            -- TODO: If the line where the newline is to be inserted is inside a-            -- block comment then the block comment should be "continued"-            -- TODO: Ends up I'm trying to replicate vim's "autoindent" feature. This -            -- should be made a function in Yi.-            <|> ( spec KEnter ?>>! do-                    insertB '\n'-                    indentAsPreviousB-                )-            -- I want softtabs to be deleted as if they are tabs. So if the -            -- current col is a multiple of 4 and the previous 4 characters-            -- are spaces then delete all 4 characters.-            -- TODO: Incorporate into Yi itself.-            <|> ( spec KBS ?>>! do-                    c <- curCol-                    line <- readRegionB =<< regionOfPartB Line Backward-                    sw <- indentSettingsB >>= return . shiftWidth-                    let indentStr = replicate sw ' '-                        toDel = if (c `mod` sw) /= 0-                                    then 1-                                    else if indentStr `isPrefixOf` reverse line -                                        then sw-                                        else 1-                    adjBlock (-toDel)-                    replicateM_ toDel $ deleteB Character Backward-                )-            -- On starting to write a block comment I want the close comment -            -- text inserted automatically.-            <|> choice -                [ pString open_tag >>! do-                    insertN $ open_tag ++ " \n" -                    indentAsPreviousB-                    insertN $ " " ++ close_tag-                    lineUp-                 | (open_tag, close_tag) <- -                    [ ("{-", "-}") -- Haskell block comments-                    , ("/*", "*/") -- C++ block comments-                    ]-                ]-    }---startExtesnionNameInsert :: ModeMap -> I Event Action ()-startExtesnionNameInsert self = beginIns self $ do-    p_current <- pointB-    m_current <- getMarkB (Just "'") -    setMarkPointB m_current p_current-    moveTo $ Point 0-    insertB '\n'-    moveTo $ Point 0-    insertN "{-# LANGUAGE "-    p <- pointB-    insertN " #-}"-    moveTo p-
− src/Yi/Config/Users/Ertai.hs
@@ -1,123 +0,0 @@-{-# LANGUAGE TypeFamilies #-}-module Yi.Config.Users.Ertai (config) where--import Yi-import Yi.Modes (removeAnnots)-import qualified Yi.Mode.Haskell as Haskell-import qualified Yi.Syntax.Haskell as Haskell-import qualified Yi.Lexer.Haskell as Haskell-import qualified Yi.Syntax.Strokes.Haskell as Haskell-import Data.List (isPrefixOf)-import Data.Maybe-import Data.Foldable (Foldable)-import Yi.Char.Unicode (greek, symbols)-import Control.Monad (replicateM_)-import Control.Applicative-import Control.Lens-import Yi.Keymap.Keys (char,(?>>!),(>>!))-import Yi.Lexer.Alex (Tok)-import qualified Yi.Syntax.Tree as Tree-import Yi.Hoogle-import Yi.Buffer-import Yi.Keymap.Vim (viWrite, v_ex_cmds, v_top_level, v_ins_char, v_opts, tildeop, savingInsertStringB, savingDeleteCharB, exCmds, exHistInfixComplete')-import Yi.Keymap (withModeY)-import Yi.MiniBuffer (matchingBufferNames)-import qualified Yi.Keymap.Vim as Vim--myModetable :: [AnyMode]-myModetable = [-               AnyMode $ haskellModeHooks Haskell.cleverMode-              ,-               AnyMode $ haskellModeHooks Haskell.preciseMode-              ,-               AnyMode $ haskellModeHooks Haskell.fastMode-              ,-               AnyMode . haskellModeHooks . removeAnnots $ Haskell.cleverMode-              ,-               AnyMode $ haskellModeHooks Haskell.fastMode-              ,-               AnyMode . haskellModeHooks . removeAnnots $ Haskell.fastMode-              ]--type Endom a = a -> a--haskellModeHooks :: (Foldable f) => Endom (Mode (f Haskell.TT))-haskellModeHooks mode =-  -- uncomment for shim:-  -- Shim.minorMode $ -     mode {-        modeGetAnnotations = Tree.tokenBasedAnnots Haskell.tokenToAnnot,--        -- modeAdjustBlock = \_ _ -> return (),-        -- modeGetStrokes = \_ _ _ _ -> [],-        modeName = "my " ++ modeName mode,-        -- example of Mode-local rebinding-        modeKeymap = topKeymapA %~-            ((char '\\' ?>> choice [char 'l' ?>>! Haskell.ghciLoadBuffer,-                                    char 'z' ?>>! Haskell.ghciGet,-                                    char 'h' ?>>! hoogle,-                                    char 'r' ?>>! Haskell.ghciSend ":r",-                                    char 't' ?>>! Haskell.ghciInferType-                                   ])-                      <||)-     }--{--main :: IO ()-main = do args <- getArgs-          if any ("--as=" `isPrefixOf`) args-            then yi defaultConfig-            else yi $ myConfig defaultVimConfig--}--config :: Config-config = defaultVimConfig { modeTable = fmap (onMode prefIndent) (myModetable ++ modeTable defaultVimConfig)-                          , defaultKm = Vim.mkKeymap extendedVimKeymap-                          , startActions = startActions defaultVimConfig ++ [makeAction (maxStatusHeightA .= 10 :: EditorM ())]-                          }---- Set soft tabs of 4 spaces in width.-prefIndent :: Mode s -> Mode s-prefIndent m = m { modeIndentSettings = IndentSettings { expandTabs = True-                                                       , shiftWidth = 2-                                                       , tabSize = 2 }-                 }--mkInputMethod :: [(String,String)] -> Keymap-mkInputMethod xs = choice [pString i >> adjustPriority (negate (length i)) >>! savingInsertStringB o | (i,o) <- xs]--extraInput :: Keymap-extraInput = ctrl (char ']') ?>> mkInputMethod (greek ++ symbols)---- need something better-unicodifySymbols :: BufferM ()-unicodifySymbols = modifyRegionB f =<< regionOfB unitViWORD-  where f x = fromMaybe x $ lookup x (greek ++ symbols)--extendedVimKeymap :: Proto Vim.ModeMap-extendedVimKeymap = Vim.defKeymap `override` \super self -> super-    { v_top_level = (deprioritize >> v_top_level super)-                    <|> (char ',' ?>>! viWrite)-                    <|> ((events $ map char "\\u") >>! unicodifySymbols)-                    <|> ((events $ map char "\\c") >>! withModeY modeToggleCommentSelection)-    , v_ins_char =-            (deprioritize >> v_ins_char super)-            -- I want softtabs to be deleted as if they are tabs. So if the-            -- current col is a multiple of 4 and the previous 4 characters-            -- are spaces then delete all 4 characters.-            <|> (spec KBS ?>>! do-                    c <- curCol-                    line <- readRegionB =<< regionOfPartB Line Backward-                    sw <- indentSettingsB >>= return . shiftWidth-                    let indentStr = replicate sw ' '-                        toDel | (c `mod` sw) == 0 && indentStr `isPrefixOf` reverse line = sw-                              | otherwise                                                = 1-                    replicateM_ toDel $ savingDeleteCharB Backward-                )-            <|> (adjustPriority (-1) >> extraInput)-    , v_opts = (v_opts super) { tildeop = True }-    , v_ex_cmds = exCmds [("b",-                       withEditor . switchToBufferWithNameE,-                       Just $ exHistInfixComplete' True matchingBufferNames)]-    }-
src/Yi/Config/Users/JP.hs view
@@ -1,8 +1,16 @@-{-# LANGUAGE CPP, TypeFamilies #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Yi.Config.Users.JP+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+ module Yi.Config.Users.JP (config) where -import Yi hiding (defaultConfig)-import Yi.Keymap.Emacs (mkKeymap, defKeymap, ModeMap(..)) -- import Yi.Users.JP.Experimental (keymap) -- You can use other keymap by importing some other module: -- import  Yi.Keymap.Cua (keymap)@@ -10,26 +18,28 @@ -- If configured with ghcAPI, Shim Mode can be enabled: -- import qualified Yi.Mode.Shim as Shim -import Control.Applicative-import Control.Lens-import Data.Traversable (sequenceA)-import Data.Foldable (Foldable,find)-import Data.Monoid-import Yi.Char.Unicode-import Yi.Hoogle-import Yi.Lexer.Alex (tokToSpan, Tok)-import Yi.Lexer.Haskell as Hask-import Yi.Mode.Haskell as Haskell-import Yi.String-import Yi.Syntax-import Yi.Syntax.Tree+import           Control.Applicative+import           Control.Lens+import           Data.Foldable (Foldable,find)+import           Data.Monoid+import           Data.Traversable (sequenceA)+import           Yi hiding (defaultConfig)+import           Yi.Hoogle import qualified Yi.Interact as I+import           Yi.Keymap.Emacs (mkKeymap, defKeymap, ModeMap(..))+import           Yi.Lexer.Alex (tokToSpan, Tok)+import           Yi.Lexer.Haskell as Hask+import           Yi.Mode.Haskell as Haskell+import qualified Yi.Rope as R+import           Yi.String+import           Yi.Syntax+import           Yi.Syntax.Tree  increaseIndent :: BufferM ()-increaseIndent = modifyExtendedSelectionB Yi.Line $ mapLines (' ':)+increaseIndent = modifyExtendedSelectionB Yi.Line $ mapLines (R.cons ' ')  decreaseIndent :: BufferM ()-decreaseIndent = modifyExtendedSelectionB Yi.Line $ mapLines (drop 1)+decreaseIndent = modifyExtendedSelectionB Yi.Line $ mapLines (R.drop 1)  osx :: Bool #ifdef darwin_HOST_OS@@ -55,15 +65,14 @@   haskellModeHooks :: (Foldable tree) => Mode (tree (Tok Token)) -> Mode (tree (Tok Token))-haskellModeHooks mode = +haskellModeHooks mode =                   -- uncomment for shim:-                  -- Shim.minorMode $ +                  -- Shim.minorMode $                      mode {-                        modeGetAnnotations = tokenBasedAnnots tta,                          -- modeAdjustBlock = \_ _ -> return (),                         -- modeGetStrokes = \_ _ _ _ -> [],-                        modeName = "my " ++ modeName mode,+                        modeName = "my " <> modeName mode,                         -- example of Mode-local rebinding                         modeKeymap = topKeymapA %~ ((ctrlCh 'c' ?>> choice [ctrlCh 'l' ?>>! ghciLoadBuffer,                                                               ctrl (char 'z') ?>>! ghciGet,@@ -74,21 +83,21 @@                                       <||)                        } --- noAnnots _ _ = []              +-- noAnnots _ _ = [] -mkInputMethod :: [(String,String)] -> Keymap-mkInputMethod xs = choice [pString i >> adjustPriority (negate (length i)) >>! insertN o | (i,o) <- xs] +mkInputMethod :: [(String, R.YiString)] -> Keymap+mkInputMethod xs = choice [pString i >> adjustPriority (negate (length i)) >>! insertN o | (i,o) <- xs]  extraInput :: Keymap-extraInput -    = spec KEsc ?>> mkInputMethod (greek ++ symbols ++ subscripts)+extraInput+    = spec KEsc ?>> mkInputMethod (greek <> symbols <> subscripts)   tta :: Yi.Lexer.Alex.Tok Token -> Maybe (Yi.Syntax.Span String) tta = sequenceA . tokToSpan . (fmap Yi.Config.Users.JP.tokenToText)  frontend :: UIBoot-Just (_, frontend) = foldr1 (<|>) $ fmap (\nm -> find ((nm ==) . fst) availableFrontends) ["vty"] +Just (_, frontend) = foldr1 (<|>) $ fmap (\nm -> find ((nm ==) . fst) availableFrontends) ["vty"]  defaultConfig :: Config defaultConfig = defaultEmacsConfig@@ -101,10 +110,10 @@ fixKeymap =   choice [(ctrlCh 'd'           ?>>! (deleteB'))                      , spec KBS             ?>>! ((adjBlock (-1) >> bdeleteB))                      , spec KDel            ?>>! ((deleteB'))]-                       + myKeymap :: KeymapSet-myKeymap = mkKeymap $ override defKeymap $ \proto _self -> +myKeymap = mkKeymap $ override defKeymap $ \proto _self ->    proto {            _completionCaseSensitive = True,            _eKeymap = (adjustPriority (-1) >> choice [extraInput]) <|| (fixKeymap <|| _eKeymap proto)@@ -116,17 +125,17 @@ config = defaultConfig {                            configInputPreprocess = I.idAutomaton,                            startFrontEnd = frontend,-                           modeTable = AnyMode (haskellModeHooks Haskell.preciseMode) -                                     : AnyMode (haskellModeHooks Haskell.cleverMode) -                                     : AnyMode (haskellModeHooks Haskell.fastMode) -                                     : AnyMode (haskellModeHooks Haskell.literateMode) +                           modeTable = AnyMode (haskellModeHooks Haskell.preciseMode)+                                     : AnyMode (haskellModeHooks Haskell.cleverMode)+                                     : AnyMode (haskellModeHooks Haskell.fastMode)+                                     : AnyMode (haskellModeHooks Haskell.literateMode)                                      : modeTable defaultConfig,-                           configUI = (configUI defaultConfig) +                           configUI = (configUI defaultConfig)                              { configFontSize = Just 10                                -- , configTheme = darkBlueTheme                              , configTheme = defaultTheme `override` \superTheme _ -> superTheme                                {-                                 selectedStyle = Endo $ \a -> a { +                                 selectedStyle = Endo $ \a -> a {                                                                   foreground = white,                                                                   background = black                                                                 }@@ -136,3 +145,162 @@                            defaultKm = myKeymap                           } +greek :: [(String, R.YiString)]+greek = [("alpha", "α")+        ,("'a", "α")+        ,("beta", "β")+        ,("'b", "β")+        ,("gamma", "γ")+        ,("'g", "γ")+        ,("Gamma", "Γ")+        ,("'G", "Γ")+        ,("delta", "δ")+        ,("'d", "δ")+        ,("Delta", "Δ")+        ,("'D", "Δ")+        ,("epsilon", "ε")+        ,("'z", "ζ")+        ,("zeta", "ζ")+        ,("'z", "ζ")+        ,("eta", "η")+        ,("theta", "θ")+        ,("Theta", "Θ")+        ,("iota", "ι")+        ,("'i", "ι")+        ,("kapa", "κ")+        ,("'k", "κ")+        ,("lambda", "λ")+        ,("'l", "λ")+        ,("Lambda", "Λ")+        ,("'L", "Λ")+        ,("mu", "μ")+        ,("'m", "μ")+        ,("nu", "ν")+        ,("'n", "ν")+        ,("xi", "ξ")+        ,("'x", "ξ")+        ,("omicron", "ο")+        ,("'o", "ο")+        ,("pi", "π")+        ,("Pi", "Π")+        ,("rho", "ρ")+        ,("'r", "ρ")+        ,("sigma", "σ")+        ,("'s", "σ")+        ,("Sigma", "Σ")+        ,("'S", "Σ")+        ,("tau", "τ")+        ,("'t", "τ")+        ,("phi", "φ")+        ,("Phi", "Φ")+        ,("chi", "χ")+        ,("Chi", "Χ")+        ,("psi", "ψ")+        ,("Psi", "Ψ")+        ,("omega", "ω")+        ,("'w", "ω")+        ,("Omega", "Ω")+        ,("'O", "Ω")+        ]++symbols :: [(String, R.YiString)]+symbols =+ [+ -- parens+  ("<","⟨")+ ,(">","⟩")+ ,(">>","⟫")+ ,("<<","⟪")++ ,("[[","⟦")+ ,("]]","⟧")++ -- quantifiers+ ,("forall", "∀")+ ,("exists", "∃")++ -- operators+ ,("<|","◃")+ -- ,("<|","◁") alternative+ ,("|>","▹")+ ,("v","∨")+ ,("u","∪")+ ,("V","⋁")+ ,("^","∧")+ ,("o","∘")+ ,(".","·")+ ,("x","×")+ ,("neg","¬")++ --- arrows+ ,("<-","←")+ ,("->","→")+ ,("|->","↦")+ ,("<-|","↤")+ ,("<--","⟵")+ ,("-->","⟶")+ ,("|-->","⟼")+ ,("==>","⟹")+ ,("=>","⇒")+ ,("<=","⇐")+ ,("~>","↝")+ ,("<~","↜")+ ,("<-<", "↢")+ ,(">->", "↣")+ ,("<->", "↔")+ ,("|<-", "⇤")+ ,("->|", "⇥")++ --- relations+ ,("c=","⊆")+ ,("c","⊂")+ ,("c-","∈")+ ,("/c-","∉")+ ,(">=","≥")+ ,("=<","≤")++ ---- equal signs+ ,("=def","≝")+ ,("=?","≟")+ ,("=-","≡")+ ,("~=","≃")+ ,("/=","≠")++ -- misc+ ,("_|_","⊥")+ ,("Top","⊤")+ ,("|N","ℕ")+ ,("|P","ℙ")+ ,("|R","ℝ")+ ,("^n","ⁿ")+ ,("::","∷")+ ,("0", "∅")+ ,("*", "★") -- or "⋆"++ -- dashes+ ,("-","−")++ -- quotes+ ,("\"","“”")++ -- turnstyles+ ,("|-", "⊢")+ ,("|/-", "⊬")+ ,("-|", "⊣")+ ,("|=", "⊨")+ ,("|/=", "⊭")+ ,("||-", "⊩")++ ]++-- More:+-- arrows: ⇸ ⇆+-- set:  ⊇ ⊃+-- circled operators: ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⍟  ⎊ ⎉+-- squared operators: ⊞ ⊟ ⊠ ⊡+-- turnstyles: ⊦ ⊧+++subscripts :: [(String, R.YiString)]+subscripts = zip (fmap (('_':). (:[])) "0123456789+-=()")+                 (fmap R.singleton "₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎")
− src/Yi/Config/Users/Jeff.hs
@@ -1,44 +0,0 @@-{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances,-     FunctionalDependencies, GeneralizedNewtypeDeriving,-     MultiParamTypeClasses, TypeSynonymInstances #-}-module Yi.Config.Users.Jeff (myConfig) where--import Control.Applicative-import Control.Lens--import Yi--import Yi.Keymap.Vim-import Yi.Snippets-import Yi.Snippets.Haskell--- import Yi.UI.Pango as Pango--- import Yi.UI.Vty as Vty--myConfig :: Config-myConfig = defaultVimConfig-  { defaultKm = myVimKeymap-  , configUI = (configUI defaultVimConfig)-    { configTheme = defaultTheme-    , configWindowFill = '~'-    }-  , startActions = [makeAction (maxStatusHeightA .= 20 :: EditorM ())]-  -- , startFrontEnd = Pango.start-  }--myVimKeymap = mkKeymap $ defKeymap `override` \super self -> super-  { v_top_level = v_top_level super ||>-      (char ';' ?>>! resetRegexE)--  , v_ins_char  = (v_ins_char super ||> tabKeymap) <|>-      choice [ ctrlCh 's' ?>>! moveToNextBufferMark deleteSnippets-             , meta (spec KLeft)  ?>>! prevWordB-             , meta (spec KRight) ?>>! nextWordB-             ]-  }--deleteSnippets = True--tabKeymap = superTab True $ fromSnippets deleteSnippets $-  [ ("f", hsFunction)-  , ("c", hsClass)-  ]
src/Yi/Config/Users/Michal.hs view
@@ -1,63 +1,66 @@-module Yi.Config.Users.Michal where--import Prelude (String, take, length, repeat, (++),-                fmap, ($), (.),-                IO, Monad(..), (>>))-import Data.List(isPrefixOf, isSuffixOf)-import System.FilePath(takeFileName)-import Yi-import Yi.Keymap.Vim-import qualified Yi.Keymap.Vim2 as V2-import qualified Yi.Keymap.Vim2.Common as V2-import qualified Yi.Keymap.Vim2.Utils as V2+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-} -import qualified Yi.Mode.Haskell as Haskell+-- |+-- Module      :  Yi.Config.Users.Michal+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable --- Used in Theme declaration-import Data.Eq-import Data.Bool-import Data.Function-import Data.Monoid((<>))-import qualified Yi.Style(Color(Default))+module Yi.Config.Users.Michal where --- Used for inserting current date---import System.Time(getTimeOfDay)-import Data.Time.Clock(getCurrentTime)-import System.Locale(defaultTimeLocale)-import Data.Time.Format(formatTime)+import           Data.Bool+import           Data.Eq+import           Data.Function+import           Data.List (isPrefixOf, isSuffixOf)+import           Data.Monoid ((<>))+import qualified Data.Text as T+import           Data.Time.Clock (getCurrentTime)+import           Data.Time.Format (formatTime)+import           Prelude (String, take, length, repeat, fmap, IO, Monad(..), (>>))+import           System.FilePath (takeFileName)+import           System.Locale (defaultTimeLocale)+import           Yi hiding (super)+import qualified Yi.Keymap.Vim as V2+import qualified Yi.Keymap.Vim.Common as V2+import qualified Yi.Keymap.Vim.Utils as V2+import qualified Yi.Rope as R+import qualified Yi.Style (Color(Default)) +myConfig :: Config myConfig = defaultVimConfig {-    modeTable = myModes ++ fmap (onMode prefIndent) (modeTable defaultVimConfig),+    modeTable = myModes <> fmap (onMode prefIndent) (modeTable defaultVimConfig),     defaultKm = myKeymapSet,     configCheckExternalChangesObsessively = False,     configUI = (configUI defaultVimConfig)-     { -       configTheme = myTheme,       +     {+       configTheme = myTheme,        configWindowFill = '~'    -- Typical for Vim      } }  defaultSearchKeymap :: Keymap defaultSearchKeymap = do-    Event (KASCII c) [] <- anyEvent-    write (isearchAddE [c])+  Event (KASCII c) [] <- anyEvent+  write . isearchAddE $ T.singleton c  myKeymapSet :: KeymapSet myKeymapSet = V2.mkKeymapSet $ V2.defVimConfig `override` \super this ->     let eval = V2.pureEval this     in super {           -- Here we can add custom bindings.-          -- See Yi.Keymap.Vim2.Common for datatypes and -          -- Yi.Keymap.Vim2.Utils for useful functions like mkStringBindingE+          -- See Yi.Keymap.Vim.Common for datatypes and+          -- Yi.Keymap.Vim.Utils for useful functions like mkStringBindingE            -- In case of conflict, that is if there exist multiple bindings           -- whose prereq function returns WholeMatch,           -- the first such binding is used.           -- So it's important to have custom bindings first.-          V2.vimBindings = myBindings eval ++ V2.vimBindings super+          V2.vimBindings = myBindings eval <> V2.vimBindings super         } -myBindings :: (String -> EditorM ()) -> [V2.VimBinding]+myBindings :: (V2.EventString -> EditorM ()) -> [V2.VimBinding] myBindings eval =     let nmap  x y = V2.mkStringBindingE V2.Normal V2.Drop (x, y, id)         imap  x y = V2.VimBindingE (\evs state -> case V2.vsMode state of@@ -78,12 +81,12 @@          -- for times when you don't press shift hard enough        , nmap  ";" (eval ":") -       , nmap  "<F3>" (withBuffer0 deleteTrailingSpaceB)-       , nmap  "<F4>" (withBuffer0 moveToSol)-       , nmap  "<F1>" (withBuffer0 readCurrentWordB >>= printMsg)+       , nmap  "<F3>" (withCurrentBuffer deleteTrailingSpaceB)+       , nmap  "<F4>" (withCurrentBuffer moveToSol)+       , nmap  "<F1>" (withCurrentBuffer readCurrentWordB >>= printMsg . R.toText) -       , imap  "<Home>" (withBuffer0 moveToSol)-       , imap  "<End>"  (withBuffer0 moveToEol)+       , imap  "<Home>" (withCurrentBuffer moveToSol)+       , imap  "<End>"  (withCurrentBuffer moveToEol)        , nmap' "<F12>"  insertCurrentDate        ] @@ -94,9 +97,10 @@ defaultColor = Yi.Style.Default  -- This is based on Vim's ':colorscheme murphy', but with gray strings, and more brown on operators.+myTheme :: Proto UIStyle myTheme = defaultTheme `override` \super _ -> super-  { modelineAttributes   = emptyAttributes { foreground = black,   background = darkcyan           }-  , tabBarAttributes     = emptyAttributes { foreground = white,   background = defaultColor            }+  { modelineAttributes   = emptyAttributes { foreground = black,   background = darkcyan }+  , tabBarAttributes     = emptyAttributes { foreground = white,   background = defaultColor }   , baseAttributes       = emptyAttributes { foreground = defaultColor, background = defaultColor, bold=True }   , commentStyle         = withFg darkred <> withBd False <> withItlc True --  , selectedStyle        = withFg black   <> withBg green <> withReverse True@@ -129,6 +133,7 @@             }         } +myModes :: [AnyMode] myModes = [diaryMode]  -- inserting current date and underline@@ -139,18 +144,18 @@   where locale = System.Locale.defaultTimeLocale  makeUnderline :: String -> String-makeUnderline s = s ++ ('\n' : line) ++ "\n"+makeUnderline s = s <> ('\n' : line) <> "\n"   where     line = take (length s) (repeat '=')-      + currentDateAndUnderline :: IO String currentDateAndUnderline =     do d <- currentDate        return $ makeUnderline d  insertCurrentDate :: YiM ()-insertCurrentDate = do d <- withUI (\_ -> currentDateAndUnderline)-                       withBuffer (insertN d)+insertCurrentDate =+  withUI (\_ -> currentDateAndUnderline) >>= withCurrentBuffer . insertN . R.fromString  -- NOTE: use fundamentalMode as a base? diaryMode :: AnyMode
src/Yi/Config/Users/Reiner.hs view
@@ -1,18 +1,33 @@-{-# LANGUAGE NoMonomorphismRestriction, NamedFieldPuns, DoAndIfThenElse #-}+{-# LANGUAGE DoAndIfThenElse #-}+{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Yi.Config.Users.Reiner+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+ module Yi.Config.Users.Reiner (setup, main) where -import Control.Lens-import Yi.Config.Simple+import           Control.Lens+import           Data.Monoid+import qualified Data.Text as T+import           System.Directory+import           System.FilePath+import           Yi.Command(buildRun)+import           Yi.Config.Simple import qualified Yi.Mode.Haskell as Haskell-import Yi.Mode.Latex(latexMode3)-import Yi.Command(buildRun)-import Yi.Utils-import Yi.Monad--import System.Directory-import System.FilePath+import           Yi.Mode.Latex(latexMode3)+import           Yi.Monad+import qualified Yi.Rope as R+import           Yi.Utils  -- | The main entry point, when used as a standalone yi.hs file.+main :: IO () main = configMain defaultEmacsConfig setup  -- | Registers my settings in the 'ConfigM' monad.@@ -26,7 +41,8 @@   publishAction "createDirectory" yiCreateDirectory    addMode Haskell.fastMode-  modeBindKeys Haskell.fastMode (ctrlCh 'c' ?>> ctrlCh 's' ?>>! insertHaskSection)+  modeBindKeys Haskell.fastMode+    (ctrlCh 'c' ?>> ctrlCh 's' ?>>! insertHaskSection)    -- LaTeX stuff   addMode latexMode3@@ -38,19 +54,19 @@ -------------------------------------------------------------------------------- yiCreateDirectory :: YiM () yiCreateDirectory = do-    BufferFileInfo{bufInfoFileName} <- withEditor $ withBuffer0 bufInfoB+    BufferFileInfo{bufInfoFileName} <- withEditor $ withCurrentBuffer bufInfoB     let dir = takeDirectory bufInfoFileName     exists <- io $ doesDirectoryExist dir-    if not exists -    then do-            io $ createDirectoryIfMissing True dir-            withEditor $ printMsg $  "Created directory '" ++ dir ++ "'."+    if not exists+    then do io $ createDirectoryIfMissing True dir+            withEditor $ printMsg $  "Created directory '" <> T.pack dir <> "'."     else withEditor $ printMsg $ "Directory already exists!" +sectionSize :: Int sectionSize = 80  -- inserts the "Actions and bindings" header above-insertHaskSection :: String -> BufferM ()+insertHaskSection :: R.YiString -> BufferM () insertHaskSection s    | lenS >= sectionSize - 6 = do            insertDashes lenS@@ -65,25 +81,29 @@            let nSpaces = sectionSize - 4 - lenS                nSpacesL = nSpaces `div` 2                nSpacesR = nSpaces - nSpacesL-           insertN (replicate nSpacesL ' ')+           insertN $ repChar nSpacesL ' '            insertN s-           insertN (replicate nSpacesR ' ')+           insertN $ repChar nSpacesR ' '            insertN "--"            newlineB            insertDashes sectionSize-  where lenS = Prelude.length s-        insertDashes n = insertN (replicate n '-')-    +  where lenS = R.length s+        insertDashes n = insertN $ repChar n '-'+        repChar n c = R.fromText . T.replicate n $ T.singleton c ++globalBindings :: I Event Yi.Config.Simple.Action () globalBindings = choice-   [ -     ctrlCh '\t' ?>>! nextWinE,-     shift (ctrlCh '\t') ?>>! prevWinE,-     metaCh 'r' ?>>! reload+   [ ctrlCh '\t' ?>>! nextWinE+   , shift (ctrlCh '\t') ?>>! prevWinE+   , metaCh 'r' ?>>! reload    ] +compileLatex :: YiM () compileLatex = do-    mfilename <- withEditor $ withBuffer0 (gets file)-    case mfilename of-        Just filename -> buildRun "pdflatex" ["--file-line-error", "--interaction=nonstopmode", filename] (const $ return ())-        Nothing -> return ()+  withEditor (withCurrentBuffer $ gets file) >>= \case+    Just filename -> buildRun "pdflatex" ["--file-line-error"+                                         , "--interaction=nonstopmode"+                                         , T.pack filename+                                         ] (const $ return ())+    Nothing -> return ()
src/Yi/FuzzyOpen.hs view
@@ -1,45 +1,53 @@--{- This file aims to provide (the essential subset of) the same functionality-   that vim plugins ctrlp and command-t provide.--   Setup:--     Add something like this to your config:--       (ctrlCh 'p' ?>>! fuzzyOpen)--   Usage:--     <C-p> (or whatever mapping user chooses) starts fuzzy open dialog.--     Typing something filters filelist.--     <Enter> opens currently selected file-     in current (the one that fuzzyOpen was initited from) window.--     <C-t> opens currently selected file in a new tab.-     <C-s> opens currently selected file in a split.--     <KUp> and <C-p> moves selection up-     <KDown> and <C-n> moves selection down--     Readline shortcuts <C-a> , <C-e>, <C-u> and <C-k> work as usual.--}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-} -module Yi.FuzzyOpen-    ( fuzzyOpen-    ) where+-- |+-- Module      :  Yi.FuzzyOpen+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+--+-- This file aims to provide (the essential subset of) the same functionality+-- that vim plugins ctrlp and command-t provide.+--+-- Setup:+--+--   Add something like this to your config:+--+--     (ctrlCh 'p' ?>>! fuzzyOpen)+--+-- Usage:+--+--   <C-p> (or whatever mapping user chooses) starts fuzzy open dialog.+--+--   Typing something filters filelist.+--+--   <Enter> opens currently selected file+--   in current (the one that fuzzyOpen was initited from) window.+--+--   <C-t> opens currently selected file in a new tab.+--   <C-s> opens currently selected file in a split.+--+--   <KUp> and <C-p> moves selection up+--   <KDown> and <C-n> moves selection down+--+--   Readline shortcuts <C-a> , <C-e>, <C-u> and <C-k> work as usual. -import Yi-import Yi.MiniBuffer-import Yi.Completion-import Yi.Utils() -- instance MonadBase YiM IO+module Yi.FuzzyOpen (fuzzyOpen) where -import Control.Monad (replicateM, replicateM_, forM, void)-import Control.Monad.Base-import System.Directory (doesDirectoryExist, getDirectoryContents)-import System.FilePath ((</>))-import Data.List (intercalate)+import           Control.Applicative+import           Control.Monad (replicateM, replicateM_, forM, void)+import           Control.Monad.Base+import           Data.Monoid+import qualified Data.Text as T+import           System.Directory (doesDirectoryExist, getDirectoryContents)+import           System.FilePath ((</>))+import           Yi+import           Yi.Completion+import           Yi.MiniBuffer+import qualified Yi.Rope as R+import           Yi.Utils ()  fuzzyOpen :: YiM () fuzzyOpen = do@@ -51,7 +59,7 @@  -- shamelessly stolen from Chapter 9 of Real World Haskell -- takes about 3 seconds to traverse linux kernel, which is not too outrageous--- TODO: check if it works at all with cyclic links +-- TODO: check if it works at all with cyclic links -- TODO: perform in background, limit file count or directory depth getRecursiveContents :: FilePath -> IO [FilePath] getRecursiveContents topdir = do@@ -88,10 +96,10 @@                 ]              <|| (insertChar >>! update)     where update = updateMatchList bufRef fileList-          updatingB bufAction = withBuffer bufAction >> update+          updatingB bufAction = withCurrentBuffer bufAction >> update -showFileList :: [FilePath] -> String-showFileList = intercalate "\n" . map ("  " ++)+showFileList :: [FilePath] -> R.YiString+showFileList = R.fromText . T.intercalate "\n" . map (mappend "  " . T.pack)  {- Implementation detail:    The index of selected file is stored as vertical cursor position.@@ -102,9 +110,9 @@  updateMatchList :: BufferRef -> [FilePath] -> YiM () updateMatchList bufRef fileList = do-    needle <- withBuffer elemsB+    needle <- R.toString <$> withCurrentBuffer elemsB     let filteredFiles = filter (subsequenceMatch needle) fileList-    withEditor $ withGivenBuffer0 bufRef $ do+    withEditor $ withGivenBuffer bufRef $ do         replaceBufferContent $ showFileList filteredFiles         moveTo 0         replaceCharB '*'@@ -121,23 +129,23 @@  openRoutine :: EditorM () -> BufferRef -> YiM () openRoutine preOpenAction bufRef = do-    chosenFile <- fmap (drop 2) $ withEditor $ withGivenBuffer0 bufRef readLnB-    withEditor $ do-        replicateM_ 2 closeBufferAndWindowE-        preOpenAction-    void $ editFile chosenFile+  chosenFile <- withEditor $ withGivenBuffer bufRef readLnB+  withEditor $ do+      replicateM_ 2 closeBufferAndWindowE+      preOpenAction+  void . editFile . drop 2 . R.toString $ chosenFile  insertChar :: Keymap insertChar = textChar >>= write . insertB  moveSelectionUp :: BufferRef -> EditorM ()-moveSelectionUp bufRef = withGivenBuffer0 bufRef $ do+moveSelectionUp bufRef = withGivenBuffer bufRef $ do     replaceCharB ' '     lineUp     replaceCharB '*'  moveSelectionDown :: BufferRef -> EditorM ()-moveSelectionDown bufRef = withGivenBuffer0 bufRef $ do+moveSelectionDown bufRef = withGivenBuffer bufRef $ do     replaceCharB ' '     lineDown     replaceCharB '*'
src/Yi/Style/Misc.hs view
@@ -1,10 +1,20 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Yi.Style.Misc+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+--+-- A couple of themes.+ module Yi.Style.Misc (happyDeluxe,  textExMachina) where  import Data.Monoid---- Have to import global Yi space to get access to Data.Prototype. That should--- be split into a separate package.-import Yi+import Yi.Style+import Yi.Style.Library+import Data.Prototype  -- TextMate themes are available on the TM wiki: -- http://wiki.macromates.com/Themes/UserSubmittedThemes
src/Yi/Templates.hs view
@@ -1,35 +1,38 @@--- | Templates for inserting into documents-module Yi.Templates-  ( templates-  , templateNames-  , lookupTemplate-  , addTemplate-  )-where+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_HADDOCK show-extensions #-} -import qualified Data.Map as Map+-- |+-- Module      :  Yi.Templates+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+--+-- Templates for inserting into documents -import Yi.Buffer (BufferM, insertN)-import Yi.Keymap (YiM)-import Yi.Editor (EditorM, withEditor, withBuffer0, printMsg)-import Yi.MiniBuffer (withMinibuffer)+module Yi.Templates ( templates+                    , templateNames+                    , lookupTemplate+                    , addTemplate+                    ) where +import qualified Data.Map as Map+import           Yi.Buffer (BufferM, insertN)+import           Yi.Editor (EditorM, withCurrentBuffer, printMsg)+import qualified Yi.Rope as R+ type Template       = String type TemplateName   = String type TemplateLookup = Map.Map TemplateName Template --- | Inserting a template from the templates defined in Yi.Templates-insertTemplate :: YiM ()-insertTemplate = withMinibuffer "template-name:" (const $ return templateNames) $ withEditor . addTemplate- addTemplate :: String -> EditorM () addTemplate tName =   case lookupTemplate tName of     Nothing -> printMsg "template-name not found"-    Just t  -> withBuffer0 $ addTemplateBuffer t+    Just t  -> withCurrentBuffer $ addTemplateBuffer t   where   addTemplateBuffer :: Template -> BufferM ()-  addTemplateBuffer t = insertN t+  addTemplateBuffer = insertN . R.fromString  templates :: TemplateLookup templates =@@ -78,7 +81,7 @@               ]     )   , ( "GPL-2"-    , unlines +    , unlines       [ "--"       , "-- This program is free software; you can redistribute it and/or"       , "-- modify it under the terms of the GNU General Public License as"
yi-contrib.cabal view
@@ -1,5 +1,5 @@ name:           yi-contrib-version:        0.8.2+version:        0.10.0 category:       Development, Editor synopsis:       Add-ons to Yi, the Haskell-Scriptable Editor description:@@ -20,13 +20,11 @@   exposed-modules:     Yi.Config.Users.Amy     Yi.Config.Users.Anders-    -- Yi.Config.Users.Cmcq -- needs build-depends: on GTK-    Yi.Config.Users.Corey-    Yi.Config.Users.Ertai+    -- Yi.Config.Users.Corey+    -- Yi.Config.Users.Ertai     Yi.Config.Users.Gwern-    Yi.Config.Users.Jeff+    -- Yi.Config.Users.Jeff     Yi.Config.Users.JP-    --Yi.Config.Users.JP.Experimental     Yi.Config.Users.Michal     Yi.Config.Users.Reiner     Yi.Style.Misc@@ -41,9 +39,13 @@     filepath < 1.4,     split >= 0.1 && < 0.3,     mtl >= 0.1.0.1,-    yi == 0.8.2,+    yi == 0.10.0,     time >= 1.0 && < 2.0,     old-locale >= 1.0 && < 1.2,-    transformers-base+    text,+    transformers-base,+    yi-language >= 0.1.0.3,+    yi-rope,+    oo-prototypes    ghc-options: -Wall