yi-contrib 0.7.2 → 0.8.0
raw patch · 11 files changed
+271/−57 lines, 11 filesdep +lensdep +old-localedep +timedep −data-accessordep ~yi
Dependencies added: lens, old-locale, time, transformers-base
Dependencies removed: data-accessor
Dependency ranges changed: yi
Files
- src/Yi/Config/Users/Amy.hs +48/−0
- src/Yi/Config/Users/Anders.hs +3/−2
- src/Yi/Config/Users/Corey.hs +2/−4
- src/Yi/Config/Users/Ertai.hs +9/−7
- src/Yi/Config/Users/Gwern.hs +4/−3
- src/Yi/Config/Users/JP.hs +11/−16
- src/Yi/Config/Users/Jeff.hs +3/−3
- src/Yi/Config/Users/Michal.hs +164/−0
- src/Yi/Config/Users/Reiner.hs +5/−5
- src/Yi/FuzzyOpen.hs +9/−12
- yi-contrib.cabal +13/−5
+ src/Yi/Config/Users/Amy.hs view
@@ -0,0 +1,48 @@+module Yi.Config.Users.Amy where++import Yi++import Prelude++-- 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 = defaultCuaConfig {+ -- Keymap Configuration+ defaultKm = extendedCuaKeymapSet,++ -- UI Configuration+ -- Override the default UI as such:+ startFrontEnd = startFrontEnd myConfig,+ -- Yi.UI.Vty.start -- for Vty+ -- (can be overridden at the command line)+ -- Options:+ configUI = defaultUIConfig+ {+ configFontSize = Nothing,+ -- 'Just 10' for specifying the size.+ configTheme = configTheme defaultUIConfig,+ -- darkBlueTheme -- Change the color scheme here.++ configWindowFill = ' '+ }+ }++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 = customizedCuaKeymapSet $+ choice [+ metaCh 'x' ?>>! helloWorld+ ]++-- A custom macro+helloWorld :: YiM ()+helloWorld = withBuffer $ insertN "Hello, world!"+
src/Yi/Config/Users/Anders.hs view
@@ -1,6 +1,7 @@ module Yi.Config.Users.Anders (config) where -import Yi hiding (Block, (.))+import Control.Lens+import Yi hiding (Block) import qualified Yi.Mode.Haskell as H import Yi.Hoogle (hoogle) import Yi.String (mapLines)@@ -34,7 +35,7 @@ haskellModeHooks 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
src/Yi/Config/Users/Corey.hs view
@@ -5,9 +5,6 @@ - The insert mode of the Vim keymap has been extended with a few additions I find useful. -}-import Yi.Prelude-import Prelude ()- import Yi import Yi.Keymap.Vim import Yi.Buffer.Indent (indentAsPreviousB)@@ -17,8 +14,9 @@ -- import qualified Yi.UI.Vty import Yi.Style.Library (darkBlueTheme)-import Data.List (isPrefixOf, reverse, replicate)+import Data.List (isPrefixOf) import Control.Monad (replicateM_)+import Control.Applicative -- Set soft tabs of 4 spaces in width. prefIndent :: Mode s -> Mode s
src/Yi/Config/Users/Ertai.hs view
@@ -7,19 +7,20 @@ import qualified Yi.Syntax.Haskell as Haskell import qualified Yi.Lexer.Haskell as Haskell import qualified Yi.Syntax.Strokes.Haskell as Haskell-import Yi.Prelude-import Prelude (map)-import System.Environment-import Data.List (isPrefixOf, reverse, length)+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 @@ -38,6 +39,7 @@ AnyMode . haskellModeHooks . removeAnnots $ Haskell.fastMode ] +type Endom a = a -> a haskellModeHooks :: (Foldable f) => Endom (Mode (f Haskell.TT)) haskellModeHooks mode =@@ -50,7 +52,7 @@ -- modeGetStrokes = \_ _ _ _ -> [], modeName = "my " ++ modeName mode, -- example of Mode-local rebinding- modeKeymap = topKeymapA ^:+ modeKeymap = topKeymapA %~ ((char '\\' ?>> choice [char 'l' ?>>! Haskell.ghciLoadBuffer, char 'z' ?>>! Haskell.ghciGet, char 'h' ?>>! hoogle,@@ -71,7 +73,7 @@ config :: Config config = defaultVimConfig { modeTable = fmap (onMode prefIndent) (myModetable ++ modeTable defaultVimConfig) , defaultKm = Vim.mkKeymap extendedVimKeymap- , startActions = startActions defaultVimConfig ++ [makeAction (maxStatusHeightA %= 10 :: EditorM ())]+ , startActions = startActions defaultVimConfig ++ [makeAction (maxStatusHeightA .= 10 :: EditorM ())] } -- Set soft tabs of 4 spaces in width.@@ -97,7 +99,7 @@ { v_top_level = (deprioritize >> v_top_level super) <|> (char ',' ?>>! viWrite) <|> ((events $ map char "\\u") >>! unicodifySymbols)- <|> ((events $ map char "\\c") >>! withModeB modeToggleCommentSelection)+ <|> ((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
src/Yi/Config/Users/Gwern.hs view
@@ -1,8 +1,9 @@ module Yi.Config.Users.Gwern (config) where +import Control.Lens import Yi import Yi.Hoogle (hoogle)-import Yi.Keymap.Emacs (defKeymap, eKeymap, mkKeymap)+import Yi.Keymap.Emacs (defKeymap, _eKeymap, mkKeymap) import qualified Yi.Mode.Haskell as H import qualified Yi.Mode.IReader as IReader (ireaderMode) @@ -17,7 +18,7 @@ -- bestHaskellMode :: Mode (Tree (Tok Token)) bestHaskellMode = -- Shim.minorMode $ H.cleverMode { modeKeymap =- topKeymapA ^: ((ctrlCh 'c' ?>> choice [ctrlCh 'l' ?>>! H.ghciLoadBuffer,+ topKeymapA %~ ((ctrlCh 'c' ?>> choice [ctrlCh 'l' ?>>! H.ghciLoadBuffer, ctrl (char 'z') ?>>! H.ghciGet, ctrl (char 'h') ?>>! hoogle, ctrlCh 'r' ?>>! H.ghciSend ":r",@@ -26,7 +27,7 @@ myKeymap :: KeymapSet myKeymap = mkKeymap $ override Yi.Keymap.Emacs.defKeymap $ \proto _self ->- proto { eKeymap = eKeymap proto ||>+ proto { _eKeymap = _eKeymap proto ||> -- Add a M-g binding for goto-line (metaCh 'g' ?>>! gotoLn) -- Use a more clever binding for Home
src/Yi/Config/Users/JP.hs view
@@ -10,16 +10,16 @@ -- If configured with ghcAPI, Shim Mode can be enabled: -- import qualified Yi.Mode.Shim as Shim -import Data.List (drop, length)+import Control.Applicative+import Control.Lens+import Data.Traversable (sequenceA)+import Data.Foldable (Foldable,find) import Data.Monoid-import Prelude () import Yi.Char.Unicode import Yi.Hoogle-import Yi.Keymap.Keys import Yi.Lexer.Alex (tokToSpan, Tok) import Yi.Lexer.Haskell as Hask import Yi.Mode.Haskell as Haskell-import Yi.Prelude import Yi.String import Yi.Syntax import Yi.Syntax.Tree@@ -65,7 +65,7 @@ -- modeGetStrokes = \_ _ _ _ -> [], modeName = "my " ++ modeName mode, -- example of Mode-local rebinding- modeKeymap = topKeymapA ^: ((ctrlCh 'c' ?>> choice [ctrlCh 'l' ?>>! ghciLoadBuffer,+ modeKeymap = topKeymapA %~ ((ctrlCh 'c' ?>> choice [ctrlCh 'l' ?>>! ghciLoadBuffer, ctrl (char 'z') ?>>! ghciGet, ctrl (char 'h') ?>>! hoogle, ctrlCh 'r' ?>>! ghciSend ":r",@@ -88,12 +88,7 @@ tta = sequenceA . tokToSpan . (fmap Yi.Config.Users.JP.tokenToText) frontend :: UIBoot-frontendName :: String-Just (frontendName, frontend) = foldr1 (<|>) $ fmap (\nm -> find ((nm ==) . fst) availableFrontends) ["cocoa", "vty"] --isCocoa :: Bool-isCocoa = frontendName == "cocoa"-+Just (_, frontend) = foldr1 (<|>) $ fmap (\nm -> find ((nm ==) . fst) availableFrontends) ["vty"] defaultConfig :: Config defaultConfig = defaultEmacsConfig@@ -111,10 +106,10 @@ myKeymap :: KeymapSet myKeymap = mkKeymap $ override defKeymap $ \proto _self -> proto {- completionCaseSensitive = True,- eKeymap = (adjustPriority (-1) >> choice [extraInput]) <|| (fixKeymap <|| eKeymap proto)- <|> (ctrl (char '>') ?>>! increaseIndent)- <|> (ctrl (char '<') ?>>! decreaseIndent)+ _completionCaseSensitive = True,+ _eKeymap = (adjustPriority (-1) >> choice [extraInput]) <|| (fixKeymap <|| _eKeymap proto)+ <|> (ctrl (char '>') ?>>! increaseIndent)+ <|> (ctrl (char '<') ?>>! decreaseIndent) } config :: Config@@ -127,7 +122,7 @@ : AnyMode (haskellModeHooks Haskell.literateMode) : modeTable defaultConfig, configUI = (configUI defaultConfig) - { configFontSize = if isCocoa then Just 12 else Just 10+ { configFontSize = Just 10 -- , configTheme = darkBlueTheme , configTheme = defaultTheme `override` \superTheme _ -> superTheme {
src/Yi/Config/Users/Jeff.hs view
@@ -3,8 +3,8 @@ MultiParamTypeClasses, TypeSynonymInstances #-} module Yi.Config.Users.Jeff (myConfig) where -import Yi.Prelude-import Prelude ()+import Control.Applicative+import Control.Lens import Yi @@ -21,7 +21,7 @@ { configTheme = defaultTheme , configWindowFill = '~' }- , startActions = [makeAction (maxStatusHeightA %= 20 :: EditorM ())]+ , startActions = [makeAction (maxStatusHeightA .= 20 :: EditorM ())] -- , startFrontEnd = Pango.start }
+ src/Yi/Config/Users/Michal.hs view
@@ -0,0 +1,164 @@+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++import qualified Yi.Mode.Haskell as Haskell++-- Used in Theme declaration+import Data.Eq+import Data.Bool+import Data.Function+import Data.Monoid((<>))+import qualified Yi.Style(Color(Default))++-- Used for inserting current date+--import System.Time(getTimeOfDay)+import Data.Time.Clock(getCurrentTime)+import System.Locale(defaultTimeLocale)+import Data.Time.Format(formatTime)++myConfig = defaultVimConfig {+ modeTable = myModes ++ fmap (onMode prefIndent) (modeTable defaultVimConfig),+ defaultKm = myKeymapSet,+ configCheckExternalChangesObsessively = False,+ configUI = (configUI defaultVimConfig)+ { + configTheme = myTheme, + configWindowFill = '~' -- Typical for Vim+ }+}++defaultSearchKeymap :: Keymap+defaultSearchKeymap = do+ Event (KASCII c) [] <- anyEvent+ write (isearchAddE [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++ -- 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+ }++myBindings :: (String -> 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+ V2.Insert _ ->+ fmap (const (y >> return V2.Continue))+ (evs `V2.matchesString` x)+ _ -> V2.NoMatch)+ nmap' x y = V2.mkStringBindingY V2.Normal (x, y, id)+ in [+ -- Tab traversal+ nmap "<C-h>" previousTabE+ , nmap "<C-l>" nextTabE+ , nmap "<C-l>" nextTabE++ -- Press space to clear incremental search highlight+ , nmap " " (eval ":nohlsearch<CR>")++ -- 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)++ , imap "<Home>" (withBuffer0 moveToSol)+ , imap "<End>" (withBuffer0 moveToEol)+ , nmap' "<F12>" insertCurrentDate+ ]++-- | I declare "proper black" in GTK, since Vty terminal seems to have grayish black in 16-color system.+-- Fortunately default _background_ color is available through Default :: Yi.Style.Color.+-- Note that this works only in background! (Default foreground color is green.)+defaultColor :: Yi.Style.Color+defaultColor = Yi.Style.Default++-- This is based on Vim's ':colorscheme murphy', but with gray strings, and more brown on operators.+myTheme = defaultTheme `override` \super _ -> super+ { 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+ , selectedStyle = withReverse True+ , errorStyle = withBg red <> withFg white+ , operatorStyle = withFg brown <> withBd False+ , hintStyle = withBg brown <> withFg black+ , importStyle = withFg blue+ , dataConstructorStyle = withFg blue+ , typeStyle = withFg blue+ , keywordStyle = withFg yellow+ , builtinStyle = withFg brown+ , strongHintStyle = withBg brown <> withUnderline True+ , stringStyle = withFg brown <> withBd False+ , preprocessorStyle = withFg blue+-- , constantStyle = withFg cyan+-- , specialStyle = withFg yellow+ }++-- Softtabs of 2 characters for Berkeley coding style, if not editing makefile.+prefIndent :: Mode syntax -> Mode syntax+prefIndent m = if modeName m == "Makefile"+ then m+ else m {+ modeIndentSettings = IndentSettings+ {+ expandTabs = True,+ shiftWidth = 2,+ tabSize = 2+ }+ }++myModes = [diaryMode]++-- inserting current date and underline+currentDate :: IO String+currentDate =+ do tim <- Data.Time.Clock.getCurrentTime+ return $ formatTime locale "%A %b %e %Y" tim+ where locale = System.Locale.defaultTimeLocale++makeUnderline :: String -> String+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)++-- NOTE: use fundamentalMode as a base?+diaryMode :: AnyMode+diaryMode = AnyMode $ (\super -> super { modeApplies = \path _contents -> let name = takeFileName path+ in ".txt" `isSuffixOf` name &&+ "diary" `isPrefixOf` name,+ modeName = "Diary",+ modeOnLoad = do modeOnLoad super+ r:_ <- regexB Forward $ makeSimpleSearch "*** TODAY ***"+ moveTo . regionStart $ r+ }) $ emptyMode
src/Yi/Config/Users/Reiner.hs view
@@ -1,13 +1,13 @@ {-# LANGUAGE NoMonomorphismRestriction, NamedFieldPuns, DoAndIfThenElse #-} module Yi.Config.Users.Reiner (setup, main) where +import Control.Lens import Yi.Config.Simple-import Yi.Prelude hiding ((%=))-import qualified Prelude- 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@@ -19,10 +19,10 @@ setup :: ConfigM () setup = do setFrontendPreferences ["pango", "vte", "vty"]- fontSize %= Just 9+ fontSize .= Just 9 globalBindKeys globalBindings- evaluator %= publishedActionsEvaluator+ evaluator .= publishedActionsEvaluator publishAction "createDirectory" yiCreateDirectory addMode Haskell.fastMode
src/Yi/FuzzyOpen.hs view
@@ -30,26 +30,24 @@ ( fuzzyOpen ) where -import Prelude () import Yi import Yi.MiniBuffer import Yi.Completion+import Yi.Utils() -- instance MonadBase YiM IO -import Control.Monad (replicateM, replicateM_)-import Control.Monad.Trans (liftIO)+import Control.Monad (replicateM, replicateM_, forM, void)+import Control.Monad.Base import System.Directory (doesDirectoryExist, getDirectoryContents)-import System.FilePath (FilePath, (</>))-import Data.List (filter, map, intersperse, drop)-import Data.Maybe (isJust)+import System.FilePath ((</>))+import Data.List (intercalate) fuzzyOpen :: YiM () fuzzyOpen = do withEditor splitE bufRef <- withEditor newTempBufferE- fileList <- liftIO $ getRecursiveContents "."+ fileList <- liftBase $ getRecursiveContents "." updateMatchList bufRef fileList- withEditor $ spawnMinibufferE "" $ const $ localKeymap bufRef fileList- return ()+ void $ withEditor $ spawnMinibufferE "" $ const $ localKeymap bufRef fileList -- shamelessly stolen from Chapter 9 of Real World Haskell -- takes about 3 seconds to traverse linux kernel, which is not too outrageous@@ -91,10 +89,9 @@ <|| (insertChar >>! update) where update = updateMatchList bufRef fileList updatingB bufAction = withBuffer bufAction >> update- updatingE editorAction = withEditor editorAction >> update showFileList :: [FilePath] -> String-showFileList = concat . intersperse "\n" . map (" " ++)+showFileList = intercalate "\n" . map (" " ++) {- Implementation detail: The index of selected file is stored as vertical cursor position.@@ -128,7 +125,7 @@ withEditor $ do replicateM_ 2 closeBufferAndWindowE preOpenAction- discard $ editFile chosenFile+ void $ editFile chosenFile insertChar :: Keymap insertChar = textChar >>= write . insertB
yi-contrib.cabal view
@@ -1,5 +1,5 @@ name: yi-contrib-version: 0.7.2+version: 0.8.0 category: Development, Editor synopsis: Add-ons to Yi, the Haskell-Scriptable Editor description:@@ -12,19 +12,22 @@ homepage: http://haskell.org/haskellwiki/Yi bug-reports: http://code.google.com/p/yi-editor/issues/list Cabal-Version: >= 1.6-tested-with: GHC==7.4.2+tested-with: GHC==7.6.3 build-type: Simple library hs-source-dirs: src exposed-modules:+ Yi.Config.Users.Amy Yi.Config.Users.Anders- -- Yi.Config.Users.Cmcq+ -- Yi.Config.Users.Cmcq -- needs build-depends: on GTK Yi.Config.Users.Corey Yi.Config.Users.Ertai Yi.Config.Users.Gwern Yi.Config.Users.Jeff Yi.Config.Users.JP+ --Yi.Config.Users.JP.Experimental+ Yi.Config.Users.Michal Yi.Config.Users.Reiner Yi.Style.Misc Yi.Templates@@ -33,9 +36,14 @@ build-depends: base >=4.0 && <5, containers,- data-accessor >= 0.2.1.4 && < 0.3,+ lens >= 3.9, directory < 1.3, filepath < 1.4, split >= 0.1 && < 0.3, mtl >= 0.1.0.1,- yi == 0.7.2+ yi == 0.8.0,+ time >= 1.0 && < 2.0,+ old-locale >= 1.0 && < 1.2,+ transformers-base++ ghc-options: -Wall