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
module HelloWorld (helloWorld, parse) where
import Yi
-- 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
-- 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"
}
import Yi
import Yi.Keymap.Vim (keymapSet, mkKeymapSet, defVimConfig, vimExCommandParsers)
import qualified Yi.Mode.Haskell as Haskell
import Yi.Style
import Yi.Style.Library
import qualified HelloWorld as HelloWorld
main :: IO ()
main = yi $ defaultVimConfig
{ defaultKm = mkKeymapSet $ defVimConfig `override` \ super self -> super
{ vimExCommandParsers = myExCmdParsers ++ vimExCommandParsers super }
}
myExCmdParsers = [HelloWorld.parse]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment