From 1e1b39599d61f1abda14585bb25b27ddcc236564 Mon Sep 17 00:00:00 2001 From: Jeffrey Tratner Date: Thu, 27 Sep 2012 11:53:45 -0400 Subject: [PATCH 1/3] Vim: use 'xiki directory' if env var undefined --- etc/vim/xiki.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/vim/xiki.vim b/etc/vim/xiki.vim index 5bfd61d3..991b335e 100644 --- a/etc/vim/xiki.vim +++ b/etc/vim/xiki.vim @@ -1,6 +1,6 @@ function! XikiLaunch() ruby << EOF - xiki_dir = ENV['XIKI_DIR'] + xiki_dir = ENV['XIKI_DIR'] || `xiki directory`.strip! unless defined? xiki_dir ['ol', 'vim/line', 'vim/tree'].each {|o| require "#{xiki_dir}/lib/xiki/#{o}"} line = Line.value indent = line[/^ +/] From 49e1278de3bc3472ccf75dc4cc21630c49a548dd Mon Sep 17 00:00:00 2001 From: Jeffrey Tratner Date: Thu, 27 Sep 2012 11:55:18 -0400 Subject: [PATCH 2/3] Vim: wrap mappings in option + only load once --- etc/vim/xiki.vim | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/etc/vim/xiki.vim b/etc/vim/xiki.vim index 991b335e..63167333 100644 --- a/etc/vim/xiki.vim +++ b/etc/vim/xiki.vim @@ -1,3 +1,22 @@ +" 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 directory`.strip! unless defined? xiki_dir @@ -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 From c420b4f056a43d33114ba16136fd0a92d20221da Mon Sep 17 00:00:00 2001 From: Jeffrey Tratner Date: Sat, 17 Nov 2012 15:22:04 -0500 Subject: [PATCH 3/3] edit to use @keithtom's more succinct version --- etc/vim/xiki.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/vim/xiki.vim b/etc/vim/xiki.vim index 63167333..47a20a46 100644 --- a/etc/vim/xiki.vim +++ b/etc/vim/xiki.vim @@ -19,7 +19,7 @@ endif function! XikiLaunch() ruby << EOF - xiki_dir = ENV['XIKI_DIR'] || `xiki directory`.strip! unless defined? 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[/^ +/]