diff --git a/etc/vim/xiki.vim b/etc/vim/xiki.vim index 5bfd61d3..47a20a46 100644 --- a/etc/vim/xiki.vim +++ b/etc/vim/xiki.vim @@ -1,6 +1,25 @@ +" Xiki with vim +" +" Requires: +" Need to set XIKI_DIR in your environment to use +" +" Configuration options: +" g:XikiUseDefaultMapping - set to 0 to disable the default XikiMappings +" +" Commands: +" XikiLaunch --> runs the given line, pipes it to xiki at the command line and +" then puts the result in the window. + +" Only load this once (no need to reload otherwise) +" (be sure to comment these next three lines out if you're +" changing the plugin) +if exists('g:XikiLoaded') + finish +endif + function! XikiLaunch() ruby << EOF - xiki_dir = ENV['XIKI_DIR'] + xiki_dir ||= ENV['XIKI_DIR'] || `xiki directory`.strip! ['ol', 'vim/line', 'vim/tree'].each {|o| require "#{xiki_dir}/lib/xiki/#{o}"} line = Line.value indent = line[/^ +/] @@ -10,7 +29,13 @@ function! XikiLaunch() EOF endfunction -nmap <2-LeftMouse> :call XikiLaunch() -imap <2-LeftMouse> :call XikiLaunch()i -imap :call XikiLaunch()i -nmap :call XikiLaunch() +" Don't set mappings if user sets g:XikiUseDefaultMapping to 0 +if !exists('g:XikiUseDefaultMapping') || g:XikiUseDefaultMapping + nmap <2-LeftMouse> :call XikiLaunch() + imap <2-LeftMouse> :call XikiLaunch()i + imap :call XikiLaunch()i + nmap :call XikiLaunch() +endif + +command! XikiLaunch call XikiLaunch() +let g:XikiLoaded = 1