-- | -- Author : jeremy@marzhillstudios.com -- Parts of this config were stolen from/inspired by -- yi/yi-contrib/src/Yi/Config/Michal.hs. import Yi import qualified Yi.Keymap.Vim as Vim import qualified Yi.Keymap.Vim.Common as Vim import qualified Yi.Keymap.Vim.Utils as Vim import Yi.Keymap.Keys import Yi.Modes import Yi.Style import Yi.Style.Library import Yi.Config.Default (availableFrontends) import Yi.Config.Misc import Data.Monoid -- TODO(jwall): : navigation -- TODO(jwall): handle file updates: checktime functionality -- TODO(jwall): Visual Mode is broken? -- default color specifications fgColor = brightwhite bgColor = black bgSelectedColor = lightGrey builtinColor = magenta commentColor = darkcyan typeColor = darkgreen keywordColor = yellow quoteColor = magenta -- extended vim keymap myKeymap :: KeymapSet myKeymap = Vim.mkKeymapSet $ Vim.defVimConfig `override` \super self -> let eval = Vim.pureEval self in super { -- put our custom bindings first so they override default bindings Vim.vimBindings = myBindings eval <> Vim.vimBindings super } -- custom keybindings myBindings :: (Vim.EventString -> EditorM ()) -> [Vim.VimBinding] myBindings eval = let nmap x y = Vim.mkStringBindingE Vim.Normal Vim.Drop (x, y, id) imap x y = Vim.VimBindingE (\evs state -> case Vim.vsMode state of Vim.Insert _ -> fmap (const (y >> return Vim.Continue)) (evs `Vim.matchesString` x) _ -> Vim.NoMatch) nmap' x y = Vim.mkStringBindingY Vim.Normal (x, y, id) in [ -- custom bindings here ] -- GUI enhanced colors guiBgColor = RGB 20 20 20 defaultVimTermTheme :: Theme defaultVimTermTheme = defaultTheme `override` \super self -> super { modelineAttributes = emptyAttributes {foreground = white, background = grey}, modelineFocusStyle = withBg grey `mappend` withFg fgColor, baseAttributes = emptyAttributes { foreground = fgColor, background = bgColor}, builtinStyle = withFg builtinColor, commentStyle = withFg commentColor, typeStyle = withFg typeColor, importStyle = withFg keywordColor, selectedStyle = withBg bgSelectedColor, stringStyle = withFg quoteColor, keywordStyle = withFg green } defaultVimGuiTheme :: Theme defaultVimGuiTheme = defaultVimTermTheme `override` \super self -> super { baseAttributes = emptyAttributes { foreground = fgColor, background = guiBgColor} } -- global indent preferences prefIndent :: Mode s -> Mode s prefIndent m = m { modeIndentSettings = IndentSettings { expandTabs = True , shiftWidth = 2 , tabSize = 2 } } myDefaultUI = configUI defaultVimConfig myConfigDefaultUI :: UIConfig myConfigDefaultUI = myDefaultUI { configFontSize = Just 9 , configTheme = defaultVimGuiTheme , configWindowFill = '~' } myConfigTermUI :: UIConfig -- reuse the above defaults here myConfigTermUI = myConfigDefaultUI { configTheme = defaultVimTermTheme } myDefaultConfig = defaultVimConfig { configUI = myConfigDefaultUI , defaultKm = myKeymap , modeTable = fmap (onMode prefIndent) (modeTable defaultVimConfig) } myConfig = case availableFrontends of (("vty", f):_) -> myDefaultConfig { configUI = myConfigTermUI } ((_, f):_) -> myDefaultConfig main :: IO () main = yi myConfig