Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgoulter/5b291e7d00945661aa71 to your computer and use it in GitHub Desktop.
Save rgoulter/5b291e7d00945661aa71 to your computer and use it in GitHub Desktop.
Yi Config with Hello World Ex Command
import Yi
import Yi.Keymap.Vim (keymapSet, mkKeymapSet, defVimConfig, vimExCommandParsers)
import qualified Yi.Mode.Haskell as Haskell
import Yi.Style
import Yi.Style.Library
-- For Ex command
import qualified Text.ParserCombinators.Parsec as P
import Yi.Keymap
import Yi.Keymap.Vim.Ex.Types
import qualified Yi.Keymap.Vim.Ex.Commands.Common as Common
defaultVimUiTheme :: Theme
defaultVimUiTheme = defaultTheme `override` \super self -> super {
selectedStyle = modelineFocusStyle self
}
myConfigUI :: UIConfig
myConfigUI = (configUI defaultVimConfig) {
configFontSize = Just 10,
configTheme = defaultVimUiTheme,
configWindowFill = '~'
}
main :: IO ()
main = yi $ defaultVimConfig {
configUI = myConfigUI,
defaultKm = mkKeymapSet $ defVimConfig `override` \ super self -> super
{ vimExCommandParsers = myExCmdParsers ++ vimExCommandParsers super }
}
-- A custom macro
helloWorld :: YiM ()
helloWorld = withBuffer $ insertN "Hello, world!"
-- helloWorld Ex Command
parse :: String -> Maybe ExCommand
parse = Common.parse $ do
P.string "helloWorld"
return $! Common.impureExCommand {
cmdAction = YiA $ helloWorld
, cmdShow = "helloWorld"
}
myExCmdParsers = [parse]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment