From b25d25308b75653311165382d3a243c842637229 Mon Sep 17 00:00:00 2001 From: arrow_zhang Date: Tue, 19 Aug 2008 23:31:34 -0700 Subject: [PATCH] [ADD] add .vim conf, replace old _vim, some xinitrc change, will use xsession later. --- conf_slk120/bash/.bashrc | 40 +- conf_slk120/bin/.bin/shell/arrow-forward | 4 + conf_slk120/bin/.bin/shell/arrow-qos | 10 + conf_slk120/bin/.bin/shell/arrow-x | 10 + conf_slk120/bin/.bin/shell/arrow-xinit | 22 +- conf_slk120/bin/.bin/shell/arxvt | 2 + conf_slk120/bin/.bin/shell/athome-simple | 7 + conf_slk120/bin/.bin/shell/ge | 3 +- conf_slk120/env/.Xdefaults | 32 +- conf_slk120/fvwm/init_env | 3 +- conf_slk120/fvwm/styles | 2 +- conf_slk120/fvwm/themes-rc | 126 + conf_slk120/fvwm/themes-rc-2 | 1 + conf_slk120/fvwm/themes/current | 1 + conf_slk120/fvwm/themes/current-main/themes-rc-2 | 0 conf_slk120/vim/.vim | 1 + conf_slk120/vim/.vimrc | 129 + conf_slk120/vim/_vim/.VimballRecord | 2 + conf_slk120/vim/_vim/autoload/tlib/Object.vim | 159 + conf_slk120/vim/_vim/autoload/tlib/Test.vim | 27 + conf_slk120/vim/_vim/autoload/tlib/TestChild.vim | 27 + conf_slk120/vim/_vim/autoload/tlib/World.vim | 694 +++++ conf_slk120/vim/_vim/autoload/tlib/agent.vim | 462 +++ conf_slk120/vim/_vim/autoload/tlib/arg.vim | 102 + conf_slk120/vim/_vim/autoload/tlib/buffer.vim | 278 ++ conf_slk120/vim/_vim/autoload/tlib/cache.vim | 70 + conf_slk120/vim/_vim/autoload/tlib/char.vim | 58 + conf_slk120/vim/_vim/autoload/viki.vim | 2432 +++++++++++++++ .../vikiAnyWord.vim => autoload/viki_anyword.vim} | 35 +- conf_slk120/vim/_vim/autoload/viki_latex.vim | 125 + conf_slk120/vim/_vim/autoload/viki_viki.vim | 590 ++++ conf_slk120/vim/_vim/compiler/deplate.vim | 6 +- conf_slk120/vim/_vim/doc/tags | 25 +- conf_slk120/vim/_vim/doc/tlib.txt | 1434 +++++++++ conf_slk120/vim/_vim/doc/viki.txt | 312 +- conf_slk120/vim/_vim/etc/Viki.lst | 10 - conf_slk120/vim/_vim/files/txt.skel | 5 +- conf_slk120/vim/_vim/ftplugin/bib/viki.vim | 6 +- conf_slk120/vim/_vim/ftplugin/viki.vim | 559 +++- conf_slk120/vim/_vim/indent/viki.vim | 172 +- conf_slk120/vim/_vim/plugin/02tlib.vim | 451 +++ conf_slk120/vim/_vim/plugin/viki.vim | 3228 ++++++-------------- conf_slk120/vim/_vim/plugin/vikiLatex.vim | 127 - conf_slk120/vim/_vim/syntax/texmath.vim | 62 + conf_slk120/vim/_vim/syntax/viki.vim | 159 +- conf_slk120/vim/_vim/syntax/wiki.vim | 77 + conf_slk120/vim/_vim/test/tlib.vim | 213 ++ conf_slk120/vim/_vimrc | 8 +- conf_slk120/xinit/.xinitrc | 27 +- 49 files changed, 9457 insertions(+), 2878 deletions(-) create mode 100755 conf_slk120/bin/.bin/shell/arrow-forward create mode 100755 conf_slk120/bin/.bin/shell/arrow-qos create mode 100755 conf_slk120/bin/.bin/shell/arrow-x create mode 100755 conf_slk120/bin/.bin/shell/arxvt create mode 100755 conf_slk120/bin/.bin/shell/athome-simple create mode 100644 conf_slk120/fvwm/themes-rc create mode 120000 conf_slk120/fvwm/themes-rc-2 create mode 120000 conf_slk120/fvwm/themes/current create mode 100644 conf_slk120/fvwm/themes/current-main/themes-rc-2 create mode 160000 conf_slk120/vim/.vim create mode 100644 conf_slk120/vim/.vimrc create mode 100644 conf_slk120/vim/_vim/.VimballRecord create mode 100644 conf_slk120/vim/_vim/autoload/tlib/Object.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/Test.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/TestChild.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/World.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/agent.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/arg.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/buffer.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/cache.vim create mode 100644 conf_slk120/vim/_vim/autoload/tlib/char.vim create mode 100644 conf_slk120/vim/_vim/autoload/viki.vim rename conf_slk120/vim/_vim/{plugin/vikiAnyWord.vim => autoload/viki_anyword.vim} (78%) mode change 100755 => 100644 create mode 100644 conf_slk120/vim/_vim/autoload/viki_latex.vim create mode 100644 conf_slk120/vim/_vim/autoload/viki_viki.vim create mode 100644 conf_slk120/vim/_vim/doc/tlib.txt mode change 100755 => 100644 conf_slk120/vim/_vim/doc/viki.txt delete mode 100755 conf_slk120/vim/_vim/etc/Viki.lst mode change 100755 => 100644 conf_slk120/vim/_vim/ftplugin/bib/viki.vim rewrite conf_slk120/vim/_vim/ftplugin/viki.vim (61%) mode change 100755 => 100644 rewrite conf_slk120/vim/_vim/indent/viki.vim (87%) mode change 100755 => 100644 create mode 100644 conf_slk120/vim/_vim/plugin/02tlib.vim rewrite conf_slk120/vim/_vim/plugin/viki.vim (77%) mode change 100755 => 100644 delete mode 100755 conf_slk120/vim/_vim/plugin/vikiLatex.vim create mode 100644 conf_slk120/vim/_vim/syntax/texmath.vim mode change 100755 => 100644 conf_slk120/vim/_vim/syntax/viki.vim create mode 100644 conf_slk120/vim/_vim/syntax/wiki.vim create mode 100644 conf_slk120/vim/_vim/test/tlib.vim diff --git a/conf_slk120/bash/.bashrc b/conf_slk120/bash/.bashrc index 5b5f0c8..5ca4e79 100644 --- a/conf_slk120/bash/.bashrc +++ b/conf_slk120/bash/.bashrc @@ -24,6 +24,7 @@ alias pac="sudo pacman -S" alias pacs="pacsearch" alias pacd="sudo pacman -Rs" alias pacdf="sudo pacman -Rsn" +alias paci="pacman -Si" #pacsearch() { # echo -e "$(pacman -Ss "$@" | sed \ # -e 's#core/.*#\\033[1;31m&\\033[0;37m#g' \ @@ -45,6 +46,7 @@ pacsearch() { #alias notes="export LANG=zh_CN.UTF-8;export LANGUAGE=zh_CN.UTF-8;LC_ALL=zh_CN.UTF-8;wine /home/arrow/.wine/drive_c/Lotus/Notes/notes.exe" #alias notes="export LANG=zh_CN.GB2312;export LANGUAGE=zh_CN.GB2312;LC_ALL=zh_CN.GB2312;wine /home/arrow/.wine/drive_c/Lotus/Notes/notes.exe" alias notes="wine /home/arrow/.wine/drive_c/Lotus/Notes/notes.exe" +alias stock="wine /home/arrow/.wine/drive_c/new_zxzq_test/TdxW.exe" alias x="startx & sleep 2 && exit" alias e8test="export LANG=zh_CN.GB2312;export LANGUAGE=zh_CN.GB2312;LC_ALL=zh_CN.GB2312;wine /home/arrow/.wine/drive_c/e8test/e8test.exe" alias qq="sudo /home/arrow/.bin/pro/qq/lumaqq" @@ -65,30 +67,10 @@ alias cp="cp -i" alias e="emacsclient" alias ssh="/usr/bin/ssh -X" -OLDPATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/java/bin:/usr/lib/java/jre/bin:/usr/lib/qt/bin:/usr/share/texmf/bin: -export ARROWPATH="$USER" -export PATH=${HOME}/.bin/shell:$OLDPATH -# export PATH=$PATH:/usr/local/gcc/bin -#export PATH=$PATH:/work/catv/CN3XXX-SDK/tools/bin:/work/catv/CN3XXX-SDK/host/bin -export PATH=$PATH:/usr/local/bin:/usr/local/sbin -export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin -export PATH=$PATH:/opt/mv_tools/bin -export PATH=${PATH}:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin: -# wnr834b -PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin -PATH=$PATH:/opt/hardhat/devkit/mips/fp_le/bin:/opt/mipsel-linux-uclibc/bin -PATH=$PATH:/usr/X11R6/bin -PATH=$PATH:/sbin:/usr/sbin -PATH=$PATH:/usr/local/sbin -PATH=$PATH:/opt/BRECIS/i686-pc-linux-gnu-x-mipsisa32-elf-newlib/bin -PATH=$PATH:/usr/local/skyinsight/bin -PATH=$PATH:/opt/kde/bin/ -PATH=$PATH:/work/.opt/build_arm_nofpu/staging_dir/bin/ -PATH=$PATH:/work/.opt/virata/tools_v10.1c/redhat-3-x86/bin -PATH=$PATH:/work/.opt/utils_work -PATH=$PATH:/opt/openoffice.org2.0/program/ -PATH=$PATH:/opt/extra/bin/ -PATH=$PATH:/work/.opt/iad6358/bin/ +XDM_PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/kde/bin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/opt/qt/bin +ARROW_PATH=/home/arrow/.bin/shell:/usr/local/bin:/usr/local/sbin:/bin:/usr/games +A_TOOL_PATH=/work/.opt/mv_tools/bin +export PATH=$ARROW_PATH:$A_TOOL_PATH$XDM_PATH export MANPATH=$MANPATH:/work/.opt/iad6358/man export EDITOR=vim @@ -97,6 +79,8 @@ export MAC_SYS="00:90:F5:25:19:C1" export SVNTP="svn://172.31.2.251:36901/svn/Platform/DG834GV/Neutral" export SVNLINUX="https://linuxsys.googlecode.com/svn/trunk" export SIP_DOMAIN=localhost +export XTERM=rxvt +export XTERMCMD=rxvt export PS1="\u@\H:\W> " #export PS1="\015\033[1m\u@\H:\W> \033[0m" @@ -116,7 +100,8 @@ fi case "$TERM" in rxvt*|xterm*) - PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~} /-/${USER}@${HOSTNAME}\007"' + PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~} /-/${USER}@${HOSTNAME}\007|"' +# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"' ;; screen*) ;; @@ -136,7 +121,8 @@ rxvt* | "rxvt-unicode") #not tty fi ;; esac -fortune +#fortune #PS1='\u@\h: \w\n$?\$ ' #PS1='\u@\h: \w\n$?\$ ' -PS1='\u@\h: \w\n$?\$ ' +PS1='\u@\h: \w \n$?\$ ' + diff --git a/conf_slk120/bin/.bin/shell/arrow-forward b/conf_slk120/bin/.bin/shell/arrow-forward new file mode 100755 index 0000000..3dd2e96 --- /dev/null +++ b/conf_slk120/bin/.bin/shell/arrow-forward @@ -0,0 +1,4 @@ +#!/bin/bash + +echo 1 > /proc/sys/net/ipv4/ip_forward +iptables -t nat -I POSTROUTING -j MASQUERADE diff --git a/conf_slk120/bin/.bin/shell/arrow-qos b/conf_slk120/bin/.bin/shell/arrow-qos new file mode 100755 index 0000000..019abaf --- /dev/null +++ b/conf_slk120/bin/.bin/shell/arrow-qos @@ -0,0 +1,10 @@ +#!/bin/bash -x +export WLAN=eth0 +tc qdisc del dev ${WLAN} root 2>/dev/null +tc qdisc add dev ${WLAN} root handle 1: htb default 10 +tc class add dev ${WLAN} root classid 1:10 htb rate 80kbps + +#tc qdisc del dev ${WLAN} ingress +#tc qdisc add dev ${WLAN} handle ffff: ingress +#tc filter add dev ${WLAN} parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate 90kbps burst 20kb drop flowid :1 + diff --git a/conf_slk120/bin/.bin/shell/arrow-x b/conf_slk120/bin/.bin/shell/arrow-x new file mode 100755 index 0000000..443e96a --- /dev/null +++ b/conf_slk120/bin/.bin/shell/arrow-x @@ -0,0 +1,10 @@ +#!/bin/bash +# login [XDMP], e.g. xdm/gdm +# xdm should open *# any host login +# and comment out displaymanager request port 0 +host=$1 +xdisplay=$2 +shift +shift +echo will do cmd [-quiet -query $host $xdisplay $@] +X -quiet -query $host $xdisplay $@ diff --git a/conf_slk120/bin/.bin/shell/arrow-xinit b/conf_slk120/bin/.bin/shell/arrow-xinit index 572ac1c..b7e8b61 100755 --- a/conf_slk120/bin/.bin/shell/arrow-xinit +++ b/conf_slk120/bin/.bin/shell/arrow-xinit @@ -1,18 +1,20 @@ #!/bin/bash sleep 1 -exec gnome-settings-daemon & -exit 0 -rxvt & +#exec gnome-settings-daemon & +#exit 0 +#rxvt & sleep 1 #exec xfce4-panel & #exec fspanel >/dev/null 2>&1 & -sleep 20 -exec stardict & +#sleep 20 +#exec stardict & -ps aux | grep -w pland | grep -v grep -if [ "$?" != "0" ]; then - pland & -fi +#ps aux | grep -w pland | grep -v grep +#if [ "$?" != "0" ]; then +# pland & +#fi +sleep 4 +scim -d -return 0 +exit 0 diff --git a/conf_slk120/bin/.bin/shell/arxvt b/conf_slk120/bin/.bin/shell/arxvt new file mode 100755 index 0000000..2b1cd03 --- /dev/null +++ b/conf_slk120/bin/.bin/shell/arxvt @@ -0,0 +1,2 @@ +#!/bin/bash +sh /home/arrow/.bin/shell/rxvt diff --git a/conf_slk120/bin/.bin/shell/athome-simple b/conf_slk120/bin/.bin/shell/athome-simple new file mode 100755 index 0000000..a0cc962 --- /dev/null +++ b/conf_slk120/bin/.bin/shell/athome-simple @@ -0,0 +1,7 @@ +#!/bin/bash -x +sudo iwconfig wlan0 essid sub31laoyou +sudo iwconfig wlan0 key "1981093011" +sudo ifconfig wlan0 0 +sudo ifconfig wlan0 192.168.0.224 +sudo ip route del to default +sudo ip route add to default via 192.168.0.1 diff --git a/conf_slk120/bin/.bin/shell/ge b/conf_slk120/bin/.bin/shell/ge index c29810f..201bb66 100755 --- a/conf_slk120/bin/.bin/shell/ge +++ b/conf_slk120/bin/.bin/shell/ge @@ -64,7 +64,8 @@ function arrow_openfile() echo -e "server open: ${CL_GREEN}$1${CL_END}" fi "$V_EXEFILE" $GEO --servername "$V_SERVERNAME" "$V_REMOTE_TAB_SILENT" "$1" 2>/dev/null - usleep 700 +# usleep 700 + sleep 1 if [ "$V_NEED_WAIT" != "$V_SERVERNAME" ]; then sleep 2 #arrow_change_dir #now change dir at init diff --git a/conf_slk120/env/.Xdefaults b/conf_slk120/env/.Xdefaults index edf90d0..4cdd423 100755 --- a/conf_slk120/env/.Xdefaults +++ b/conf_slk120/env/.Xdefaults @@ -30,24 +30,28 @@ rxvt*colorIT: green rxvt*scrollColor: #888888 rxvt*preeditType:Root rxvt.preeditType:Root +rxvt.searchable-scrollback:M-e rxvt*font:\ - xft:Courier:style=Regular:pixelsize=16,\ - xft:WenQuanYi Bitmap Song:style=Regular:pixelsize=16,\ - xft:Courier 10 Pitch:style=Regular:pixelsize=16,\ - xft:Terminus:style=Regular:pixelsize=16,\ - xft:SimSun:style=Regular:pixelsize=16 + -*-courier-medium-r-*-*-14-140-*-75-*-*-*-*,\ + xft:Courier:style=Regular:pixelsize=15,\ + xft:WenQuanYi Bitmap Song:style=Regular:pixelsize=15,\ + xft:Courier 10 Pitch:style=Regular:pixelsize=15,\ + xft:Terminus:style=Regular:pixelsize=15,\ + xft:SimSun:style=Regular:pixelsize=15 rxvt*boldFont:\ - xft:Courier:style=Bold:pixelsize=16,\ - xft:WenQuanYi Bitmap Song:style=Bold,pixelsize=16,\ - xft:Courier 10 Pitch:style=Bold,pixelsize=16,\ - xft:Terminus:style=Bold,pixelsize=16,\ - xft:NSimSun:style=Bold,pixelsize=16 + -*-courier-bold-r-*-*-14-140-*-75-*-*-*-*,\ + xft:Courier:style=Bold:pixelsize=15,\ + xft:WenQuanYi Bitmap Song:style=Bold,pixelsize=15,\ + xft:Courier 10 Pitch:style=Bold,pixelsize=15,\ + xft:Terminus:style=Bold,pixelsize=15,\ + xft:NSimSun:style=Bold,pixelsize=15 rxvt*italicFont:\ - xft:WenQuanYi Bitmap Song:style=Bold Italic:pixelsize=16,\ - xft:Courier 10 Pitch:style=Bold Italic:pixelsize=16,\ - xft:Terminus:style=Bold Italic:pixelsize=16,\ - xft:NSimSun:style=Bold Italic:pixelsize=16 + -*-courier-medium-i-*-*-14-140-*-75-*-*-*-*,\ + xft:WenQuanYi Bitmap Song:style=Bold Italic:pixelsize=15,\ + xft:Courier 10 Pitch:style=Bold Italic:pixelsize=15,\ + xft:Terminus:style=Bold Italic:pixelsize=15,\ + xft:NSimSun:style=Bold Italic:pixelsize=15 *customization: -color xterm.vt100.metaSendsEscape: true diff --git a/conf_slk120/fvwm/init_env b/conf_slk120/fvwm/init_env index 61596f5..b6bdc23 100644 --- a/conf_slk120/fvwm/init_env +++ b/conf_slk120/fvwm/init_env @@ -19,7 +19,8 @@ Colorset 17 fg black, bg #c6cbd6 Colorset 18 fg black, bg #c6c3c6, RootTransparent buffer, Tint #c3c6c3 65 DeskTopSize 2x2 -SetEnv ARROWFONT "xft:WenQuanYi Bitmap Song:style=Regular:shadow=1:pixelsize=13:StringEncoding=GBK-0:encoding=ISO10646-1" +SetEnv ARROWFONT "serif" +# SetEnv ARROWFONT "xft:WenQuanYi Bitmap Song:style=Regular:shadow=1:pixelsize=13:StringEncoding=GBK-0:encoding=ISO10646-1" # SetEnv ARROWFONT "xft:WenQuanYi Bitmap Song:style=Regular" # SetEnv ARROWFONT "xft:WenQuanYi Bitmap Song:style=Regular:shadow=1:pixelsize=13:StringEncoding=GBK-0:encoding=ISO10646-1" # SetEnv ARROWFONT "StringEncoding=gbk-0:xft:WenQuanYi\ Bitmap\ Song:size=11:shadow=1:encoding=iso10646-1" diff --git a/conf_slk120/fvwm/styles b/conf_slk120/fvwm/styles index 8a03d81..ee5dccc 100644 --- a/conf_slk120/fvwm/styles +++ b/conf_slk120/fvwm/styles @@ -23,7 +23,7 @@ Style * Font $[ARROWFONT] Style * IconFont $[ARROWFONT] DefaultFont $[ARROWFONT] MenuStyle * font $[ARROWFONT] -# Style * TitleFont $[ARROWFONT] +Style * TitleFont $[ARROWFONT] # Style * BorderWidth 2, HandleWidth 4 diff --git a/conf_slk120/fvwm/themes-rc b/conf_slk120/fvwm/themes-rc new file mode 100644 index 0000000..fadcdb2 --- /dev/null +++ b/conf_slk120/fvwm/themes-rc @@ -0,0 +1,126 @@ +# fvwm/themes-rc 0.7.0 build 13-Aug-2008 19:52:28 +# Auto-generated by fvwm-themes-config for arrow@somewhere. +# +# .================================================. +# | ____ _ _ _ _ | The best | +# | Designed for ( __X \/ X \/\/ )\/\ `----------| +# | ) _) \ / \ / \ | +# |-------------. (__) * \/ * \/\(_/\/\_) - 2.5.26 | +# | 13- 8月-2008 | | +# `================================================' +# _______________________________________________________________ +# ( _________________________ ________________________________) +# ) (__ _ _ _ _ . ) ( __ __ ____ . ____* ___ +# ( __)( \/ )( \/\/ )/\/\ * ( )( ) )( __)* /\/\ ( __)/ __) +# ) ( . \ /* \ // \ . ) ( ) _ ( *) _). / \* ) _).\__ \ +# (___) * \/ . \/\/(_/\/\_) (___)(__(__)(____)(_/\/\_)(____)(___/ + +DestroyFunc FuncFvwmResetInitFunctions +AddToFunc FuncFvwmResetInitFunctions ++ I DestroyFunc StartFunction ++ I DestroyFunc InitFunction ++ I DestroyFunc RestartFunction ++ I DestroyFunc SessionInitFunction ++ I DestroyFunc SessionRestartFunction ++ I AddToFunc StartFunction ++ I + I FuncFvwmLoadAllHooks + +DestroyFunc FuncFvwmRestartFvwmTheme +AddToFunc FuncFvwmRestartFvwmTheme ++ I KillModule FvwmTheme ++ I DestroyModuleConfig FvwmTheme: * ++ I ModuleSynchronous FvwmTheme + +DestroyFunc FuncFvwmShowVersionInfo +AddToFunc FuncFvwmShowVersionInfo ++ I FuncFvwmShowMessage "FVWM Version" "$[version.line]^nfvwm-themes 0.7.0 built on Aug 13 2008 at 19:52:28" + +DestroyFunc FuncFvwmShowComponentInfo +AddToFunc FuncFvwmShowComponentInfo ++ I PipeRead `/usr/bin/fvwm-themes-config --pipe --show-info --component $0` + +FuncFvwmResetInitFunctions + +DestroyFunc FuncFvwmThemesConfigAndUpdate +AddToFunc FuncFvwmThemesConfigAndUpdate ++ I FvwmScript FvwmScript-NoteMessage "Theme switching" ++ I Wait FvwmScript-NoteMessage ++ I PipeRead `/usr/bin/fvwm-themes-config $0 --pipe` +#+ I FuncFvwmResetInitFunctions ++ I Read themes-rc-3 ++ I FuncFvwmStartAllHooks ++ I All (FvwmScript-NoteMessage) Delete + +DestroyFunc FuncFvwmThemesCenterUpdate +AddToFunc FuncFvwmThemesCenterUpdate ++ I FvwmScript FvwmScript-NoteMessage "Theme switching" ++ I Wait FvwmScript-NoteMessage +#+ I FuncFvwmResetInitFunctions ++ I Read themes-rc-3 ++ I FuncFvwmStartAllHooks ++ I All (FvwmScript-NoteMessage) Delete + +DestroyFunc FuncFvwmThemesReset +AddToFunc FuncFvwmThemesReset ++ I FuncFvwmThemesConfigAndUpdate --reset + +DestroyFunc FuncFvwmThemesFresh +AddToFunc FuncFvwmThemesFresh ++ I FuncFvwmThemesConfigAndUpdate --fresh + +DestroyFunc FuncFvwmThemesFreshUncached +AddToFunc FuncFvwmThemesFreshUncached ++ I FuncFvwmThemesConfigAndUpdate "--fresh --no-cfg-cache" + +DestroyFunc FuncFvwmThemesSetMinimalReload +AddToFunc FuncFvwmThemesSetMinimalReload ++ I FuncFvwmThemesConfigAndUpdate "--set-minimal-reload=$0" + +DestroyFunc FuncFvwmThemesLoad +AddToFunc FuncFvwmThemesLoad ++ I FuncFvwmThemesConfigAndUpdate "--load=$0" + +DestroyFunc FuncFvwmThemesDrop +AddToFunc FuncFvwmThemesDrop ++ I FuncFvwmThemesConfigAndUpdate "--drop=$0" + +DestroyFunc FuncFvwmThemesOption +AddToFunc FuncFvwmThemesOption ++ I FuncFvwmThemesConfigAndUpdate "--option=$0" + +DestroyFunc FuncFvwmThemesVariant +AddToFunc FuncFvwmThemesVariant ++ I FuncFvwmThemesConfigAndUpdate "--variant=$0" + +DestroyFunc FuncFvwmThemesSetLocked +AddToFunc FuncFvwmThemesSetLocked ++ I FuncFvwmThemesConfigAndUpdate "--set-locked=$0" + +# --------------------------------------------------- +# Some global functions, extending FVWM functionality + +DestroyFunc FuncFvwmStopModule +AddToFunc FuncFvwmStopModule ++ I KillModule $0 + +DestroyFunc FuncFvwmStopModuleByAlias +AddToFunc FuncFvwmStopModuleByAlias ++ I KillModule $0 $1 + +DestroyFunc FuncFvwmRestartModule +AddToFunc FuncFvwmRestartModule ++ I FuncFvwmStopModule $0 ++ I Module $0 + +DestroyFunc FuncFvwmRestartModuleByAlias +AddToFunc FuncFvwmRestartModuleByAlias ++ I FuncFvwmStopModuleByAlias $0 $1 ++ I Module $0 $1 $2 + +DestroyFunc FuncFvwmRemoveAllButtons +AddToFunc FuncFvwmRemoveAllButtons ++ I Style "*" NoButton 1, NoButton 3, NoButton 5, NoButton 7, NoButton 9 ++ I Style "*" NoButton 2, NoButton 4, NoButton 6, NoButton 8, NoButton 0 ++ I TitleStyle Height 5 + +Read themes-rc-2 diff --git a/conf_slk120/fvwm/themes-rc-2 b/conf_slk120/fvwm/themes-rc-2 new file mode 120000 index 0000000..36ae891 --- /dev/null +++ b/conf_slk120/fvwm/themes-rc-2 @@ -0,0 +1 @@ +themes/current-main/themes-rc-2 \ No newline at end of file diff --git a/conf_slk120/fvwm/themes/current b/conf_slk120/fvwm/themes/current new file mode 120000 index 0000000..8c9ef0c --- /dev/null +++ b/conf_slk120/fvwm/themes/current @@ -0,0 +1 @@ +current-main \ No newline at end of file diff --git a/conf_slk120/fvwm/themes/current-main/themes-rc-2 b/conf_slk120/fvwm/themes/current-main/themes-rc-2 new file mode 100644 index 0000000..e69de29 diff --git a/conf_slk120/vim/.vim b/conf_slk120/vim/.vim new file mode 160000 index 0000000..a5acf5e --- /dev/null +++ b/conf_slk120/vim/.vim @@ -0,0 +1 @@ +Subproject commit a5acf5edd2a718b68ea45a240aa939b89e7209ec diff --git a/conf_slk120/vim/.vimrc b/conf_slk120/vim/.vimrc new file mode 100644 index 0000000..236f80d --- /dev/null +++ b/conf_slk120/vim/.vimrc @@ -0,0 +1,129 @@ +"Author:arrow, for archlinux + +if v:progname =~? "evim" + finish +endif +set nocompatible +set backupdir=~/.tmp,/tmp,./ +set backup " keep a backup file +set history=100 " keep 50 lines of command line history +set ruler " show the cursor position all the time +set showcmd " display incomplete commands +map Q gq +map t gt +map T gT +set encoding=UTF-8 +set report=0 +set ignorecase +set nowrap +set incsearch +filetype plugin indent on +set autoindent +set tabstop=8 +set softtabstop=8 +set shiftwidth=8 +set cinoptions=>8,n-8,{8,^-8,:8,=8,g8,h8,p8,t8,+8,(8,u8,w1,m1 shiftwidth=8 tabstop=8 +set noexpandtab +set cindent +set notagbsearch +set tagrelative +if &t_Co > 2 || has("gui_running") + syntax on + set hlsearch +endif +nmap :nohlsearch +"nmap :only +"nmap :set noscrollbind:set scrollopt=:set nowrap:set foldmethod=manual:set foldcolumn=0:onlyzR +"nmap :set tags-=/usr/include/tags +"nmap :set tags+=/usr/include/tags +"nmap :set tags+=/kernel/tags +"nmap :set tags-=/kernel/tags +set backspace=indent,eol,start +set nosmartindent +set formatoptions=croqlmM +set textwidth=80 +set laststatus=2 +set statusline=%((%1*%M%*%R%Y)%)%f%=%(\[%3l-%02c]%)[%03b/%02B]T9\ %P~%L +set tags=tags +if has("multi_byte") + set fileencoding=utf-8 + set fileencodings=utf-8,chinese,ucs-bom + set ambiwidth=double +endif + +if has("autocmd") + filetype plugin indent on + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | + \ endif + set formatprg=fmt + au FileType c set formatprg=indent + au FileType cpp set formatprg=indent + if !exists("auto_arrow_c") + let auto_arrow_c=1 + au BufNewFile *.c 0r ~/.vim/files/c.skel + "au BufNewFile *.c normal gnp + au BufNewFile ver.h 0r ~/.vim/files/ver.skel + au BufNewFile *.h 0r ~/.vim/files/h.skel + au BufNewFile *.sh 0r ~/.vim/files/sh.skel + au BufNewFile *.txt 0r ~/.vim/files/txt.skel + au BufNewFile Makefile 0r ~/.vim/files/makefile.skel + au BufNewFile Rules.make 0r ~/.vim/files/Rules.make.skel + ":%s/_filename_/\=bufname("%") + :"%s/_datetime_/\=strftime("%c") + map gse :%s/_filename_/\=bufname("%")/:%s/_datetime_/\=strftime("%c")/ + au BufNewFile *.[ch] normal gse + au BufNewFile *.sh normal gse + "au BufNewFile *.txt normal gse + endif + au BufRead,BufNewFile *.viki set ft=viki +endif +if has("gui_running") + "set menu + :source $VIMRUNTIME/delmenu.vim + :source $VIMRUNTIME/lang/menu_en_gb.utf-8.vim + :source $VIMRUNTIME/menu.vim + set foldcolumn=0 + set guioptions=aegilLtb + "colorscheme delek + set guifont=Courier\ 12 +else + "colorscheme default +endif +colorscheme default +set mouse=a +:language time C +":language ctype C +:language messages C +set showtabline=2 +hi IncSearch term=reverse cterm=reverse gui=reverse +hi Search term=reverse ctermbg=darkmagenta ctermfg=white guibg=darkmagenta guifg=white +hi Cursor gui=reverse guifg=darkcyan guibg=white +" +let g:vikiUseParentSuffix=1 +"let g:vikiOpenUrlWith_mailto = 'mail %{URL}' +"let g:vikiOpenFileWith_html = "silent !firefox %{FILE}" +"let g:vikiOpenFileWith_ANY = "silent !gvim %{FILE}" +"fun! ConvertPDF() +" if !exists("b:convertedPDF") +" exec "cd ". expand("%:p:h") +" exec "%!pdftotext ". expand("%:t") ." -" +" :%!par 72w +" cd - +" setlocal noswapfile buftype=nowrite +" let b:convertedPDF = 1 +" endif +"endf +"let g:vikiOpenFileWith_pdf = 'call VikiOpenLink("%{FILE}", "", 1)|silent call ConvertPDF()' +"let g:deplatePrg = "deplate -x -X " +"au FileType viki compiler deplate +"let g:vikiNameSuffix=".viki" +"autocmd! BufRead,BufNewFile *.viki set filetype=viki +"autocmd! BufRead,BufNewFile $HOME/viki/* set filetype=viki +set mousehide " Hide the mouse when typing text +set mousemodel=extend +set path=.,include,/usr/include,, +set wildmenu +set wildmode=list:full +let g:vimwiki_home = "~/wiki/" diff --git a/conf_slk120/vim/_vim/.VimballRecord b/conf_slk120/vim/_vim/.VimballRecord new file mode 100644 index 0000000..e0bb586 --- /dev/null +++ b/conf_slk120/vim/_vim/.VimballRecord @@ -0,0 +1,2 @@ +Viki.vba: call delete('/home/arrow/.vim/autoload/viki.vim')|call delete('/home/arrow/.vim/autoload/viki_anyword.vim')|call delete('/home/arrow/.vim/autoload/viki_latex.vim')|call delete('/home/arrow/.vim/autoload/viki_viki.vim')|call delete('/home/arrow/.vim/compiler/deplate.vim')|call delete('/home/arrow/.vim/doc/viki.txt')|call delete('/home/arrow/.vim/ftplugin/bib/viki.vim')|call delete('/home/arrow/.vim/ftplugin/viki.vim')|call delete('/home/arrow/.vim/indent/viki.vim')|call delete('/home/arrow/.vim/plugin/viki.vim')|call delete('/home/arrow/.vim/syntax/viki.vim')|call delete('/home/arrow/.vim/syntax/texmath.vim') +Viki.vba: call delete('/home/arrow/.vim/autoload/viki.vim')|call delete('/home/arrow/.vim/autoload/viki_anyword.vim')|call delete('/home/arrow/.vim/autoload/viki_latex.vim')|call delete('/home/arrow/.vim/autoload/viki_viki.vim')|call delete('/home/arrow/.vim/compiler/deplate.vim')|call delete('/home/arrow/.vim/doc/viki.txt')|call delete('/home/arrow/.vim/ftplugin/bib/viki.vim')|call delete('/home/arrow/.vim/ftplugin/viki.vim')|call delete('/home/arrow/.vim/indent/viki.vim')|call delete('/home/arrow/.vim/plugin/viki.vim')|call delete('/home/arrow/.vim/syntax/viki.vim')|call delete('/home/arrow/.vim/syntax/texmath.vim') diff --git a/conf_slk120/vim/_vim/autoload/tlib/Object.vim b/conf_slk120/vim/_vim/autoload/tlib/Object.vim new file mode 100644 index 0000000..e279610 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/Object.vim @@ -0,0 +1,159 @@ +" Object.vim -- Prototype objects? +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://members.a1.net/t.link/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-05-01. +" @Last Change: 2007-09-11. +" @Revision: 0.1.116 + +" :filedoc: +" Provides a prototype plus some OO-like methods. + + +if &cp || exists("loaded_tlib_object_autoload") + finish +endif +let loaded_tlib_object_autoload = 1 + +let s:id_counter = 0 +let s:prototype = {'_class': ['object'], '_super': [], '_id': 0} "{{{2 + +" :def: function! tlib#Object#New(?fields={}) +" This function creates a prototype that provides some kind of +" inheritance mechanism and a way to call parent/super's methods. +" +" The usage demonstrated in the following example works best, when every +" class/prototype is defined in a file of its own. +" +" The reason for why there is a dedicated constructor function is that +" this layout facilitates the use of templates and that methods are +" hidden from the user. Other solutions are possible. +" +" EXAMPLES: > +" let s:prototype = tlib#Object#New({ +" \ '_class': ['FooBar'], +" \ 'foo': 1, +" \ 'bar': 2, +" \ }) +" " Constructor +" function! FooBar(...) +" let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) +" return object +" endf +" function! s:prototype.babble() { +" echo "I think, therefore I am ". (self.foo * self.bar) ." months old." +" } +" +" < This could now be used like this: > +" let myfoo = FooBar({'foo': 3}) +" call myfoo.babble() +" => I think, therefore I am 6 months old. +" echo myfoo.IsA('FooBar') +" => 1 +" echo myfoo.IsA('object') +" => 1 +" echo myfoo.IsA('Foo') +" => 0 +" echo myfoo.RespondTo('babble') +" => 1 +" echo myfoo.RespondTo('speak') +" => 0 +function! tlib#Object#New(...) "{{{3 + return s:prototype.New(a:0 >= 1 ? a:1 : {}) +endf + + +function! s:prototype.New(...) dict "{{{3 + let object = deepcopy(self) + let s:id_counter += 1 + let object._id = s:id_counter + if a:0 >= 1 && !empty(a:1) + call object.Extend(a:1) + endif + return object +endf + + +function! s:prototype.Inherit(object) dict "{{{3 + let class = copy(self._class) + " TLogVAR class + let objid = self._id + for c in get(a:object, '_class', []) + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:object, 'keep') + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, a:object) + return self +endf + + +function! s:prototype.Extend(dictionary) dict "{{{3 + let super = copy(self) + let class = copy(self._class) + " TLogVAR class + let objid = self._id + let thisclass = get(a:dictionary, '_class', []) + for c in type(thisclass) == 3 ? thisclass : [thisclass] + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:dictionary) + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, super) + return self +endf + + +function! s:prototype.IsA(class) dict "{{{3 + return index(self._class, a:class) != -1 +endf + + +function! s:prototype.IsRelated(object) dict "{{{3 + return len(filter(a:object._class, 'self.IsA(v:val)')) > 1 +endf + + +function! s:prototype.RespondTo(name) dict "{{{3 + " return has_key(self, a:name) && type(self[a:name]) == 2 + return has_key(self, a:name) +endf + + +function! s:prototype.Super(method, arglist) dict "{{{3 + for o in self._super + " TLogVAR o + if o.RespondTo(a:method) + " let self._tmp_method = o[a:method] + " TLogVAR self._tmp_method + " return call(self._tmp_method, a:arglist, self) + return call(o[a:method], a:arglist, self) + endif + endfor + echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self) +endf + + +function! s:prototype.Methods() dict "{{{3 + let o = items(self) + call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"') + let acc = {} + for e in o + let id = matchstr(string(e[1]), '\d\+') + let acc[id] = e[0] + endfor + return acc +endf + diff --git a/conf_slk120/vim/_vim/autoload/tlib/Test.vim b/conf_slk120/vim/_vim/autoload/tlib/Test.vim new file mode 100644 index 0000000..a41fa4c --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/Test.vim @@ -0,0 +1,27 @@ +" Test.vim -- A test class +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://members.a1.net/t.link/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-05-01. +" @Last Change: 2007-09-11. +" @Revision: 0.1.8 + +" :enddoc: + +if &cp || exists("loaded_tlib_Test_autoload") + finish +endif +let loaded_tlib_Test_autoload = 1 + + +let s:prototype = tlib#Object#New({'_class': ['Test']}) "{{{2 +function! tlib#Test#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'Test.vim' +endf + diff --git a/conf_slk120/vim/_vim/autoload/tlib/TestChild.vim b/conf_slk120/vim/_vim/autoload/tlib/TestChild.vim new file mode 100644 index 0000000..34c5fcd --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/TestChild.vim @@ -0,0 +1,27 @@ +" TestChild.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://members.a1.net/t.link/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-05-18. +" @Last Change: 2007-09-11. +" @Revision: 0.1.12 + +" :enddoc: + +if &cp || exists("loaded_tlib_TestChild_autoload") + finish +endif +let loaded_tlib_TestChild_autoload = 1 + + +let s:prototype = tlib#Test#New({'_class': ['TestChild']}) "{{{2 +function! tlib#TestChild#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'TestChild.vim' +endf + diff --git a/conf_slk120/vim/_vim/autoload/tlib/World.vim b/conf_slk120/vim/_vim/autoload/tlib/World.vim new file mode 100644 index 0000000..f732821 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/World.vim @@ -0,0 +1,694 @@ +" World.vim -- The World prototype for tlib#input#List() +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://members.a1.net/t.link/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-05-01. +" @Last Change: 2008-03-08. +" @Revision: 0.1.431 + +" :filedoc: +" A prototype used by |tlib#input#List|. +" Inherits from |tlib#Object#New|. + + +if &cp || exists("loaded_tlib_world_autoload") + finish +endif +let loaded_tlib_world_autoload = 1 + + +let s:prototype = tlib#Object#New({ + \ '_class': 'World', + \ 'name': 'world', + \ 'allow_suspend': 1, + \ 'base': [], + \ 'bufnr': -1, + \ 'display_format': '', + \ 'filter': [['']], + \ 'filter_format': '', + \ 'follow_cursor': '', + \ 'index_table': [], + \ 'initial_filter': [['']], + \ 'initial_index': 1, + \ 'initialized': 0, + \ 'key_handlers': [], + \ 'list': [], + \ 'next_state': '', + \ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'), + \ 'offset': 1, + \ 'offset_horizontal': 0, + \ 'pick_last_item': tlib#var#Get('tlib_pick_last_item', 'bg'), + \ 'post_handlers': [], + \ 'query': '', + \ 'resize': 0, + \ 'resize_vertical': 0, + \ 'retrieve_eval': '', + \ 'return_agent': '', + \ 'rv': '', + \ 'scratch': '__InputList__', + \ 'scratch_filetype': 'tlibInputList', + \ 'scratch_vertical': 0, + \ 'sel_idx': [], + \ 'show_empty': 0, + \ 'state': 'display', + \ 'state_handlers': [], + \ 'sticky': 0, + \ 'timeout': 0, + \ 'timeout_resolution': 2, + \ 'type': '', + \ 'win_wnr': -1, + \ }) + " \ 'handlers': [], + +function! tlib#World#New(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Set_display_format(value) dict "{{{3 + if a:value == 'filename' + call self.Set_highlight_filename() + let self.display_format = 'world.FormatFilename(%s)' + else + let self.display_format = a:value + endif +endf + + +function! s:prototype.Set_highlight_filename() dict "{{{3 + let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' + " \ 'syntax match TLibMarker /\%>'. (1 + eval(g:tlib_inputlist_width_filename)) .'c |.\{-}| / | hi def link TLibMarker Special' + " let self.tlib_UseInputListScratch .= '| syntax match TLibDir /\%>'. (4 + eval(g:tlib_inputlist_width_filename)) .'c\S\{-}[\/].*$/ | hi def link TLibDir Directory' +endf + + +function! s:prototype.Highlight_filename() dict "{{{3 + " exec 'syntax match TLibDir /\%>'. (3 + eval(g:tlib_inputlist_width_filename)) .'c \(\S:\)\?[\/].*$/ contained containedin=TLibMarker' + exec 'syntax match TLibDir /\(\a:\|\.\.\..\{-}\)\?[\/][^&<>*|]*$/ contained containedin=TLibMarker' + exec 'syntax match TLibMarker /\%>'. (1 + eval(g:tlib_inputlist_width_filename)) .'c |\( \|[[:alnum:]%*+-]*\)| \S.*$/ contains=TLibDir' + hi def link TLibMarker Special + hi def link TLibDir Directory +endf + + +function! s:prototype.FormatFilename(file) dict "{{{3 + let fname = fnamemodify(a:file, ":p:t") + " let fname = fnamemodify(a:file, ":t") + " if isdirectory(a:file) + " let fname .='/' + " endif + let dname = fnamemodify(a:file, ":h") + " let dname = pathshorten(fnamemodify(a:file, ":h")) + let dnmax = &co - max([eval(g:tlib_inputlist_width_filename), len(fname)]) - 11 - self.index_width - &fdc + if len(dname) > dnmax + let dname = '...'. strpart(fnamemodify(a:file, ":h"), len(dname) - dnmax) + endif + let marker = [] + if g:tlib_inputlist_filename_indicators + let bnr = bufnr(a:file) + " TLogVAR a:file, bnr, self.bufnr + if bnr != -1 + if bnr == self.bufnr + call add(marker, '%') + else + call add(marker, ' ') + " elseif buflisted(a:file) + " if getbufvar(a:file, "&mod") + " call add(marker, '+') + " else + " call add(marker, 'B') + " endif + " elseif bufloaded(a:file) + " call add(marker, 'h') + " else + " call add(marker, 'u') + endif + else + call add(marker, ' ') + endif + endif + call insert(marker, '|') + call add(marker, '|') + return printf("%-". eval(g:tlib_inputlist_width_filename) ."s %s %s", fname, join(marker, ''), dname) +endf + + +function! s:prototype.GetSelectedItems(current) dict "{{{3 + if stridx(self.type, 'i') != -1 + let rv = copy(self.sel_idx) + else + let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') + endif + if a:current != '' + let ci = index(rv, a:current) + if ci != -1 + call remove(rv, ci) + endif + call insert(rv, a:current) + endif + if stridx(self.type, 'i') != -1 + if !empty(self.index_table) + " TLogVAR rv, self.index_table + call map(rv, 'self.index_table[v:val - 1]') + " TLogVAR rv + endif + endif + return rv +endf + + +function! s:prototype.SelectItem(mode, index) dict "{{{3 + let bi = self.GetBaseIdx(a:index) + " if self.RespondTo('MaySelectItem') + " if !self.MaySelectItem(bi) + " return 0 + " endif + " endif + " TLogVAR bi + let si = index(self.sel_idx, bi) + " TLogVAR self.sel_idx + " TLogVAR si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode == 'toggle' + call remove(self.sel_idx, si) + endif + return 1 +endf + + +function! s:prototype.FormatArgs(format_string, arg) dict "{{{3 + let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) + return [a:format_string] + repeat([string(a:arg)], nargs) +endf + + +function! s:prototype.GetRx(filter) dict "{{{3 + return '\('. join(filter(copy(a:filter), 'v:val[0] != "!"'), '\|') .'\)' +endf + + +function! s:prototype.GetRx0(...) dict "{{{3 + exec tlib#arg#Let(['negative']) + let rx0 = [] + for filter in self.filter + " TLogVAR filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " TLogVAR rx + if !empty(rx) && (negative ? rx[0] == g:tlib_inputlist_not : rx[0] != g:tlib_inputlist_not) + call add(rx0, rx) + endif + endfor + let rx0s = join(rx0, '\|') + if empty(rx0s) + return '' + else + return '\V\('. rx0s .'\)' + endif +endf + + +function! s:prototype.GetItem(idx) dict "{{{3 + return self.list[a:idx - 1] +endf + + +function! s:prototype.GetListIdx(baseidx) dict "{{{3 + " if empty(self.index_table) + let baseidx = a:baseidx + " else + " let baseidx = 0 + self.index_table[a:baseidx - 1] + " " TLogVAR a:baseidx, baseidx, self.index_table + " endif + let rv = index(self.table, baseidx) + " TLogVAR rv, self.table + return rv +endf + + +function! s:prototype.GetBaseIdx(idx) dict "{{{3 + " TLogVAR a:idx, self.table, self.index_table + if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) + return self.table[a:idx - 1] + else + return '' + endif +endf + + +function! s:prototype.GetBaseItem(idx) dict "{{{3 + return self.base[a:idx - 1] +endf + + +function! s:prototype.SetBaseItem(idx, item) dict "{{{3 + let self.base[a:idx - 1] = a:item +endf + + +function! s:prototype.GetCurrentItem() dict "{{{3 + let idx = self.prefidx + if stridx(self.type, 'i') != -1 + return idx + elseif !empty(self.list) + if len(self.list) >= idx + return self.list[idx - 1] + endif + else + return '' + endif +endf + + +function! s:prototype.CurrentItem() dict "{{{3 + if stridx(self.type, 'i') != -1 + return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) + else + if self.llen == 1 + " TLogVAR self.llen + return self.list[0] + elseif self.prefidx > 0 + " TLogVAR self.prefidx + return self.GetCurrentItem() + endif + endif +endf + + +function! s:prototype.SetFilter() dict "{{{3 + " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') + let mrx = '\V'. self.filter_format + let self.filter_pos = [] + let self.filter_neg = [] + for filter in self.filter + " TLogVAR filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " TLogVAR rx + if rx[0] == g:tlib_inputlist_not + if len(rx) > 1 + call add(self.filter_neg, mrx .'\('. rx[1:-1] .'\)') + endif + else + call add(self.filter_pos, mrx .'\('. rx .'\)') + endif + endfor +endf + + +function! s:prototype.Match(text, ...) dict "{{{3 + for rx in self.filter_neg + if a:text =~ rx + return 0 + endif + endfor + for rx in self.filter_pos + if a:text !~ rx + return 0 + endif + endfor + " for filter in self.filter + " " TLogVAR filter + " let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " " TLogVAR rx + " if rx[0] == g:tlib_inputlist_not + " if len(rx) > 1 && a:text =~ mrx .'\('. rx[1:-1] .'\)' + " return 0 + " endif + " elseif a:text !~ mrx .'\('. rx .'\)' + " return 0 + " endif + " " if a:text !~ mrx. self.GetRx(filter) + " " return 0 + " " endif + " endfor + return 1 +endf + + +function! s:prototype.MatchBaseIdx(idx) dict "{{{3 + let text = self.GetBaseItem(a:idx) + if !empty(self.filter_format) + let text = eval(call(function("printf"), self.FormatArgs(self.filter_format, text))) + endif + return self.Match(text) +endf + + +function! s:prototype.BuildTable() dict "{{{3 + call self.SetFilter() + let self.table = filter(range(1, len(self.base)), 'self.MatchBaseIdx(v:val)') +endf + + +function! s:prototype.ReduceFilter() dict "{{{3 + " TLogVAR self.filter + if self.filter[0] == [''] && len(self.filter) > 1 + call remove(self.filter, 0) + elseif empty(self.filter[0][0]) && len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + else + let self.filter[0][0] = self.filter[0][0][0:-2] + endif +endf + + +function! s:prototype.SetInitialFilter(filter) dict "{{{3 + " let self.initial_filter = [[''], [a:filter]] + let self.initial_filter = [[a:filter]] +endf + + +function! s:prototype.PopFilter() dict "{{{3 + " TLogVAR self.filter + if len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + elseif len(self.filter) > 1 + call remove(self.filter, 0) + else + let self.filter[0] = [''] + endif +endf + + +function! s:prototype.FilterIsEmpty() dict "{{{3 + " TLogVAR self.filter + return self.filter == copy(self.initial_filter) +endf + + +function! s:prototype.DisplayFilter() dict "{{{3 + " TLogVAR self.filter + let filter1 = map(deepcopy(self.filter), '"(". join(reverse(v:val), " OR ") .")"') + " TLogVAR filter1 + return join(reverse(filter1), ' AND ') +endf + + +function! s:prototype.UseScratch() dict "{{{3 + return tlib#scratch#UseScratch(self) +endf + + +function! s:prototype.CloseScratch(...) dict "{{{3 + TVarArg ['reset_scratch', 0] + " TVarArg ['reset_scratch', 1] + " TLogVAR reset_scratch + return tlib#scratch#CloseScratch(self, reset_scratch) +endf + + +function! s:prototype.UseInputListScratch() dict "{{{3 + let scratch = self.UseScratch() + " TLogVAR scratch + syntax match InputlListIndex /^\d\+:/ + syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex + syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex + hi def link InputlListIndex Constant + hi def link InputlListCursor Search + hi def link InputlListSelected IncSearch + " exec "au BufEnter call tlib#input#Resume(". string(self.name) .")" + setlocal nowrap + " hi def link InputlListIndex Special + " let b:tlibDisplayListMarks = {} + let b:tlibDisplayListMarks = [] + call tlib#hook#Run('tlib_UseInputListScratch', self) + return scratch +endf + + +" :def: function! s:prototype.Reset(?initial=0) +function! s:prototype.Reset(...) dict "{{{3 + TVarArg ['initial', 0] + " TLogVAR initial + let self.state = 'display' + let self.offset = 1 + let self.filter = deepcopy(self.initial_filter) + let self.idx = '' + let self.prefidx = 0 + call self.UseInputListScratch() + call self.ResetSelected() + call self.Retrieve(!initial) + return self +endf + + +function! s:prototype.ResetSelected() dict "{{{3 + let self.sel_idx = [] +endf + + +function! s:prototype.Retrieve(anyway) dict "{{{3 + " TLogVAR a:anyway, self.base + " TLogDBG (a:anyway || empty(self.base)) + if (a:anyway || empty(self.base)) + let ra = self.retrieve_eval + " TLogVAR ra + if !empty(ra) + let back = self.SwitchWindow('win') + let world = self + let self.base = eval(ra) + " TLogVAR self.base + exec back + return 1 + endif + endif + return 0 +endf + + +function! s:prototype.DisplayHelp() dict "{{{3 + let help = [ + \ 'Help:', + \ 'Mouse ... Pick an item Letter ... Filter the list', + \ printf('Number ... Pick an item "%s", "%s", %sWORD ... AND, OR, NOT', + \ g:tlib_inputlist_and, g:tlib_inputlist_or, g:tlib_inputlist_not), + \ 'Enter ... Pick the current item , ... Reduce filter', + \ ' ... Reset the display Up/Down ... Next/previous item', + \ ' ... Edit top filter string Page Up/Down ... Scroll', + \ ' ... Abort', + \ ] + + if self.allow_suspend + call add(help, + \ ' ... Suspend/Resume ... Switch to origin') + endif + + if stridx(self.type, 'm') != -1 + let help += [ + \ '#, ... (Un)Select the current item', + \ ' ... (Un)Select all currently visible items', + \ ' ... (Un)Select items', + \ ] + " \ ' ... Show only selected', + endif + for handler in self.key_handlers + let key = get(handler, 'key_name', '') + if !empty(key) + let desc = get(handler, 'help', '') + call add(help, printf('%-12s ... %s', key, desc)) + endif + endfor + let help += [ + \ '', + \ 'Warning:', + \ 'Please don''t resize the window with the mouse.', + \ '', + \ 'Note on filtering:', + \ 'The filter is prepended with "\V". Basically, filtering is case-insensitive.', + \ 'Letters at word boundaries or upper-case lettes in camel-case names is given', + \ 'more weight. If an OR-joined pattern start with "!", matches will be excluded.', + \ '', + \ 'Press any key to continue.', + \ ] + norm! ggdG + call append(0, help) + norm! Gddgg + call self.Resize(len(help), 0) +endf + + +function! s:prototype.Resize(hsize, vsize) dict "{{{3 + " TLogVAR self.scratch_vertical, a:hsize, a:vsize + if self.scratch_vertical + if a:vsize + exec 'vert resize '. eval(a:vsize) + endif + else + if a:hsize + exec 'resize '. eval(a:hsize) + endif + endif +endf + + +" :def: function! s:prototype.DisplayList(query, ?list) +function! s:prototype.DisplayList(query, ...) dict "{{{3 + " TLogVAR a:query + " TLogVAR self.state + let list = a:0 >= 1 ? a:1 : [] + call self.UseScratch() + " TLogVAR self.scratch + " TAssert IsNotEmpty(self.scratch) + if self.state == 'scroll' + exec 'norm! '. self.offset .'zt' + elseif self.state == 'help' + call self.DisplayHelp() + else + " let ll = len(list) + let ll = self.llen + " let x = len(ll) + 1 + let x = self.index_width + 1 + " TLogVAR ll + if self.state =~ '\' + let resize = get(self, 'resize', 0) + " TLogVAR resize + let resize = resize == 0 ? ll : min([ll, resize]) + let resize = min([resize, (&lines * g:tlib_inputlist_pct / 100)]) + " TLogVAR resize, ll, &lines + call self.Resize(resize, get(self, 'resize_vertical', 0)) + norm! ggdG + let w = winwidth(0) - &fdc + " let w = winwidth(0) - &fdc - 1 + let lines = copy(list) + let lines = map(lines, 'printf("%-'. w .'.'. w .'s", substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g"))') + " TLogVAR lines + call append(0, lines) + norm! Gddgg + endif + " TLogVAR self.prefidx + let base_pref = self.GetBaseIdx(self.prefidx) + " TLogVAR base_pref + if self.state =~ '\' + call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') + " TLogVAR b:tlibDisplayListMarks + call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') + " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + " call add(b:tlibDisplayListMarks, self.prefidx) + " call self.DisplayListMark(x, self.GetBaseIdx(self.prefidx), '*') + endif + let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + call add(b:tlibDisplayListMarks, base_pref) + call self.DisplayListMark(x, base_pref, '*') + call self.SetOffset() + " TLogVAR self.offset + " TLogDBG winheight('.') + " if self.prefidx > winheight(0) + " let lt = len(list) - winheight('.') + 1 + " if self.offset > lt + " exec 'norm! '. lt .'zt' + " else + exec 'norm! '. self.offset .'zt' + " endif + " else + " norm! 1zt + " endif + let rx0 = self.GetRx0() + " TLogVAR rx0 + if !empty(g:tlib_inputlist_higroup) + if empty(rx0) + match none + else + exec 'match '. g:tlib_inputlist_higroup .' /\c'. escape(rx0, '/') .'/' + endif + endif + let query = a:query + let options = [] + if self.sticky + call add(options, 's') + endif + if !empty(options) + let query .= printf(' [%s]', join(options)) + endif + let &statusline = query + endif + redraw +endf + + +function! s:prototype.SetOffset() dict "{{{3 + " TLogVAR self.prefidx, self.offset + " TLogDBG winheight(0) + " TLogDBG self.prefidx > self.offset + winheight(0) - 1 + let listtop = len(self.list) - winheight(0) + 1 + if listtop < 1 + let listtop = 1 + endif + if self.prefidx > listtop + let self.offset = listtop + elseif self.prefidx > self.offset + winheight(0) - 1 + let listoff = self.prefidx - winheight(0) + 1 + let self.offset = min([listtop, listoff]) + " TLogVAR self.prefidx + " TLogDBG len(self.list) + " TLogDBG winheight(0) + " TLogVAR listtop, listoff, self.offset + elseif self.prefidx < self.offset + let self.offset = self.prefidx + endif + " TLogVAR self.offset +endf + + +function! s:prototype.DisplayListMark(x, y, mark) dict "{{{3 + " TLogVAR a:y, a:mark + if a:x > 0 && a:y >= 0 + " TLogDBG a:x .'x'. a:y .' '. a:mark + let sy = self.GetListIdx(a:y) + 1 + " TLogVAR sy + if sy >= 1 + call setpos('.', [0, sy, a:x, 0]) + exec 'norm! r'. a:mark + " exec 'norm! '. a:y .'gg'. a:x .'|r'. a:mark + endif + endif + return a:y +endf + + +function! s:prototype.SwitchWindow(where) dict "{{{3 + let wnr = get(self, a:where.'_wnr') + " TLogVAR wnr + return tlib#win#Set(wnr) +endf + + +function! s:prototype.FollowCursor() dict "{{{3 + if !empty(self.follow_cursor) + let back = self.SwitchWindow('win') + " TLogVAR back + " TLogDBG winnr() + try + call call(self.follow_cursor, [self, [self.CurrentItem()]]) + finally + exec back + endtry + endif +endf + + +function! s:prototype.SetOrigin(...) dict "{{{3 + TVarArg ['winview', 0] + let self.win_wnr = winnr() + let self.bufnr = bufnr('%') + let self.cursor = getpos('.') + if winview + let self.winview = tlib#win#GetLayout() + endif + return self +endf + + +function! s:prototype.RestoreOrigin(...) dict "{{{3 + TVarArg ['winview', 0] + if winview + call tlib#win#SetLayout(self.winview) + endif + " TLogVAR self.win_wnr, self.bufnr, self.cursor + if self.win_wnr != winnr() + exec self.win_wnr .'wincmd w' + endif + exec 'buffer! '. self.bufnr + call setpos('.', self.cursor) +endf + diff --git a/conf_slk120/vim/_vim/autoload/tlib/agent.vim b/conf_slk120/vim/_vim/autoload/tlib/agent.vim new file mode 100644 index 0000000..11c17b9 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/agent.vim @@ -0,0 +1,462 @@ +" agent.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-24. +" @Last Change: 2008-03-08. +" @Revision: 0.1.140 + +if &cp || exists("loaded_tlib_agent_autoload") "{{{2 + finish +endif +let loaded_tlib_agent_autoload = 1 + +" :filedoc: +" Various agents for use as key handlers in tlib#input#List() + +" General {{{1 + +function! tlib#agent#Exit(world, selected) "{{{3 + call a:world.CloseScratch() + let a:world.state = 'exit escape' + let a:world.list = [] + " let a:world.base = [] + call a:world.ResetSelected() + return a:world +endf + + +function! tlib#agent#CopyItems(world, selected) "{{{3 + let @* = join(a:selected, "\n") + let a:world.state = 'redisplay' + return a:world +endf + + + +" InputList related {{{1 + +function! tlib#agent#PageUp(world, selected) "{{{3 + let a:world.offset -= (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#PageDown(world, selected) "{{{3 + let a:world.offset += (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#Up(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + let a:world.idx = '' + if a:world.prefidx > lines + let a:world.prefidx -= lines + else + let a:world.prefidx = len(a:world.list) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Down(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + let a:world.idx = '' + if a:world.prefidx <= (len(a:world.list) - lines) + let a:world.prefidx += lines + else + let a:world.prefidx = 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#UpN(world, selected) "{{{3 + return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#DownN(world, selected) "{{{3 + return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#ShiftLeft(world, selected) "{{{3 + let a:world.offset_horizontal -= (winwidth(0) / 2) + if a:world.offset_horizontal < 0 + let a:world.offset_horizontal = 0 + endif + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#ShiftRight(world, selected) "{{{3 + let a:world.offset_horizontal += (winwidth(0) / 2) + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#Reset(world, selected) "{{{3 + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#Input(world, selected) "{{{3 + let flt0 = a:world.filter[0][0] + let flt1 = input('Filter: ', flt0) + echo + if flt1 != flt0 && !empty(flt1) + let a:world.filter[0][0] = flt1 + endif + let a:world.state = 'display' + return a:world +endf + + +" Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the +" original position in the parent window. +function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 + let world = a:world + let winnr = world.win_wnr + " TLogVAR winnr + if winnr != -1 + let world = tlib#agent#Suspend(world, a:selected) + if world.state =~ '\' + call world.SwitchWindow('win') + " let pos = world.cursor + " " TLogVAR pos + " if !empty(pos) + " call setpos('.', pos) + " endif + return world + endif + endif + let world.state = 'redisplay' + return world +endf + + +" Suspend lets you temporarily leave the input loop of +" |tlib#input#List|. You can resume editing the list by pressing , +" . , , or in the suspended window. +function! tlib#agent#Suspend(world, selected) "{{{3 + if a:world.allow_suspend + " TAssert IsNotEmpty(a:world.scratch) + " TLogDBG bufnr('%') + let br = tlib#buffer#Set(a:world.scratch) + " TLogVAR br, a:world.bufnr, a:world.scratch + " TLogDBG bufnr('%') + let b:tlib_suspend = ['', '', '', '', ''] + for m in b:tlib_suspend + exec 'noremap '. m .' :call tlib#input#Resume("world")' + endfor + let b:tlib_world = a:world + exec br + let a:world.state = 'exit suspend' + else + echom 'Suspend disabled' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#Help(world, selected) "{{{3 + let a:world.state = 'help' + return a:world +endf + + +function! tlib#agent#OR(world, selected) "{{{3 + if !empty(a:world.filter[0]) + call insert(a:world.filter[0], '') + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#AND(world, selected) "{{{3 + if !empty(a:world.filter[0]) + call insert(a:world.filter, ['']) + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#ReduceFilter(world, selected) "{{{3 + call a:world.ReduceFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#PopFilter(world, selected) "{{{3 + call a:world.PopFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Debug(world, selected) "{{{3 + " echo string(world.state) + echo string(a:world.filter) + echo string(a:world.idx) + echo string(a:world.prefidx) + echo string(a:world.sel_idx) + call getchar() + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Select(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + " let a:world.state = 'display keepcursor' + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectUp(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx > 1 + let a:world.prefidx -= 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectDown(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx < len(a:world.list) + let a:world.prefidx += 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectAll(world, selected) "{{{3 + let listrange = range(1, len(a:world.list)) + let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) + \ ? 'toggle' : 'set' + for i in listrange + call a:world.SelectItem(mode, i) + endfor + let a:world.state = 'display keepcursor' + return a:world +endf + + +function! tlib#agent#ToggleStickyList(world, selected) "{{{3 + let a:world.sticky = !a:world.sticky + let a:world.state = 'display keepcursor' + return a:world +endf + + + +" EditList related {{{1 + +function! tlib#agent#EditItem(world, selected) "{{{3 + let lidx = a:world.prefidx + " TLogVAR lidx + " TLogVAR a:world.table + let bidx = a:world.GetBaseIdx(lidx) + " TLogVAR bidx + let item = a:world.GetBaseItem(bidx) + let item = input(lidx .'@'. bidx .': ', item) + if item != '' + call a:world.SetBaseItem(bidx, item) + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#NewItem(world, selected) "{{{3 + let basepi = a:world.GetBaseIdx(a:world.prefidx) + let item = input('New item: ') + call insert(a:world.base, item, basepi) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#DeleteItems(world, selected) "{{{3 + let remove = copy(a:world.sel_idx) + let basepi = a:world.GetBaseIdx(a:world.prefidx) + if index(remove, basepi) == -1 + call add(remove, basepi) + endif + " call map(remove, 'a:world.GetBaseIdx(v:val)') + for idx in reverse(sort(remove)) + call remove(a:world.base, idx - 1) + endfor + let a:world.state = 'display' + call a:world.ResetSelected() + " let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#Cut(world, selected) "{{{3 + let world = tlib#agent#Copy(a:world, a:selected) + return tlib#agent#DeleteItems(world, a:selected) +endf + + +function! tlib#agent#Copy(world, selected) "{{{3 + let a:world.clipboard = [] + let bidxs = copy(a:world.sel_idx) + call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) + for bidx in sort(bidxs) + call add(a:world.clipboard, a:world.GetBaseItem(bidx)) + endfor + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Paste(world, selected) "{{{3 + if has_key(a:world, 'clipboard') + for e in reverse(copy(a:world.clipboard)) + call insert(a:world.base, e, a:world.prefidx) + endfor + endif + let a:world.state = 'display' + call a:world.ResetSelected() + return a:world +endf + + +function! tlib#agent#EditReturnValue(world, rv) "{{{3 + return [a:world.state !~ '\', a:world.base] +endf + + + +" Files related {{{1 + +function! tlib#agent#ViewFile(world, selected) "{{{3 + let back = a:world.SwitchWindow('win') + call tlib#file#With('edit', 'buffer', a:selected, a:world) + exec back + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#EditFile(world, selected) "{{{3 + return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) +endf + + +function! tlib#agent#EditFileInSplit(world, selected) "{{{3 + call a:world.CloseScratch() + " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) + " call tlib#file#With('split', 'sbuffer', a:selected[1:-1], a:world) + call tlib#file#With('split', 'sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 + call a:world.CloseScratch() + " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) + " call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world) + call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInTab(world, selected) "{{{3 + call a:world.CloseScratch() + call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 + let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 + let a:world.state = 'redisplay' + return a:world +endf + +function! tlib#agent#ShowInfo(world, selected) + for f in a:selected + if filereadable(f) + let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] + echo fnamemodify(f, ':t') .':' + echo ' '. join(desc, '; ') + endif + endfor + echohl MoreMsg + echo 'Press any key to continue' + echohl NONE + call getchar() + let a:world.state = 'redisplay' + return a:world +endf + + + +" Buffer related {{{1 + +function! tlib#agent#PreviewLine(world, selected) "{{{3 + let l = a:selected[0] + let ww = winnr() + exec a:world.win_wnr .'wincmd w' + call tlib#buffer#ViewLine(l) + exec ww .'wincmd w' + let a:world.state = 'redisplay' + return a:world +endf + + +" If not called from the scratch, we assume/guess that we don't have to +" suspend the input-evaluation loop. +function! tlib#agent#GotoLine(world, selected) "{{{3 + if !empty(a:selected) + let l = a:selected[0] + if a:world.win_wnr != winnr() + let world = tlib#agent#Suspend(a:world, a:selected) + exec a:world.win_wnr .'wincmd w' + endif + call tlib#buffer#ViewLine(l) + endif + return a:world +endf + + +function! tlib#agent#DoAtLine(world, selected) "{{{3 + if !empty(a:selected) + let cmd = input('Command: ', '', 'command') + if !empty(cmd) + call a:world.SwitchWindow('win') + let pos = getpos('.') + for l in a:selected + call tlib#buffer#ViewLine(l, '') + exec cmd + endfor + call setpos('.', pos) + endif + endif + call a:world.ResetSelected() + let a:world.state = 'exit' + return a:world +endf + diff --git a/conf_slk120/vim/_vim/autoload/tlib/arg.vim b/conf_slk120/vim/_vim/autoload/tlib/arg.vim new file mode 100644 index 0000000..341aea8 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/arg.vim @@ -0,0 +1,102 @@ +" arg.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2008-06-15. +" @Revision: 0.0.49 + +if &cp || exists("loaded_tlib_arg_autoload") + finish +endif +let loaded_tlib_arg_autoload = 1 + + +" :def: function! tlib#arg#Get(n, var, ?default="", ?test='') +" Set a positional argument from a variable argument list. +" See tlib#string#RemoveBackslashes() for an example. +function! tlib#arg#Get(n, var, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let atest = a:0 >= 2 ? a:2 : '' + " TLogVAR default, atest + if !empty(atest) + let atest = ' && (a:'. a:n .' '. atest .')' + endif + let test = printf('a:0 >= %d', a:n) . atest + return printf('let %s = %s ? a:%d : %s', a:var, test, a:n, string(default)) +endf + + +" :def: function! tlib#arg#Let(list, ?default='') +" Set a positional arguments from a variable argument list. +" See tlib#input#List() for an example. +function! tlib#arg#Let(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let list = map(copy(a:list), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(range(1, len(list)), 'call("tlib#arg#Get", [v:val] + list[v:val - 1])') + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#Key(dict, list, ?default='') +" See |:TKeyArg|. +function! tlib#arg#Key(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let dict = a:list[0] + let list = map(copy(a:list[1:-1]), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(list, '"let ". v:val[0] ." = ". string(get(dict, v:val[0], v:val[1]))') + " TLogVAR dict, list, args + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0) +function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1 + TVarArg ['keys', {}], ['evaluate', 0] + let keyargs = {} + let args = split(a:string, '\\\@ +" exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +function! tlib#arg#Ex(arg, ...) "{{{3 + if exists('*fnameescape') && a:0 == 0 + return fnameescape(a:arg) + else + " let chars = '%# \' + let chars = '%#! ' + if a:0 >= 1 + let chars .= a:1 + endif + return escape(a:arg, chars) + endif +endf + + diff --git a/conf_slk120/vim/_vim/autoload/tlib/buffer.vim b/conf_slk120/vim/_vim/autoload/tlib/buffer.vim new file mode 100644 index 0000000..24ceb3c --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/buffer.vim @@ -0,0 +1,278 @@ +" buffer.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2007-11-16. +" @Revision: 0.0.238 + +if &cp || exists("loaded_tlib_buffer_autoload") + finish +endif +let loaded_tlib_buffer_autoload = 1 + + +" Set the buffer to buffer and return a command as string that can be +" evaluated by |:execute| in order to restore the original view. +function! tlib#buffer#Set(buffer) "{{{3 + let lazyredraw = &lazyredraw + set lazyredraw + try + let cb = bufnr('%') + let sn = bufnr(a:buffer) + if sn != cb + let ws = bufwinnr(sn) + if ws != -1 + let wb = bufwinnr('%') + exec ws.'wincmd w' + return wb.'wincmd w' + else + silent exec 'sbuffer! '. sn + return 'wincmd c' + endif + else + return '' + endif + finally + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#Eval(buffer, code) +" Evaluate CODE in BUFFER. +" +" EXAMPLES: > +" call tlib#buffer#Eval('foo.txt', 'echo b:bar') +function! tlib#buffer#Eval(buffer, code) "{{{3 + " let cb = bufnr('%') + " let wb = bufwinnr('%') + " " TLogVAR cb + " let sn = bufnr(a:buffer) + " let sb = sn != cb + let lazyredraw = &lazyredraw + set lazyredraw + let restore = tlib#buffer#Set(a:buffer) + try + exec a:code + " if sb + " let ws = bufwinnr(sn) + " if ws != -1 + " try + " exec ws.'wincmd w' + " exec a:code + " finally + " exec wb.'wincmd w' + " endtry + " else + " try + " silent exec 'sbuffer! '. sn + " exec a:code + " finally + " wincmd c + " endtry + " endif + " else + " exec a:code + " endif + finally + exec restore + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0) +function! tlib#buffer#GetList(...) + TVarArg ['show_hidden', 0], ['show_number', 0] + let ls_bang = show_hidden ? '!' : '' + redir => bfs + exec 'silent ls'. ls_bang + redir END + let buffer_list = split(bfs, '\n') + let buffer_nr = map(copy(buffer_list), 'matchstr(v:val, ''\s*\zs\d\+\ze'')') + " TLogVAR buffer_list + if show_number + call map(buffer_list, 'matchstr(v:val, ''\s*\d\+.\{-}\ze\s\+line \d\+\s*$'')') + else + call map(buffer_list, 'matchstr(v:val, ''\s*\d\+\zs.\{-}\ze\s\+line \d\+\s*$'')') + endif + " TLogVAR buffer_list + " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')') + " TLogVAR buffer_list + call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))') + " TLogVAR buffer_list + return [buffer_nr, buffer_list] +endf + + +" :def: function! tlib#buffer#ViewLine(line, ?position='z') +" line is either a number or a string that begins with a number. +" For possible values for position see |scroll-cursor|. +" See also |g:tlib_viewline_position|. +function! tlib#buffer#ViewLine(line, ...) "{{{3 + if a:line + TVarArg 'pos' + let ln = matchstr(a:line, '^\d\+') + let lt = matchstr(a:line, '^\d\+: \zs.*') + " TLogVAR pos, ln, lt + exec ln + if empty(pos) + let pos = tlib#var#Get('tlib_viewline_position', 'wbg') + endif + " TLogVAR pos + if !empty(pos) + exec 'norm! '. pos + endif + let @/ = '\%'. ln .'l.*' + endif +endf + + +function! tlib#buffer#HighlightLine(line) "{{{3 + exec 'match MatchParen /\V\%'. a:line .'l.*/' +endf + + +" Delete the lines in the current buffer. Wrapper for |:delete|. +function! tlib#buffer#DeleteRange(line1, line2) "{{{3 + exec a:line1.','.a:line2.'delete' +endf + + +" Replace a range of lines. +function! tlib#buffer#ReplaceRange(line1, line2, lines) + call tlib#buffer#DeleteRange(a:line1, a:line2) + call append(a:line1 - 1, a:lines) +endf + + +" Initialize some scratch area at the bottom of the current buffer. +function! tlib#buffer#ScratchStart() "{{{3 + norm! Go + let b:tlib_inbuffer_scratch = line('$') + return b:tlib_inbuffer_scratch +endf + + +" Remove the in-buffer scratch area. +function! tlib#buffer#ScratchEnd() "{{{3 + if !exists('b:tlib_inbuffer_scratch') + echoerr 'tlib: In-buffer scratch not initalized' + endif + call tlib#buffer#DeleteRange(b:tlib_inbuffer_scratch, line('$')) + unlet b:tlib_inbuffer_scratch +endf + + +" Run exec on all buffers via bufdo and return to the original buffer. +function! tlib#buffer#BufDo(exec) "{{{3 + let bn = bufnr('%') + exec 'bufdo '. a:exec + exec 'buffer! '. bn +endf + + +" :def: function! tlib#buffer#InsertText(text, keyargs) +" Keyargs: +" 'shift': 0|N +" 'col': col('.')|N +" 'lineno': line('.')|N +" 'indent': 0|1 +" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) +" Insert text (a string) in the buffer. +function! tlib#buffer#InsertText(text, ...) "{{{3 + TVarArg ['keyargs', {}] + TKeyArg keyargs, ['shift', 0], ['col', col('.')], ['lineno', line('.')], ['pos', 'e'], + \ ['indent', 0] + " TLogVAR shift, col, lineno, pos, indent + let line = getline(lineno) + if col + shift > 0 + let pre = line[0 : (col - 1 + shift)] + let post = line[(col + shift): -1] + else + let pre = '' + let post = line + endif + " TLogVAR lineno, line, pre, post + let text0 = pre . a:text . post + let text = split(text0, '\n', 1) + " TLogVAR text + let icol = len(pre) + " exec 'norm! '. lineno .'G' + call cursor(lineno, col) + if indent && col > 1 + if &fo =~# '[or]' + " This doesn't work because it's not guaranteed that the + " cursor is set. + let cline = getline('.') + norm! a + "norm! o + " TAssertExec redraw | sleep 3 + let idt = strpart(getline('.'), 0, col('.') + shift) + " TLogVAR idt + let idtl = len(idt) + -1,.delete + " TAssertExec redraw | sleep 3 + call append(lineno - 1, cline) + call cursor(lineno, col) + " TAssertExec redraw | sleep 3 + if idtl == 0 && icol != 0 + let idt = matchstr(pre, '^\s\+') + let idtl = len(idt) + endif + else + let [m_0, idt, iline; rest] = matchlist(pre, '^\(\s*\)\(.*\)$') + let idtl = len(idt) + endif + if idtl < icol + let idt .= repeat(' ', icol - idtl) + endif + " TLogVAR idt + for i in range(1, len(text) - 1) + let text[i] = idt . text[i] + endfor + " TLogVAR text + endif + " exec 'norm! '. lineno .'Gdd' + norm! dd + call append(lineno - 1, text) + let tlen = len(text) + let posshift = matchstr(pos, '\d\+') + if pos =~ '^e' + exec lineno + tlen - 1 + exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' + elseif pos =~ '^s' + exec lineno + exec 'norm! '. len(pre) .'|' + if !empty(posshift) + exec 'norm! '. posshift .'h' + endif + endif + " TLogDBG string(getline(1, '$')) +endf + + +function! tlib#buffer#InsertText0(text, ...) "{{{3 + TVarArg ['keyargs', {}] + let mode = get(keyargs, 'mode', 'i') + " TLogVAR mode + if !has_key(keyargs, 'shift') + let col = col('.') + " if mode =~ 'i' + " let col += 1 + " endif + let keyargs.shift = col >= col('$') ? 0 : -1 + " let keyargs.shift = col('.') >= col('$') ? 0 : -1 + " TLogVAR col + " TLogDBG col('.') .'-'. col('$') .': '. string(getline('.')) + endif + " TLogVAR keyargs.shift + return tlib#buffer#InsertText(a:text, keyargs) +endf + + +function! tlib#buffer#CurrentByte() "{{{3 + return line2byte(line('.')) + col('.') +endf + diff --git a/conf_slk120/vim/_vim/autoload/tlib/cache.vim b/conf_slk120/vim/_vim/autoload/tlib/cache.vim new file mode 100644 index 0000000..254e262 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/cache.vim @@ -0,0 +1,70 @@ +" cache.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2007-11-01. +" @Revision: 0.1.28 + +if &cp || exists("loaded_tlib_cache_autoload") + finish +endif +let loaded_tlib_cache_autoload = 1 + + +" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0) +function! tlib#cache#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let dir = tlib#var#Get('tlib_cache', 'wbg') + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) + endif + if a:0 >= 1 && !empty(a:1) + let file = a:1 + else + if empty(expand('%:t')) + return '' + endif + let file = expand('%:p') + let file = tlib#file#Relative(file, tlib#file#Join([dir, '..'])) + endif + " TLogVAR file, dir + let mkdir = a:0 >= 2 ? a:2 : 0 + let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g') + let dirs = [dir, a:type] + let dirf = fnamemodify(file, ':h') + if dirf != '.' + call add(dirs, dirf) + endif + let dir = tlib#file#Join(dirs) + " TLogVAR dir + let dir = tlib#dir#PlainName(dir) + " TLogVAR dir + let file = fnamemodify(file, ':t') + " TLogVAR file, dir + if mkdir && !isdirectory(dir) + call mkdir(dir, 'p') + endif + let cache_file = tlib#file#Join([dir, file]) + " TLogVAR cache_file + return cache_file +endf + + +function! tlib#cache#Save(cfile, dictionary) "{{{3 + if !empty(a:cfile) + call writefile([string(a:dictionary)], a:cfile, 'b') + endif +endf + + +function! tlib#cache#Get(cfile) "{{{3 + if !empty(a:cfile) && filereadable(a:cfile) + let val = readfile(a:cfile, 'b') + return eval(join(val, "\n")) + else + return {} + endif +endf + + diff --git a/conf_slk120/vim/_vim/autoload/tlib/char.vim b/conf_slk120/vim/_vim/autoload/tlib/char.vim new file mode 100644 index 0000000..d485c37 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/tlib/char.vim @@ -0,0 +1,58 @@ +" char.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2007-10-21. +" @Revision: 0.0.29 + +if &cp || exists("loaded_tlib_char_autoload") + finish +endif +let loaded_tlib_char_autoload = 1 + + +" :def: function! tlib#char#Get(?timeout=0) +" Get a character. +" +" EXAMPLES: > +" echo tlib#char#Get() +" echo tlib#char#Get(5) +function! tlib#char#Get(...) "{{{3 + TVarArg ['timeout', 0], ['resolution', 0] + if timeout == 0 || !has('reltime') + return getchar() + else + return tlib#char#GetWithTimeout(timeout, resolution) + endif + return -1 +endf + + +function! tlib#char#IsAvailable() "{{{3 + let ch = getchar(1) + return type(ch) == 0 && ch != 0 +endf + + +function! tlib#char#GetWithTimeout(timeout, ...) "{{{3 + TVarArg ['resolution', 2] + " TLogVAR a:timeout, resolution + let start = tlib#time#MSecs() + while 1 + let c = getchar(0) + if type(c) != 0 || c != 0 + return c + else + let now = tlib#time#MSecs() + let diff = tlib#time#DiffMSecs(now, start, resolution) + " TLogVAR diff + if diff > a:timeout + return -1 + endif + endif + endwh + return -1 +endf + + diff --git a/conf_slk120/vim/_vim/autoload/viki.vim b/conf_slk120/vim/_vim/autoload/viki.vim new file mode 100644 index 0000000..7e037ae --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/viki.vim @@ -0,0 +1,2432 @@ +" viki.vim +" @Author: Thomas Link (micathom AT gmail com?subject=vim-viki) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-03-25. +" @Last Change: 2008-06-22. +" @Revision: 0.460 + +if &cp || exists("loaded_viki_auto") "{{{2 + finish +endif +let loaded_viki_auto = 1 + +""" General {{{1 + +" Outdated way to keep cursor information +function! s:ResetSavedCursorPosition() "{{{3 + let s:cursorSet = -1 + let s:cursorCol = -1 + let s:cursorVCol = -1 + let s:cursorLine = -1 + let s:cursorWinTLine = -1 + let s:cursorEol = 0 + let s:lazyredraw = &lazyredraw +endf + +call s:ResetSavedCursorPosition() + +" Outdated: a cheap implementation of printf +function! s:sprintf1(string, arg) "{{{3 + if exists('printf') + return printf(string, a:arg) + else + let rv = substitute(a:string, '\C[^%]\zs%s', escape(a:arg, '"\'), 'g') + let rv = substitute(rv, '%%', '%', 'g') + return rv + end +endf + +let s:InterVikiRx = '^\(['. g:vikiUpperCharacters .']\+\)::\(.*\)$' +let s:InterVikis = [] + +" Define an interviki name +" viki#Define(name, prefix, ?suffix="*", ?index="Index.${suffix}") +" suffix == "*" -> g:vikiNameSuffix +function! viki#Define(name, prefix, ...) "{{{3 + if a:name =~ '[^A-Z]' + throw 'Invalid interviki name: '. a:name + endif + call add(s:InterVikis, a:name .'::') + call sort(s:InterVikis) + let g:vikiInter{a:name} = a:prefix + let g:vikiInter{a:name}_suffix = a:0 >= 1 && a:1 != '*' ? a:1 : g:vikiNameSuffix + let index = a:0 >= 2 && a:2 != '' ? a:2 : g:vikiIndex + let findex = fnamemodify(g:vikiInter{a:name} .'/'. index . g:vikiInter{a:name}_suffix, ':p') + if filereadable(findex) + let vname = viki#MakeName(a:name, index, 0) + let g:vikiInter{a:name}_index = index + else + " let vname = '[['. a:name .'::]]' + let vname = a:name .'::' + end + " let vname = escape(vname, ' \%#') + " exec 'command! -bang -nargs=? -complete=customlist,viki#EditComplete '. a:name .' call viki#Edit(escape(empty() ?'. string(vname) .' : , "#"), "")' + exec 'command! -bang -nargs=? -complete=customlist,viki#EditComplete '. a:name .' call viki#Edit(empty() ?'. string(vname) .' : viki#InterEditArg('. string(a:name) .', ), "")' + if g:vikiMenuPrefix != '' + if g:vikiMenuLevel > 0 + let name = [ a:name[0 : g:vikiMenuLevel - 1] .'&'. a:name[g:vikiMenuLevel : -1] ] + let weight = [] + for i in reverse(range(g:vikiMenuLevel)) + call insert(name, a:name[i]) + call insert(weight, char2nr(a:name[i]) + 500) + endfor + let ml = len(split(g:vikiMenuPrefix, '[^\\]\zs\.')) + let mw = repeat('500.', ml) . join(weight, '.') + else + let name = [a:name] + let mw = '' + endif + exec 'amenu '. mw .' '. g:vikiMenuPrefix . join(name, '.') .' :VikiEdit! '. vname .'' + endif +endf + +for [s:iname, s:idef] in items(g:viki_intervikis) + " viki#Define(name, prefix, ?suffix="*", ?index="Index.${suffix}") + if type(s:idef) == 1 + call call('viki#Define', [s:iname, s:idef]) + else + call call('viki#Define', [s:iname] + s:idef) + endif + unlet! s:iname s:idef +endfor + +function! s:AddToRegexp(regexp, pattern) "{{{3 + if a:pattern == '' + return a:regexp + elseif a:regexp == '' + return a:pattern + else + return a:regexp .'\|'. a:pattern + endif +endf + +" Make all filenames use slashes +function! viki#CanonicFilename(fname) "{{{3 + return substitute(simplify(a:fname), '[\/]\+', '/', 'g') +endf + +" Build the rx to find viki names +function! viki#FindRx() "{{{3 + let rx = s:AddToRegexp('', b:vikiSimpleNameSimpleRx) + let rx = s:AddToRegexp(rx, b:vikiExtendedNameSimpleRx) + let rx = s:AddToRegexp(rx, b:vikiUrlSimpleRx) + return rx +endf + +" Wrap edit commands. Every action that creates a new buffer should use +" this function. +function! s:EditWrapper(cmd, fname) "{{{3 + " TLogVAR a:cmd, a:fname + let fname = escape(simplify(a:fname), ' %#') + " let fname = escape(simplify(a:fname), '%#') + if a:cmd =~ g:vikiNoWrapper + " TLogDBG a:cmd .' '. fname + " echom 'No wrapper: '. a:cmd .' '. fname + exec a:cmd .' '. fname + else + try + if g:vikiHide == 'hide' + " TLogDBG 'hide '. a:cmd .' '. fname + exec 'hide '. a:cmd .' '. fname + elseif g:vikiHide == 'update' + update + " TLogDBG a:cmd .' '. fname + exec a:cmd .' '. fname + else + " TLogDBG a:cmd .' '. fname + exec a:cmd .' '. fname + endif + catch /^Vim\%((\a\+)\)\=:E37/ + echoerr "Vim raised E37: You tried to abondon a dirty buffer (see :h E37)" + echoerr "Viki: You may want to reconsider your g:vikiHide or 'hidden' settings" + catch /^Vim\%((\a\+)\)\=:E325/ + " catch + " echohl error + " echom v:errmsg + " echohl NONE + endtry + endif +endf + +" Find the previous heading +function! viki#FindPrevHeading() + let vikisr=@/ + let cl = getline('.') + if cl =~ '^\*' + let head = matchstr(cl, '^\*\+') + let head = '*\{1,'. len(head) .'}' + else + let head = '*\+' + endif + call search('\V\^'. head .'\s', 'bW') + let @/=vikisr +endf + +" Find the next heading +function! viki#FindNextHeading() + let pos = getpos('.') + " TLogVAR pos + let cl = getline('.') + " TLogDBG 'line0='. cl + if cl =~ '^\*' + let head = matchstr(cl, '^\*\+') + let head = '*\{1,'. len(head) .'}' + else + let head = '*\+' + endif + " TLogDBG 'head='. head + " TLogVAR pos + call setpos('.', pos) + let vikisr = @/ + call search('\V\^'. head .'\s', 'W') + let @/=vikisr +endf + +" Test whether we want to markup a certain viki name type for the current +" buffer +" viki#IsSupportedType(type, ?types=b:vikiNameTypes) +function! viki#IsSupportedType(type, ...) "{{{3 + if a:0 >= 1 + let types = a:1 + elseif exists('b:vikiNameTypes') + let types = b:vikiNameTypes + else + let types = g:vikiNameTypes + end + if types == '' + return 1 + else + " return stridx(b:vikiNameTypes, a:type) >= 0 + return types =~# '['. a:type .']' + endif +endf + +" Build an rx from a list of names +function! viki#RxFromCollection(coll) "{{{3 + " TAssert IsList(a:coll) + let rx = join(a:coll, '\|') + if rx == '' + return '' + else + return '\V\('. rx .'\)' + endif +endf + +" Mark inexistent viki names +" VikiMarkInexistent(line1, line2, ?maxcol, ?quick) +" maxcol ... check only up to maxcol +" quick ... check only if the cursor is located after a link +function! s:MarkInexistent(line1, line2, ...) "{{{3 + if !exists('b:vikiMarkInexistent') || !b:vikiMarkInexistent + return + endif + if s:cursorCol == -1 + " let cursorRestore = 1 + let li0 = line('.') + let co0 = col('.') + let co1 = co0 - 1 + else + " let cursorRestore = 0 + let li0 = s:cursorLine + let co0 = s:cursorCol + let co1 = co0 - 2 + end + if a:0 >= 2 && a:2 > 0 && synIDattr(synID(li0, co1, 1), 'name') !~ '^viki.*Link$' + return + endif + + let lazyredraw = &lazyredraw + set lazyredraw + + let maxcol = a:0 >= 1 ? (a:1 == -1 ? 9999999 : a:1) : 9999999 + + if a:line1 > 0 + keepjumps call cursor(a:line1, 1) + let min = a:line1 + else + go + let min = 1 + endif + let max = a:line2 > 0 ? a:line2 : line('$') + + if line('.') == 1 && line('$') == max + let b:vikiNamesNull = [] + let b:vikiNamesOk = [] + else + if !exists('b:vikiNamesNull') | let b:vikiNamesNull = [] | endif + if !exists('b:vikiNamesOk') | let b:vikiNamesOk = [] | endif + endif + let b:vikiNamesNull0 = copy(b:vikiNamesNull) + let b:vikiNamesOk0 = copy(b:vikiNamesOk) + + let feedback = (max - min) > b:vikiFeedbackMin + let b:vikiMarkingInexistent = 1 + try + if feedback + call tlib#progressbar#Init(line('$'), 'Viki: Mark inexistent %s', 20) + endif + + " if line('.') == 1 + " keepjumps norm! G$ + " else + " keepjumps norm! k$ + " endif + + let rx = viki#FindRx() + let pp = 0 + let ll = 0 + let cc = 0 + keepjumps let li = search(rx, 'Wc', max) + let co = col('.') + while li != 0 && !(ll == li && cc == co) && li >= min && li <= max && co <= maxcol + let lic = line('.') + if synIDattr(synID(lic, col('.'), 1), "name") !~ '^vikiFiles' + if feedback + call tlib#progressbar#Display(lic) + endif + let ll = li + let co1 = co - 1 + " TLogVAR co1 + let def = viki#GetLink(1, getline('.'), co1) + " TAssert IsList(def) + " TLogDBG getline('.')[co1 : -1] + " TLogVAR def + if empty(def) + echom 'Internal error: VikiMarkInexistent: '. co .' '. getline('.') + else + exec viki#SplitDef(def) + " TLogVAR v_part + if v_part =~ '^'. b:vikiSimpleNameSimpleRx .'$' + if v_dest =~ g:vikiSpecialProtocols + " TLogDBG "v_dest =~ g:vikiSpecialProtocols => 0" + let check = 0 + elseif v:version >= 700 && viki#IsHyperWord(v_part) + " TLogDBG "viki#IsHyperWord(v_part) => 0" + let check = 0 + elseif v_name == g:vikiSelfRef + " TLogDBG "simple self ref" + let check = 0 + else + " TLogDBG "else1 => 1" + let check = 1 + let partx = escape(v_part, "'\"\\/") + if partx !~ '^\[' + let partx = '\<'.partx + endif + if partx !~ '\]$' + let partx = partx.'\>' + endif + endif + elseif v_dest =~ '^'. b:vikiUrlSimpleRx .'$' + " TLogDBG "v_dest =~ '^'. b:vikiUrlSimpleRx .'$' => 0" + let check = 0 + let partx = escape(v_part, "'\"\\/") + call filter(b:vikiNamesNull, 'v:val != partx') + if index(b:vikiNamesOk, partx) == -1 + call insert(b:vikiNamesOk, partx) + endif + elseif v_part =~ b:vikiExtendedNameSimpleRx + if v_dest =~ '^'. g:vikiSpecialProtocols .':' + " TLogDBG "v_dest =~ '^'. g:vikiSpecialProtocols .':' => 0" + let check = 0 + else + " TLogDBG "else2 => 1" + let check = 1 + let partx = escape(v_part, "'\"\\/") + endif + " elseif v_part =~ b:vikiCmdSimpleRx + " <+TBD+> + else + " TLogDBG "else3 => 0" + let check = 0 + endif + " TLogVAR check, v_dest + " if check && v_dest != "" && v_dest != g:vikiSelfRef && !isdirectory(v_dest) + if check && v_dest != g:vikiSelfRef && !isdirectory(v_dest) + if filereadable(v_dest) + call filter(b:vikiNamesNull, 'v:val != partx') + if index(b:vikiNamesOk, partx) == -1 + call insert(b:vikiNamesOk, partx) + endif + else + if index(b:vikiNamesNull, partx) == -1 + call insert(b:vikiNamesNull, partx) + endif + call filter(b:vikiNamesOk, 'v:val != partx') + endif + " TLogVAR partx, b:vikiNamesNull, b:vikiNamesOk + endif + endif + unlet! def + endif + keepjumps let li = search(rx, 'W', max) + let co = col('.') + endwh + if b:vikiNamesOk0 != b:vikiNamesOk || b:vikiNamesNull0 != b:vikiNamesNull + call viki#HighlightInexistent() + if tlib#var#Get('vikiCacheInexistent', 'wbg') + call viki#SaveCache() + endif + endif + let b:vikiCheckInexistent = 0 + finally + " if cursorRestore && !s:cursorSet + " call viki#RestoreCursorPosition(li0, co0) + " endif + if feedback + call tlib#progressbar#Restore() + endif + let &lazyredraw = lazyredraw + unlet! b:vikiMarkingInexistent + endtry +endf + +" Actually highlight inexistent file names +function! viki#HighlightInexistent() "{{{3 + if b:vikiMarkInexistent == 1 + if exists('b:vikiNamesNull') + exe 'syntax clear '. b:vikiInexistentHighlight + let rx = viki#RxFromCollection(b:vikiNamesNull) + if rx != '' + exe 'syntax match '. b:vikiInexistentHighlight .' /'. rx .'/' + endif + endif + elseif b:vikiMarkInexistent == 2 + if exists('b:vikiNamesOk') + syntax clear vikiOkLink + syntax clear vikiExtendedOkLink + let rx = viki#RxFromCollection(b:vikiNamesOk) + if rx != '' + exe 'syntax match vikiOkLink /'. rx .'/' + endif + endif + endif +endf + +" Check a text element for inexistent names +if v:version == 700 && !has('patch8') + function! s:SID() + let fullname = expand("") + return matchstr(fullname, '\d\+_') + endf + + function! viki#MarkInexistentInElement(elt) "{{{3 + let lr = &lazyredraw + set lazyredraw + call viki#SaveCursorPosition() + let kpk = s:SID() . "MarkInexistentIn" . a:elt + call {kpk}() + call viki#RestoreCursorPosition() + call s:ResetSavedCursorPosition() + let &lazyredraw = lr + return '' + endf +else + function! viki#MarkInexistentInElement(elt) "{{{3 + let lr = &lazyredraw + set lazyredraw + " let pos = getpos('.') + " TLogVAR pos + try + call viki#SaveCursorPosition() + call s:MarkInexistentIn{a:elt}() + call viki#RestoreCursorPosition() + call s:ResetSavedCursorPosition() + return '' + finally + " TLogVAR pos + " call setpos('.', pos) + let &lazyredraw = lr + endtry + endf +endif + +function! viki#MarkInexistentInRange(line1, line2) "{{{3 + let lr = &lazyredraw + set lazyredraw + " let pos = getpos('.') + " TLogVAR pos + try + call viki#SaveCursorPosition() + call s:MarkInexistent(a:line1, a:line2) + call viki#RestoreCursorPosition() + call s:ResetSavedCursorPosition() + " call s:MarkInexistent(a:line1, a:line2) + finally + " TLogVAR pos + " call setpos('.', pos) + let &lazyredraw = lr + endtry +endf + +function! s:MarkInexistentInParagraph() "{{{3 + if getline('.') =~ '\S' + call s:MarkInexistent(line("'{"), line("'}")) + endif +endf + +function! s:MarkInexistentInDocument() "{{{3 + call s:MarkInexistent(1, line("$")) +endf + +function! s:MarkInexistentInParagraphVisible() "{{{3 + let l0 = max([line("'{"), line("w0")]) + " let l1 = line("'}") + let l1 = line(".") + call s:MarkInexistent(l0, l1) +endf + +function! s:MarkInexistentInParagraphQuick() "{{{3 + let l0 = line("'{") + let l1 = line("'}") + call s:MarkInexistent(l0, l1, -1, 1) +endf + +function! s:MarkInexistentInLine() "{{{3 + call s:MarkInexistent(line("."), line(".")) +endf + +function! s:MarkInexistentInLineQuick() "{{{3 + call s:MarkInexistent(line("."), line("."), (col('.') + 1), 1) +endf + +" Set values for the cache +function! s:CValsSet(cvals, var) "{{{3 + if exists('b:'. a:var) + let a:cvals[a:var] = b:{a:var} + endif +endf + +" First-time markup of inexistent names. Handles cached values. Called +" from syntax/viki.vim +function! viki#MarkInexistentInitial() "{{{3 + " let save_inexistent = 0 + if tlib#var#Get('vikiCacheInexistent', 'wbg') + let cfile = tlib#cache#Filename('viki_inexistent', '', 1) + " TLogVAR cfile + if getftime(cfile) < getftime(expand('%:p')) + " let cfile = '' + " let save_inexistent = 1 + elseif !empty(cfile) + " if !empty(cfile) + let cvals = tlib#cache#Get(cfile) + " TLogVAR cvals + if !empty(cvals) + for [key, value] in items(cvals) + let b:{key} = value + unlet value + endfor + call viki#HighlightInexistent() + return + endif + endif + else + let cfile = '' + endif + call viki#MarkInexistentInElement('Document') + " if save_inexistent + " call viki#SaveCache(cfile) + " endif +endf + +function! viki#SaveCache(...) "{{{3 + if tlib#var#Get('vikiCacheInexistent', 'wbg') + let cfile = a:0 >= 1 ? a:1 : tlib#cache#Filename('viki_inexistent', '', 1) + if !empty(cfile) + " TLogVAR cfile + let cvals = {} + call s:CValsSet(cvals, 'vikiNamesNull') + call s:CValsSet(cvals, 'vikiNamesOk') + call s:CValsSet(cvals, 'vikiInexistentHighlight') + call s:CValsSet(cvals, 'vikiMarkInexistent') + call tlib#cache#Save(cfile, cvals) + endif + endif +endf + +" The function called from autocommands: re-check for inexistent names +" when re-entering a buffer. +function! viki#CheckInexistent() "{{{3 + if g:vikiEnabled && exists("b:vikiCheckInexistent") && b:vikiCheckInexistent > 0 + call viki#MarkInexistentInRange(b:vikiCheckInexistent, b:vikiCheckInexistent) + endif +endf + +" Initialize buffer-local variables on the basis of other variables "..." +" or from a global variable. +function! viki#SetBufferVar(name, ...) "{{{3 + if !exists('b:'.a:name) + if a:0 > 0 + let i = 1 + while i <= a:0 + exe 'let altVar = a:'. i + if altVar[0] == '*' + exe 'let b:'.a:name.' = '. strpart(altVar, 1) + return + elseif exists(altVar) + exe 'let b:'.a:name.' = '. altVar + return + endif + let i = i + 1 + endwh + throw 'VikiSetBuffer: Couldn't set '. a:name + else + exe 'let b:'.a:name.' = g:'.a:name + endif + endif +endf + +" Get some vimscript code to set a variable from either a buffer-local or +" a global variable +function! s:LetVar(name, var) "{{{3 + if exists('b:'.a:var) + return 'let '.a:name.' = b:'.a:var + elseif exists('g:'.a:var) + return 'let '.a:name.' = g:'.a:var + else + return '' + endif +endf + +" Call a fn.family if existent, call fn otherwise. +" viki#DispatchOnFamily(fn, ?family='', *args) +function! viki#DispatchOnFamily(fn, ...) "{{{3 + let fam = a:0 >= 1 && a:1 != '' ? a:1 : viki#Family() + if !exists('g:loaded_viki_'. fam) + exec 'runtime autoload/viki_'. fam .'.vim' + endif + if fam == '' || !exists('*viki_'.fam.'#'.a:fn) + let cmd = 'viki' + else + let cmd = fam + endif + let cmd .= '#'. a:fn + if a:0 >= 2 + let args = join(map(range(2, a:0), 'string(a:{v:val})'), ', ') + else + let args = '' + endif + " TLogDBG args + " TLogDBG cmd .'('. args .')' + exe 'return viki_'. cmd .'('. args .')' +endf + +function! viki#IsHyperWord(word) "{{{3 + if !exists('b:vikiHyperWordTable') + return 0 + endif + return has_key(b:vikiHyperWordTable, s:CanonicHyperWord(a:word)) +endf + +function! viki#HyperWordValue(word) "{{{3 + return b:vikiHyperWordTable[s:CanonicHyperWord(a:word)] +endf + +function! s:CanonicHyperWord(word) "{{{3 + " return substitute(a:word, '\s\+', '\\s\\+', 'g') + return substitute(a:word, '\s\+', ' ', 'g') +endf + +function! viki#CollectFileWords(table, simpleWikiName) "{{{3 + let patterns = [] + if exists('b:vikiNameSuffix') + call add(patterns, b:vikiNameSuffix) + endif + if g:vikiNameSuffix != '' && index(patterns, g:vikiNameSuffix) == -1 + call add(patterns, g:vikiNameSuffix) + end + let suffix = '.'. expand('%:e') + if suffix != '.' && index(patterns, suffix) == -1 + call add(patterns, suffix) + end + for p in patterns + let files = glob(expand('%:p:h').'/*'. p) + if files != '' + let files_l = split(files, '\n') + call filter(files_l, '!isdirectory(v:val) && v:val != expand("%:p")') + if !empty(files_l) + for w in files_l + let ww = s:CanonicHyperWord(fnamemodify(w, ":t:r")) + if !has_key(a:table, ww) && + \ (a:simpleWikiName == '' || ww !~# a:simpleWikiName) + let a:table[ww] = w + endif + endfor + endif + endif + endfor +endf + + +function! viki#CollectHyperWords(table) "{{{3 + let vikiWordsBaseDir = expand('%:p:h') + for filename in g:vikiHyperWordsFiles + if filename =~ '^\./' + let bn = fnamemodify(filename, ':t') + let filename = vikiWordsBaseDir . filename[1:-1] + let acc = [] + for dir in tlib#file#Split(vikiWordsBaseDir) + call add(acc, dir) + let fn = tlib#file#Join(add(copy(acc), bn)) + call s:CollectVikiWords(a:table, fn, vikiWordsBaseDir) + endfor + else + call s:CollectVikiWords(a:table, filename, vikiWordsBaseDir) + endif + endfor +endf + + +function! s:CollectVikiWords(table, filename, basedir) "{{{3 + " TLogVAR a:filename, a:basedir + if filereadable(a:filename) + let dir = fnamemodify(a:filename, ':p:h') + " TLogVAR dir + call tlib#dir#Push(dir, 1) + try + let hyperWords = readfile(a:filename) + for wl in hyperWords + if wl =~ '^\s*%' + continue + endif + let ml = matchlist(wl, '^\(.\{-}\) *\t\+ *\(.\+\)$') + " let ml = matchlist(wl, '^\(\S\+\) *\t\+ *\(.\+\)$') + " let ml = matchlist(wl, '^\(\S\+\)[[:space:]]\+\(.\+\)$') + if !empty(ml) + let mkey = s:CanonicHyperWord(ml[1]) + let mval = ml[2] + if mval == '-' + if has_key(a:table, mkey) + call remove(a:table, mkey) + endif + elseif !has_key(a:table, mkey) + " TLogVAR mval + " call TLogDBG(viki#IsInterViki(mval)) + if viki#IsInterViki(mval) + let interviki = viki#InterVikiName(mval) + let suffix = viki#InterVikiSuffix(mval, interviki) + let name = viki#InterVikiPart(mval) + " TLogVAR mkey, interviki, suffix, name + let a:table[mkey] = { + \ 'interviki': interviki, + \ 'suffix': suffix, + \ 'name': name, + \ } + else + let a:table[mkey] = tlib#file#Relative(mval, a:basedir) + " TLogVAR mkey, mval, a:basedir, a:table[mkey] + endif + endif + endif + endfor + finally + call tlib#dir#Pop() + endtry + endif +endf + +" Get a rx that matches a simple name +function! viki#GetSimpleRx4SimpleWikiName() "{{{3 + let upper = s:UpperCharacters() + let lower = s:LowerCharacters() + let simpleWikiName = '\<['.upper.']['.lower.']\+\(['.upper.']['.lower.'0-9]\+\)\+\>' + " This will mistakenly highlight words like LaTeX + " let simpleWikiName = '\<['.upper.']['.lower.']\+\(['.upper.']['.lower.'0-9]\+\)\+' + return simpleWikiName +endf + +" Return a viki name for a vikiname on a specified interviki +" viki#MakeName(iviki, name, ?quote=1) +function! viki#MakeName(iviki, name, ...) "{{{3 + let quote = a:0 >= 1 ? a:1 : 1 + let name = a:name + if quote && name !~ '\C'. viki#GetSimpleRx4SimpleWikiName() + let name = '[-'. name .'-]' + endif + if a:iviki != '' + let name = a:iviki .'::'. name + endif + return name +endf + +" Return a string defining upper-case characters +function! s:UpperCharacters() "{{{3 + return exists('b:vikiUpperCharacters') ? b:vikiUpperCharacters : g:vikiUpperCharacters +endf + +" Return a string defining lower-case characters +function! s:LowerCharacters() "{{{3 + return exists('b:vikiLowerCharacters') ? b:vikiLowerCharacters : g:vikiLowerCharacters +endf + +" Remove backslashes from string +function! s:StripBackslash(string) "{{{3 + return substitute(a:string, '\\\(.\)', '\1', 'g') +endf + +" Map a key that triggers checking for inexistent names +function! viki#MapMarkInexistent(key, element) "{{{3 + if a:key == "\n" + let key = '' + elseif a:key == ' ' + let key = '' + else + let key = a:key + endif + let arg = maparg(key, 'i') + if arg == '' + let arg = key + endif + let map = '=viki#MarkInexistentInElement("'. a:element .'")' + let map = stridx(g:vikiMapBeforeKeys, a:key) != -1 ? arg.map : map.arg + exe 'inoremap '. key .' '. map +endf + + +" In case this function gets called repeatedly for the same position, check only once. +let s:hookcursormoved_oldpos = [] +function! viki#HookCheckPreviousPosition(mode) "{{{3 + " if a:mode == 'n' + if s:hookcursormoved_oldpos != b:hookcursormoved_oldpos + keepjumps keepmarks call s:MarkInexistent(b:hookcursormoved_oldpos[1], b:hookcursormoved_oldpos[1]) + let s:hookcursormoved_oldpos = b:hookcursormoved_oldpos + endif +endf + + +" Restore the cursor position +" TODO: adapt for vim7 +" viki#RestoreCursorPosition(?line, ?VCol, ?EOL, ?Winline) +function! viki#RestoreCursorPosition(...) "{{{3 + " let li = a:0 >= 1 && a:1 != '' ? a:1 : s:cursorLine + " " let co = a:0 >= 2 && a:2 != '' ? a:2 : s:cursorVCol + " let co = a:0 >= 2 && a:2 != '' ? a:2 : s:cursorCol + " " let eol = a:0 >= 3 && a:3 != '' ? a:3 : s:cursorEol + " let wli = a:0 >= 4 && a:4 != '' ? a:4 : s:cursorWinTLine + let li = s:cursorLine + let co = s:cursorCol + let wli = s:cursorWinTLine + if li >= 0 + let ve = &virtualedit + set virtualedit=all + if wli > 0 + exe 'keepjumps norm! '. wli .'zt' + endif + " TLogVAR li, co + call cursor(li, co) + let &virtualedit = ve + endif +endf + +" Save the cursor position +" TODO: adapt for vim7 +function! viki#SaveCursorPosition() "{{{3 + let ve = &virtualedit + set virtualedit=all + " let s:lazyredraw = &lazyredraw + " set nolazyredraw + let s:cursorSet = 1 + let s:cursorCol = col('.') + let s:cursorEol = (col('.') == col('$')) + let s:cursorVCol = virtcol('.') + if s:cursorEol + let s:cursorVCol = s:cursorVCol + 1 + endif + let s:cursorLine = line('.') + keepjumps norm! H + let s:cursorWinTLine = line('.') + call cursor(s:cursorLine, s:cursorCol) + let &virtualedit = ve + " call viki#DebugCursorPosition() + return '' +endf + +" Display a debug message +function! viki#DebugCursorPosition(...) "{{{3 + let msg = 'DBG ' + if a:0 >= 1 && a:1 != '' + let msg = msg . a:1 .' ' + endif + let msg = msg . "s:cursorCol=". s:cursorCol + \ ." s:cursorEol=". s:cursorEol + \ ." ($=". col('$') .')' + \ ." s:cursorVCol=". s:cursorVCol + \ ." s:cursorLine=". s:cursorLine + \ ." s:cursorWinTLine=". s:cursorWinTLine + if a:0 >= 2 && a:2 + echo msg + else + echom msg + endif +endf + +" Check if the key maps should support a specified functionality +function! viki#MapFunctionality(mf, key) + return a:mf == 'ALL' || (a:mf =~# '\<'. a:key .'\>') +endf + +" Re-set minor mode if the buffer is already in viki minor mode. +function! viki#MinorModeReset() "{{{3 + if exists("b:vikiEnabled") && b:vikiEnabled == 1 + call viki#DispatchOnFamily('MinorMode', '', 1) + endif +endf + +" Check whether line is within a region syntax +function! viki#IsInRegion(line) "{{{3 + let i = 0 + let max = col('$') + while i < max + if synIDattr(synID(a:line, i, 1), "name") == "vikiRegion" + return 1 + endif + let i = i + 1 + endw + return 0 +endf + +" Set back references for use with viki#GoBack() +function! s:SetBackRef(file, li, co) "{{{3 + let br = s:GetBackRef() + call filter(br, 'v:val[0] != a:file') + call insert(br, [a:file, a:li, a:co]) +endf + +" Retrieve a certain back reference +function! s:SelectThisBackRef(n) "{{{3 + return 'let [vbf, vbl, vbc] = s:GetBackRef()['. a:n .']' +endf + +" Select a back reference +function! s:SelectBackRef(...) "{{{3 + if a:0 >= 1 && a:1 >= 0 + let s = a:1 + else + let br = s:GetBackRef() + let br0 = map(copy(br), 'v:val[0]') + let st = tlib#input#List('s', 'Select Back Reference', br0) + if st != '' + let s = index(br0, st) + else + let s = -1 + endif + endif + if s >= 0 + return s:SelectThisBackRef(s) + endif + return '' +endf + +" Retrieve information for back references +function! s:GetBackRef() + if g:vikiSaveHistory + let id = expand('%:p') + if empty(id) + return [] + else + if !has_key(g:VIKIBACKREFS, id) + let g:VIKIBACKREFS[id] = [] + endif + return g:VIKIBACKREFS[id] + endif + else + if !exists('b:VIKIBACKREFS') + let b:VIKIBACKREFS = [] + endif + return b:VIKIBACKREFS + endif +endf + +" Jump to the parent buffer (or go back in history) +function! viki#GoParent() "{{{3 + if exists('b:vikiParent') + call viki#Edit(b:vikiParent) + else + call viki#GoBack() + endif +endf + +" Go back in history +function! viki#GoBack(...) "{{{3 + let s = (a:0 >= 1) ? a:1 : -1 + let br = s:SelectBackRef(s) + if br == '' + echomsg "Viki: No back reference defined? (". s ."/". br .")" + else + exe br + let buf = bufnr("^". vbf ."$") + if buf >= 0 + call s:EditWrapper('buffer', buf) + else + call s:EditWrapper('edit', vbf) + endif + if vbf == expand("%:p") + call cursor(vbl, vbc) + else + throw "Viki: Couldn't open file: ". vbf + endif + endif +endf + +" Expand template strings as in +" "foo %{FILE} bar", 'FILE', 'file.txt' => "foo file.txt bar" +function! viki#SubstituteArgs(str, ...) "{{{3 + let i = 1 + " let rv = escape(a:str, '\') + let rv = a:str + let default = '' + let done = 0 + while a:0 >= i + exec "let lab = a:". i + exec "let val = a:". (i+1) + if lab == '' + let default = val + else + let rv0 = substitute(rv, '\C\(^\|[^%]\)\zs%{'. lab .'}', escape(val, '\&'), "g") + if rv != rv0 + let done = 1 + let rv = rv0 + endif + endif + let i = i + 2 + endwh + if !done + let rv .= ' '. default + end + let rv = substitute(rv, '%%', "%", "g") + return rv +endf + +" Handle special anchors in extented viki names +" Example: [[index#l=10]] +if !exists('*VikiAnchor_l') "{{{2 + function! VikiAnchor_l(arg) "{{{3 + if a:arg =~ '^\d\+$' + exec a:arg + endif + endf +endif + +" Example: [[index#line=10]] +if !exists('*VikiAnchor_line') "{{{2 + function! VikiAnchor_line(arg) "{{{3 + call VikiAnchor_l(a:arg) + endf +endif + +" Example: [[index#rx=foo]] +if !exists('*VikiAnchor_rx') "{{{2 + function! VikiAnchor_rx(arg) "{{{3 + let arg = escape(s:StripBackslash(a:arg), '/') + exec 'keepjumps norm! gg/'. arg .' ' + endf +endif + +" Example: [[index#vim=/foo]] +if !exists('*VikiAnchor_vim') "{{{2 + function! VikiAnchor_vim(arg) "{{{3 + exec s:StripBackslash(a:arg) + endf +endif + +" Return an rx for searching anchors +function! viki#GetAnchorRx(anchor) + " TLogVAR a:anchor + let anchorRx = tlib#var#Get('vikiAnchorMarker', 'wbg') . a:anchor + if exists('b:vikiEnabled') + let anchorRx = '\^\s\*\('. b:vikiCommentStart .'\)\?\s\*'. anchorRx + if exists('b:vikiAnchorRx') + " !!! b:vikiAnchorRx must be a very nomagic (\V) regexp + " expression + let varx = viki#SubstituteArgs(b:vikiAnchorRx, 'ANCHOR', a:anchor) + let anchorRx = '\('.anchorRx.'\|'. varx .'\)' + endif + endif + " TLogVAR anchorRx + return '\V'. anchorRx +endf + +" Set automatic anchor marks: #ma => 'a +function! viki#SetAnchorMarks() "{{{3 + let pos = getpos(".") + " TLogVAR pos + let sr = @/ + let anchorRx = viki#GetAnchorRx('m\(\[a-zA-Z]\)\s\*\$') + " exec 'silent keepjumps g /'. anchorRx .'/exec "norm! m". substitute(getline("."), anchorRx, ''\2'', "")' + exec 'silent keepjumps g /'. anchorRx .'/exec "norm! m". matchlist(getline("."), anchorRx)[1]' + let @/ = sr + " TLogVAR pos + call setpos('.', pos) +endf + +" Get the window number where the destination file should be opened +function! viki#GetWinNr(...) "{{{3 + let winNr = a:0 >= 1 ? a:1 : 0 + " TLogVAR winNr + if type(winNr) == 0 && winNr == 0 + if exists('b:vikiSplit') + let winNr = b:vikiSplit + elseif exists('g:vikiSplit') + let winNr = g:vikiSplit + else + let winNr = 0 + endif + endif + return winNr +endf + +" Set the window where to open a file/display a buffer +function! viki#SetWindow(winNr) "{{{3 + let winNr = viki#GetWinNr(a:winNr) + " TLogVAR winNr + if type(winNr) == 1 && winNr == 'tab' + tabnew + elseif winNr != 0 + let wm = s:HowManyWindows() + if winNr == -2 + wincmd v + elseif wm == 1 || winNr == -1 + wincmd s + else + exec winNr ."wincmd w" + end + endif +endf + +" Open a filename in a certain window and jump to an anchor if any +" viki#OpenLink(filename, anchor, ?create=0, ?postcmd='', ?wincmd=0) +function! viki#OpenLink(filename, anchor, ...) "{{{3 + " TLogVAR a:filename + let create = a:0 >= 1 ? a:1 : 0 + let postcmd = a:0 >= 2 ? a:2 : '' + if a:0 >= 3 + let winNr = a:3 + elseif exists('b:vikiNextWindow') + let winNr = b:vikiNextWindow + else + let winNr = 0 + endif + " TLogVAR winNr + + let li = line('.') + let co = col('.') + let fi = expand('%:p') + + let filename = fnamemodify(a:filename, ':p') + if exists('*simplify') + let filename = simplify(filename) + endif + " TLogVAR filename + let buf = bufnr('^'. filename .'$') + call viki#SetWindow(winNr) + if buf >= 0 && bufloaded(buf) + call s:EditLocalFile('buffer', buf, fi, li, co, a:anchor) + elseif create && exists('b:createVikiPage') + call s:EditLocalFile(b:createVikiPage, filename, fi, li, co, g:vikiDefNil) + elseif exists('b:editVikiPage') + call s:EditLocalFile(b:editVikiPage, filename, fi, li, co, g:vikiDefNil) + elseif isdirectory(filename) + call s:EditLocalFile(g:vikiExplorer, tlib#dir#PlainName(filename), fi, li, co, g:vikiDefNil) + else + call s:EditLocalFile('edit', filename, fi, li, co, a:anchor) + endif + if postcmd != '' + exec postcmd + endif +endf + +" Open a local file in vim +function! s:EditLocalFile(cmd, fname, fi, li, co, anchor) "{{{3 + " TLogVAR a:cmd, a:fname + let vf = viki#Family() + let cb = bufnr('%') + call tlib#dir#Ensure(fnamemodify(a:fname, ':p:h')) + call s:EditWrapper(a:cmd, a:fname) + if cb != bufnr('%') + set buflisted + endif + if vf != '' + let b:vikiFamily = vf + endif + call s:SetBackRef(a:fi, a:li, a:co) + if g:vikiPromote && (!exists('b:vikiEnabled') || !b:vikiEnable) + call viki#DispatchOnFamily('MinorMode', vf, 1) + endif + call viki#DispatchOnFamily('FindAnchor', vf, a:anchor) +endf + +" Get the current viki family +function! viki#Family(...) "{{{3 + let anyway = a:0 >= 1 ? a:1 : 0 + if (anyway || (exists('b:vikiEnabled') && b:vikiEnabled)) && exists('b:vikiFamily') && !empty(b:vikiFamily) + return b:vikiFamily + else + return g:vikiFamily + endif +endf + +" Return the number of windows +function! s:HowManyWindows() "{{{3 + let i = 1 + while winbufnr(i) > 0 + let i = i + 1 + endwh + return i - 1 +endf + +" Decompose an url into filename, anchor, args +function! viki#DecomposeUrl(dest) "{{{3 + let dest = substitute(a:dest, '^\c/*\([a-z]\)|', '\1:', "") + let rv = "" + let i = 0 + while 1 + let in = match(dest, '%\d\d', i) + if in >= 0 + let c = "0x".strpart(dest, in + 1, 2) + let rv = rv. strpart(dest, i, in - i) . nr2char(c) + let i = in + 3 + else + break + endif + endwh + let rv = rv. strpart(dest, i) + let uend = match(rv, '[?#]') + if uend >= 0 + let args = matchstr(rv, '?\zs.\+$', uend) + let anchor = matchstr(rv, '#\zs.\+$', uend) + let rv = strpart(rv, 0, uend) + else + let args = "" + let anchor = "" + let rv = rv + end + return "let filename='". rv ."'|let anchor='". anchor ."'|let args='". args ."'" +endf + +" Get a list of special files' suffixes +function! viki#GetSpecialFilesSuffixes() "{{{3 + " TAssert IsList(g:vikiSpecialFiles) + if exists("b:vikiSpecialFiles") + " TAssert IsList(b:vikiSpecialFiles) + return b:vikiSpecialFiles + g:vikiSpecialFiles + else + return g:vikiSpecialFiles + endif +endf + +" Get an rx matching special files' suffixes +function! viki#GetSpecialFilesSuffixesRx(...) "{{{3 + let sfx = a:0 >= 1 ? a:1 : viki#GetSpecialFilesSuffixes() + return join(sfx, '\|') +endf + +" Check if dest is a special file +function! viki#IsSpecialFile(dest) "{{{3 + return (a:dest =~ '\.\('. viki#GetSpecialFilesSuffixesRx() .'\)$' && + \ (g:vikiSpecialFilesExceptions == "" || + \ !(a:dest =~ g:vikiSpecialFilesExceptions))) +endf + +" Check if dest uses a special protocol +function! viki#IsSpecialProtocol(dest) "{{{3 + return a:dest =~ '^\('.b:vikiSpecialProtocols.'\):' && + \ (b:vikiSpecialProtocolsExceptions == "" || + \ !(a:dest =~ b:vikiSpecialProtocolsExceptions)) +endf + +" Check if dest is somehow special +function! viki#IsSpecial(dest) "{{{3 + return viki#IsSpecialProtocol(a:dest) || + \ viki#IsSpecialFile(a:dest) || + \ isdirectory(a:dest) +endf + +" Open a viki name/link +function! s:FollowLink(def, ...) "{{{3 + " TLogVAR a:def + let winNr = a:0 >= 1 ? a:1 : 0 + " TLogVAR winNr + exec viki#SplitDef(a:def) + if type(winNr) == 0 && winNr == 0 + " TAssert IsNumber(winNr) + if exists('v_winnr') + let winNr = v_winnr + elseif exists('b:vikiOpenInWindow') + if b:vikiOpenInWindow =~ '^l\(a\(s\(t\)\?\)\?\)\?' + let winNr = s:HowManyWindows() + elseif b:vikiOpenInWindow =~ '^[+-]\?\d\+$' + if b:vikiOpenInWindow[0] =~ '[+-]' + exec 'let winNr = '. bufwinnr("%") . b:vikiOpenInWindow + else + let winNr = b:vikiOpenInWindow + endif + endif + endif + endif + let inter = s:GuessInterViki(a:def) + let bn = bufnr('%') + " TLogVAR v_name, v_dest, v_anchor + if v_name == g:vikiSelfRef || v_dest == g:vikiSelfRef + call viki#DispatchOnFamily('FindAnchor', '', v_anchor) + elseif v_dest == g:vikiDefNil + throw 'No target? '. string(a:def) + else + call s:OpenLink(v_dest, v_anchor, winNr) + endif + if exists('b:vikiEnabled') && b:vikiEnabled && inter != '' && !exists('b:vikiInter') + let b:vikiInter = inter + endif + return "" +endf + +" Actually open a viki name/link +function! s:OpenLink(dest, anchor, winNr) + let b:vikiNextWindow = a:winNr + " TLogVAR a:dest, a:anchor, a:winNr + try + if viki#IsSpecialProtocol(a:dest) + call VikiOpenSpecialProtocol(viki#MakeUrl(a:dest, a:anchor)) + elseif viki#IsSpecialFile(a:dest) + call VikiOpenSpecialFile(a:dest) + elseif isdirectory(a:dest) + " exec g:vikiExplorer .' '. a:dest + call viki#OpenLink(a:dest, a:anchor, 0, '', a:winNr) + elseif filereadable(a:dest) "reference to a local, already existing file + call viki#OpenLink(a:dest, a:anchor, 0, '', a:winNr) + elseif bufexists(a:dest) && buflisted(a:dest) + call s:EditWrapper('buffer!', a:dest) + else + let ok = input("File doesn't exists. Create '".a:dest."'? (Y/n) ", "y") + if ok != "" && ok != "n" + let b:vikiCheckInexistent = line(".") + call viki#OpenLink(a:dest, a:anchor, 1, '', a:winNr) + endif + endif + finally + let b:vikiNextWindow = 0 + endtry +endf + +function! viki#MakeUrl(dest, anchor) "{{{3 + if a:anchor == "" + return a:dest + else + " if a:dest[-1:-1] != '/' + " let dest = a:dest .'/' + " else + " let dest = a:dest + " endif + " return join([dest, a:anchor], '#') + return join([a:dest, a:anchor], '#') + endif +endf + +" Guess the interviki name from a viki name definition +function! s:GuessInterViki(def) "{{{3 + exec viki#SplitDef(a:def) + if v_type == 's' + let exp = v_name + elseif v_type == 'e' + let exp = v_dest + else + return '' + endif + if viki#IsInterViki(exp) + return viki#InterVikiName(exp) + else + return '' + endif +endf + +" Somewhat pointless legacy function +" TODO: adapt for vim7 +function! s:MakeVikiDefPart(txt) "{{{3 + if a:txt == '' + return g:vikiDefNil + else + return a:txt + endif +endf + +" TODO: adapt for vim7 +" Return a structure or whatever describing a viki name/link +function! viki#MakeDef(v_name, v_dest, v_anchor, v_part, v_type) "{{{3 + let arr = map([a:v_name, a:v_dest, a:v_anchor, a:v_part, a:v_type, 0], 's:MakeVikiDefPart(v:val)') + " TLogDBG string(arr) + return arr +endf + +" Legacy function: Today we would use dictionaries for this +" TODO: adapt for vim7 +" Return vimscript code that defines a set of variables on the basis of a +" viki name definition +function! viki#SplitDef(def) "{{{3 + " TAssert IsList(a:def) + " TLogDBG string(a:def) + if empty(a:def) + let rv = 'let [v_name, v_dest, v_anchor, v_part, v_type, v_winnr] = ["", "", "", "", "", ""]' + else + if a:def[4] == 'e' + let mod = viki#ExtendedModifier(a:def[3]) + if mod =~# '*' + let a:def[5] = -1 + endif + endif + let rv = 'let [v_name, v_dest, v_anchor, v_part, v_type, v_winnr] = '. string(a:def) + endif + return rv +endf + +" Get a viki name's/link's name, destination, or anchor +" function! s:GetVikiNamePart(txt, erx, idx, errorMsg) "{{{3 +" if a:idx +" " let rv = substitute(a:txt, '^\C'. a:erx ."$", '\'.a:idx, "") +" let rv = matchlist(a:txt, '^\C'. a:erx ."$")[a:idx] +" if rv == '' +" return g:vikiDefNil +" else +" return rv +" endif +" else +" return g:vikiDefNil +" endif +" endf + +function! s:ExtractMatch(match, idx, default) "{{{3 + if a:idx > 0 + return get(a:match, a:idx, a:default) + else + return a:default + endif +endf + +" If txt matches a viki name typed as defined by compound return a +" structure defining this viki name. +function! viki#LinkDefinition(txt, col, compound, ignoreSyntax, type) "{{{3 + " TLogVAR a:txt, a:compound, a:col + exe a:compound + if erx != '' + let ebeg = -1 + let cont = match(a:txt, erx, 0) + " TLogDBG 'cont='. cont .'('. a:col .')' + while (ebeg >= 0 || (0 <= cont) && (cont <= a:col)) + let contn = matchend(a:txt, erx, cont) + " TLogDBG 'contn='. contn .'('. cont.')' + if (cont <= a:col) && (a:col < contn) + let ebeg = match(a:txt, erx, cont) + let elen = contn - ebeg + break + else + let cont = match(a:txt, erx, contn) + endif + endwh + " TLogDBG 'ebeg='. ebeg + if ebeg >= 0 + let part = strpart(a:txt, ebeg, elen) + let match = matchlist(part, '^\C'. erx .'$') + let name = s:ExtractMatch(match, nameIdx, g:vikiDefNil) + let dest = s:ExtractMatch(match, destIdx, g:vikiDefNil) + let anchor = s:ExtractMatch(match, anchorIdx, g:vikiDefNil) + " let name = s:GetVikiNamePart(part, erx, nameIdx, "no name") + " let dest = s:GetVikiNamePart(part, erx, destIdx, "no destination") + " let anchor = s:GetVikiNamePart(part, erx, anchorIdx, "no anchor") + " TLogVAR name, dest, anchor, part, a:type + return viki#MakeDef(name, dest, anchor, part, a:type) + elseif a:ignoreSyntax + return [] + else + throw "Viki: Malformed viki v_name: " . a:txt . " (". erx .")" + endif + else + return [] + endif +endf + +" Return a viki filename with a suffix +function! viki#WithSuffix(fname) + " TLogVAR a:fname + " TLogDBG isdirectory(a:fname) + if isdirectory(a:fname) + return a:fname + else + return a:fname . s:GetSuffix() + endif +endf + +" Get the suffix to use for viki filenames +function! s:GetSuffix() "{{{3 + if exists('b:vikiNameSuffix') + return b:vikiNameSuffix + endif + if g:vikiUseParentSuffix + let sfx = expand("%:e") + " TLogVAR sfx + if !empty(sfx) + return '.'. sfx + endif + endif + return g:vikiNameSuffix +endf + +" Return the real destination for a simple viki name +function! viki#ExpandSimpleName(dest, name, suffix) "{{{3 + " TLogVAR a:dest + if a:name == '' + return a:dest + else + if a:dest == '' + let dest = a:name + else + let dest = a:dest . g:vikiDirSeparator . a:name + endif + " TLogVAR dest, a:suffix + if a:suffix == g:vikiDefSep + " TLogDBG 'ExpandSimpleName 1' + return viki#WithSuffix(dest) + elseif isdirectory(dest) + " TLogDBG 'ExpandSimpleName 2' + return dest + else + " TLogDBG 'ExpandSimpleName 3' + return dest . a:suffix + endif + endif +endf + +" Check whether a vikiname uses an interviki +function! viki#IsInterViki(vikiname) + return viki#IsSupportedType('i') && a:vikiname =~# s:InterVikiRx +endf + +" Get the interviki name of a vikiname +function! viki#InterVikiName(vikiname) + " return substitute(a:vikiname, s:InterVikiRx, '\1', '') + return matchlist(a:vikiname, s:InterVikiRx)[1] +endf + +" Get the plain vikiname of a vikiname +function! viki#InterVikiPart(vikiname) + " return substitute(a:vikiname, s:InterVikiRx, '\2', '') + return matchlist(a:vikiname, s:InterVikiRx)[2] +endf + +" Return vimscript code describing an interviki +function! s:InterVikiDef(vikiname, ...) + let ow = a:0 >= 1 ? a:1 : viki#InterVikiName(a:vikiname) + let vd = s:LetVar('i_dest', 'vikiInter'.ow) + let id = s:LetVar('i_index', 'vikiInter'.ow.'_index') + " TLogVAR a:vikiname, ow, id + if !empty(id) + let vd .= '|'. id + endif + " TLogVAR vd + if vd != '' + exec vd + if i_dest =~ '^\*\S\+(' + let it = 'fn' + elseif i_dest[0] =~ '%' + let it = 'fmt' + else + let it = 'prefix' + endif + return vd .'|let i_type="'. it .'"|let i_name="'. ow .'"' + end + return vd +endf + +" Return an interviki's root directory +function! viki#InterVikiDest(vikiname, ...) + TVarArg 'ow', ['rx', 0] + " TLogVAR ow, rx + if empty(ow) + let ow = viki#InterVikiName(a:vikiname) + let v_dest = viki#InterVikiPart(a:vikiname) + else + let v_dest = a:vikiname + endif + let vd = s:InterVikiDef(a:vikiname, ow) + " TLogVAR vd + if vd != '' + exec vd + let f = strpart(i_dest, 1) + " TLogVAR i_type, i_dest + if !empty(rx) + let f = s:RxifyFilename(f) + endif + if i_type == 'fn' + exec 'let v_dest = '. s:sprintf1(f, v_dest) + elseif i_type == 'fmt' + let v_dest = s:sprintf1(f, v_dest) + else + if empty(v_dest) && exists('i_index') + let v_dest = i_index + endif + let i_dest = expand(i_dest) + if !empty(rx) + let sep = '[\/]' + let i_dest = s:RxifyFilename(i_dest) + else + let sep = g:vikiDirSeparator + endif + let v_dest = i_dest . sep . v_dest + endif + " TLogVAR v_dest + return v_dest + else + " TLogVAR ow + echohl Error + echom "Viki: InterViki is not defined: ". ow + echohl NONE + return g:vikiDefNil + endif +endf + +function! s:RxifyFilename(filename) "{{{3 + let f = tlib#rx#Escape(a:filename) + if exists('+shellslash') + let f = substitute(f, '\(\\\\\|/\)', '[\\/]', 'g') + endif + return f +endf + +" Return an interviki's suffix +function! viki#InterVikiSuffix(vikiname, ...) + exec tlib#arg#Let(['ow']) + if empty(ow) + let ow = viki#InterVikiName(a:vikiname) + endif + let vd = s:InterVikiDef(a:vikiname, ow) + if vd != '' + exec vd + if i_type =~ 'fn' + return '' + else + if fnamemodify(a:vikiname, ':e') != '' + let useSuffix = '' + else + exec s:LetVar('useSuffix', 'vikiInter'.ow.'_suffix') + endif + return useSuffix + endif + else + return '' + endif +endf + +" Return the modifiers in extended viki names +function! viki#ExtendedModifier(part) + " let mod = substitute(a:part, b:vikiExtendedNameRx, '\'.b:vikiExtendedNameModIdx, '') + let mod = matchlist(a:part, b:vikiExtendedNameRx)[b:vikiExtendedNameModIdx] + if mod != a:part + return mod + else + return '' + endif +endf + +" Complete a file's basename on the basis of a list of suffixes +function! viki#FindFileWithSuffix(filename, suffixes) "{{{3 + " TAssert IsList(a:suffixes) + " TLogVAR a:filename, a:suffixes + if filereadable(a:filename) + return a:filename + else + for elt in a:suffixes + if elt != '' + let fn = a:filename .".". elt + if filereadable(fn) + return fn + endif + else + return g:vikiDefNil + endif + endfor + endif + return g:vikiDefNil +endf + +" Do something if no viki name was found under the cursor position +function! s:LinkNotFoundEtc(oldmap, ignoreSyntax) "{{{3 + if a:oldmap == "" + echomsg "Viki: Show me the way to the next viki name or I have to ... ".a:ignoreSyntax.":".getline(".") + elseif a:oldmap == 1 + return "\" + else + return a:oldmap + endif +endf + +" This is the core function that builds a viki name definition from what +" is under the cursor. +" viki#GetLink(ignoreSyntax, ?txt, ?col=0, ?supported=b:vikiNameTypes) +function! viki#GetLink(ignoreSyntax, ...) "{{{3 + let col = a:0 >= 2 ? a:2 : 0 + let types = a:0 >= 3 ? a:3 : b:vikiNameTypes + if a:0 >= 1 && a:1 != '' + let txt = a:1 + let vikiType = a:ignoreSyntax + let tryAll = 1 + else + let synName = synIDattr(synID(line('.'), col('.'), 0), 'name') + if synName ==# 'vikiLink' + let vikiType = 1 + let tryAll = 0 + elseif synName ==# 'vikiExtendedLink' + let vikiType = 2 + let tryAll = 0 + elseif synName ==# 'vikiURL' + let vikiType = 3 + let tryAll = 0 + elseif synName ==# 'vikiCommand' || synName ==# 'vikiMacro' + let vikiType = 4 + let tryAll = 0 + elseif a:ignoreSyntax + let vikiType = a:ignoreSyntax + let tryAll = 1 + else + return '' + endif + let txt = getline('.') + let col = col('.') - 1 + endif + " TLogDBG "txt=". txt + " TLogDBG "col=". col + " TLogDBG "tryAll=". tryAll + " TLogDBG "vikiType=". tryAll + if (tryAll || vikiType == 2) && viki#IsSupportedType('e', types) + if exists('b:getExtVikiLink') + exe 'let def = ' . b:getExtVikiLink.'()' + else + let def = viki#LinkDefinition(txt, col, b:vikiExtendedNameCompound, a:ignoreSyntax, 'e') + endif + " TAssert IsList(def) + if !empty(def) + return viki#DispatchOnFamily('CompleteExtendedNameDef', '', def) + endif + endif + if (tryAll || vikiType == 3) && viki#IsSupportedType('u', types) + if exists('b:getURLViki') + exe 'let def = ' . b:getURLViki . '()' + else + let def = viki#LinkDefinition(txt, col, b:vikiUrlCompound, a:ignoreSyntax, 'u') + endif + " TAssert IsList(def) + if !empty(def) + return viki#DispatchOnFamily('CompleteExtendedNameDef', '', def) + endif + endif + if (tryAll || vikiType == 4) && viki#IsSupportedType('x', types) + if exists('b:getCmdViki') + exe 'let def = ' . b:getCmdViki . '()' + else + let def = viki#LinkDefinition(txt, col, b:vikiCmdCompound, a:ignoreSyntax, 'x') + endif + " TAssert IsList(def) + if !empty(def) + return viki#DispatchOnFamily('CompleteCmdDef', '', def) + endif + endif + if (tryAll || vikiType == 1) && viki#IsSupportedType('s', types) + if exists('b:getVikiLink') + exe 'let def = ' . b:getVikiLink.'()' + else + let def = viki#LinkDefinition(txt, col, b:vikiSimpleNameCompound, a:ignoreSyntax, 's') + endif + " TLogVAR def + " TAssert IsList(def) + if !empty(def) + return viki#DispatchOnFamily('CompleteSimpleNameDef', '', def) + endif + endif + return [] +endf + +" Follow a viki name if any or complain about not having found a valid +" viki name under the cursor. +" viki#MaybeFollowLink(oldmap, ignoreSyntax, ?winNr=0) +function! viki#MaybeFollowLink(oldmap, ignoreSyntax, ...) "{{{3 + let winNr = a:0 >= 1 ? a:1 : 0 + " TLogVAR winNr + let def = viki#GetLink(a:ignoreSyntax) + " TAssert IsList(def) + if empty(def) + return s:LinkNotFoundEtc(a:oldmap, a:ignoreSyntax) + else + return s:FollowLink(def, winNr) + endif +endf + + +function! viki#InterEditArg(iname, name) "{{{3 + if a:name !~ '^'. tlib#rx#Escape(a:iname) .'::' + return a:iname .'::'. a:name + else + return a:name + endif +endf + + +" Edit a vikiname +" viki#Edit(name, ?bang='', ?winNr=0, ?ìgnoreSpecial=0) +function! viki#Edit(name, ...) "{{{3 + TVarArg ['bang', ''], ['winNr', 0], ['ignoreSpecial', 0] + " TLogVAR a:name + if exists('b:vikiEnabled') && bang != '' && + \ exists('b:vikiFamily') && b:vikiFamily != '' + " \ (!exists('b:vikiFamily') || b:vikiFamily != '') + if g:vikiHomePage != '' + call viki#OpenLink(g:vikiHomePage, '', '', '', winNr) + else + call s:EditWrapper('buffer', 1) + endif + endif + if a:name == '*' + let name = g:vikiHomePage + else + let name = a:name + end + let name = substitute(name, '\\', '/', 'g') + if !exists('b:vikiNameTypes') + call viki#SetBufferVar('vikiNameTypes') + call viki#DispatchOnFamily('SetupBuffer', '', 0) + endif + let def = viki#GetLink(1, '[['. name .']]', 0, '') + " TLogVAR def + " TAssert IsList(def) + if empty(def) + call s:LinkNotFoundEtc('', 1) + else + exec viki#SplitDef(def) + if ignoreSpecial + call viki#OpenLink(v_dest, '', '', '', winNr) + else + call s:OpenLink(v_dest, '', winNr) + endif + endif +endf + + +function! viki#Browse(name) "{{{3 + " TLogVAR a:name + let iname = a:name .'::' + let vd = s:InterVikiDef(iname, a:name) + " TLogVAR vd + if !empty(vd) + exec vd + " TLogVAR i_type + if i_type == 'prefix' + exec s:LetVar('sfx', 'vikiInter'. a:name .'_suffix') + " TLogVAR i_dest, sfx + let files = split(globpath(i_dest, '**'), '\n') + if !empty(sfx) + call filter(files, 'v:val =~ '''. tlib#rx#Escape(sfx) .'$''') + endif + let files = tlib#input#List('m', 'Select files', files, [ + \ {'display_format': 'filename'}, + \ ]) + for fn in files + call viki#OpenLink(fn, g:vikiDefNil) + " echom fn + endfor + return + endif + endif + echoerr 'Viki: No an interviki name: '. a:name +endf + +function! viki#BrowseComplete(ArgLead, CmdLine, CursorPos) "{{{3 + let rv = copy(s:InterVikis) + let rv = filter(rv, 'v:val =~ ''^'. a:ArgLead .'''') + let rv = map(rv, 'matchstr(v:val, ''\w\+'')') + return rv +endf + + +" Helper function for the command line completion of :VikiEdit +function! s:EditCompleteAgent(interviki, afname, fname) "{{{3 + if isdirectory(a:afname) + return a:afname .'/' + else + if exists('g:vikiInter'. a:interviki .'_suffix') + let sfx = g:vikiInter{a:interviki}_suffix + else + let sfx = s:GetSuffix() + endif + if sfx != '' && sfx == '.'. fnamemodify(a:fname, ':e') + let name = fnamemodify(a:fname, ':t:r') + else + let name = a:fname + endif + " if name !~ '\C'. viki#GetSimpleRx4SimpleWikiName() + " let name = '[-'. a:fname .'-]' + " endif + if a:interviki != '' + let name = a:interviki .'::'. name + endif + return name + endif +endf + +" Helper function for the command line completion of :VikiEdit +function! s:EditCompleteMapAgent1(val, sfx, iv, rx) "{{{3 + if isdirectory(a:val) + let rv = a:val .'/' + else + let rsfx = '\V'. a:sfx .'\$' + if a:sfx != '' && a:val !~ rsfx + return '' + else + let rv = substitute(a:val, rsfx, '', '') + if isdirectory(rv) + let rv = a:val + endif + endif + endif + " TLogVAR rv, a:rx + " let rv = substitute(rv, a:rx, '\1', '') + let rv = matchlist(rv, a:rx)[1] + " TLogVAR rv + if empty(a:iv) + return rv + else + return a:iv .'::'. rv + endif +endf + +" Command line completion of :VikiEdit +function! viki#EditComplete(ArgLead, CmdLine, CursorPos) "{{{3 + " TLogVAR a:ArgLead, a:CmdLine, a:CursorPos + let arglead = a:ArgLead + let ii = matchstr(a:CmdLine, '^\s*\(\d*\(verb\|debug\|sil\|sp\|vert\|tab\)\w\+!\?\s\+\)*\zs\(\u\+\)\ze\s') + " TLogVAR ii + if !empty(ii) && arglead !~ '::' + let arglead = ii.'::'.arglead + endif + let i = viki#InterVikiName(arglead) + " TLogVAR i, arglead + if index(s:InterVikis, i.'::') >= 0 + if exists('g:vikiInter'. i .'_suffix') + let sfx = g:vikiInter{i}_suffix + else + let sfx = s:GetSuffix() + endif + else + let i = '' + let sfx = s:GetSuffix() + endif + " TLogVAR i + if i != '' && exists('g:vikiInter'. i) + " TLogDBG 'A' + let f = matchstr(arglead, '::\(\[-\)\?\zs.*$') + let d = viki#InterVikiDest(f.'*', i) + let r = '^'. viki#InterVikiDest('\(.\{-}\)', i, 1) .'$' + " TLogVAR f,d,r + let d = substitute(d, '\', '/', 'g') + let rv = split(glob(d), '\n') + " TLogVAR d,rv + if sfx != '' + call filter(rv, 'isdirectory(v:val) || ".". fnamemodify(v:val, ":e") == sfx') + endif + " TLogVAR rv + call map(rv, 's:EditCompleteMapAgent1(v:val, sfx, i, r)') + " TLogVAR rv + call filter(rv, '!empty(v:val)') + " TLogVAR rv + " call map(rv, string(i). '."::". substitute(v:val, r, ''\1'', "")') + else + " TLogDBG 'B' + let rv = split(glob(arglead.'*'.sfx), '\n') + " TLogVAR rv + call map(rv, 's:EditCompleteAgent('. string(i) .', v:val, v:val)') + " TLogVAR rv + if arglead == '' + let rv += s:InterVikis + else + let rv += filter(copy(s:InterVikis), 'v:val =~ ''\V\^''.arglead') + endif + endif + " TLogVAR rv + " call map(rv, 'escape(v:val, "%# ")') + return rv +endf + +" Edit the current directory's index page +function! viki#Index() "{{{3 + if exists('b:vikiIndex') + let fname = viki#WithSuffix(b:vikiIndex) + else + let fname = viki#WithSuffix(g:vikiIndex) + endif + if filereadable(fname) + return viki#OpenLink(fname, '') + else + echom "Index page not found: ". fname + endif +endf + + +fun! viki#FindNextRegion(name) "{{{3 + let rx = s:GetRegionStartRx(a:name) + return search(rx, 'We') +endf + + +""" indent {{{1 +fun! viki#GetIndent() + let lr = &lazyredraw + set lazyredraw + try + " Find a non-blank line above the current line. + let lnum = prevnonblank(v:lnum - 1) + + " At the start of the file use zero indent. + if lnum == 0 + " TLogVAR lnum + return 0 + endif + + let ind = indent(lnum) + " if ind == 0 + " TLogVAR ind + " return 0 + " end + + let line = getline(lnum) " last line + + let cnum = v:lnum + let cind = indent(cnum) + let cline = getline(cnum) + + " Do not change indentation in regions + if viki#IsInRegion(cnum) + " TLogVAR cnum, cind + return cind + endif + + let cHeading = matchend(cline, '^\*\+\s\+') + if cHeading >= 0 + " TLogVAR cHeading + return 0 + endif + + let pnum = v:lnum - 1 + let pind = indent(pnum) + let pline = getline(pnum) " last line + let plCont = matchend(pline, '\\$') + + if plCont >= 0 + " TLogVAR plCont, cind + return cind + end + + if cind > 0 + " TLogVAR cind + " Do not change indentation of: + " - commented lines + " - headings + if cline =~ '^\(\s*%\|\*\)' + " TLogVAR cline, ind + return ind + endif + + let markRx = '^\s\+\([#?!+]\)\1\{2,2}\s\+' + let listRx = '^\s\+\([-+*#?@]\|[0-9#]\+\.\|[a-zA-Z?]\.\)\s\+' + let priRx = '^\s\+#[A-F]\d\? \+\([x_0-9%-]\+ \+\)\?' + let descRx = '^\s\+.\{-1,}\s::\s\+' + + let clMark = matchend(cline, markRx) + let clList = matchend(cline, listRx) + let clPri = matchend(cline, priRx) + let clDesc = matchend(cline, descRx) + " let cln = clList >= 0 ? clList : clDesc + + let swhalf = &sw / 2 + + if clList >= 0 || clDesc >= 0 || clMark >= 0 || clPri >= 0 + " let spaceEnd = matchend(cline, '^\s\+') + " let rv = (spaceEnd / &sw) * &sw + let rv = (cind / &sw) * &sw + " TLogVAR clList, clDesc, clMark, clPri, rv + return rv + else + let plMark = matchend(pline, markRx) + if plMark >= 0 + " TLogVAR plMark + " return plMark + return pind + 4 + endif + + let plList = matchend(pline, listRx) + if plList >= 0 + " TLogVAR plList + return plList + endif + + let plPri = matchend(pline, priRx) + if plPri >= 0 + " let rv = indent(pnum) + &sw / 2 + let rv = pind + swhalf + " TLogVAR plPri, rv + " return plPri + return rv + endif + + let plDesc = matchend(pline, descRx) + if plDesc >= 0 + " TLogVAR plDesc, pind + if plDesc >= 0 && g:vikiIndentDesc == '::' + " return plDesc + return pind + else + return pind + swhalf + endif + endif + + " TLogVAR cind, ind, rv + if cind < ind + let rv = (cind / &sw) * &sw + return rv + elseif cind >= ind + if cind % &sw == 0 + return cind + else + return ind + end + endif + endif + endif + + " TLogVAR ind + return ind + finally + let &lazyredraw = lr + endtry +endf + +function! viki#ExecExternal(cmd) "{{{3 + exec a:cmd + if !has("gui_running") + " Scrambled window with vim + redraw! + endif +endf + + +""" #Files related stuff {{{1 +fun! viki#FilesUpdateAll() "{{{3 + let p = getpos('.') + try + norm! gg + while viki#FindNextRegion('Files') + call viki#FilesUpdate() + norm! j + endwh + finally + call setpos('.', p) + endtry +endf + +fun! viki#FilesExec(cmd, bang, ...) "{{{3 + let [lh, lb, le, indent] = s:GetRegionGeometry('Files') + if a:0 >= 1 && a:1 + let lb = line('.') + let le = line('.') + 1 + endif + let ilen = len(indent) + let done = [] + for f in s:CollectFileNames(lb, le, a:bang) + let ff = escape(f, '%#\ ') + let x = viki#SubstituteArgs(a:cmd, + \ '', ff, + \ 'FILE', f, + \ 'FFILE', ff, + \ 'DIR', fnamemodify(f, ':h')) + if index(done, x) == -1 + exec x + call add(done, x) + endif + endfor +endf + +fun! viki#FilesCmd(cmd, bang) "{{{3 + let [lh, lb, le, indent] = s:GetRegionGeometry('Files') + let ilen = len(indent) + for t in s:CollectFileNames(lb, le, a:bang) + exec VikiCmd_{a:cmd} .' '. escape(t, '%#\ ') + endfor +endf + +fun! viki#FilesCall(cmd, bang) "{{{3 + let [lh, lb, le, indent] = s:GetRegionGeometry('Files') + let ilen = len(indent) + for t in s:CollectFileNames(lb, le, a:bang) + call VikiCmd_{a:cmd}(t) + endfor +endf + +fun! s:CollectFileNames(lb, le, bang) "{{{3 + let afile = viki#FilesGetFilename(getline('.')) + let acc = [] + for l in range(a:lb, a:le - 1) + let line = getline(l) + let bfile = viki#FilesGetFilename(line) + if s:IsEligibleLine(afile, bfile, a:bang) + call add(acc, fnamemodify(bfile, ':p')) + endif + endfor + return acc +endf + +fun! s:IsEligibleLine(afile, bfile, bang) "{{{3 + if empty(a:bang) + return 1 + else + if isdirectory(a:bfile) + return 0 + else + let adir = isdirectory(a:afile) ? a:afile : fnamemodify(a:afile, ':h') + let bdir = isdirectory(a:bfile) ? a:bfile : fnamemodify(a:bfile, ':h') + let rv = s:IsSubdir(adir, bdir) + return rv + endif + endif +endf + +fun! s:IsSubdir(adir, bdir) "{{{3 + if a:adir == '' || a:bdir == '' + return 0 + elseif a:adir == a:bdir + return 1 + else + return s:IsSubdir(a:adir, fnamemodify(a:bdir, ':h')) + endif +endf + +fun! viki#FilesUpdate() "{{{3 + let [lh, lb, le, indent] = s:GetRegionGeometry('Files') + " 'vikiFiles', 'vikiFilesRegion' + call s:DeleteRegionBody(lb, le) + call viki#DirListing(lh, lb, indent) +endf + +fun! viki#DirListing(lhs, lhb, indent) "{{{3 + let args = s:GetRegionArgs(a:lhs, a:lhb - 1) + let patt = get(args, 'glob', '') + " TLogVAR patt + if empty(patt) + echoerr 'Viki: No glob pattern defnied: '. string(args) + else + let p = getpos('.') + let t = @t + try + " let style = get(args, 'style', 'ls') + " let ls = VikiGetDirListing_{style}(split(glob(patt), '\n')) + let ls = split(glob(patt), '\n') + " TLogVAR ls + let types = get(args, 'types', '') + " TLogVAR ls + if !empty(types) + let show_files = stridx(types, 'f') != -1 + let show_dirs = stridx(types, 'd') != -1 + call filter(ls, '(show_files && !isdirectory(v:val)) || (show_dirs && isdirectory(v:val))') + endif + let filter = get(args, 'filter', '') + if !empty(filter) + call filter(ls, 'v:val =~ filter') + endif + let exclude = get(args, 'exclude', '') + if !empty(exclude) + call filter(ls, 'v:val !~ exclude') + endif + let order = get(args, 'order', '') + " if !empty(order) + " if order == 'd' + " call sort(ls, 's:SortDirsFirst') + " endif + " endif + let list = split(get(args, 'list', ''), ',\s*') + call map(ls, 'a:indent.s:GetFileEntry(v:val, list)') + let @t = join(ls, "\") ."\" + exec 'norm! '. a:lhb .'G"tP' + finally + let @t = t + call setpos('.', p) + endtry + endif +endf + +" fun! VikiGetDirListing_ls(files) +" return a:files +" endf + +fun! s:GetFileEntry(file, list) "{{{3 + " let prefix = substitute(a:file, '[^/]', '', 'g') + " let prefix = substitute(prefix, '/', repeat(' ', &shiftwidth), 'g') + let attr = [] + if index(a:list, 'detail') != -1 + let type = getftype(a:file) + if type != 'file' + if type == 'dir' + call add(attr, 'D') + else + call add(attr, type) + endif + endif + call add(attr, strftime('%c', getftime(a:file))) + call add(attr, getfperm(a:file)) + else + if isdirectory(a:file) + call add(attr, 'D') + endif + endif + let f = [] + let d = s:GetDepth(a:file) + " if index(a:list, 'tree') == -1 + " call add(f, '[[') + " call add(f, repeat('|-', d)) + " if index(attr, 'D') == -1 + " call add(f, ' ') + " else + " call add(f, '-+ ') + " endif + " call add(f, fnamemodify(a:file, ':t') .'].]') + " else + if index(a:list, 'flat') == -1 + call add(f, repeat(' ', d * &shiftwidth)) + endif + call add(f, '[['. a:file .']!]') + " endif + if !empty(attr) + call add(f, ' {'. join(attr, '|') .'}') + endif + let c = get(s:savedComments, a:file, '') + if !empty(c) + call add(f, c) + endif + return join(f, '') +endf + +fun! s:GetDepth(file) "{{{3 + return len(substitute(a:file, '[^/]', '', 'g')) +endf + +fun! s:GetRegionArgs(ls, le) "{{{3 + let t = @t + " let p = getpos('.') + try + let t = s:GetBrokenLine(a:ls, a:le) + let t = matchstr(t, '^\s*#\([A-Z]\([a-z][A-Za-z]*\)\?\>\|!!!\)\zs.\{-}\ze<<$') + let args = {} + let rx = '^\s*\(\(\S\{-}\)=\("\(\(\"\|.\{-}\)\{-}\)"\|\(\(\S\+\|\\ \)\+\)\)\|\(\w\)\+!\)\s*' + let s = 0 + let sm = len(t) + while s < sm + let m = matchlist(t, rx, s) + if empty(m) + echoerr "Viki: Can't parse argument list: ". t + else + let key = m[2] + if !empty(key) + let val = empty(m[4]) ? m[6] : m[4] + if val =~ '^".\{-}"' + let val = val[1:-2] + endif + let args[key] = substitute(val, '\\\(.\)', '\1', 'g') + else + let key = m[8] + if key == '^no\u' + let antikey = substitute(key, '^no\zs.', '\l&', '') + else + let antikey = 'no'. substitute(key, '^.', '\u&', '') + endif + let args[key] = 1 + let args[antikey] = 0 + endif + let s += len(m[0]) + endif + endwh + return args + finally + let @t = t + " call setpos('.', p) + endtry +endf + +fun! s:GetBrokenLine(ls, le) "{{{3 + let t = @t + try + exec 'norm! '. a:ls .'G"ty'. a:le .'G' + let @t = substitute(@t, '[^\\]\zs\\\n\s*', '', 'g') + let @t = substitute(@t, '\n*$', '', 'g') + return @t + finally + let @t = t + endtry +endf + +fun! s:GetRegionStartRx(...) "{{{3 + let name = a:0 >= 1 && !empty(a:1) ? '\(\('. a:1 .'\>\)\)' : '\([A-Z]\([a-z][A-Za-z]*\)\?\>\|!!!\)' + let rx_start = '^\([[:blank:]]*\)#'. name .'\(\\\n\|.\)\{-}<<\(.*\)$' + return rx_start +endf + +fun! s:GetRegionGeometry(...) "{{{3 + let p = getpos('.') + try + norm! $ + let rx_start = s:GetRegionStartRx(a:0 >= 1 ? a:1 : '') + let hds = search(rx_start, 'cbWe') + if hds > 0 + let hde = search(rx_start, 'ce') + let hdt = s:GetBrokenLine(hds, hde) + let hdm = matchlist(hdt, rx_start) + let hdi = hdm[1] + let rx_end = '\V\^\[[:blank:]]\*'. escape(hdm[5], '\') .'\[[:blank:]]\*\$' + let hbe = search(rx_end) + if hds > 0 && hde > 0 && hbe > 0 + return [hds, hde + 1, hbe, hdi] + else + echoerr "Viki: Can't determine region geometry: ". string([hds, hde, hbe, hdi, hdm, rx_start, rx_end]) + endif + else + echoerr "Viki: Can't determine region geometry: ". join([rx_start], ', ') + endif + return [0, 0, 0, ''] + finally + call setpos('.', p) + endtry +endf + +fun! s:DeleteRegionBody(...) "{{{3 + if a:0 >= 2 + let lb = a:1 + let le = a:2 + else + let [lh, lb, le, indent] = s:GetRegionGeometry('Files') + endif + call s:SaveComments(lb, le - 1) + if le > lb + exec 'norm! '. lb .'Gd'. (le - 1) .'G' + endif +endf + +fun! s:SaveComments(lb, le) "{{{3 + let s:savedComments = {} + for l in range(a:lb, a:le) + let t = getline(l) + let k = viki#FilesGetFilename(t) + if !empty(k) + let s:savedComments[k] = viki#FilesGetComment(t) + endif + endfor +endf + +fun! viki#FilesGetFilename(t) "{{{3 + return matchstr(a:t, '^\s*\[\[\zs.\{-}\ze\]!\]') +endf + +fun! viki#FilesGetComment(t) "{{{3 + return matchstr(a:t, '^\s*\[\[.\{-}\]!\]\( {.\{-}}\)\?\zs.*') +endf + diff --git a/conf_slk120/vim/_vim/plugin/vikiAnyWord.vim b/conf_slk120/vim/_vim/autoload/viki_anyword.vim old mode 100755 new mode 100644 similarity index 78% rename from conf_slk120/vim/_vim/plugin/vikiAnyWord.vim rename to conf_slk120/vim/_vim/autoload/viki_anyword.vim index c9d8ee8..037b9fa --- a/conf_slk120/vim/_vim/plugin/vikiAnyWord.vim +++ b/conf_slk120/vim/_vim/autoload/viki_anyword.vim @@ -1,27 +1,24 @@ " vikiAnyWord.vim -" @Author: Thomas Link (mailto:samul@web.de?subject=vim-vikiAnyWord) +" @Author: Thomas Link (mailto:micathom AT gmail com?subject=vim-vikiAnyWord) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 04-Apr-2005. -" @Last Change: 16-Feb-2006. -" @Revision: 0.14 +" @Last Change: 2007-10-12. +" @Revision: 0.35 -if &cp || exists("loaded_vikianyword") +if &cp || exists('loaded_viki_anyword') finish endif -let loaded_vikianyword = 1 +let loaded_viki_anyword = 1 """" Any Word {{{1 -fun! VikiMinorModeAnyWord (state) "{{{3 - let b:vikiFamily = 'AnyWord' - call VikiMinorMode(a:state) +function! viki_anyword#MinorMode(state) "{{{3 + let b:vikiFamily = 'anyword' + call viki_viki#MinorMode(a:state) endfun -command! VikiMinorModeAnyWord call VikiMinorModeAnyWord(1) -command! VikiMinorModeMaybeAnyWord call VikiMinorModeAnyWord(-1) -fun! VikiSetupBufferAnyWord(state, ...) "{{{3 - echom "DBG VikiSetupBufferAnyWord" +function! viki_anyword#SetupBuffer(state, ...) "{{{3 let dontSetup = a:0 > 0 ? a:1 : '' - call VikiSetupBuffer(a:state, dontSetup) + call viki_viki#SetupBuffer(a:state, dontSetup) if b:vikiNameTypes =~? "s" && !(dontSetup =~? "s") if b:vikiNameTypes =~# "S" && !(dontSetup =~# "S") let simpleWikiName = b:vikiSimpleNameQuoteBeg @@ -64,7 +61,7 @@ fun! VikiSetupBufferAnyWord(state, ...) "{{{3 let b:vikiMarkInexistent = 2 endf -fun! VikiDefineMarkupAnyWord(state) "{{{3 +function! viki_anyword#DefineMarkup(state) "{{{3 if b:vikiNameTypes =~? "s" && b:vikiSimpleNameRx != "" exe "syn match vikiRevLink /" . b:vikiSimpleNameRx . "/" endif @@ -76,9 +73,9 @@ fun! VikiDefineMarkupAnyWord(state) "{{{3 endif endfun -fun! VikiDefineHighlightingAnyWord(state, ...) "{{{3 +function! viki_anyword#DefineHighlighting(state, ...) "{{{3 let dontSetup = a:0 > 0 ? a:1 : '' - call VikiDefineHighlighting(a:state) + call viki_viki#DefineHighlighting(a:state) if version < 508 command! -nargs=+ VikiHiLink hi link else @@ -88,10 +85,10 @@ fun! VikiDefineHighlightingAnyWord(state, ...) "{{{3 delcommand VikiHiLink endf -fun! VikiFindAnyWord(flag, ...) "{{{3 - let rx = VikiRxFromCollection(b:vikiNamesOk) +function! viki_anyword#Find(flag, ...) "{{{3 + let rx = viki#RxFromCollection(b:vikiNamesOk) let i = a:0 >= 1 ? a:1 : 0 - call VikiFind(a:flag, i, rx) + call viki#Find(a:flag, i, rx) endfun diff --git a/conf_slk120/vim/_vim/autoload/viki_latex.vim b/conf_slk120/vim/_vim/autoload/viki_latex.vim new file mode 100644 index 0000000..ac16034 --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/viki_latex.vim @@ -0,0 +1,125 @@ +" vikiLatex.vim -- viki add-on for LaTeX +" @Author: Thomas Link (micathom AT gmail com?subject=vim) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 28-Jän-2004. +" @Last Change: 2007-10-05. +" @Revision: 0.195 + +if &cp || exists('loaded_viki_latex') + finish +endif +let loaded_viki_latex = 1 + +function! viki_latex#SetupBuffer(state, ...) + let noMatch = "" + let b:vikiNameSuffix = '.tex' + call viki_viki#SetupBuffer(a:state, "sSic") + let b:vikiAnchorRx = '\\label{%{ANCHOR}}' + let b:vikiNameTypes = substitute(b:vikiNameTypes, '\C[Sicx]', "", "g") + let b:vikiLaTeXCommands = 'viki\|include\|input\|usepackage\|psfig\|includegraphics\|bibliography\|ref' + if exists("g:vikiLaTeXUserCommands") + let b:vikiLaTeXCommands = b:vikiLaTeXCommands .'\|'. g:vikiLaTeXUserCommands + endif + if b:vikiNameTypes =~# "s" + let b:vikiSimpleNameRx = '\(\\\('. b:vikiLaTeXCommands .'\)\(\[\(.\{-}\)\]\)\?{\(.\{-}\)}\)' + let b:vikiSimpleNameSimpleRx = '\\\('. b:vikiLaTeXCommands .'\)\(\[.\{-}\]\)\?{.\{-}}' + let b:vikiSimpleNameNameIdx = 2 + let b:vikiSimpleNameDestIdx = 5 + let b:vikiSimpleNameAnchorIdx = 4 + let b:vikiSimpleNameCompound = 'let erx="'. escape(b:vikiSimpleNameRx, '\"') + \ .'" | let nameIdx='. b:vikiSimpleNameNameIdx + \ .' | let destIdx='. b:vikiSimpleNameDestIdx + \ .' | let anchorIdx='. b:vikiSimpleNameAnchorIdx + else + let b:vikiSimpleNameRx = noMatch + let b:vikiSimpleNameSimpleRx = noMatch + let b:vikiSimpleNameNameIdx = 0 + let b:vikiSimpleNameDestIdx = 0 + let b:vikiSimpleNameAnchorIdx = 0 + endif +endf + +function! viki_latex#CheckFilename(filename, ...) + if a:filename != "" + """ search in the current directory + let i = 1 + while i <= a:0 + let fn = a:filename .a:{i} + " TLogVAR fn + if filereadable(fn) + return fn + endif + let i = i + 1 + endwh + + """ use kpsewhich + let i = 1 + while i <= a:0 + let fn = a:filename .a:{i} + let rv = system('kpsewhich '. string(fn)) + if rv != "" + return substitute(rv, "\n", "", "g") + endif + let i = i + 1 + endwh + endif + return "" +endfun + + +function! viki_latex#CompleteSimpleNameDef(def) + exec viki#SplitDef(a:def) + if v_name == g:vikiDefNil + throw "Viki: Malformed command (no name): ". string(a:def) + endif + let opts = v_anchor + let v_anchor = g:vikiDefNil + let useSuffix = g:vikiDefSep + + if v_name == "input" + let v_dest = viki_latex#CheckFilename(v_dest, "", ".tex", ".sty") + elseif v_name == "usepackage" + let v_dest = viki_latex#CheckFilename(v_dest, ".sty") + elseif v_name == "include" + let v_dest = viki_latex#CheckFilename(v_dest, ".tex") + elseif v_name == "viki" + let v_dest = viki_latex#CheckFilename(v_dest, ".tex") + let v_anchor = opts + elseif v_name == "psfig" + let f == matchstr(v_dest, "figure=\zs.\{-}\ze[,}]") + let v_dest = viki_latex#CheckFilename(v_dest, "") + elseif v_name == "includegraphics" + let v_dest = viki_latex#CheckFilename(v_dest, "", + \ ".eps", ".ps", ".pdf", ".png", ".jpeg", ".jpg", ".gif", ".wmf") + elseif v_name == "bibliography" + if !exists('b:vikiMarkingInexistent') + let bibs = split(v_dest, ",") + let f = tlib#input#List('s', "Select Bibliography", bibs) + let v_dest = empty(f) ? '' : viki_latex#CheckFilename(f, ".bib") + endif + elseif v_name == "ref" + let v_anchor = v_dest + let v_dest = g:vikiSelfRef + elseif exists("*VikiLaTeX_".v_name) + exec VikiLaTeX_{v_name}(v_dest, opts) + else + throw "Viki LaTeX: unsupported command: ". v_name + endif + + if v_dest == "" + if !exists('b:vikiMarkingInexistent') + throw "Viki LaTeX: can't find: ". v_name ." ". string(a:def) + endif + else + return viki#MakeDef(v_name, v_dest, v_anchor, v_part, 'simple') + endif +endfun + +function! viki_latex#MinorMode(state) + let b:vikiFamily = "latex" + call viki_viki#MinorMode(a:state) +endf + +" au FileType tex let b:vikiFamily="LaTeX" + +" vim: ff=unix diff --git a/conf_slk120/vim/_vim/autoload/viki_viki.vim b/conf_slk120/vim/_vim/autoload/viki_viki.vim new file mode 100644 index 0000000..7fb9cff --- /dev/null +++ b/conf_slk120/vim/_vim/autoload/viki_viki.vim @@ -0,0 +1,590 @@ +" vikiDeplate.vim +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-09-03. +" @Last Change: 2007-11-15. +" @Revision: 0.0.95 + +if &cp || exists("loaded_viki_viki") + finish +endif +let loaded_viki_viki = 1 + +let s:save_cpo = &cpo +set cpo&vim + + +""" viki/deplate {{{1 +" Prepare a buffer for use with viki.vim. Setup all buffer-local +" variables etc. +" This also sets up the rx for the different viki name types. +" viki_viki#SetupBuffer(state, ?dontSetup='') +function! viki_viki#SetupBuffer(state, ...) "{{{3 + if !g:vikiEnabled + return + endif + " TLogDBG expand('%') .': '. (exists('b:vikiFamily') ? b:vikiFamily : 'default') + + let dontSetup = a:0 > 0 ? a:1 : "" + let noMatch = "" + + if exists("b:vikiNoSimpleNames") && b:vikiNoSimpleNames + let b:vikiNameTypes = substitute(b:vikiNameTypes, '\Cs', '', 'g') + endif + if exists("b:vikiDisableType") && b:vikiDisableType != "" + let b:vikiNameTypes = substitute(b:vikiNameTypes, '\C'. b:vikiDisableType, '', 'g') + endif + + call viki#SetBufferVar("vikiAnchorMarker") + call viki#SetBufferVar("vikiSpecialProtocols") + call viki#SetBufferVar("vikiSpecialProtocolsExceptions") + call viki#SetBufferVar("vikiMarkInexistent") + call viki#SetBufferVar("vikiTextstylesVer") + " call viki#SetBufferVar("vikiTextstylesVer") + call viki#SetBufferVar("vikiLowerCharacters") + call viki#SetBufferVar("vikiUpperCharacters") + call viki#SetBufferVar("vikiFeedbackMin") + + if a:state == 1 + call viki#SetBufferVar("vikiCommentStart", + \ "b:commentStart", "b:ECcommentOpen", "b:EnhCommentifyCommentOpen", + \ "*matchstr(&commentstring, '^\\zs.*\\ze%s')") + call viki#SetBufferVar("vikiCommentEnd", + \ "b:commentEnd", "b:ECcommentClose", "b:EnhCommentifyCommentClose", + \ "*matchstr(&commentstring, '%s\\zs.*\\ze$')") + elseif !exists('b:vikiCommentStart') + " This actually is an error. + if &debug != '' + echom "Viki: FTPlugin wasn't loaded. Viki requires :filetype plugin on" + endif + let b:vikiCommentStart = '%' + let b:vikiCommentEnd = '' + endif + + let b:vikiSimpleNameQuoteChars = '^][:*/&?<>|\"' + + let b:vikiSimpleNameQuoteBeg = '\[-' + let b:vikiSimpleNameQuoteEnd = '-\]' + let b:vikiQuotedSelfRef = "^". b:vikiSimpleNameQuoteBeg . b:vikiSimpleNameQuoteEnd ."$" + let b:vikiQuotedRef = "^". b:vikiSimpleNameQuoteBeg .'.\+'. b:vikiSimpleNameQuoteEnd ."$" + + let b:vikiAnchorNameRx = '['. b:vikiLowerCharacters .']['. + \ b:vikiLowerCharacters . b:vikiUpperCharacters .'_0-9]*' + + let interviki = '\<['. b:vikiUpperCharacters .']\+::' + + " if viki#IsSupportedType("sSc") && !(dontSetup =~? "s") + if viki#IsSupportedType("s") && !(dontSetup =~? "s") + if viki#IsSupportedType("S") && !(dontSetup =~# "S") + let quotedVikiName = b:vikiSimpleNameQuoteBeg + \ .'['. b:vikiSimpleNameQuoteChars .']' + \ .'\{-}'. b:vikiSimpleNameQuoteEnd + else + let quotedVikiName = "" + endif + if viki#IsSupportedType("c") && !(dontSetup =~# "c") + let simpleWikiName = viki#GetSimpleRx4SimpleWikiName() + if quotedVikiName != "" + let quotedVikiName = quotedVikiName .'\|' + endif + else + let simpleWikiName = '\(\)' + endif + let simpleHyperWords = '' + if v:version >= 700 && viki#IsSupportedType('w') && !(dontSetup =~# 'w') + let b:vikiHyperWordTable = {} + if viki#IsSupportedType('f') && !(dontSetup =~# 'f') + call viki#CollectFileWords(b:vikiHyperWordTable, simpleWikiName) + endif + call viki#CollectHyperWords(b:vikiHyperWordTable) + let hyperWords = keys(b:vikiHyperWordTable) + if !empty(hyperWords) + let simpleHyperWords = join(map(hyperWords, '"\\<".tlib#rx#Escape(v:val)."\\>"'), '\|') .'\|' + let simpleHyperWords = substitute(simpleHyperWords, ' \+', '\\s\\+', 'g') + endif + endif + let b:vikiSimpleNameRx = '\C\(\('. interviki .'\)\?'. + \ '\('. simpleHyperWords . quotedVikiName . simpleWikiName .'\)\)'. + \ '\(#\('. b:vikiAnchorNameRx .'\)\>\)\?' + let b:vikiSimpleNameSimpleRx = '\C\(\<['.b:vikiUpperCharacters.']\+::\)\?'. + \ '\('. simpleHyperWords . quotedVikiName . simpleWikiName .'\)'. + \ '\(#'. b:vikiAnchorNameRx .'\>\)\?' + let b:vikiSimpleNameNameIdx = 1 + let b:vikiSimpleNameDestIdx = 0 + let b:vikiSimpleNameAnchorIdx = 6 + let b:vikiSimpleNameCompound = 'let erx="'. escape(b:vikiSimpleNameRx, '\"') + \ .'" | let nameIdx='. b:vikiSimpleNameNameIdx + \ .' | let destIdx='. b:vikiSimpleNameDestIdx + \ .' | let anchorIdx='. b:vikiSimpleNameAnchorIdx + else + let b:vikiSimpleNameRx = noMatch + let b:vikiSimpleNameSimpleRx = noMatch + let b:vikiSimpleNameNameIdx = 0 + let b:vikiSimpleNameDestIdx = 0 + let b:vikiSimpleNameAnchorIdx = 0 + endif + + if viki#IsSupportedType("u") && !(dontSetup =~# "u") + let urlChars = 'A-Za-z0-9.,:%?=&_~@$/|+-' + let b:vikiUrlRx = '\<\(\('.b:vikiSpecialProtocols.'\):['. urlChars .']\+\)'. + \ '\(#\([A-Za-z0-9]*\)\)\?' + let b:vikiUrlSimpleRx = '\<\('. b:vikiSpecialProtocols .'\):['. urlChars .']\+'. + \ '\(#[A-Za-z0-9]*\)\?' + let b:vikiUrlNameIdx = 0 + let b:vikiUrlDestIdx = 1 + let b:vikiUrlAnchorIdx = 4 + let b:vikiUrlCompound = 'let erx="'. escape(b:vikiUrlRx, '\"') + \ .'" | let nameIdx='. b:vikiUrlNameIdx + \ .' | let destIdx='. b:vikiUrlDestIdx + \ .' | let anchorIdx='. b:vikiUrlAnchorIdx + else + let b:vikiUrlRx = noMatch + let b:vikiUrlSimpleRx = noMatch + let b:vikiUrlNameIdx = 0 + let b:vikiUrlDestIdx = 0 + let b:vikiUrlAnchorIdx = 0 + endif + + if viki#IsSupportedType("x") && !(dontSetup =~# "x") + " let vikicmd = '['. b:vikiUpperCharacters .']\w*' + let vikicmd = '\(IMG\|Img\|INC\%[LUDE]\)\>' + let vikimacros = '\(img\|ref\)\>' + let b:vikiCmdRx = '\({'. vikimacros .'\|#'. vikicmd .'\)\(.\{-}\):\s*\(.\{-}\)\($\|}\)' + let b:vikiCmdSimpleRx = '\({'. vikimacros .'\|#'. vikicmd .'\).\{-}\($\|}\)' + let b:vikiCmdNameIdx = 1 + let b:vikiCmdDestIdx = 5 + let b:vikiCmdAnchorIdx = 4 + let b:vikiCmdCompound = 'let erx="'. escape(b:vikiCmdRx, '\"') + \ .'" | let nameIdx='. b:vikiCmdNameIdx + \ .' | let destIdx='. b:vikiCmdDestIdx + \ .' | let anchorIdx='. b:vikiCmdAnchorIdx + else + let b:vikiCmdRx = noMatch + let b:vikiCmdSimpleRx = noMatch + let b:vikiCmdNameIdx = 0 + let b:vikiCmdDestIdx = 0 + let b:vikiCmdAnchorIdx = 0 + endif + + if viki#IsSupportedType("e") && !(dontSetup =~# "e") + let b:vikiExtendedNameRx = + \ '\[\[\(\('.b:vikiSpecialProtocols.'\)://[^]]\+\|[^]#]\+\)\?'. + \ '\(#\([^]]*\)\)\?\]\(\[\([^]]\+\)\]\)\?\([!~*$\-]*\)\]' + " \ '\(#\('. b:vikiAnchorNameRx .'\)\)\?\]\(\[\([^]]\+\)\]\)\?[!~*\-]*\]' + let b:vikiExtendedNameSimpleRx = + \ '\[\[\('. b:vikiSpecialProtocols .'://[^]]\+\|[^]#]\+\)\?'. + \ '\(#[^]]*\)\?\]\(\[[^]]\+\]\)\?[!~*$\-]*\]' + " \ '\(#'. b:vikiAnchorNameRx .'\)\?\]\(\[[^]]\+\]\)\?[!~*\-]*\]' + let b:vikiExtendedNameNameIdx = 6 + let b:vikiExtendedNameModIdx = 7 + let b:vikiExtendedNameDestIdx = 1 + let b:vikiExtendedNameAnchorIdx = 4 + let b:vikiExtendedNameCompound = 'let erx="'. escape(b:vikiExtendedNameRx, '\"') + \ .'" | let nameIdx='. b:vikiExtendedNameNameIdx + \ .' | let destIdx='. b:vikiExtendedNameDestIdx + \ .' | let anchorIdx='. b:vikiExtendedNameAnchorIdx + else + let b:vikiExtendedNameRx = noMatch + let b:vikiExtendedNameSimpleRx = noMatch + let b:vikiExtendedNameNameIdx = 0 + let b:vikiExtendedNameDestIdx = 0 + let b:vikiExtendedNameAnchorIdx = 0 + endif + + let b:vikiInexistentHighlight = "vikiInexistentLink" + + if a:state == 2 + if g:vikiAutoMarks + call viki#SetAnchorMarks() + endif + if g:vikiNameSuffix != '' + exec 'setlocal suffixesadd+='. g:vikiNameSuffix + endif + if exists('b:vikiNameSuffix') && b:vikiNameSuffix != '' && b:vikiNameSuffix != g:vikiNameSuffix + exec 'setlocal suffixesadd+='. b:vikiNameSuffix + endif + if exists('g:loaded_hookcursormoved') && g:loaded_hookcursormoved >= 3 && exists('b:vikiMarkInexistent') && b:vikiMarkInexistent + let b:hookcursormoved_syntaxleave = ['vikiLink', 'vikiExtendedLink', 'vikiURL', 'vikiOkLink', 'vikiInexistentLink'] + for cond in g:vikiHCM + call hookcursormoved#Register(cond, function('viki#HookCheckPreviousPosition')) + endfor + endif + endif +endf + + +" Define viki core syntax groups for hyperlinks +function! viki_viki#DefineMarkup(state) "{{{3 + if viki#IsSupportedType("sS") && b:vikiSimpleNameSimpleRx != "" + exe "syntax match vikiLink /" . b:vikiSimpleNameSimpleRx . "/" + endif + if viki#IsSupportedType("e") && b:vikiExtendedNameSimpleRx != "" + exe "syntax match vikiExtendedLink '" . b:vikiExtendedNameSimpleRx . "' skipnl" + endif + if viki#IsSupportedType("u") && b:vikiUrlSimpleRx != "" + exe "syntax match vikiURL /" . b:vikiUrlSimpleRx . "/" + endif +endf + + +" Define the highlighting of the core syntax groups for hyperlinks +function! viki_viki#DefineHighlighting(state) "{{{3 + exec 'hi vikiInexistentLink '. g:viki_highlight_inexistent_{&background} + exec 'hi vikiHyperLink '. g:viki_highlight_hyperlink_{&background} + + if viki#IsSupportedType("sS") + hi def link vikiLink vikiHyperLink + hi def link vikiOkLink vikiHyperLink + hi def link vikiRevLink Normal + endif + if viki#IsSupportedType("e") + hi def link vikiExtendedLink vikiHyperLink + hi def link vikiExtendedOkLink vikiHyperLink + hi def link vikiRevExtendedLink Normal + endif + if viki#IsSupportedType("u") + hi def link vikiURL vikiHyperLink + endif +endf + + +" Define viki-related key maps +function! viki_viki#MapKeys(state) "{{{3 + if exists('b:vikiDidMapKeys') + return + endif + if a:state == 1 + if exists('b:vikiMapFunctionalityMinor') && b:vikiMapFunctionalityMinor + let mf = b:vikiMapFunctionalityMinor + else + let mf = g:vikiMapFunctionalityMinor + endif + elseif exists('b:vikiMapFunctionality') && b:vikiMapFunctionality + let mf = b:vikiMapFunctionality + else + let mf = g:vikiMapFunctionality + endif + + " if !hasmapto('viki#MaybeFollowLink') + if viki#MapFunctionality(mf, 'c') + nnoremap :call viki#MaybeFollowLink(0,1) + inoremap :call viki#MaybeFollowLink(0,1) + " nnoremap :call viki#MaybeFollowLink(0,1,-1) + endif + if viki#MapFunctionality(mf, 'f') + " nnoremap :call viki#MaybeFollowLink(0,1) + " inoremap :call viki#MaybeFollowLink(0,1) + " nnoremap :call viki#MaybeFollowLink(0,1,-1) + exec 'nnoremap '. g:vikiMapLeader .'f :call viki#MaybeFollowLink(0,1)' + exec 'nnoremap '. g:vikiMapLeader .'s :call viki#MaybeFollowLink(0,1,-1)' + exec 'nnoremap '. g:vikiMapLeader .'v :call viki#MaybeFollowLink(0,1,-2)' + exec 'nnoremap '. g:vikiMapLeader .'1 :call viki#MaybeFollowLink(0,1,1)' + exec 'nnoremap '. g:vikiMapLeader .'2 :call viki#MaybeFollowLink(0,1,2)' + exec 'nnoremap '. g:vikiMapLeader .'3 :call viki#MaybeFollowLink(0,1,3)' + exec 'nnoremap '. g:vikiMapLeader .'4 :call viki#MaybeFollowLink(0,1,4)' + exec 'nnoremap '. g:vikiMapLeader .'t :call viki#MaybeFollowLink(0,1,"tab")' + endif + if viki#MapFunctionality(mf, 'mf') + " && !hasmapto("viki#MaybeFollowLink") + nnoremap :call viki#MaybeFollowLink(0,1) + inoremap :call viki#MaybeFollowLink(0,1) + endif + " endif + + " if !hasmapto('VikiMarkInexistent') + if viki#MapFunctionality(mf, 'i') + exec 'noremap '. g:vikiMapLeader .'d :call viki#MarkInexistentInElement("Document")' + exec 'noremap '. g:vikiMapLeader .'p :call viki#MarkInexistentInElement("Paragraph")' + endif + if viki#MapFunctionality(mf, 'I') + if g:vikiMapInexistent + let i = 0 + let m = strlen(g:vikiMapKeys) + while i < m + let k = g:vikiMapKeys[i] + call viki#MapMarkInexistent(k, "LineQuick") + let i = i + 1 + endwh + let i = 0 + let m = strlen(g:vikiMapQParaKeys) + while i < m + let k = g:vikiMapQParaKeys[i] + call viki#MapMarkInexistent(k, "ParagraphVisible") + let i = i + 1 + endwh + endif + endif + " endif + + if viki#MapFunctionality(mf, 'e') + " && !hasmapto("viki#Edit") + exec 'noremap '. g:vikiMapLeader .'e :VikiEdit ' + endif + + if viki#MapFunctionality(mf, 'q') && exists("*VEnclose") + " && !hasmapto("VikiQuote") + exec 'vnoremap '. g:vikiMapLeader .'q :VikiQuote:call viki#MarkInexistentInElement("LineQuick")' + exec 'nnoremap '. g:vikiMapLeader .'q viw:VikiQuote:call viki#MarkInexistentInElement("LineQuick")' + exec 'inoremap '. g:vikiMapLeader .'q viw:VikiQuote:call viki#MarkInexistentInElement("LineQuick")i' + endif + + if viki#MapFunctionality(mf, 'p') + exec 'nnoremap '. g:vikiMapLeader .' :call viki#GoParent()' + exec 'nnoremap '. g:vikiMapLeader .' :call viki#GoParent()' + endif + + if viki#MapFunctionality(mf, 'b') + " && !hasmapto("VikiGoBack") + exec 'nnoremap '. g:vikiMapLeader .'b :call viki#GoBack()' + exec 'nnoremap '. g:vikiMapLeader .' :call viki#GoBack()' + endif + if viki#MapFunctionality(mf, 'mb') + nnoremap :call viki#GoBack(0) + inoremap :call viki#GoBack(0) + endif + + if viki#MapFunctionality(mf, 'F') + exec 'nnoremap '. g:vikiMapLeader .'n :VikiFindNext' + exec 'nnoremap '. g:vikiMapLeader .'N :VikiFindPrev' + exec 'nmap '. g:vikiMapLeader .'F '. g:vikiMapLeader .'n'. g:vikiMapLeader .'f' + endif + if viki#MapFunctionality(mf, 'tF') + nnoremap :VikiFindNext + nnoremap :VikiFindPrev + endif + if viki#MapFunctionality(mf, 'Files') + exec 'nnoremap '. g:vikiMapLeader .'u :VikiFilesUpdate' + exec 'nnoremap '. g:vikiMapLeader .'U :VikiFilesUpdateAll' + exec 'nnoremap '. g:vikiMapLeader .'x :VikiFilesExec ' + exec 'nnoremap '. g:vikiMapLeader .'X :VikiFilesExec! ' + endif + let b:vikiDidMapKeys = 1 +endf + + +" Initialize viki as minor mode (add-on to some buffer filetype) +"state ... no-op:0, minor:1, major:2 +function! viki_viki#MinorMode(state) "{{{3 + if !g:vikiEnabled + return 0 + endif + if a:state == 0 + return 0 + endif + let state = a:state < 0 ? -a:state : a:state + let vf = viki#Family(1) + " c ... CamelCase + " s ... Simple viki name + " S ... Simple quoted viki name + " e ... Extended viki name + " u ... URL + " i ... InterViki + " call viki#SetBufferVar('vikiNameTypes', 'g:vikiNameTypes', "*'csSeui'") + call viki#SetBufferVar('vikiNameTypes') + call viki#DispatchOnFamily('SetupBuffer', vf, state) + call viki#DispatchOnFamily('DefineMarkup', vf, state) + call viki#DispatchOnFamily('DefineHighlighting', vf, state) + call viki#DispatchOnFamily('MapKeys', vf, state) + if !exists('b:vikiEnabled') || b:vikiEnabled < state + let b:vikiEnabled = state + endif + " call viki#DispatchOnFamily('VikiDefineMarkup', vf, state) + " call viki#DispatchOnFamily('VikiDefineHighlighting', vf, state) + return 1 +endf + + +" Find an anchor +function! viki_viki#FindAnchor(anchor) "{{{3 + " TLogVAR a:anchor + if a:anchor == g:vikiDefNil || a:anchor == '' + return + endif + let mode = matchstr(a:anchor, '^\(l\(ine\)\?\|rx\|vim\)\ze=') + if exists('*VikiAnchor_'. mode) + let arg = matchstr(a:anchor, '=\zs.\+$') + call VikiAnchor_{mode}(arg) + else + let co = col('.') + let li = line('.') + let anchorRx = viki#GetAnchorRx(a:anchor) + " TLogVAR anchorRx + keepjumps go + let found = search(anchorRx, 'Wc') + " TLogVAR found + if !found + call cursor(li, co) + if g:vikiFreeMarker + call search('\c\V'. escape(a:anchor, '\'), 'w') + endif + endif + endif + exec g:vikiPostFindAnchor +endf + + +" Complete missing information in the definition of an extended viki name +function! viki_viki#CompleteExtendedNameDef(def) "{{{3 + " TLogVAR a:def + exec viki#SplitDef(a:def) + if v_dest == g:vikiDefNil + if v_anchor == g:vikiDefNil + throw "Viki: Malformed extended viki name (no destination): ". string(a:def) + else + let v_dest = g:vikiSelfRef + endif + elseif viki#IsInterViki(v_dest) + let useSuffix = viki#InterVikiSuffix(v_dest) + let v_dest = viki#InterVikiDest(v_dest) + " TLogVAR v_dest + if v_dest != g:vikiDefNil + let v_dest = viki#ExpandSimpleName('', v_dest, useSuffix) + " TLogVAR v_dest + endif + else + if v_dest =~? '^[a-z]:' " an absolute dos path + elseif v_dest =~? '^\/' " an absolute unix path + elseif v_dest =~? '^'.b:vikiSpecialProtocols.':' " some protocol + elseif v_dest =~ '^\~' " user home + " let v_dest = $HOME . strpart(v_dest, 1) + let v_dest = fnamemodify(v_dest, ':p') + let v_dest = viki#CanonicFilename(v_dest) + else " a relative path + let v_dest = expand("%:p:h") .g:vikiDirSeparator. v_dest + let v_dest = viki#CanonicFilename(v_dest) + endif + if v_dest != '' && v_dest != g:vikiSelfRef && !viki#IsSpecial(v_dest) + let mod = viki#ExtendedModifier(v_part) + if fnamemodify(v_dest, ':e') == '' && mod !~# '!' + let v_dest = viki#WithSuffix(v_dest) + endif + endif + endif + if v_name == g:vikiDefNil + let v_name = fnamemodify(v_dest, ':t:r') + endif + let v_type = v_type == g:vikiDefNil ? 'e' : v_type + " TLogVAR v_name, v_dest, v_anchor, v_part, v_type + return viki#MakeDef(v_name, v_dest, v_anchor, v_part, v_type) +endf + + +" Complete missing information in the definition of a command viki name +function! viki_viki#CompleteCmdDef(def) "{{{3 + " TLogVAR a:def + exec viki#SplitDef(a:def) + " TLogVAR v_name, v_dest, v_anchor + let args = v_anchor + let v_anchor = g:vikiDefNil + if v_name ==# "#IMG" || v_name =~# "{img" + let v_dest = viki#FindFileWithSuffix(v_dest, viki#GetSpecialFilesSuffixes()) + " TLogVAR v_dest + elseif v_name ==# "#Img" + let id = matchstr(args, '\sid=\zs\w\+') + if id != '' + let v_dest = viki#FindFileWithSuffix(id, viki#GetSpecialFilesSuffixes()) + endif + elseif v_name =~ "^#INC" + " <+TBD+> Search path? + elseif v_name =~ '^{ref\>' + let v_anchor = v_dest + let v_name = g:vikiSelfRef + let v_dest = g:vikiSelfRef + " TLogVAR v_name, v_anchor, v_dest + else + " throw "Viki: Unknown command: ". v_name + let v_name = g:vikiDefNil + let v_dest = g:vikiDefNil + " let v_anchor = g:vikiDefNil + endif + let v_type = v_type == g:vikiDefNil ? 'cmd' : v_type + let vdef = viki#MakeDef(v_name, v_dest, v_anchor, v_part, v_type) + " TLogVAR vdef + return vdef +endf + + +" Complete missing information in the definition of a simple viki name +function! viki_viki#CompleteSimpleNameDef(def) "{{{3 + " TLogVAR a:def + exec viki#SplitDef(a:def) + if v_name == g:vikiDefNil + throw "Viki: Malformed simple viki name (no name): ". string(a:def) + endif + + if !(v_dest == g:vikiDefNil) + throw "Viki: Malformed simple viki name (destination=".v_dest."): ". string(a:def) + endif + + " TLogVAR v_name + if viki#IsInterViki(v_name) + let i_name = viki#InterVikiName(v_name) + let useSuffix = viki#InterVikiSuffix(v_name) + let v_name = viki#InterVikiPart(v_name) + elseif viki#IsHyperWord(v_name) + let hword = viki#HyperWordValue(v_name) + if type(hword) == 4 + let i_name = hword.interviki + let useSuffix = hword.suffix + let v_name = hword.name + else + let i_name = '' + let useSuffix = '' + let v_name = hword + end + else + let i_name = '' + let v_dest = expand("%:p:h") + let useSuffix = g:vikiDefSep + endif + " TLogVAR i_name + + if viki#IsSupportedType("S") + " TLogVAR v_name + if v_name =~ b:vikiQuotedSelfRef + let v_name = g:vikiSelfRef + elseif v_name =~ b:vikiQuotedRef + let v_name = matchstr(v_name, "^". b:vikiSimpleNameQuoteBeg .'\zs.\+\ze'. b:vikiSimpleNameQuoteEnd ."$") + endif + elseif !viki#IsSupportedType("c") + throw "Viki: CamelCase names not allowed" + endif + + if v_name != g:vikiSelfRef + " TLogVAR v_dest, v_name, useSuffix + let rdest = viki#ExpandSimpleName(v_dest, v_name, useSuffix) + " TLogVAR rdest + else + let rdest = g:vikiDefNil + " TLogVAR rdest + endif + + if i_name != '' + let rdest = viki#InterVikiDest(rdest, i_name) + " TLogVAR rdest + " let v_name = '' + endif + + let v_type = v_type == g:vikiDefNil ? 's' : v_type + " TLogVAR v_type + return viki#MakeDef(v_name, rdest, v_anchor, v_part, v_type) +endf + + +" Find a viki name +" viki_viki#Find(flag, ?count=0, ?rx=nil) +function! viki_viki#Find(flag, ...) "{{{3 + let rx = (a:0 >= 2 && a:2 != '') ? a:2 : viki#FindRx() + if rx != "" + let i = a:0 >= 1 ? a:1 : 0 + while i >= 0 + call search(rx, a:flag) + let i = i - 1 + endwh + endif +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/conf_slk120/vim/_vim/compiler/deplate.vim b/conf_slk120/vim/_vim/compiler/deplate.vim index 21a6c58..128e392 100755 --- a/conf_slk120/vim/_vim/compiler/deplate.vim +++ b/conf_slk120/vim/_vim/compiler/deplate.vim @@ -1,9 +1,9 @@ " viki.vim -" @Author: Thomas Link (samul AT web.de) +" @Author: Thomas Link (micathom AT gmail com?subject=vim) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 25-Apr-2004. -" @Last Change: 20-Dez-2005. -" @Revision: 0.41 +" @Last Change: 2007-08-27. +" @Revision: 0.42 " " Description: " Use deplate as the "compiler" for viki files. diff --git a/conf_slk120/vim/_vim/doc/tags b/conf_slk120/vim/_vim/doc/tags index 284d3fa..aa45fb7 100755 --- a/conf_slk120/vim/_vim/doc/tags +++ b/conf_slk120/vim/_vim/doc/tags @@ -196,6 +196,11 @@ :TlistUpdate taglist.txt /*:TlistUpdate* :VikiDefine viki.txt /*:VikiDefine* :VikiEdit viki.txt /*:VikiEdit* +:VikiFilesCall viki.txt /*:VikiFilesCall* +:VikiFilesCmd viki.txt /*:VikiFilesCmd* +:VikiFilesExec viki.txt /*:VikiFilesExec* +:VikiFilesUpdate viki.txt /*:VikiFilesUpdate* +:VikiFilesUpdateAll viki.txt /*:VikiFilesUpdateAll* :VikiFind viki.txt /*:VikiFind* :VikiFindNext viki.txt /*:VikiFindNext* :VikiFindPrev viki.txt /*:VikiFindPrev* @@ -386,11 +391,6 @@ Tlist_Get_Tagname_By_Line() taglist.txt /*Tlist_Get_Tagname_By_Line()* Tlist_Set_App() taglist.txt /*Tlist_Set_App()* Tlist_Update_File_Tags() taglist.txt /*Tlist_Update_File_Tags()* Tshortcuts latex-suite.txt /*Tshortcuts* -VikiDefineHighlighting() viki.txt /*VikiDefineHighlighting()* -VikiDefineMarkup() viki.txt /*VikiDefineMarkup()* -VikiFindAnchor() viki.txt /*VikiFindAnchor()* -VikiGoBack() viki.txt /*VikiGoBack()* -VikiMaybeFollowLink() viki.txt /*VikiMaybeFollowLink()* VikiMinorMode() viki.txt /*VikiMinorMode()* VikiMode() viki.txt /*VikiMode()* VikiOpenSpecialFile() viki.txt /*VikiOpenSpecialFile()* @@ -716,6 +716,7 @@ b:vikiInverseFold viki.txt /*b:vikiInverseFold* b:vikiMaxFoldLevel viki.txt /*b:vikiMaxFoldLevel* b:vikiNameSuffix viki.txt /*b:vikiNameSuffix* b:vikiNoSimpleNames viki.txt /*b:vikiNoSimpleNames* +b:vikiParent viki.txt /*b:vikiParent* bash-support bashsupport.txt /*bash-support* bashsupport bashsupport.txt /*bashsupport* bashsupport-aligned-comm bashsupport.txt /*bashsupport-aligned-comm* @@ -2119,7 +2120,6 @@ font-styles latexhelp.txt /*font-styles* forward-searching latex-suite.txt /*forward-searching* g:vikiCommentStart viki.txt /*g:vikiCommentStart* g:vikiExplorer viki.txt /*g:vikiExplorer* -g:vikiFolds viki.txt /*g:vikiFolds* g:vikiFreeMarker viki.txt /*g:vikiFreeMarker* g:vikiHeadingFont viki.txt /*g:vikiHeadingFont* g:vikiHide viki.txt /*g:vikiHide* @@ -2133,6 +2133,7 @@ g:vikiSaveHistory viki.txt /*g:vikiSaveHistory* g:vikiTypewriterFont viki.txt /*g:vikiTypewriterFont* g:vikiUpperCharacters viki.txt /*g:vikiUpperCharacters* g:vikiUseParentSuffix viki.txt /*g:vikiUseParentSuffix* +g:viki_intervikis viki.txt /*g:viki_intervikis* gdbvim-commands gdbvim.txt /*gdbvim-commands* gdbvim-mappings gdbvim.txt /*gdbvim-mappings* gdbvim-settings gdbvim.txt /*gdbvim-settings* @@ -2745,7 +2746,12 @@ utl_usr.txt utl_usr.txt /*utl_usr.txt* verbatim latexhelp.txt /*verbatim* verse latexhelp.txt /*verse* viewer-customization latex-suite.txt /*viewer-customization* -viki-any-word viki.txt /*viki-any-word* +viki#Define() viki.txt /*viki#Define()* +viki#FindAnchor() viki.txt /*viki#FindAnchor()* +viki#GoBack() viki.txt /*viki#GoBack()* +viki#GoParent() viki.txt /*viki#GoParent()* +viki#MaybeFollowLink() viki.txt /*viki#MaybeFollowLink()* +viki-anyword viki.txt /*viki-anyword* viki-backslash viki.txt /*viki-backslash* viki-bibtex viki.txt /*viki-bibtex* viki-commands viki.txt /*viki-commands* @@ -2755,12 +2761,15 @@ viki-customization viki.txt /*viki-customization* viki-description viki.txt /*viki-description* viki-descriptions viki.txt /*viki-descriptions* viki-extended-names viki.txt /*viki-extended-names* +viki-files viki.txt /*viki-files* +viki-filetype-detection viki.txt /*viki-filetype-detection* viki-functions viki.txt /*viki-functions* viki-headings viki.txt /*viki-headings* viki-highlight viki.txt /*viki-highlight* viki-homepage viki.txt /*viki-homepage* viki-indent-disable viki.txt /*viki-indent-disable* viki-installation viki.txt /*viki-installation* +viki-intervikis viki.txt /*viki-intervikis* viki-key-bindings viki.txt /*viki-key-bindings* viki-latex viki.txt /*viki-latex* viki-lists viki.txt /*viki-lists* @@ -2785,6 +2794,8 @@ viki-vars-simple-names viki.txt /*viki-vars-simple-names* viki-vars-urls viki.txt /*viki-vars-urls* viki.txt viki.txt /*viki.txt* vikiFamily viki.txt /*vikiFamily* +vikiFoldBodyLevel viki.txt /*vikiFoldBodyLevel* +vikiFolds viki.txt /*vikiFolds* vikiLatex viki.txt /*vikiLatex* vikiLatex-UserCommands viki.txt /*vikiLatex-UserCommands* vikiNameSuffix viki.txt /*vikiNameSuffix* diff --git a/conf_slk120/vim/_vim/doc/tlib.txt b/conf_slk120/vim/_vim/doc/tlib.txt new file mode 100644 index 0000000..42c1944 --- /dev/null +++ b/conf_slk120/vim/_vim/doc/tlib.txt @@ -0,0 +1,1434 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Thomas Link, micathom at gmail com + + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +======================================================================== +Contents~ + + plugin/02tlib.vim + :TLet ................................... |:TLet| + :TScratch ............................... |:TScratch| + :TVarArg ................................ |:TVarArg| + :TKeyArg ................................ |:TKeyArg| + :TBrowseOutput .......................... |:TBrowseOutput| + g:tlib_pick_last_item ................... |g:tlib_pick_last_item| + g:tlib_sortprefs_threshold .............. |g:tlib_sortprefs_threshold| + g:tlib_scratch_pos ...................... |g:tlib_scratch_pos| + g:tlib_inputlist_pct .................... |g:tlib_inputlist_pct| + g:tlib_inputlist_width_filename ......... |g:tlib_inputlist_width_filename| + g:tlib_inputlist_higroup ................ |g:tlib_inputlist_higroup| + g:tlib_inputlist_livesearch_threshold ... |g:tlib_inputlist_livesearch_threshold| + g:tlib_inputlist_filename_indicators .... |g:tlib_inputlist_filename_indicators| + g:tlib_tags_extra ....................... |g:tlib_tags_extra| + g:tlib_tag_substitute ................... |g:tlib_tag_substitute| + g:tlib_filename_sep ..................... |g:tlib_filename_sep| + g:tlib_cache ............................ |g:tlib_cache| + g:tlib_viewline_position ................ |g:tlib_viewline_position| + g:tlib_inputlist_and .................... |g:tlib_inputlist_and| + g:tlib_inputlist_or ..................... |g:tlib_inputlist_or| + g:tlib_inputlist_not .................... |g:tlib_inputlist_not| + g:tlib_numeric_chars .................... |g:tlib_numeric_chars| + g:tlib_keyagents_InputList_s ............ |g:tlib_keyagents_InputList_s| + g:tlib_scroll_lines ..................... |g:tlib_scroll_lines| + g:tlib_keyagents_InputList_m ............ |g:tlib_keyagents_InputList_m| + g:tlib_handlers_EditList ................ |g:tlib_handlers_EditList| + autoload/tlib/Object.vim + tlib#Object#New ......................... |tlib#Object#New()| + prototype.New + prototype.Inherit + prototype.Extend + prototype.IsA + prototype.IsRelated + prototype.RespondTo + prototype.Super + prototype.Methods + autoload/tlib/World.vim + tlib#World#New .......................... |tlib#World#New()| + prototype.Set_display_format + prototype.Set_highlight_filename + prototype.Highlight_filename + prototype.FormatFilename + prototype.GetSelectedItems + prototype.SelectItem + prototype.FormatArgs + prototype.GetRx + prototype.GetRx0 + prototype.GetItem + prototype.GetListIdx + prototype.GetBaseIdx + prototype.GetBaseItem + prototype.SetBaseItem + prototype.GetCurrentItem + prototype.CurrentItem + prototype.SetFilter + prototype.Match + prototype.MatchBaseIdx + prototype.BuildTable + prototype.ReduceFilter + prototype.SetInitialFilter + prototype.PopFilter + prototype.FilterIsEmpty + prototype.DisplayFilter + prototype.UseScratch + prototype.CloseScratch + prototype.UseInputListScratch + prototype.Reset + prototype.ResetSelected + prototype.Retrieve + prototype.DisplayHelp + prototype.Resize + prototype.DisplayList + prototype.SetOffset + prototype.DisplayListMark + prototype.SwitchWindow + prototype.FollowCursor + prototype.SetOrigin + prototype.RestoreOrigin + autoload/tlib/agent.vim + tlib#agent#Exit ......................... |tlib#agent#Exit()| + tlib#agent#CopyItems .................... |tlib#agent#CopyItems()| + tlib#agent#PageUp ....................... |tlib#agent#PageUp()| + tlib#agent#PageDown ..................... |tlib#agent#PageDown()| + tlib#agent#Up ........................... |tlib#agent#Up()| + tlib#agent#Down ......................... |tlib#agent#Down()| + tlib#agent#UpN .......................... |tlib#agent#UpN()| + tlib#agent#DownN ........................ |tlib#agent#DownN()| + tlib#agent#ShiftLeft .................... |tlib#agent#ShiftLeft()| + tlib#agent#ShiftRight ................... |tlib#agent#ShiftRight()| + tlib#agent#Reset ........................ |tlib#agent#Reset()| + tlib#agent#Input ........................ |tlib#agent#Input()| + tlib#agent#SuspendToParentWindow ........ |tlib#agent#SuspendToParentWindow()| + tlib#agent#Suspend ...................... |tlib#agent#Suspend()| + tlib#agent#Help ......................... |tlib#agent#Help()| + tlib#agent#OR ........................... |tlib#agent#OR()| + tlib#agent#AND .......................... |tlib#agent#AND()| + tlib#agent#ReduceFilter ................. |tlib#agent#ReduceFilter()| + tlib#agent#PopFilter .................... |tlib#agent#PopFilter()| + tlib#agent#Debug ........................ |tlib#agent#Debug()| + tlib#agent#Select ....................... |tlib#agent#Select()| + tlib#agent#SelectUp ..................... |tlib#agent#SelectUp()| + tlib#agent#SelectDown ................... |tlib#agent#SelectDown()| + tlib#agent#SelectAll .................... |tlib#agent#SelectAll()| + tlib#agent#ToggleStickyList ............. |tlib#agent#ToggleStickyList()| + tlib#agent#EditItem ..................... |tlib#agent#EditItem()| + tlib#agent#NewItem ...................... |tlib#agent#NewItem()| + tlib#agent#DeleteItems .................. |tlib#agent#DeleteItems()| + tlib#agent#Cut .......................... |tlib#agent#Cut()| + tlib#agent#Copy ......................... |tlib#agent#Copy()| + tlib#agent#Paste ........................ |tlib#agent#Paste()| + tlib#agent#EditReturnValue .............. |tlib#agent#EditReturnValue()| + tlib#agent#ViewFile ..................... |tlib#agent#ViewFile()| + tlib#agent#EditFile ..................... |tlib#agent#EditFile()| + tlib#agent#EditFileInSplit .............. |tlib#agent#EditFileInSplit()| + tlib#agent#EditFileInVSplit ............. |tlib#agent#EditFileInVSplit()| + tlib#agent#EditFileInTab ................ |tlib#agent#EditFileInTab()| + tlib#agent#ToggleScrollbind ............. |tlib#agent#ToggleScrollbind()| + tlib#agent#ShowInfo ..................... |tlib#agent#ShowInfo()| + tlib#agent#PreviewLine .................. |tlib#agent#PreviewLine()| + tlib#agent#GotoLine ..................... |tlib#agent#GotoLine()| + tlib#agent#DoAtLine ..................... |tlib#agent#DoAtLine()| + autoload/tlib/arg.vim + tlib#arg#Get ............................ |tlib#arg#Get()| + tlib#arg#Let ............................ |tlib#arg#Let()| + tlib#arg#Key ............................ |tlib#arg#Key()| + tlib#arg#StringAsKeyArgs ................ |tlib#arg#StringAsKeyArgs()| + tlib#arg#Ex ............................. |tlib#arg#Ex()| + autoload/tlib/buffer.vim + tlib#buffer#Set ......................... |tlib#buffer#Set()| + tlib#buffer#Eval ........................ |tlib#buffer#Eval()| + tlib#buffer#GetList ..................... |tlib#buffer#GetList()| + tlib#buffer#ViewLine .................... |tlib#buffer#ViewLine()| + tlib#buffer#HighlightLine ............... |tlib#buffer#HighlightLine()| + tlib#buffer#DeleteRange ................. |tlib#buffer#DeleteRange()| + tlib#buffer#ReplaceRange ................ |tlib#buffer#ReplaceRange()| + tlib#buffer#ScratchStart ................ |tlib#buffer#ScratchStart()| + tlib#buffer#ScratchEnd .................. |tlib#buffer#ScratchEnd()| + tlib#buffer#BufDo ....................... |tlib#buffer#BufDo()| + tlib#buffer#InsertText .................. |tlib#buffer#InsertText()| + tlib#buffer#InsertText0 ................. |tlib#buffer#InsertText0()| + tlib#buffer#CurrentByte ................. |tlib#buffer#CurrentByte()| + autoload/tlib/cache.vim + tlib#cache#Filename ..................... |tlib#cache#Filename()| + tlib#cache#Save ......................... |tlib#cache#Save()| + tlib#cache#Get .......................... |tlib#cache#Get()| + autoload/tlib/char.vim + tlib#char#Get ........................... |tlib#char#Get()| + tlib#char#IsAvailable ................... |tlib#char#IsAvailable()| + tlib#char#GetWithTimeout ................ |tlib#char#GetWithTimeout()| + autoload/tlib/cmd.vim + tlib#cmd#OutputAsList ................... |tlib#cmd#OutputAsList()| + tlib#cmd#BrowseOutput ................... |tlib#cmd#BrowseOutput()| + tlib#cmd#UseVertical .................... |tlib#cmd#UseVertical()| + tlib#cmd#Time ........................... |tlib#cmd#Time()| + autoload/tlib/comments.vim + tlib#comments#Comments .................. |tlib#comments#Comments()| + autoload/tlib/dir.vim + tlib#dir#CanonicName .................... |tlib#dir#CanonicName()| + tlib#dir#PlainName ...................... |tlib#dir#PlainName()| + tlib#dir#Ensure ......................... |tlib#dir#Ensure()| + tlib#dir#MyRuntime ...................... |tlib#dir#MyRuntime()| + tlib#dir#CD ............................. |tlib#dir#CD()| + tlib#dir#Push ........................... |tlib#dir#Push()| + tlib#dir#Pop ............................ |tlib#dir#Pop()| + autoload/tlib/eval.vim + tlib#eval#FormatValue ................... |tlib#eval#FormatValue()| + autoload/tlib/file.vim + tlib#file#Split ......................... |tlib#file#Split()| + tlib#file#Join .......................... |tlib#file#Join()| + tlib#file#Relative ...................... |tlib#file#Relative()| + tlib#file#With .......................... |tlib#file#With()| + autoload/tlib/hook.vim + tlib#hook#Run ........................... |tlib#hook#Run()| + autoload/tlib/input.vim + tlib#input#List ......................... |tlib#input#List()| + tlib#input#ListD ........................ |tlib#input#ListD()| + tlib#input#ListW ........................ |tlib#input#ListW()| + tlib#input#EditList ..................... |tlib#input#EditList()| + tlib#input#Resume ....................... |tlib#input#Resume()| + tlib#input#CommandSelect ................ |tlib#input#CommandSelect()| + tlib#input#Edit ......................... |tlib#input#Edit()| + autoload/tlib/list.vim + tlib#list#Inject ........................ |tlib#list#Inject()| + tlib#list#Compact ....................... |tlib#list#Compact()| + tlib#list#Flatten ....................... |tlib#list#Flatten()| + tlib#list#FindAll ....................... |tlib#list#FindAll()| + tlib#list#Find .......................... |tlib#list#Find()| + tlib#list#Any ........................... |tlib#list#Any()| + tlib#list#All ........................... |tlib#list#All()| + tlib#list#Remove ........................ |tlib#list#Remove()| + tlib#list#RemoveAll ..................... |tlib#list#RemoveAll()| + tlib#list#Zip ........................... |tlib#list#Zip()| + tlib#list#Uniq .......................... |tlib#list#Uniq()| + autoload/tlib/progressbar.vim + tlib#progressbar#Init ................... |tlib#progressbar#Init()| + tlib#progressbar#Display ................ |tlib#progressbar#Display()| + tlib#progressbar#Restore ................ |tlib#progressbar#Restore()| + autoload/tlib/rx.vim + tlib#rx#Escape .......................... |tlib#rx#Escape()| + autoload/tlib/scratch.vim + tlib#scratch#UseScratch ................. |tlib#scratch#UseScratch()| + tlib#scratch#CloseScratch ............... |tlib#scratch#CloseScratch()| + autoload/tlib/string.vim + tlib#string#RemoveBackslashes ........... |tlib#string#RemoveBackslashes()| + tlib#string#Chomp ....................... |tlib#string#Chomp()| + tlib#string#Printf1 ..................... |tlib#string#Printf1()| + tlib#string#TrimLeft .................... |tlib#string#TrimLeft()| + tlib#string#TrimRight ................... |tlib#string#TrimRight()| + tlib#string#Strip ....................... |tlib#string#Strip()| + autoload/tlib/syntax.vim + tlib#syntax#Collect ..................... |tlib#syntax#Collect()| + tlib#syntax#Names ....................... |tlib#syntax#Names()| + autoload/tlib/tab.vim + tlib#tab#BufMap ......................... |tlib#tab#BufMap()| + tlib#tab#TabWinNr ....................... |tlib#tab#TabWinNr()| + tlib#tab#Set ............................ |tlib#tab#Set()| + autoload/tlib/tag.vim + tlib#tag#Retrieve ....................... |tlib#tag#Retrieve()| + tlib#tag#Collect ........................ |tlib#tag#Collect()| + tlib#tag#Format ......................... |tlib#tag#Format()| + autoload/tlib/time.vim + tlib#time#MSecs ......................... |tlib#time#MSecs()| + tlib#time#Now ........................... |tlib#time#Now()| + tlib#time#Diff .......................... |tlib#time#Diff()| + tlib#time#DiffMSecs ..................... |tlib#time#DiffMSecs()| + autoload/tlib/type.vim + tlib#type#IsNumber ...................... |tlib#type#IsNumber()| + tlib#type#IsString ...................... |tlib#type#IsString()| + tlib#type#IsFuncref ..................... |tlib#type#IsFuncref()| + tlib#type#IsList ........................ |tlib#type#IsList()| + tlib#type#IsDictionary .................. |tlib#type#IsDictionary()| + autoload/tlib/url.vim + tlib#url#Decode ......................... |tlib#url#Decode()| + tlib#url#DecodeChar ..................... |tlib#url#DecodeChar()| + tlib#url#EncodeChar ..................... |tlib#url#EncodeChar()| + tlib#url#Encode ......................... |tlib#url#Encode()| + autoload/tlib/var.vim + tlib#var#Let ............................ |tlib#var#Let()| + tlib#var#EGet ........................... |tlib#var#EGet()| + tlib#var#Get ............................ |tlib#var#Get()| + tlib#var#List ........................... |tlib#var#List()| + autoload/tlib/win.vim + tlib#win#Set ............................ |tlib#win#Set()| + tlib#win#GetLayout ...................... |tlib#win#GetLayout()| + tlib#win#SetLayout ...................... |tlib#win#SetLayout()| + tlib#win#Width .......................... |tlib#win#Width()| + + +======================================================================== +plugin/02tlib.vim~ + + *:TLet* +:TLet VAR = VALUE + Commands + Set a variable only if it doesn't already exist. + EXAMPLES: > + TLet foo = 1 + TLet foo = 2 + echo foo + => 1 +< + + *:TScratch* +:TScratch + Open a scratch buffer (a buffer without a file). + TScratch ... use split window + TScratch! ... use the whole frame + This command takes an (inner) dictionnary as optional argument. + EXAMPLES: > + TScratch 'scratch': '__FOO__' + => Open a scratch buffer named __FOO__ +< + + *:TVarArg* +:TVarArg VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(...) + TVarArg ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TKeyArg* +:TKeyArg DICT, VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(keyargs) + TKeyArg a:keyargs, ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TBrowseOutput* +TBrowseOutput COMMAND + Every wondered how to effciently browse the output of a command + without redirecting it to a file? This command takes a command as + argument and presents the output via |tlib#input#List()| so that you + can easily search for a keyword (e.g. the name of a variable or + function) and the like. + + If you press enter, the selected line will be copied to the command + line. Press ESC to cancel browsing. + + EXAMPLES: > + TBrowseOutput 20verb TeaseTheCulprit +< + + *g:tlib_pick_last_item* +g:tlib_pick_last_item (default: 1) + When 1, automatically select a the last remaining item after applying + any filters. + + *g:tlib_sortprefs_threshold* +g:tlib_sortprefs_threshold (default: 200) + If a list is bigger than this value, don't try to be smart when + selecting an item. Be slightly faster instead. + + *g:tlib_scratch_pos* +g:tlib_scratch_pos (default: 'botright') + Scratch window position + + *g:tlib_inputlist_pct* +g:tlib_inputlist_pct (default: 70) + Size of the input list window (in percent) from the main size (of &lines). + + *g:tlib_inputlist_width_filename* +g:tlib_inputlist_width_filename (default: '&co / 3') + Size of filename columns when listing filenames + + *g:tlib_inputlist_higroup* +g:tlib_inputlist_higroup (default: 'IncSearch') + The highlight group to use for showing matches in the input list window. + + *g:tlib_inputlist_livesearch_threshold* +g:tlib_inputlist_livesearch_threshold (default: 500) + If a list contains more items, don't do an incremental "live search", + but use |input()| the quere the user for a filter. This is useful on + slower machines or with very long lists. + + *g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_filename_indicators (default: 0) + If true, show some indicators about the status of a filename (eg + buflisted(), bufloaded() etc.). + This is disabled by default because vim checks also for the file on + disk when doing this. + + *g:tlib_tags_extra* +g:tlib_tags_extra (default: '') + Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. + + *g:tlib_tag_substitute* +g:tlib_tag_substitute + Filter the tag description through |substitute()| for these filetypes. + This applies only if the tag cmd field (see |taglist()|) is used. + + *g:tlib_filename_sep* +g:tlib_filename_sep (default: '/') + + *g:tlib_cache* +g:tlib_cache (default: '') + The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache' + + *g:tlib_viewline_position* +g:tlib_viewline_position (default: 'zz') + Where to display the line when using |tlib#buffer#ViewLine|. + For possible values for position see |scroll-cursor|. + + +Keys for |tlib#input#List|~ + + *g:tlib_inputlist_and* +g:tlib_inputlist_and (default: ' ') + + *g:tlib_inputlist_or* +g:tlib_inputlist_or (default: '|') + + *g:tlib_inputlist_not* +g:tlib_inputlist_not (default: '-') + + *g:tlib_numeric_chars* +g:tlib_numeric_chars + When editing a list with |tlib#input#List|, typing these numeric chars + (as returned by getchar()) will select an item based on its index, not + based on its name. I.e. in the default setting, typing a "4" will + select the fourth item, not the item called "4". + In order to make keys 0-9 filter the items in the list and make + select an item by its index, remove the keys 48 to 57 from + this dictionary. + Format: [KEY] = BASE ... the number is calculated as KEY - BASE. + + *g:tlib_keyagents_InputList_s* +g:tlib_keyagents_InputList_s + + *g:tlib_scroll_lines* +g:tlib_scroll_lines (default: 10) + Number of items to move when pressing in the input list window. + + *g:tlib_keyagents_InputList_m* +g:tlib_keyagents_InputList_m + + *g:tlib_handlers_EditList* +g:tlib_handlers_EditList + + +======================================================================== +autoload/tlib/Object.vim~ +Provides a prototype plus some OO-like methods. + + *tlib#Object#New()* +tlib#Object#New(?fields={}) + This function creates a prototype that provides some kind of + inheritance mechanism and a way to call parent/super's methods. + + The usage demonstrated in the following example works best, when every + class/prototype is defined in a file of its own. + + The reason for why there is a dedicated constructor function is that + this layout facilitates the use of templates and that methods are + hidden from the user. Other solutions are possible. + + EXAMPLES: > + let s:prototype = tlib#Object#New({ + \ '_class': ['FooBar'], + \ 'foo': 1, + \ 'bar': 2, + \ }) + " Constructor + function! FooBar(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object + endf + function! s:prototype.babble() { + echo "I think, therefore I am ". (self.foo * self.bar) ." months old." + } + +< This could now be used like this: > + let myfoo = FooBar({'foo': 3}) + call myfoo.babble() + => I think, therefore I am 6 months old. + echo myfoo.IsA('FooBar') + => 1 + echo myfoo.IsA('object') + => 1 + echo myfoo.IsA('Foo') + => 0 + echo myfoo.RespondTo('babble') + => 1 + echo myfoo.RespondTo('speak') + => 0 +< + + +prototype.New + + +prototype.Inherit + + +prototype.Extend + + +prototype.IsA + + +prototype.IsRelated + + +prototype.RespondTo + + +prototype.Super + + +prototype.Methods + + +======================================================================== +autoload/tlib/World.vim~ +A prototype used by |tlib#input#List|. +Inherits from |tlib#Object#New|. + + *tlib#World#New()* +tlib#World#New(...) + + +prototype.Set_display_format + + +prototype.Set_highlight_filename + + +prototype.Highlight_filename + + +prototype.FormatFilename + + +prototype.GetSelectedItems + + +prototype.SelectItem + + +prototype.FormatArgs + + +prototype.GetRx + + +prototype.GetRx0 + + +prototype.GetItem + + +prototype.GetListIdx + + +prototype.GetBaseIdx + + +prototype.GetBaseItem + + +prototype.SetBaseItem + + +prototype.GetCurrentItem + + +prototype.CurrentItem + + +prototype.SetFilter + + +prototype.Match + + +prototype.MatchBaseIdx + + +prototype.BuildTable + + +prototype.ReduceFilter + + +prototype.SetInitialFilter + + +prototype.PopFilter + + +prototype.FilterIsEmpty + + +prototype.DisplayFilter + + +prototype.UseScratch + + +prototype.CloseScratch + + +prototype.UseInputListScratch + + +prototype.Reset + + +prototype.ResetSelected + + +prototype.Retrieve + + +prototype.DisplayHelp + + +prototype.Resize + + +prototype.DisplayList + + +prototype.SetOffset + + +prototype.DisplayListMark + + +prototype.SwitchWindow + + +prototype.FollowCursor + + +prototype.SetOrigin + + +prototype.RestoreOrigin + + +======================================================================== +autoload/tlib/agent.vim~ +Various agents for use as key handlers in tlib#input#List() + + *tlib#agent#Exit()* +tlib#agent#Exit(world, selected) + + *tlib#agent#CopyItems()* +tlib#agent#CopyItems(world, selected) + + *tlib#agent#PageUp()* +tlib#agent#PageUp(world, selected) + + *tlib#agent#PageDown()* +tlib#agent#PageDown(world, selected) + + *tlib#agent#Up()* +tlib#agent#Up(world, selected, ...) + + *tlib#agent#Down()* +tlib#agent#Down(world, selected, ...) + + *tlib#agent#UpN()* +tlib#agent#UpN(world, selected) + + *tlib#agent#DownN()* +tlib#agent#DownN(world, selected) + + *tlib#agent#ShiftLeft()* +tlib#agent#ShiftLeft(world, selected) + + *tlib#agent#ShiftRight()* +tlib#agent#ShiftRight(world, selected) + + *tlib#agent#Reset()* +tlib#agent#Reset(world, selected) + + *tlib#agent#Input()* +tlib#agent#Input(world, selected) + + *tlib#agent#SuspendToParentWindow()* +tlib#agent#SuspendToParentWindow(world, selected) + Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the + original position in the parent window. + + *tlib#agent#Suspend()* +tlib#agent#Suspend(world, selected) + Suspend lets you temporarily leave the input loop of + |tlib#input#List|. You can resume editing the list by pressing , + . , , or in the suspended window. + + *tlib#agent#Help()* +tlib#agent#Help(world, selected) + + *tlib#agent#OR()* +tlib#agent#OR(world, selected) + + *tlib#agent#AND()* +tlib#agent#AND(world, selected) + + *tlib#agent#ReduceFilter()* +tlib#agent#ReduceFilter(world, selected) + + *tlib#agent#PopFilter()* +tlib#agent#PopFilter(world, selected) + + *tlib#agent#Debug()* +tlib#agent#Debug(world, selected) + + *tlib#agent#Select()* +tlib#agent#Select(world, selected) + + *tlib#agent#SelectUp()* +tlib#agent#SelectUp(world, selected) + + *tlib#agent#SelectDown()* +tlib#agent#SelectDown(world, selected) + + *tlib#agent#SelectAll()* +tlib#agent#SelectAll(world, selected) + + *tlib#agent#ToggleStickyList()* +tlib#agent#ToggleStickyList(world, selected) + + *tlib#agent#EditItem()* +tlib#agent#EditItem(world, selected) + + *tlib#agent#NewItem()* +tlib#agent#NewItem(world, selected) + + *tlib#agent#DeleteItems()* +tlib#agent#DeleteItems(world, selected) + + *tlib#agent#Cut()* +tlib#agent#Cut(world, selected) + + *tlib#agent#Copy()* +tlib#agent#Copy(world, selected) + + *tlib#agent#Paste()* +tlib#agent#Paste(world, selected) + + *tlib#agent#EditReturnValue()* +tlib#agent#EditReturnValue(world, rv) + + *tlib#agent#ViewFile()* +tlib#agent#ViewFile(world, selected) + + *tlib#agent#EditFile()* +tlib#agent#EditFile(world, selected) + + *tlib#agent#EditFileInSplit()* +tlib#agent#EditFileInSplit(world, selected) + + *tlib#agent#EditFileInVSplit()* +tlib#agent#EditFileInVSplit(world, selected) + + *tlib#agent#EditFileInTab()* +tlib#agent#EditFileInTab(world, selected) + + *tlib#agent#ToggleScrollbind()* +tlib#agent#ToggleScrollbind(world, selected) + + *tlib#agent#ShowInfo()* +tlib#agent#ShowInfo(world, selected) + + *tlib#agent#PreviewLine()* +tlib#agent#PreviewLine(world, selected) + + *tlib#agent#GotoLine()* +tlib#agent#GotoLine(world, selected) + If not called from the scratch, we assume/guess that we don't have to + suspend the input-evaluation loop. + + *tlib#agent#DoAtLine()* +tlib#agent#DoAtLine(world, selected) + + +======================================================================== +autoload/tlib/arg.vim~ + + *tlib#arg#Get()* +tlib#arg#Get(n, var, ?default="", ?test='') + Set a positional argument from a variable argument list. + See tlib#string#RemoveBackslashes() for an example. + + *tlib#arg#Let()* +tlib#arg#Let(list, ?default='') + Set a positional arguments from a variable argument list. + See tlib#input#List() for an example. + + *tlib#arg#Key()* +tlib#arg#Key(dict, list, ?default='') + See |:TKeyArg|. + + *tlib#arg#StringAsKeyArgs()* +tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0) + + *tlib#arg#Ex()* +tlib#arg#Ex(arg, ?chars='%#! ') + Escape some characters in a string. + + Use |fnamescape()| if available. + + EXAMPLES: > + exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +< + + +======================================================================== +autoload/tlib/buffer.vim~ + + *tlib#buffer#Set()* +tlib#buffer#Set(buffer) + Set the buffer to buffer and return a command as string that can be + evaluated by |:execute| in order to restore the original view. + + *tlib#buffer#Eval()* +tlib#buffer#Eval(buffer, code) + Evaluate CODE in BUFFER. + + EXAMPLES: > + call tlib#buffer#Eval('foo.txt', 'echo b:bar') +< + + *tlib#buffer#GetList()* +tlib#buffer#GetList(?show_hidden=0, ?show_number=0) + + *tlib#buffer#ViewLine()* +tlib#buffer#ViewLine(line, ?position='z') + line is either a number or a string that begins with a number. + For possible values for position see |scroll-cursor|. + See also |g:tlib_viewline_position|. + + *tlib#buffer#HighlightLine()* +tlib#buffer#HighlightLine(line) + + *tlib#buffer#DeleteRange()* +tlib#buffer#DeleteRange(line1, line2) + Delete the lines in the current buffer. Wrapper for |:delete|. + + *tlib#buffer#ReplaceRange()* +tlib#buffer#ReplaceRange(line1, line2, lines) + Replace a range of lines. + + *tlib#buffer#ScratchStart()* +tlib#buffer#ScratchStart() + Initialize some scratch area at the bottom of the current buffer. + + *tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchEnd() + Remove the in-buffer scratch area. + + *tlib#buffer#BufDo()* +tlib#buffer#BufDo(exec) + Run exec on all buffers via bufdo and return to the original buffer. + + *tlib#buffer#InsertText()* +tlib#buffer#InsertText(text, keyargs) + Keyargs: + 'shift': 0|N + 'col': col('.')|N + 'lineno': line('.')|N + 'indent': 0|1 + 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) + Insert text (a string) in the buffer. + + *tlib#buffer#InsertText0()* +tlib#buffer#InsertText0(text, ...) + + *tlib#buffer#CurrentByte()* +tlib#buffer#CurrentByte() + + +======================================================================== +autoload/tlib/cache.vim~ + + *tlib#cache#Filename()* +tlib#cache#Filename(type, ?file=%, ?mkdir=0) + + *tlib#cache#Save()* +tlib#cache#Save(cfile, dictionary) + + *tlib#cache#Get()* +tlib#cache#Get(cfile) + + +======================================================================== +autoload/tlib/char.vim~ + + *tlib#char#Get()* +tlib#char#Get(?timeout=0) + Get a character. + + EXAMPLES: > + echo tlib#char#Get() + echo tlib#char#Get(5) +< + + *tlib#char#IsAvailable()* +tlib#char#IsAvailable() + + *tlib#char#GetWithTimeout()* +tlib#char#GetWithTimeout(timeout, ...) + + +======================================================================== +autoload/tlib/cmd.vim~ + + *tlib#cmd#OutputAsList()* +tlib#cmd#OutputAsList(command) + + *tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutput(command) + See |:TBrowseOutput|. + + *tlib#cmd#UseVertical()* +tlib#cmd#UseVertical(?rx='') + Look at the history whether the command was called with vertical. If + an rx is provided check first if the last entry in the history matches + this rx. + + *tlib#cmd#Time()* +tlib#cmd#Time(cmd) + Print the time in seconds a command takes. + + +======================================================================== +autoload/tlib/comments.vim~ + + *tlib#comments#Comments()* +tlib#comments#Comments(...) + function! tlib#comments#Comments(?rx='') + + +======================================================================== +autoload/tlib/dir.vim~ + + *tlib#dir#CanonicName()* +tlib#dir#CanonicName(dirname) + EXAMPLES: > + tlib#dir#CanonicName('foo/bar') + => 'foo/bar/' +< + + *tlib#dir#PlainName()* +tlib#dir#PlainName(dirname) + EXAMPLES: > + tlib#dir#PlainName('foo/bar/') + => 'foo/bar' +< + + *tlib#dir#Ensure()* +tlib#dir#Ensure(dir) + Create a directory if it doesn't already exist. + + *tlib#dir#MyRuntime()* +tlib#dir#MyRuntime() + Return the first directory in &rtp. + + *tlib#dir#CD()* +tlib#dir#CD(dir, ?locally=0) + + *tlib#dir#Push()* +tlib#dir#Push(dir, ?locally=0) + + *tlib#dir#Pop()* +tlib#dir#Pop() + + +======================================================================== +autoload/tlib/eval.vim~ + + *tlib#eval#FormatValue()* +tlib#eval#FormatValue(value, ...) + + +======================================================================== +autoload/tlib/file.vim~ + + *tlib#file#Split()* +tlib#file#Split(filename) + EXAMPLES: > + tlib#file#Split('foo/bar/filename.txt') + => ['foo', 'bar', 'filename.txt'] +< + + *tlib#file#Join()* +tlib#file#Join(filename_parts) + EXAMPLES: > + tlib#file#Join(['foo', 'bar', 'filename.txt']) + => 'foo/bar/filename.txt' +< + + *tlib#file#Relative()* +tlib#file#Relative(filename, basedir) + EXAMPLES: > + tlib#file#Relative('foo/bar/filename.txt', 'foo') + => 'bar/filename.txt' +< + + *tlib#file#With()* +tlib#file#With(fcmd, bcmd, files, ?world={}) + + +======================================================================== +autoload/tlib/hook.vim~ + + *tlib#hook#Run()* +tlib#hook#Run(hook, ?dict={}) + Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. + + +======================================================================== +autoload/tlib/input.vim~ +Input-related, select from a list etc. + + *tlib#input#List()* +tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) + Select a single or multiple items from a list. Return either the list + of selected elements or its indexes. + + By default, typing numbers will select an item by its index. See + |g:tlib_numeric_chars| to find out how to change this. + + The item is automatically selected if the numbers typed equals the + number of digits of the list length. I.e. if a list contains 20 items, + typing 1 will first highlight item 1 but it won't select/use it + because 1 is an ambiguous input in this context. If you press enter, + the first item will be selected. If you press another digit (e.g. 0), + item 10 will be selected. Another way to select item 1 would be to + type 01. If the list contains only 9 items, typing 1 would select the + first item right away. + + type can be: + s ... Return one selected element + si ... Return the index of the selected element + m ... Return a list of selcted elements + mi ... Return a list of indexes + + EXAMPLES: > + echo tlib#input#List('s', 'Select one item', [100,200,300]) + echo tlib#input#List('si', 'Select one item', [100,200,300]) + echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) + echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) +< + + *tlib#input#ListD()* +tlib#input#ListD(dict) + A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from + dict. + + *tlib#input#ListW()* +tlib#input#ListW(world, ?command='') + The second argument, command is meant for internal use only. + The same as |tlib#input#List| but the arguments are packed into world + (an instance of tlib#World as returned by |tlib#World#New|). + + *tlib#input#EditList()* +tlib#input#EditList(query, list, ?timeout=0) + Edit a list. + + EXAMPLES: > + echo tlib#input#EditList('Edit:', [100,200,300]) +< + + *tlib#input#Resume()* +tlib#input#Resume(name) + + *tlib#input#CommandSelect()* +tlib#input#CommandSelect(command, ?keyargs={}) + Take a command, view the output, and let the user select an item from + its output. + + EXAMPLE: > + command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') + command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +< + + *tlib#input#Edit()* +tlib#input#Edit(name, value, callback, ?cb_args=[]) + + Edit a value (asynchronously) in a scratch buffer. Use name for + identification. Call callback when done (or on cancel). + In the scratch buffer: + Press or to enter the new value, c to cancel + editing. + EXAMPLES: > + fun! FooContinue(success, text) + if a:success + let b:var = a:text + endif + endf + call tlib#input#Edit('foo', b:var, 'FooContinue') +< + + +======================================================================== +autoload/tlib/list.vim~ + + *tlib#list#Inject()* +tlib#list#Inject(list, initial_value, funcref) + EXAMPLES: > + echo tlib#list#Inject([1,2,3], 0, function('Add') + => 6 +< + + *tlib#list#Compact()* +tlib#list#Compact(list) + EXAMPLES: > + tlib#list#Compact([0,1,2,3,[], {}, ""]) + => [1,2,3] +< + + *tlib#list#Flatten()* +tlib#list#Flatten(list) + EXAMPLES: > + tlib#list#Flatten([0,[1,2,[3,""]]]) + => [0,1,2,3,""] +< + + *tlib#list#FindAll()* +tlib#list#FindAll(list, filter, ?process_expr="") + Basically the same as filter() + + EXAMPLES: > + tlib#list#FindAll([1,2,3], 'v:val >= 2') + => [2, 3] +< + + *tlib#list#Find()* +tlib#list#Find(list, filter, ?default="", ?process_expr="") + + EXAMPLES: > + tlib#list#Find([1,2,3], 'v:val >= 2') + => 2 +< + + *tlib#list#Any()* +tlib#list#Any(list, expr) + EXAMPLES: > + tlib#list#Any([1,2,3], 'v:val >= 2') + => 1 +< + + *tlib#list#All()* +tlib#list#All(list, expr) + EXAMPLES: > + tlib#list#All([1,2,3], 'v:val >= 2') + => 0 +< + + *tlib#list#Remove()* +tlib#list#Remove(list, element) + EXAMPLES: > + tlib#list#Remove([1,2,1,2], 2) + => [1,1,2] +< + + *tlib#list#RemoveAll()* +tlib#list#RemoveAll(list, element) + EXAMPLES: > + tlib#list#RemoveAll([1,2,1,2], 2) + => [1,1] +< + + *tlib#list#Zip()* +tlib#list#Zip(lists, ?default='') + EXAMPLES: > + tlib#list#Zip([[1,2,3], [4,5,6]]) + => [[1,4], [2,5], [3,6]] +< + + *tlib#list#Uniq()* +tlib#list#Uniq(list, ...) + + +======================================================================== +autoload/tlib/progressbar.vim~ + + *tlib#progressbar#Init()* +tlib#progressbar#Init(max, ...) + EXAMPLE: > + call tlib#progressbar#Init(20) + try + for i in range(20) + call tlib#progressbar#Display(i) + call DoSomethingThatTakesSomeTime(i) + endfor + finally + call tlib#progressbar#Restore() + endtry +< + + *tlib#progressbar#Display()* +tlib#progressbar#Display(value, ...) + + *tlib#progressbar#Restore()* +tlib#progressbar#Restore() + + +======================================================================== +autoload/tlib/rx.vim~ + + *tlib#rx#Escape()* +tlib#rx#Escape(text, ?magic='m') + magic can be one of: m, M, v, V + See :help 'magic' + + +======================================================================== +autoload/tlib/scratch.vim~ + + *tlib#scratch#UseScratch()* +tlib#scratch#UseScratch(?keyargs={}) + Display a scratch buffer (a buffer with no file). See :TScratch for an + example. + Return the scratch's buffer number. + + *tlib#scratch#CloseScratch()* +tlib#scratch#CloseScratch(keyargs, ...) + Close a scratch buffer as defined in keyargs (usually a World). + + +======================================================================== +autoload/tlib/string.vim~ + + *tlib#string#RemoveBackslashes()* +tlib#string#RemoveBackslashes(text, ?chars=' ') + Remove backslashes from text (but only in front of the characters in + chars). + + *tlib#string#Chomp()* +tlib#string#Chomp(string) + + *tlib#string#Printf1()* +tlib#string#Printf1(format, string) + This function deviates from |printf()| in certain ways. + Additional items: + %{rx} ... insert escaped regexp + %{fuzzyrx} ... insert typo-tolerant regexp + + *tlib#string#TrimLeft()* +tlib#string#TrimLeft(string) + + *tlib#string#TrimRight()* +tlib#string#TrimRight(string) + + *tlib#string#Strip()* +tlib#string#Strip(string) + + +======================================================================== +autoload/tlib/syntax.vim~ + + *tlib#syntax#Collect()* +tlib#syntax#Collect() + + *tlib#syntax#Names()* +tlib#syntax#Names(?rx='') + + +======================================================================== +autoload/tlib/tab.vim~ + + *tlib#tab#BufMap()* +tlib#tab#BufMap() + Return a dictionary of bufnumbers => [[tabpage, winnr] ...] + + *tlib#tab#TabWinNr()* +tlib#tab#TabWinNr(buffer) + Find a buffer's window at some tab page. + + *tlib#tab#Set()* +tlib#tab#Set(tabnr) + + +======================================================================== +autoload/tlib/tag.vim~ + + *tlib#tag#Retrieve()* +tlib#tag#Retrieve(rx, ?extra_tags=0) + Get all tags matching rx. Basically, this function simply calls + |taglist()|, but when extra_tags is true, the list of the tag files + (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. + + Example use: + If want to include tags for, eg, JDK, normal tags use can become slow. + You could proceed as follows: + 1. Create a tags file for the JDK sources. When creating the tags + file, make sure to include inheritance information and the like + (command-line options like --fields=+iaSm --extra=+q should be ok). + In this example, we want tags only for public methods (there are + most likely better ways to do this): > + ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src + head -n 6 tags > tags0 + grep access:public tags >> tags0 +< 2. Say 'tags' included project specific tags files. In + ~/vimfiles/after/ftplugin/java.vim insert: > + let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +< 3. When this function is invoked as > + echo tlib#tag#Retrieve('print') +< It will return only project-local tags. If it is invoked as > + echo tlib#tag#Retrieve('print', 1) +< tags from the JDK will be included. + + *tlib#tag#Collect()* +tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) + Retrieve tags that meet the the constraints (a dictionnary of fields and + regexp, with the exception of the kind field that is a list of chars). + For the use of the optional use_extra argument see + |tlib#tag#Retrieve()|. + + *tlib#tag#Format()* +tlib#tag#Format(tag) + + +======================================================================== +autoload/tlib/time.vim~ + + *tlib#time#MSecs()* +tlib#time#MSecs() + + *tlib#time#Now()* +tlib#time#Now() + + *tlib#time#Diff()* +tlib#time#Diff(a, b, ...) + + *tlib#time#DiffMSecs()* +tlib#time#DiffMSecs(a, b, ...) + + +======================================================================== +autoload/tlib/type.vim~ + + *tlib#type#IsNumber()* +tlib#type#IsNumber(expr) + + *tlib#type#IsString()* +tlib#type#IsString(expr) + + *tlib#type#IsFuncref()* +tlib#type#IsFuncref(expr) + + *tlib#type#IsList()* +tlib#type#IsList(expr) + + *tlib#type#IsDictionary()* +tlib#type#IsDictionary(expr) + + +======================================================================== +autoload/tlib/url.vim~ + + *tlib#url#Decode()* +tlib#url#Decode(url) + Decode an encoded URL. + + *tlib#url#DecodeChar()* +tlib#url#DecodeChar(char) + Decode a single character. + + *tlib#url#EncodeChar()* +tlib#url#EncodeChar(char) + Encode a single character. + + *tlib#url#Encode()* +tlib#url#Encode(url, ...) + Encode an url. + + +======================================================================== +autoload/tlib/var.vim~ + + *tlib#var#Let()* +tlib#var#Let(name, val) + Define a variable called NAME if yet undefined. + You can also use the :TLLet command. + + EXAMPLES: > + exec tlib#var#Let('g:foo', 1) + TLet g:foo = 1 +< + + *tlib#var#EGet()* +tlib#var#EGet(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo eval(tlib#var#EGet('foo', 'vg')) => 1 + echo eval(tlib#var#EGet('foo', 'bg')) => 2 + echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +< + + *tlib#var#Get()* +tlib#var#Get(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo tlib#var#Get('foo', 'vg') => 1 + echo tlib#var#Get('foo', 'bg') => 2 + echo tlib#var#Get('foo', 'wbg') => 3 +< + + *tlib#var#List()* +tlib#var#List(rx, ?prefix='') + Get a list of variables matching rx. + EXAMPLE: + echo tlib#var#List('tlib_', 'g:') + + +======================================================================== +autoload/tlib/win.vim~ + + *tlib#win#Set()* +tlib#win#Set(winnr) + Return vim code to jump back to the original window. + + *tlib#win#GetLayout()* +tlib#win#GetLayout(?save_view=0) + + *tlib#win#SetLayout()* +tlib#win#SetLayout(layout) + + *tlib#win#Width()* +tlib#win#Width(wnr) + + diff --git a/conf_slk120/vim/_vim/doc/viki.txt b/conf_slk120/vim/_vim/doc/viki.txt old mode 100755 new mode 100644 index 00062b6..944d8ff --- a/conf_slk120/vim/_vim/doc/viki.txt +++ b/conf_slk120/vim/_vim/doc/viki.txt @@ -1,7 +1,7 @@ *viki.txt* Viki - A Pseudo Local Wiki Tool Viki MANUAL - Thomas Link (samul AT web de) + Thomas Link (micathom AT gmail com?subject=vim) ================================================================================ @@ -23,11 +23,11 @@ markup. MINOR WIKI MODE: Just type |:VikiMinorMode| and all wiki names and URLs will be highlighted. When the cursor is over a wiki name, you can press to jump to (or -create) the referred page. Pressing vb brings you back to the -original document. Alternatively, you can use and -to jump back and forth. (NOTE: In minor mode, it's possible that viki words -and URLs are not highlighted when they are included in some syntactic -regions.) +create) the referred page (on a terminal use vf). Pressing +vb brings you back to the original document. Alternatively, you +can use and to jump back and forth. (NOTE: In +minor mode, it's possible that viki words and URLs are not highlighted when +they are included in some syntactic regions.) FULL WIKI MODE: In full mode, viki becomes a personal wiki @@ -69,39 +69,35 @@ own markup. *viki-installation* Installation~ -Extract viki.zip to your local vimfiles directory (see also -|add-global-plugin|) so that you get: > +Edit the vba file and type: > - (Linux etc.) $HOME/.vim/ - (Windows) $VIM/vimfiles/ - compiler/ doc/ etc/ ftplugin/ plugin/ syntax/ + :so % -These directories are used for installing user-specific plugins. It's possible -that these directories already exist and are populated with other plugins -- -in which case you probably already knew this. ;-) +See :help vimball for details. If you have difficulties or use vim 7.0, +please make sure, you have the current version of vimball (vimscript +#1502) installed. -Uninstalling viki requires deleting the files from the viki archive by hand. -Alternatively, you can feed the file etc/Viki.lst to rm: > - - cd $HOME/.vim/ - rm -i `cat etc/Viki.lst` +This script requires tlib (vimscript #1863) to be installed. -Viki will be automatically loaded when starting vim. In case you have vim -already running and don't want to restart it, you can also type: > - - :runtime plugin/viki.vim +Viki requires: > + + :set nocompatible + :filetype plugin indent on + :syntax on -Then run > +You might also want to set 'expandtab' (local to buffer) in +after/ftplugin/viki.vim: > -(Linux etc.) > - :helptags $HOME/.vim/doc + setlocal expandtab + +Viki will be automatically loaded when starting vim. In case you have vim +already running and don't want to restart it, you can also type: > -(Windows) > - :helptags $VIM/vimfiles/doc + :runtime plugin/viki.vim Viki doesn't set the viki filetype for you. How you set the filetype is up to you to decide. Basically, there are two possibilities: based on a suffix or -based on the location. See below for examples. +based on the location. See |viki-filetype-detection|. Customization: *viki-customization* @@ -112,10 +108,10 @@ It's probably a good idea to check the values of the following variables: context set these variables to something like (this refers to the characters allowed in simple viki names and in anchors; for East Asian languages you probably prefer to use quoted viki names anyway): > - + " this is in iso-latin-1 - let g:vikiLowerCharacters = "a-zäöüßáàéèíìóòçñ" - let g:vikiUpperCharacters = "A-ZÄÖÜ" + let g:vikiLowerCharacters = "a-zäöüßáàéèíìóòçñ" + let g:vikiUpperCharacters = "A-ZÄÖÜ" < - |g:vikiUseParentSuffix| (see also |viki-names|); I personally prefer this to be ON > @@ -146,20 +142,62 @@ you could make viki to open references to pdf files right in VIM: > let b:convertedPDF = 1 endif endf - let g:vikiOpenFileWith_pdf = 'call VikiOpenLink("%{FILE}", "", 1)|silent call ConvertPDF()' + let g:vikiOpenFileWith_pdf = 'call viki#OpenLink("%{FILE}", "", 1)|silent call ConvertPDF()' + *viki-intervikis* Later on, you probably want to define some intervikis. A |interviki| is a shortcut to a different viki directory/namespace, so that you have to care -less about page names: > +less about page names. + +There are two ways to define an interviki: + + *viki#Define()* + 1. Use viki#Define(name, prefix, ?suffix="*", ?index="Index.${suffix}") + + call viki#Define('SCI', $HOME."/Projects/Sci/Ideas", ".txt") + + This command will automatically define a menu for each interviki + (unless g:vikiMenuPrefix is empty) and it will also define a command + with the name of the interviki that can be used to quickly access viki + files from the vim command line. + + *g:viki_intervikis* + 2. Use g:viki_intervikis (a dictionary). The values can be either a list + (arguments for |viki#Define()|) or a string. - call VikiDefine('SCI', $HOME."/Projects/Sci/Ideas", ".txt") + let g:viki_intervikis['SCI'] = [$HOME."/Projects/Sci/Ideas", ".txt"] + let g:viki_intervikis['PROJ'] = $HOME."/Projects" + +Intervikis added to g:viki_intervikis will be defined via |viki#Define()| when +first loading ~/vimfiles/autoload/viki.vim. I.e. you cannot use automatically +defined commands or menus before loading the autoload file. So, if you don't +use the menus and the interviki commands to open files from the command line, +use the variable. Otherwise, calling |viki#Define()| from +~/vimfiles/after/plugin/viki.vim might be the better solution (which would +also load autoload/viki.vim on startup though). This could then be accessed as SCI::ThisIdea, which would refer to the file "~/Projects/Sci/Ideas/ThisIdea.txt". -VikiDefine also defines a command (:SCI in this example) that opens a wiki's +viki#Define also defines a command (:SCI in this example) that opens a wiki's index file (an optional 4th argument or "${g:vikiIndex}.${suffix}"). +Intervikis can also be defined as patterns or functions as in the following +example: > + + fun! GetAddress(vikiname) + let surname = substitute(a:vikiname, '^\(\u.\{-}\)\(\u\U*\)\?$', '\1', '') + let firstname = substitute(a:vikiname, '^\(\u.\{-}\)\(\u\U*\)\?$', '\2', '') + return 'https://www.example.com/cgi/search.cgi?search='. surname .','. firstname + endf + + call viki#Define('CONTACT', '*GetAddress("%s")') + call viki#Define('INDEX', '%/foo/%s/index.html') + +CONTACT::JohnDoe would the refer to +https://www.example.com/cgi/search.cgi?search=Dow,John and [[INDEX::bar]] +would refer to /foo/bar/index.html + In order to use the LaTeX enabled viki variant, add this to your |vimrc| file: > au FileType tex let b:vikiFamily="LaTeX" @@ -171,6 +209,7 @@ In order to automatically set |deplate| as the compiler for viki files: > let g:deplatePrg = "deplate -x -X " au FileType viki compiler deplate + *viki-filetype-detection* Some users might want to automatically set the filetype to viki depening on the file extension. This can be done using |:autocmd|: > @@ -183,8 +222,8 @@ You can also use |:autocmd| to set the filetype depending on the path: > If the variables b:getVikiLink or b:getExtVikiLink exist, their values are used as _function_ names for returning the current viki name's definition. A -viki definition is a "multvalue" (see multvals.vim, vimscript #171) of the -three elements name, destination, anchor with g:vikiDefSep as the separator. +viki definition is an array of the three elements name, destination, anchor +with g:vikiDefSep as the separator. If the variables b:editVikiPage or b:createVikiPage exist, their values are interpreted as _command_ names for editing readable or creating new wiki @@ -204,11 +243,6 @@ and set it to whatever you want. =============================================================================== *viki-requirements* -Requirements~ - -- multvals.vim (vimscript #171, >= 3.8.0) - - Optional Enhancements~ - genutils.vim (vimscript #197 for saving back references; but see @@ -307,6 +341,18 @@ A viki name is either: program; this behaviour can be changed by redefining the function |VikiOpenSpecialProtocol()|. + 4. Hyperwords (not supported by deplate) + Hyperwords are defined in either ./.vikiWords or &rtp[0]/vikiWords.txt + each word in a line in the form "word destination" (lines beginning + with '%' are ignored). These words are automatically highlighted. + Depending on your setting of |vikiNameTypes|, viki may try to make + hyperwords out of the filenames in the current buffer's directory. + I.e. if |vikiNameSuffix| is '.txt' and there is a file 'example.txt' + in the same directory as the current buffer's file, then each + occurrence of the word 'example' will be turned into a clickable link. + You can prevent a file name from being highlighted as hyperword by + defining an entry in the vikiWords file with "-" as destination. + Adding #[a-z0-9]\+ to the wiki name denotes a reference to a specific anchor. Examples for wiki names referring to an anchor: > @@ -356,7 +402,7 @@ Headings~ NOTE: Headings can span more than one line by putting a backslash ('\') at the end of the line. - + NOTE: If |g:vikiHeadingFont| is defined, the heading will be set in this font. @@ -435,30 +481,19 @@ NOTE: See also |g:vikiMarkupEndsWithNewline|. *viki-textstyles* Textstyles~ -There are two markup styles which are selected on the basis of -|vikiTextStyles|. 2 is the default now. - -If |vikiTextStyles| is 2, the markup is like this: > __emphasized__, ''typewriter'' -If |vikiTextStyles| is 1, the markup is like this: > - - *bold*, **continuous bold** - /italic/, //continuous italic// - _underlined_, __continuous underline__ - =typewriter=, ==continuous typewriter== - < NOTE: There must not by a whitespace after the opening mark. NOTE: For the word styles, there must be a non-word character (|/\W|) - before the opening mark, i.e. a/b/c will be highlighted as normal text -- + before the opening mark, i.e. a__b__c will be highlighted as normal text -- it won't be highlighted. You could use the continuous markup for putting the "b" in the example in italic. NOTE: If |g:vikiTypewriterFont| is defined, this font will be used to highlight text in typewriter style. - + NOTE: See also |g:vikiMarkupEndsWithNewline|. @@ -560,11 +595,13 @@ Backslashes~ *viki-key-bindings* Default Key Binding~ - ... |VikiMaybeFollowLink()|: Usually only works when the cursor is over + ... |viki#MaybeFollowLink()|: Usually only works when the cursor is over a wiki syntax group -- if the second argument is 1 it tries to interpret the -text under the cursor as a wiki name anyway. +text under the cursor as a wiki name anyway. (NOTE: If you're working on a +terminal, most likely won't work. Use vf instead.) vf ... Open in window +vt ... Open in a new tab vs ... Open in a new window vv ... Open in a new window but split vertically - see also |vikiSplit| @@ -573,15 +610,17 @@ text under the cursor as a wiki name anyway. ve ... |:VikiEdit| edit a viki page -vb ... |VikiGoBack()| +vb v ... |viki#GoBack()| +v v ... |viki#GoParent()| + vq ... |:VikiQuote| mark selected text a quoted viki name vd ... |:VikiMarkInexistent| in the whole document vp ... |:VikiMarkInexistent| in the current paragraph If |g:vikiMapMouse| is true then these mappings are active, too: - ... |VikiMaybeFollowLink()| - ... |VikiGoBack()| (always jumps to the last known entry point) + ... |viki#MaybeFollowLink()| + ... |viki#GoBack()| (always jumps to the last known entry point) Additional Key Binding In Full Viki Mode @@ -603,6 +642,8 @@ Commands~ - VikiMode (do additional highlighting) Basically the same as: > set ft=viki +< The main difference between these two is that VikiMode unlets + b:did_ftplugin to make sure that the ftplugin gets loaded. *:VikiFind* *:VikiFindNext* *:VikiFindPrev* @@ -646,19 +687,17 @@ Commands~ Open the |viki-homepage|. - VikiDefine NAME BASE ?SUFFIX *:VikiDefine* - Define an interviki. + Define an interviki. See also |viki#Define()|. ================================================================================ *viki-functions* Functions~ - VikiMinorMode(state) *VikiMinorMode()* -- VikiMode(state) *VikiMode()* - a:state: - +/-1 ... Minor mode (negative number ~ don't complain) - +/-2 ... Full mode (negative number ~ don't complain) -- VikiMaybeFollowLink(oldmap, ignoreSyntax) *VikiMaybeFollowLink()* +- VikiMode(family) *VikiMode()* + +- viki#MaybeFollowLink(oldmap, ignoreSyntax) *viki#MaybeFollowLink()* oldmap: If there isn't a viki link under the cursor: "" ... throw error 1 ... return \ @@ -667,16 +706,21 @@ Functions~ 0 ... no viki name found 1 ... look if there is a viki name under cursor anyways -- VikiFindAnchor(anchor) *VikiFindAnchor()* +- viki#FindAnchor(anchor) *viki#FindAnchor()* -- VikiGoBack() *VikiGoBack()* - Viki keeps record about the "source" files from where a viki page was - entered. Calling this function jumps back to the "source" file (if only one - such back reference is known) or let's you select from a list of "source" - files. The information is stored in buffer variables -- i.e., it gets lost - after closing the buffer. Care was taken to reduce information clutter, - which is why the number of possible back references per "source" file was - limited to one. + *b:vikiParent* +- viki#GoParent() *viki#GoParent()* + If b:vikiParent is defined, open this viki name, otherwise use + |viki#GoBack()|. + +- viki#GoBack() *viki#GoBack()* + Viki keeps record about the "source" files from where a viki page was + entered. Calling this function jumps back to the "source" file (if only + one such back reference is known) or let's you select from a list of + "source" files. The information is stored in buffer variables -- i.e., it + gets lost after closing the buffer. Care was taken to reduce information + clutter, which is why the number of possible back references per "source" + file was limited to one. - VikiOpenSpecialFile(filename) *VikiOpenSpecialFile()* Handles filenames that match |vikiSpecialFiles|. @@ -704,10 +748,6 @@ Functions~ !rundll32 url.dll ...". All protocol names are translated to lower case. -- VikiDefineMarkup(mode) *VikiDefineMarkup()* - -- VikiDefineHighlighting(mode) *VikiDefineHighlighting()* - ================================================================================ *viki-variables* @@ -811,18 +851,18 @@ Markup: - g:vikiFamily, b:vikiFamily *vikiFamily* By defining this variable, family specific functions will be called for: - - VikiSetupBuffer{b:vikiFamily}(state) - - VikiDefineMarkup{b:vikiFamily}(state) - - VikiDefineHighlighting{b:vikiFamily}(state) - - VikiCompleteSimpleNameDef{b:vikiFamily}(def) - - VikiCompleteExtendedNameDef{b:vikiFamily}(def) - - VikiFindAnchor{b:vikiFamily}(anchor) + - viki#{b:vikiFamily}#SetupBuffer(state) + - viki#{b:vikiFamily}#DefineMarkup(state) + - viki#{b:vikiFamily}#DefineHighlighting(state) + - viki#{b:vikiFamily}#CompleteSimpleNameDef(def) + - viki#{b:vikiFamily}#CompleteExtendedNameDef(def) + - viki#{b:vikiFamily}#FindAnchor(anchor) If one of these functions is undefined for a "viki family", then the default one is called. Apart from the default behaviour the following families are defined: - - LaTeX (see |viki-latex|) - - AnyWord (see |viki-any-word|) + - latex (see |viki-latex|) + - anyword (see |viki-anyword|) Etc: @@ -836,13 +876,16 @@ Etc: Any positive number ... open always in this window - b:vikiNameTypes, g:vikiNameTypes *vikiNameTypes* - Default value: "csSeui" + Default value: "csSeuixwf" s ... Simple viki name c ... CamelCase S ... simple, quoted viki name i ... |interviki| + w ... Hyperwords + f ... file-bases hyperwords e ... Extended viki name u ... URL + x ... Directives (some commands, regions ...) Disable certain types of viki names globally or for a single buffer. (experimental, doesn't fully work yet) @@ -878,12 +921,23 @@ Etc: b:vikiMaxFoldLevel. I.e., if you set |foldlevel| to 1, you will see only the text at level b:vikiMaxFoldLevel. -- g:vikiFolds *g:vikiFolds* +- g:vikiFoldBodyLevel, b:vikiFoldBodyLevel *vikiFoldBodyLevel* + Default: 4 + If set to 0, the "b" mode in |vikiFolds| will set the body level depending + on the headings used in the current buffer. Otherwise + g:vikiHeadingMaxLevel + 1 will be used. + +- g:vikiFolds, b:vikiFolds *vikiFolds* Default: hl Define which elements should be folded: h :: Heading H :: Headings (but inverse folding) l :: Lists + b :: The body has max heading level + 1. This is slightly faster + than the other version as vim never has to scan the text; but + the behaviour may vary depending on the sequence of headings if + |vikiFoldBodyLevel| is set to 0. + s :: ??? - b:vikiNoSimpleNames *b:vikiNoSimpleNames* Default: 0 @@ -927,6 +981,69 @@ The colors are tested using color scheme with a white background. ================================================================================ + *viki-files* +Files Region~ + +Viki knows a special #Files region. + +Example: > + #Files glob=lib/** types=f << + [[example1.rb]] This is an example file + [[example2.rb]] This is another example + [[lib/example1.rb]] + [[lib/example2.rb]] + + #Files glob=*.txt types=f << + [[example.txt]] The manual + +The filenames are stored as extended viki names. Each line can take a comment +that is restored upon automatic update. + +There are a few special commands to deal with this region. + + *:VikiFilesUpdate* +:VikiFilesUpdate + - Update the current #Files region under the cursor. + + *:VikiFilesUpdateAll* +:VikiFilesUpdateAll + - Update all #Files region in the current buffer. + + +If in the following commands a "!" is added, the command works only on files +in the same directory or a subdirectory as the file on the current line. + + *:VikiFilesExec* +:VikiFilesExec[!] FORMAT_STRING + - |:execute| a vim command after doing some replacements with the command + string. For each formatted string the command is issued only once -- + i.e. you can work easily with the directories. If no special formatting + string is contained, the preformatted filename is appended to the command. + %{FILE} ... filename + %{FFILE} ... preformatted filename (with '#%\ ' escaped) + %{DIR} ... file's directory + + *:VikiFilesCmd* +:VikiFilesCmd[!] VIKI_COMMAND_NAME + - |:execute| VikiCmd_{VIKI_COMMAND_NAME} FILENAME + + *:VikiFilesCall* +:VikiFilesCall[!] FUNCTION_NAME + - |:call| VikiCmd_{FUNCTION_NAME}(FILENAME) + + +Default Key Binding~ +vu ... :VikiFilesUpdate +vU ... :VikiFilesUpdateAll +vx ... :VikiFilesExec +vX ... :VikiFilesExec! + +Example: > + Use ":VikiFilesExec! e" (vXe) to edit all the files in + the same directory or a subdirectory of the current file under the cursor. + + +================================================================================ *viki-compile* Viki Compile~ @@ -973,15 +1090,15 @@ as simple viki names.) This plugin also highlights a hypothetical \viki[anchor]{name} command, which could be defined as: \newcommand{\viki}[2][]{#2} -If b:vikiFamily is set to "LaTeX", then calling |:VikiMinorMode| will use +If b:vikiFamily is set to "latex", then calling |:VikiMinorMode| will use these commands instead of normal viki names. This change can be made permanent by adding this line to your |vimrc| file: > - au FileType tex let b:vikiFamily="LaTeX" + au FileType tex let b:vikiFamily="latex" < *:VikiMinorModeLaTeX* LaTeX support is switched on with the command :VikiMinorModeLaTeX. This -command sets b:vikiFamily to "LaTeX" and calls |:VikiMinorMode|. This +command sets b:vikiFamily to "latex" and calls |:VikiMinorMode|. This command relies on the external kpsewhich tool, which has to be installed on your computer. @@ -1006,10 +1123,10 @@ simple minded example: > ================================================================================ - *viki-any-word* + *viki-anyword* Viki Any Word~ -If b:vikiFamily or g:vikiFamily is set to "AnyWord", then any word becomes a +If b:vikiFamily or g:vikiFamily is set to "anyword", then any word becomes a potential viki link. This feature conflicts with the highlighting of links to inexistent files. @@ -1024,8 +1141,7 @@ The bibtex ftplugin defines record labels as anchors. Thus, if make an |interviki| definition point to your bib files you can refer to bib entries as viki names. Example: > - let g:vikiInterBIB = $HOME ."/local/share/texmf/bibtex/bib/tml" - let g:vikiInterBIB_suffix = ".bib" + call viki#Define('BIB', $HOME ."/local/share/texmf/bibtex/bib/tml", ".bib") Then, activating the following viki name BIB::[-monos-]#rec02 diff --git a/conf_slk120/vim/_vim/etc/Viki.lst b/conf_slk120/vim/_vim/etc/Viki.lst deleted file mode 100755 index 9e6fa28..0000000 --- a/conf_slk120/vim/_vim/etc/Viki.lst +++ /dev/null @@ -1,10 +0,0 @@ -./compiler/deplate.vim -./doc/viki.txt -./etc/Viki.lst -./ftplugin/bib/viki.vim -./ftplugin/viki.vim -./indent/viki.vim -./plugin/viki.vim -./plugin/vikiAnyWord.vim -./plugin/vikiLatex.vim -./syntax/viki.vim diff --git a/conf_slk120/vim/_vim/files/txt.skel b/conf_slk120/vim/_vim/files/txt.skel index 0f285df..ad331d0 100755 --- a/conf_slk120/vim/_vim/files/txt.skel +++ b/conf_slk120/vim/_vim/files/txt.skel @@ -1,4 +1 @@ -% copyright (C) 2007 GPL3 -* - -% vi: ft=viki:fdl=9 +====== ====== diff --git a/conf_slk120/vim/_vim/ftplugin/bib/viki.vim b/conf_slk120/vim/_vim/ftplugin/bib/viki.vim old mode 100755 new mode 100644 index 9d62f18..d524ec4 --- a/conf_slk120/vim/_vim/ftplugin/bib/viki.vim +++ b/conf_slk120/vim/_vim/ftplugin/bib/viki.vim @@ -1,10 +1,10 @@ " viki.vim -- Make adaptions for bibtex -" @Author: Thomas Link (samul AT web.de) +" @Author: Thomas Link (micathom AT gmail com?subject=vim) " @Website: http://members.a1.net/t.link/ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 28-Jul-2004. -" @Last Change: 28-Jul-2004. -" @Revision: 0.7 +" @Last Change: 2007-08-27. +" @Revision: 0.8 let b:vikiAnchorRx = '\^\c\s\*@\[a-z]\+\s\*{\s\*%{ANCHOR}\s\*,\.\*\$' diff --git a/conf_slk120/vim/_vim/ftplugin/viki.vim b/conf_slk120/vim/_vim/ftplugin/viki.vim old mode 100755 new mode 100644 dissimilarity index 61% index e1de5c2..1eba808 --- a/conf_slk120/vim/_vim/ftplugin/viki.vim +++ b/conf_slk120/vim/_vim/ftplugin/viki.vim @@ -1,147 +1,412 @@ -" viki.vim -- the viki ftplugin -" @Author: Thomas Link (samul AT web.de) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 12-Jän-2004. -" @Last Change: 29-Mär-2006. -" @Revision: 146 - -if !g:vikiEnabled - finish -endif - -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -let b:vikiCommentStart = "%" -let b:vikiCommentEnd = "" -if !exists("b:vikiMaxFoldLevel") - let b:vikiMaxFoldLevel = 5 -endif -if !exists("b:vikiInverseFold") - let b:vikiInverseFold = 0 -endif - -exe "setlocal commentstring=". substitute(b:vikiCommentStart, "%", "%%", "g") - \ ."%s". substitute(b:vikiCommentEnd, "%", "%%", "g") -exe "setlocal comments=:". b:vikiCommentStart - -setlocal foldmethod=expr -setlocal foldexpr=VikiFoldLevel(v:lnum) -setlocal expandtab -setlocal iskeyword+=# - -let b:vikiEnabled = 2 - -let &include='\(^\s*#INC.\{-}\(\sfile=\|:\)\)' -" let &include='\(^\s*#INC.\{-}\(\sfile=\|:\)\|\[\[\)' -" set includeexpr=substitute(v:fname,'\].*$','','') - -let &define='^\s*\(#Def.\{-}id=\|#\(Fn\|Footnote\).\{-}\(:\|id=\)\|#VAR.\{-}\s\)' - -let b:vikiHeadingMaxLevel = 0 - -" if !exists('b:vikiHideBody') | let b:vikiHideBody = 0 | endif - -" if !hasmapto(":VikiFind") -" nnoremap :VikiFindNext -" nnoremap vn :VikiFindNext -" nnoremap :VikiFindPrev -" nnoremap vN :VikiFindPrev -" endif - -" compiler deplate - - -if exists('*VikiFoldLevel') - finish -endif - -fun! VikiFoldLevel(lnum) - let vikiFolds = exists('b:vikiFolds') ? b:vikiFolds : g:vikiFolds - if stridx(vikiFolds, 'h') >= 0 - if vikiFolds =~? 'h' - let fl = ScanHeading(a:lnum, a:lnum, vikiFolds) - if fl != '' - return fl - endif - endif - if vikiFolds =~# 'l' - let list = MatchList(a:lnum) - if list > 0 - " return '>'. (b:vikiHeadingMaxLevel + (list / &sw)) - return (b:vikiHeadingMaxLevel + (list / &sw)) - elseif getline(a:lnum) !~ '^[[:blank:]]' && MatchList(a:lnum - 1) > 0 - let fl = ScanHeading(a:lnum - 1, 1, vikiFolds) - if fl != '' - if fl[0] == '>' - let fl = strpart(fl, 1) - endif - return '<'. (fl + 1) - endif - endif - endif - if vikiFolds =~# 's' - if exists('b:vikiFoldDef') - exec b:vikiFoldDef - if vikiFoldLine == a:lnum - return vikiFoldLevel - endif - endif - let i = 1 - while i > a:lnum - let vfl = VikiFoldLevel(a:lnum - i) - if vfl[0] == '>' - let b:vikiFoldDef = 'let vikiFoldLine='. a:lnum - \ .'|let vikiFoldLevel="'. vfl .'"' - return vfl - elseif vfl == '=' - let i = i + 1 - endif - endwh - endif - if b:vikiHeadingMaxLevel == 0 - return 0 - elseif vikiFolds =~# 'b' - return b:vikiHeadingMaxLevel + 1 - else - return "=" - endif - endif - return 0 -endfun - -fun! ScanHeading(lnum, top, vikiFolds) - let lnum = a:lnum - while lnum >= a:top - let head = MatchHead(lnum) - if head > 0 - if head > b:vikiHeadingMaxLevel - let b:vikiHeadingMaxLevel = head - endif - if b:vikiInverseFold || a:vikiFolds =~# 'H' - if b:vikiMaxFoldLevel > head - return ">". (b:vikiMaxFoldLevel - head) - else - return ">0" - end - else - return ">". head - endif - endif - let lnum = lnum - 1 - endwh - return '' -endf - -fun! MatchHead(lnum) - " let head = matchend(getline(a:lnum), '\V\^'. escape(b:vikiHeadingStart, '\') .'\ze\s\+') - return matchend(getline(a:lnum), '\V\^'. b:vikiHeadingStart .'\+\ze\s\+') -endf - -fun! MatchList(lnum) - let rx = '^[[:blank:]]\+\ze\(#[A-F]\d\?\|#\d[A-F]\?\|[-+*#?@]\|[0-9#]\+\.\|[a-zA-Z?]\.\|.\{-1,}[[:blank:]]::\)[[:blank:]]' - return matchend(getline(a:lnum), rx) -endf - +" viki.vim -- the viki ftplugin +" @Author: Thomas Link (micathom AT gmail com?subject=vim) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 12-Jän-2004. +" @Last Change: 2008-02-14. +" @Revision: 404 + +" if !g:vikiEnabled +" finish +" endif + +if exists("b:did_ftplugin") "{{{2 + finish +endif +let b:did_ftplugin = 1 +" if exists("b:did_viki_ftplugin") +" finish +" endif +" let b:did_viki_ftplugin = 1 + +let b:vikiCommentStart = "%" +let b:vikiCommentEnd = "" +let b:vikiHeadingMaxLevel = -1 +if !exists("b:vikiMaxFoldLevel") | let b:vikiMaxFoldLevel = 5 | endif "{{{2 +if !exists("b:vikiInverseFold") | let b:vikiInverseFold = 0 | endif "{{{2 + +exec "setlocal commentstring=". substitute(b:vikiCommentStart, "%", "%%", "g") + \ ."%s". substitute(b:vikiCommentEnd, "%", "%%", "g") +exec "setlocal comments=fb:-,fb:+,fb:*,fb:#,fb:?,fb:@,:". b:vikiCommentStart + +setlocal foldmethod=expr +setlocal foldexpr=VikiFoldLevel(v:lnum) +setlocal foldtext=VikiFoldText() +setlocal expandtab +" setlocal iskeyword+=#,{ +setlocal iskeyword+={ +setlocal iskeyword-=_ + +let &include='\(^\s*#INC.\{-}\(\sfile=\|:\)\)' +" let &include='\(^\s*#INC.\{-}\(\sfile=\|:\)\|\[\[\)' +" set includeexpr=substitute(v:fname,'\].*$','','') + +let &define='^\s*\(#Def.\{-}id=\|#\(Fn\|Footnote\).\{-}\(:\|id=\)\|#VAR.\{-}\s\)' + +" if !exists('b:vikiHideBody') | let b:vikiHideBody = 0 | endif + +" if !hasmapto(":VikiFind") +" nnoremap :VikiFindNext +" nnoremap vn :VikiFindNext +" nnoremap :VikiFindPrev +" nnoremap vN :VikiFindPrev +" endif + +" compiler deplate + +map [[ :call viki#FindPrevHeading() +map ][ :call viki#FindNextHeading() +map ]] ][ +map [] [[ + +let b:undo_ftplugin = 'setlocal iskeyword< expandtab< foldtext< foldexpr< foldmethod< comments< commentstring< ' + \ .'define< include<' + \ .'| unlet b:vikiHeadingMaxLevel b:vikiCommentStart b:vikiCommentEnd b:vikiInverseFold b:vikiMaxFoldLevel ' + \ .' b:vikiEnabled ' + \ .'| unmap [[' + \ .'| unmap ]]' + \ .'| unmap ][' + \ .'| unmap []' + +let b:vikiEnabled = 2 + +if exists('*VikiFoldLevel') "{{{2 + finish +endif + +function! VikiFoldText() "{{{3 + let line = getline(v:foldstart) + if synIDattr(synID(v:foldstart, 1, 1), 'name') =~ '^vikiFiles' + let line = fnamemodify(viki#FilesGetFilename(line), ':h') + else + let ctxtlev = tlib#var#Get('vikiFoldsContext', 'wbg') + let ctxt = get(ctxtlev, v:foldlevel, 0) + " TLogVAR ctxt + " TLogDBG type(ctxt) + if type(ctxt) == 3 + let [ctxtbeg, ctxtend] = ctxt + else + let ctxtbeg = 1 + let ctxtend = ctxt + end + let line = matchstr(line, '^\s*\zs.*$') + for li in range(ctxtbeg, ctxtend) + let li = v:foldstart + li + if li > v:foldend + break + endif + let lp = matchstr(getline(li), '^\s*\zs.\{-}\ze\s*$') + if !empty(lp) + let lp = substitute(lp, '\s\+', ' ', 'g') + let line .= ' | '. lp + endif + endfor + endif + return v:folddashes . line +endf + +function! s:VikiFolds() "{{{3 + let vikiFolds = tlib#var#Get('vikiFolds', 'bg') + " TLogVAR vikiFolds + if vikiFolds == 'ALL' + let vikiFolds = 'hlsfb' + " let vikiFolds = 'hHlsfb' + elseif vikiFolds == 'DEFAULT' + let vikiFolds = 'hf' + endif + " TLogVAR vikiFolds + return vikiFolds +endf + +function! s:SetMaxLevel() "{{{3 + let pos = getpos('.') + " TLogVAR b:vikiHeadingStart + let vikiHeadingRx = '\V\^'. b:vikiHeadingStart .'\+\ze\s' + let b:vikiHeadingMaxLevel = 0 + exec 'keepjumps g/'. vikiHeadingRx .'/let l = matchend(getline("."), vikiHeadingRx) | if l > b:vikiHeadingMaxLevel | let b:vikiHeadingMaxLevel = l | endif' + " TLogVAR b:vikiHeadingMaxLevel + call setpos('.', pos) +endf + +if g:vikiFoldMethodVersion == 5 + + function! VikiFoldLevel(lnum) "{{{3 + " TLogVAR a:lnum + let vikiFolds = s:VikiFolds() + if vikiFolds =~# 'h' + " TLogVAR b:vikiHeadingStart + let lt = getline(a:lnum) + let fh = matchend(lt, '\V\^'. b:vikiHeadingStart .'\+\ze\s') + if fh != -1 + " TLogVAR fh, b:vikiHeadingMaxLevel + if b:vikiHeadingMaxLevel == -1 + " TLogDBG 'SetMaxLevel' + call s:SetMaxLevel() + endif + if fh > b:vikiHeadingMaxLevel + let b:vikiHeadingMaxLevel = fh + endif + if vikiFolds =~# 'H' + " TLogDBG 'inverse folds' + let fh = b:vikiHeadingMaxLevel - fh + 1 + endif + " TLogVAR fh, lt + return '>'.fh + endif + let body_level = indent(a:lnum) / &sw + 1 + return b:vikiHeadingMaxLevel + body_level + endif + endf + +elseif g:vikiFoldMethodVersion == 4 + + function! VikiFoldLevel(lnum) "{{{3 + " TLogVAR a:lnum + let vikiFolds = s:VikiFolds() + if vikiFolds =~# 'h' + " TLogVAR b:vikiHeadingStart + let lt = getline(a:lnum) + let fh = matchend(lt, '\V\^'. b:vikiHeadingStart .'\+\ze\s') + if fh != -1 + " TLogVAR fh, b:vikiHeadingMaxLevel + if b:vikiHeadingMaxLevel == -1 + " TLogDBG 'SetMaxLevel' + call s:SetMaxLevel() + endif + if fh > b:vikiHeadingMaxLevel + let b:vikiHeadingMaxLevel = fh + endif + if vikiFolds =~# 'H' + " TLogDBG 'inverse folds' + let fh = b:vikiHeadingMaxLevel - fh + 1 + endif + " TLogVAR fh, lt + return '>'.fh + endif + if b:vikiHeadingMaxLevel <= 0 + return b:vikiHeadingMaxLevel + 1 + else + return '=' + endif + endif + endf + +elseif g:vikiFoldMethodVersion == 3 + + function! VikiFoldLevel(lnum) "{{{3 + let lt = getline(a:lnum) + if lt !~ '\S' + return '=' + endif + let fh = matchend(lt, '\V\^'. b:vikiHeadingStart .'\+\ze\s') + if fh != -1 + " let fh += 1 + if b:vikiHeadingMaxLevel == -1 + call s:SetMaxLevel() + endif + if fh > b:vikiHeadingMaxLevel + let b:vikiHeadingMaxLevel = fh + " TLogVAR b:vikiHeadingMaxLevel + endif + " TLogVAR fh + return fh + endif + let li = indent(a:lnum) + let tf = b:vikiHeadingMaxLevel + 1 + (li / &sw) + " TLogVAR tf + return tf + endf + +elseif g:vikiFoldMethodVersion == 2 + + function! VikiFoldLevel(lnum) "{{{3 + let lt = getline(a:lnum) + let fh = matchend(lt, '\V\^'. b:vikiHeadingStart .'\+\ze\s') + if fh != -1 + return fh + endif + let ll = prevnonblank(a:lnum) + if ll != a:lnum + return '=' + endif + let li = indent(a:lnum) + let pl = prevnonblank(a:lnum - 1) + let pi = indent(pl) + if li == pi || pl == 0 + return '=' + elseif li > pi + return 'a'. ((li - pi) / &sw) + else + return 's'. ((pi - li) / &sw) + endif + endf + +else + + function! VikiFoldLevel(lnum) "{{{3 + let lc = getpos('.') + " TLogVAR lc + let w0 = line('w0') + let lr = &lazyredraw + set lazyredraw + try + let vikiFolds = s:VikiFolds() + if vikiFolds == '' + " TLogDBG 'no folds' + return + endif + if b:vikiHeadingMaxLevel == -1 + call s:SetMaxLevel() + endif + if vikiFolds =~# 'f' + let idt = indent(a:lnum) + if synIDattr(synID(a:lnum, idt, 1), 'name') =~ '^vikiFiles' + call s:SetHeadingMaxLevel(1) + " TLogDBG 'vikiFiles: '. idt + return b:vikiHeadingMaxLevel + idt / &shiftwidth + endif + endif + if stridx(vikiFolds, 'h') >= 0 + if vikiFolds =~? 'h' + let fl = s:ScanHeading(a:lnum, a:lnum, vikiFolds) + if fl != '' + " TLogDBG 'heading: '. fl + return fl + endif + endif + if vikiFolds =~# 'l' + let list = s:MatchList(a:lnum) + if list > 0 + call s:SetHeadingMaxLevel(1) + " TLogVAR list + " return '>'. (b:vikiHeadingMaxLevel + (list / &sw)) + return (b:vikiHeadingMaxLevel + (list / &sw)) + elseif getline(a:lnum) !~ '^[[:blank:]]' && s:MatchList(a:lnum - 1) > 0 + let fl = s:ScanHeading(a:lnum - 1, 1, vikiFolds) + if fl != '' + if fl[0] == '>' + let fl = strpart(fl, 1) + endif + " TLogDBG 'list indent: '. fl + return '<'. (fl + 1) + endif + endif + endif + " I have no idea what this is about. + " Is this about "inverse" folding? + " if vikiFolds =~# 's' + " if exists('b:vikiFoldDef') + " exec b:vikiFoldDef + " if vikiFoldLine == a:lnum + " return vikiFoldLevel + " endif + " endif + " let i = 1 + " while i > a:lnum + " let vfl = VikiFoldLevel(a:lnum - i) + " if vfl[0] == '>' + " let b:vikiFoldDef = 'let vikiFoldLine='. a:lnum + " \ .'|let vikiFoldLevel="'. vfl .'"' + " return vfl + " elseif vfl == '=' + " let i = i + 1 + " endif + " endwh + " endif + call s:SetHeadingMaxLevel(1) + " if b:vikiHeadingMaxLevel == 0 + " return 0 + " elseif vikiFolds =~# 'b' + if vikiFolds =~# 'b' + let bl = exists('b:vikiFoldBodyLevel') ? b:vikiFoldBodyLevel : g:vikiFoldBodyLevel + if bl > 0 + " TLogDBG 'body: '. bl + return bl + else + " TLogDBG 'body fallback: '. b:vikiHeadingMaxLevel + return b:vikiHeadingMaxLevel + 1 + endif + else + " TLogDBG 'else' + return "=" + endif + endif + " TLogDBG 'zero' + return 0 + finally + exec 'norm! '. w0 .'zt' + " TLogVAR lc + call setpos('.', lc) + let &lazyredraw = lr + endtry + endfun + + function! s:ScanHeading(lnum, top, vikiFolds) "{{{3 + " TLogVAR a:lnum, a:top + let [lhead, head] = s:SearchHead(a:lnum, a:top) + " TLogVAR head + if head > 0 + if head > b:vikiHeadingMaxLevel + let b:vikiHeadingMaxLevel = head + endif + if b:vikiInverseFold || a:vikiFolds =~# 'H' + if b:vikiMaxFoldLevel > head + return ">". (b:vikiMaxFoldLevel - head) + else + return ">0" + end + else + return ">". head + endif + endif + return '' + endf + + function! s:SetHeadingMaxLevel(once) "{{{3 + if a:once && b:vikiHeadingMaxLevel == 0 + return + endif + let pos = getpos('.') + " TLogVAR pos + try + silent! keepjumps exec 'g/\V\^'. b:vikiHeadingStart .'\+\s/call s:SetHeadingMaxLevelAtCurrentLine(line(".")' + finally + " TLogVAR pos + call setpos('.', pos) + endtry + endf + + function! s:SetHeadingMaxLevelAtCurrentLine(lnum) "{{{3 + let m = s:MatchHead(lnum) + if m > b:vikiHeadingMaxLevel + let b:vikiHeadingMaxLevel = m + endif + endf + + function! s:SearchHead(lnum, top) "{{{3 + let pos = getpos('.') + " TLogVAR pos + try + exec a:lnum + norm! $ + let ln = search('\V\^'. b:vikiHeadingStart .'\+\s', 'bWcs', a:top) + if ln + return [ln, s:MatchHead(ln)] + endif + return [0, 0] + finally + " TLogVAR pos + call setpos('.', pos) + endtry + endf + + function! s:MatchHead(lnum) "{{{3 + " let head = matchend(getline(a:lnum), '\V\^'. escape(b:vikiHeadingStart, '\') .'\ze\s\+') + return matchend(getline(a:lnum), '\V\^'. b:vikiHeadingStart .'\+\ze\s') + endf + + function! s:MatchList(lnum) "{{{3 + let rx = '^[[:blank:]]\+\ze\(#[A-F]\d\?\|#\d[A-F]\?\|[-+*#?@]\|[0-9#]\+\.\|[a-zA-Z?]\.\|.\{-1,}[[:blank:]]::\)[[:blank:]]' + return matchend(getline(a:lnum), rx) + endf + +endif diff --git a/conf_slk120/vim/_vim/indent/viki.vim b/conf_slk120/vim/_vim/indent/viki.vim old mode 100755 new mode 100644 dissimilarity index 87% index af1d60d..54bae56 --- a/conf_slk120/vim/_vim/indent/viki.vim +++ b/conf_slk120/vim/_vim/indent/viki.vim @@ -1,146 +1,26 @@ -" viki.vim -- viki indentation -" @Author: Thomas Link (samul AT web.de) -" @Website: http://members.a1.net/t.link/ -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 16-Jän-2004. -" @Last Change: 29-Okt-2005. -" @Revision: 0.222 - -if !g:vikiEnabled - finish -endif - -if exists("b:did_indent") || exists("g:vikiNoIndent") - finish -endif -let b:did_indent = 1 - -" Possible values: 'sw', '::' -if !exists("g:vikiIndentDesc") | let g:vikiIndentDesc = 'sw' | endif "{{{2 - -setlocal indentexpr=VikiGetIndent() -setlocal indentkeys& -setlocal indentkeys=0=#\ ,0=?\ ,0=<*>\ ,0=-\ ,0=+\ ,0=@\ ,=::\ ,!^F,o,O,e -" setlocal indentkeys=0=#,0=?,0=<*>,0=-,=::,!^F,o,O,e - -" Only define the function once. -if exists("*VikiGetIndent") - finish -endif - -fun! VikiGetIndent() - " Find a non-blank line above the current line. - let lnum = prevnonblank(v:lnum - 1) - - " At the start of the file use zero indent. - if lnum == 0 - return 0 - endif - - let ind = indent(lnum) - let line = getline(lnum) " last line - - let cnum = v:lnum - let cind = indent(cnum) - let cline = getline(cnum) - - " Do not change indentation in regions - if VikiIsInRegion(cnum) - return cind - endif - - let cHeading = matchend(cline, '^\*\+\s\+') - if cHeading >= 0 - return 0 - endif - - let pnum = v:lnum - 1 - let pind = indent(pnum) - - let pline = getline(pnum) " last line - let plCont = matchend(pline, '\\$') - - if plCont >= 0 - let plHeading = matchend(pline, '^\*\+\s\+') - " if plHeading >= 0 - " " echo "DBG continuation plHeading=". plHeading - " return plHeading - " else - " " echo "DBG continuation pind=". pind - return pind - " endif - end - - if cind > 0 - " Do not change indentation of: - " - commented lines - " - headings - if cline =~ '^\(\s*%\|\*\)' - " echom "DBG comment or heading: ". cline - return ind - endif - - let markRx = '^\s\+\([#?!+]\)\1\{2,2}\s\+' - let listRx = '^\s\+\([-+*#?@]\|[0-9#]\+\.\|[a-zA-Z?]\.\)\s\+' - let priRx = '^\s\+#[A-F]\d\? \+[x_] \+' - let descRx = '^\s\+.\{-1,}\s::\s\+' - - let clMark = matchend(cline, markRx) - let clList = matchend(cline, listRx) - let clPri = matchend(cline, priRx) - let clDesc = matchend(cline, descRx) - " let cln = clList >= 0 ? clList : clDesc - - if clList >= 0 || clDesc >= 0 || clMark >= 0 || clPri >= 0 - let spaceEnd = matchend(cline, '^\s\+') - let rv = (spaceEnd / &sw) * &sw - " echom "DBG clList=". clList ." clDesc=". clDesc - return rv - else - let plMark = matchend(pline, markRx) - if plMark >= 0 - return plMark - endif - - let plList = matchend(pline, listRx) - if plList >= 0 - " echom "DBG plList ". plList ." ". pline - return plList - endif - - let plPri = matchend(pline, priRx) - " echom "DBG plPri=". plPri - if plPri >= 0 - return plPri - endif - - let plDesc = matchend(pline, descRx) - if plDesc >= 0 - " echom "DBG plDesc ". pind + (&sw / 2) - if plDesc >= 0 && g:vikiIndentDesc == '::' - return plDesc - else - return pind + (&sw / 2) - endif - endif - - if cind < ind - let rv = (cind / &sw) * &sw - " echom "DBG cind < ind ". rv - return rv - elseif cind >= ind - if cind % &sw == 0 - " echom "DBG cind % &sw ". cind - return cind - else - " echom "DBG cind >= ind ". ind - return ind - end - endif - endif - endif - - " echom "DBG fallback" - return ind -endfun - +" viki.vim -- viki indentation +" @Author: Thomas Link (micathom AT gmail com?subject=vim) +" @Website: http://members.a1.net/t.link/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 16-Jän-2004. +" @Last Change: 2007-09-03. +" @Revision: 0.263 + +if !g:vikiEnabled + finish +endif + +if exists("b:did_indent") || exists("g:vikiNoIndent") + finish +endif +let b:did_indent = 1 + +" Possible values: 'sw', '::' +if !exists("g:vikiIndentDesc") | let g:vikiIndentDesc = 'sw' | endif "{{{2 + +setlocal indentexpr=viki#GetIndent() +" setlocal indentkeys& +setlocal indentkeys=0=#\ ,0=?\ ,0=<*>\ ,0=-\ ,0=+\ ,0=@\ ,=::\ ,!^F,o,O +" setlocal indentkeys=0=#,0=?,0=<*>,0=-,=::,!^F,o,O +" setlocal indentkeys=0=#,0=?,0=<*>,0=-,=::,!^F,o,O,e + diff --git a/conf_slk120/vim/_vim/plugin/02tlib.vim b/conf_slk120/vim/_vim/plugin/02tlib.vim new file mode 100644 index 0000000..e4bfb9a --- /dev/null +++ b/conf_slk120/vim/_vim/plugin/02tlib.vim @@ -0,0 +1,451 @@ +" tlib.vim -- Some utility functions +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-04-10. +" @Last Change: 2008-06-15. +" @Revision: 460 +" GetLatestVimScripts: 1863 1 tlib.vim +" +" Please see also ../test/tlib.vim for usage examples. +" +" TODO: +" - tlib#agent#SwitchLayout(): switch between horizontal and vertical +" layout for the list +" - tlib#cache#Purge(): delete old cache files (for the moment use find) +" - tlib#file#Relative(): currently relies on cwd to be set +" - tlib#input#EditList(): Disable selection by index number +" - tlib#input#List(): Some kind of command line to edit some +" preferences (sort etc.) on the fly +" - tlib#input#List(): Make commands accessible via popup-menu + +if &cp || exists("loaded_tlib") + finish +endif +if v:version < 700 "{{{2 + echoerr "tlib requires Vim >= 7" + finish +endif +let loaded_tlib = 23 +let s:save_cpo = &cpo +set cpo&vim + + +" Commands {{{1 +" :display: :TLet VAR = VALUE +" Set a variable only if it doesn't already exist. +" EXAMPLES: > +" TLet foo = 1 +" TLet foo = 2 +" echo foo +" => 1 +command! -nargs=+ TLet if !exists(matchstr(, '^[^=[:space:]]\+')) | exec 'let '. | endif + + +" Open a scratch buffer (a buffer without a file). +" TScratch ... use split window +" TScratch! ... use the whole frame +" This command takes an (inner) dictionnary as optional argument. +" EXAMPLES: > +" TScratch 'scratch': '__FOO__' +" => Open a scratch buffer named __FOO__ +command! -bar -nargs=* -bang TScratch call tlib#scratch#UseScratch({'scratch_split': '' != '!', }) + + +" :display: :TVarArg VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(...) +" TVarArg ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TVarArg exec tlib#arg#Let([]) + + +" :display: :TKeyArg DICT, VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(keyargs) +" TKeyArg a:keyargs, ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TKeyArg exec tlib#arg#Key([]) + + +" :display: TBrowseOutput COMMAND +" Every wondered how to effciently browse the output of a command +" without redirecting it to a file? This command takes a command as +" argument and presents the output via |tlib#input#List()| so that you +" can easily search for a keyword (e.g. the name of a variable or +" function) and the like. +" +" If you press enter, the selected line will be copied to the command +" line. Press ESC to cancel browsing. +" +" EXAMPLES: > +" TBrowseOutput 20verb TeaseTheCulprit +command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput() + + + +" Variables {{{1 + +" When 1, automatically select a the last remaining item after applying +" any filters. +TLet g:tlib_pick_last_item = 1 + +" If a list is bigger than this value, don't try to be smart when +" selecting an item. Be slightly faster instead. +TLet g:tlib_sortprefs_threshold = 200 + +" Scratch window position +TLet g:tlib_scratch_pos = 'botright' + +" Size of the input list window (in percent) from the main size (of &lines). +TLet g:tlib_inputlist_pct = 70 + +" Size of filename columns when listing filenames +TLet g:tlib_inputlist_width_filename = '&co / 3' +" TLet g:tlib_inputlist_width_filename = 25 + +" The highlight group to use for showing matches in the input list window. +TLet g:tlib_inputlist_higroup = 'IncSearch' + +" If a list contains more items, don't do an incremental "live search", +" but use |input()| the quere the user for a filter. This is useful on +" slower machines or with very long lists. +TLet g:tlib_inputlist_livesearch_threshold = 500 + +" If true, show some indicators about the status of a filename (eg +" buflisted(), bufloaded() etc.). +" This is disabled by default because vim checks also for the file on +" disk when doing this. +TLet g:tlib_inputlist_filename_indicators = 0 + +" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. +TLet g:tlib_tags_extra = '' + +" Filter the tag description through |substitute()| for these filetypes. +" This applies only if the tag cmd field (see |taglist()|) is used. +" :nodefault: +TLet g:tlib_tag_substitute = { + \ 'java': [['\s*{\s*$', '', '']], + \ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']], + \ 'vim': [ + \ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''], + \ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''], + \ ['"\?\s*{{{\d.*$', '', ''], + \ ], + \ } + +TLet g:tlib_filename_sep = '/' +" TLet g:tlib_filename_sep = exists('+shellslash') && !&shellslash ? '\' : '/' " {{{2 + +" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache' +TLet g:tlib_cache = '' + +" Where to display the line when using |tlib#buffer#ViewLine|. +" For possible values for position see |scroll-cursor|. +TLet g:tlib_viewline_position = 'zz' + +" :doc: +" Keys for |tlib#input#List|~ + +TLet g:tlib_inputlist_and = ' ' +TLet g:tlib_inputlist_or = '|' +TLet g:tlib_inputlist_not = '-' + +" When editing a list with |tlib#input#List|, typing these numeric chars +" (as returned by getchar()) will select an item based on its index, not +" based on its name. I.e. in the default setting, typing a "4" will +" select the fourth item, not the item called "4". +" In order to make keys 0-9 filter the items in the list and make +" select an item by its index, remove the keys 48 to 57 from +" this dictionary. +" Format: [KEY] = BASE ... the number is calculated as KEY - BASE. +" :nodefault: +TLet g:tlib_numeric_chars = { + \ 48: 48, + \ 49: 48, + \ 50: 48, + \ 51: 48, + \ 52: 48, + \ 53: 48, + \ 54: 48, + \ 55: 48, + \ 56: 48, + \ 57: 48, + \ 176: 176, + \ 177: 176, + \ 178: 176, + \ 179: 176, + \ 180: 176, + \ 181: 176, + \ 182: 176, + \ 183: 176, + \ 184: 176, + \ 185: 176, + \} + +" :nodefault: +TLet g:tlib_keyagents_InputList_s = { + \ "\": 'tlib#agent#PageUp', + \ "\": 'tlib#agent#PageDown', + \ "\": 'tlib#agent#Up', + \ "\": 'tlib#agent#Down', + \ "\": 'tlib#agent#UpN', + \ "\": 'tlib#agent#DownN', + \ "\": 'tlib#agent#ShiftLeft', + \ "\": 'tlib#agent#ShiftRight', + \ 18: 'tlib#agent#Reset', + \ 242: 'tlib#agent#Reset', + \ 17: 'tlib#agent#Input', + \ 241: 'tlib#agent#Input', + \ 27: 'tlib#agent#Exit', + \ 26: 'tlib#agent#Suspend', + \ 250: 'tlib#agent#Suspend', + \ 15: 'tlib#agent#SuspendToParentWindow', + \ 63: 'tlib#agent#Help', + \ "\": 'tlib#agent#Help', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ 191: 'tlib#agent#Debug', + \ char2nr(g:tlib_inputlist_or): 'tlib#agent#OR', + \ char2nr(g:tlib_inputlist_and): 'tlib#agent#AND', + \ } + +" Number of items to move when pressing in the input list window. +TLet g:tlib_scroll_lines = 10 + +" :nodefault: +TLet g:tlib_keyagents_InputList_m = { + \ 35: 'tlib#agent#Select', + \ "\": 'tlib#agent#SelectUp', + \ "\": 'tlib#agent#SelectDown', + \ 1: 'tlib#agent#SelectAll', + \ 225: 'tlib#agent#SelectAll', + \ } +" "\": 'tlib#agent#Select' + +" :nodefault: +TLet g:tlib_handlers_EditList = [ + \ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '', 'help': 'Edit item'}, + \ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '', 'help': 'Delete item(s)'}, + \ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '', 'help': 'New item'}, + \ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '', 'help': 'Cut item(s)'}, + \ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '', 'help': 'Copy item(s)'}, + \ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '', 'help': 'Paste item(s)'}, + \ {'pick_last_item': 0}, + \ {'return_agent': 'tlib#agent#EditReturnValue'}, + \ ] + + +augroup TLib + autocmd! +augroup END + + +let &cpo = s:save_cpo +unlet s:save_cpo + +finish +----------------------------------------------------------------------- + +CHANGES: +0.1 +Initial release + +0.2 +- More list convenience functions +- tlib#EditList() +- tlib#InputList(): properly handle duplicate items; it type contains +'i', the list index + 1 is returned, not the element + +0.3 +- tlib#InputList(): Show feedback in statusline instead of the echo area +- tlib#GetVar(), tlib#GetValue() + +0.4 +- tlib#InputList(): Up/Down keys wrap around list +- tlib#InputList(): FIX: Problem when reducing the filter & using AND +- tlib#InputList(): Made work (can be configured via +- tlib#InputList(): special display_format: "filename" +- tlib#Object: experimental support for some kind of OOP +- tlib#World: Extracted some functions from tlib.vim to tlib/World.vim +- tlib#FileJoin(), tlib#FileSplit(), tlib#RelativeFilename() +- tlib#Let() +- tlib#EnsureDirectoryExists(dir) +- tlib#DirName(dir) +- tlib#DecodeURL(url), tlib#EncodeChar(char), tlib#EncodeURL(url) +- FIX: Problem when using shift-up/down with filtered lists + +0.5 +- tlib#InputList(): FIX: Selecting items in filtered view +- tlib#InputList(): : Remove last AND pattern from filter + +0.6 +- tlib#InputList(): Disabled map +- tlib#InputList(): try to be smart about user itentions only if a +list's length is < g:tlib_sortprefs_threshold (default: 200) +- tlib#Object: Super() method +- tlib#MyRuntimeDir() +- tlib#GetCacheName(), tlib#CacheSave(), tlib#CacheGet() +- tlib#Args(), tlib#GetArg() +- FIX: tlib#InputList(): Display problem with first item + +0.7 +- tlib#InputList(): ... Suspend/Resume input +- tlib#InputList(): ... Input text on the command line (useful on +slow systems when working with very large lists) +- tlib#InputList(): AND-pattern starting with '!' will work as 'exclude +matches' +- tlib#InputList(): FIX pop OR-patterns properly +- tlib#InputList(): display_format == filename: don't add '/' to +directory names (avoid filesystem access) + +0.8 +- FIX: Return empty cache name for buffers that have no files attached to it +- Some re-arranging + +0.9 +- Re-arrangements & modularization (this means many function names have +changed, on the other hand only those functions are loaded that are +actually needed) +- tlib#input#List(): Added maps with m-modifiers for , , +- tlib#input#List(): Make sure &fdm is manual +- tlib#input#List(): When exiting the list view, consume the next 5 +characters in the queue (if any) +- tlib#input#EditList(): Now has cut, copy, paste functionality. +- Added documentation and examples + +0.10 +- tlib#input#List(): (v)split type of commands leave the original window +untouched (you may use to replace its contents) +- tlib#file#With(): Check whether an existing buffer is loaded. +- Scratch related functions went to tlib/scratch.vim so that they are +accessible from other scripts. +- Configure the list window height via g:tlib_inputlist_pct (1..100%) + +0.11 +NEW: + - The :TLet command replaces :TLLet (which was removed) + - :TScratch[!] command (with ! don't split but use the whole window) + - tlib#rx#Escape(text, ?magic='m') + - tlib#buffer#GetList(?show_hidden=0) + - tlib#dir#CD(), tlib#dir#Push(), tlib#dir#Pop() + - tlib#input#ListW: A slightly remodeled version of tlib#input#List + that takes a World as second argument. + - Added some documentation doc/tlib.txt (most of it is automatically + compiled from the source files) +CHANGES: + - tlib#input#List(): The default keys for AND, NOT have changed to + be more Google-like (space, minus); the keys can be configured via + global variables. +IMPROVEMENTS: + - In file listings, indicate if a file is loaded, listed, modified + etc. + - tlib#input#List(): Highlight the filter pattern + - tlib#input#List(): scrolls g:tlib_scroll_lines + (default=10) lines +FIXES: + - tlib#input#List(): Centering line, clear match, clear & restore + the search register + - tlib#input#List(): Ensure the window layout doesn't change (if the + number of windows hasn't changed) + - tlib#arg#Ex(): Don't escape backslashes by default + +0.12 +NEW: + - tlib/tab.vim +CHANGES: + - Renamed tlib#win#SetWin() to tlib#win#Set() +IMPROVEMENTS: + - tlib#input#List(): , keys work in some lists + - tlib#input#List(): If an index_table is provided this will be used + instead of the item's list index. +FIXES: + - tlib#input#List(): Problem with scrolling, when the list was + shorter than the window (eg when using a vertical window). + - tlib#cache#Filename(): Don't rewrite name as relative filename if + explicitly given as argument. Avoid double (back)slashes. + - TLet: simplified + +0.13 +CHANGES: + - Scratch: Set &fdc=0. + - The cache directory can be configured via g:tlib_cache + - Renamed tlib#buffer#SetBuffer() to tlib#buffer#Set(). +FIXES: + - tlib#input#List(): Select the active item per mouse. + - TLet: simplified + +0.14 +NEW: + - tlib#buffer#InsertText() +CHANGES: + - tlib#win#[SG]etLayout(): Use a dictionnary, set &cmdheight. +FIXES: + - Wrong order with pre-defined filters. + +0.15 +NEW: + - tlib#string#TrimLeft(), tlib#string#TrimRight(), tlib#string#Strip() + - Progress bar + +0.16 +NEW: + - tlib#string#Printf1() + +0.17 +NEW: + - TBrowseOutput +- Some minor changes + +0.18 +NEW: + - tlib/time.vim + - g:tlib_inputlist_livesearch_threshold +CHANGES: + - tlib#input#ListD(), World: Don't redisplay the list while typing + new letters; calculate filter regexps only once before filtering the + list. + - World.vim: Minor changes to how filenames are handled. + +0.19 +NEW: + - tag.vim +FIX: + - dir.vim: Use plain dir name in tlib#dir#Ensure() + - tlib#input#List(): An initial filter argument creates [[filter]] + and not as before [[''], [filter]]. + - tlib#input#List(): When type was "si" and the item was picked by + filter, the wrong index was returned. + - tlib#input#List(): Don't check if chars are typed when displaying + the list for the first time. + +0.20 +- The arguments of tlib#tag#Collect() have changed. +- tlib#input#List(): The view can be "suspended" on initial display. +- tlib#input#List(): Follow/trace cursor functionality + +0.21 +- tlib#buffer#InsertText(): Respect tabs and (experimental) formatoptions+=or +- tlib/syntax.vim: Syntax-related functions + +0.22 +- FIX: very magic mode for tlib#rx#Escape() (thanks A Politz) +- FIX: tlib#arg#Ex: escape "!" + +0.23 +- Respect the setting of g:tlib_inputlist_filename_indicators +- tlib#input#List(): Reset syntax on resume; option to make list window "sticky" +- tlib#agent#ToggleStickyList() +- Simplified tlib#url#Decode() +- tlib#arg#Ex(): use fnameescape() if available + diff --git a/conf_slk120/vim/_vim/plugin/viki.vim b/conf_slk120/vim/_vim/plugin/viki.vim old mode 100755 new mode 100644 dissimilarity index 77% index b781ea9..a276af1 --- a/conf_slk120/vim/_vim/plugin/viki.vim +++ b/conf_slk120/vim/_vim/plugin/viki.vim @@ -1,2225 +1,1003 @@ -" Viki.vim -- A pseudo mini-wiki minor mode for Vim -" @Author: Thomas Link (samul AT web.de) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 08-Dec-2003. -" @Last Change: Sat Sep 02 03:00 PM 2006 C -" @Revision: 1.11.1302 -" -" vimscript #861 -" -" Short Description: -" This plugin adds wiki-like hypertext capabilities to any document. -" Just type :VikiMinorMode and all wiki names will be highlighted. If -" you press when the cursor is over a wiki name, you jump to (or -" create) the referred page. When invoked as :VikiMode or via :set -" ft=viki additional highlighting is provided. -" -" Requirements: -" - multvals.vim (vimscript #171, >= 3.6.2, 13-Sep-2004) -" -" Optional Enhancements: -" - genutils.vim (vimscript #197 for saving back references) -" - imaps.vim (vimscript #244 or #475 for |:VimQuote|) -" - kpsewhich (not a vim plugin :-) for vikiLaTeX -" -" TODO: -" - New region: file listing (auto-generate/update a file listing; i.e. -" the region content is automatically generated when opening a file or -" so) -" - VikiRename: rename links/files (requires a cross-plattform grep or -" similar; maybe 7.0) -" - don't know how to deal with viki names that span several lines (e.g. -" in LaTeX mode) -" -" Change Log: (See bottom of file) -" - -if &cp || exists("loaded_viki") "{{{2 - finish -endif -if !exists('loaded_multvals') "{{{2 - runtime plugin/multvals.vim -endif -if !exists("loaded_multvals") || loaded_multvals < 308 "{{{2 - echoerr "Viki.vim requires multvals.vim >= 308" - finish -endif -let loaded_viki = 111 - -let g:vikiDefNil = '' -let g:vikiDefSep = "\n" - -let s:vikiSelfEsc = '\' -let g:vikiSelfRef = '.' - -if !exists("g:vikiEnabled") "{{{2 - let g:vikiEnabled = 1 -endif - -if !exists("tlist_viki_settings") "{{{2 - let tlist_viki_settings="deplate;s:structure" -endif - -if !exists("g:vikiLowerCharacters") "{{{2 - let g:vikiLowerCharacters = "a-z" -endif - -if !exists("g:vikiUpperCharacters") "{{{2 - let g:vikiUpperCharacters = "A-Z" -endif - -if !exists("g:vikiMenuPrefix") "{{{2 - let g:vikiMenuPrefix = "Plugin.Viki." -endif - -if !exists("g:vikiSpecialProtocols") "{{{2 - let g:vikiSpecialProtocols = 'https\?\|ftps\?\|nntp\|mailto\|mailbox\|file' -endif - -if !exists("g:vikiSpecialProtocolsExceptions") "{{{2 - let g:vikiSpecialProtocolsExceptions = "" -endif - -if !exists("g:vikiSpecialFiles") "{{{2 - let g:vikiSpecialFiles = 'gif\|bmp\|eps\|png\|jpe\?g\|wm[fav]\|e\?ps' - \ .'\|mp\d\|ogg\|m3u\|mpe\?g\|avi\|aac\|voc\|wav\|aiff\?\|au' - \ .'\|pdf\|dvi\|doc\|xls\|html\?\|doc\|rtf\|xls\|od[gts]' -endif - -if !exists("g:vikiSpecialFilesExceptions") "{{{2 - let g:vikiSpecialFilesExceptions = "" -endif - -fun! VikiHyperLinkColor() "{{{3 - if exists("g:vikiHyperLinkColor") - return g:vikiHyperLinkColor - elseif &background == "light" - return "DarkBlue" - else - return "LightBlue" - endif -endf - -fun! VikiInexistentColor() "{{{3 - if exists("g:vikiInexistentColor") - return g:vikiInexistentColor - elseif &background == "light" - return "DarkRed" - else - return "Red" - endif -endf - -if !exists("g:vikiUseParentSuffix") | let g:vikiUseParentSuffix = 0 | endif "{{{2 -if !exists("g:vikiNameSuffix") | let g:vikiNameSuffix = "" | endif "{{{2 -if !exists("g:vikiAnchorMarker") | let g:vikiAnchorMarker = "#" | endif "{{{2 -if !exists("g:vikiFreeMarker") | let g:vikiFreeMarker = 0 | endif "{{{2 -if !exists("g:vikiNameTypes") | let g:vikiNameTypes = "csSeuix" | endif "{{{2 -if !exists("g:vikiSaveHistory") | let g:vikiSaveHistory = 0 | endif "{{{2 -if !exists("g:vikiExplorer") | let g:vikiExplorer = "Sexplore" | endif "{{{2 -if !exists("g:vikiNoWrapper") | let g:vikiNoWrapper = '\cexplore' | endif "{{{2 -if !exists("g:vikiMarkInexistent") | let g:vikiMarkInexistent = 1 | endif "{{{2 -if !exists("g:vikiMapInexistent") | let g:vikiMapInexistent = 1 | endif "{{{2 -if !exists("g:vikiMapKeys") | let g:vikiMapKeys = "]).,;:!?\"' " | endif "{{{2 -if !exists("g:vikiMapQParaKeys") | let g:vikiMapQParaKeys = "\n" | endif "{{{2 -if !exists("g:vikiMapBeforeKeys") | let g:vikiMapBeforeKeys = ']' | endif "{{{2 -if !exists("g:vikiFamily") | let g:vikiFamily = "" | endif "{{{2 -if !exists("g:vikiDirSeparator") | let g:vikiDirSeparator = "/" | endif "{{{2 -if !exists("g:vikiTextstylesVer") | let g:vikiTextstylesVer = 2 | endif "{{{2 -if !exists("g:vikiBasicSyntax") | let g:vikiBasicSyntax = 0 | endif "{{{2 -if !exists("g:vikiFancyHeadings") | let g:vikiFancyHeadings = 0 | endif "{{{2 -if !exists("g:vikiHomePage") | let g:vikiHomePage = '' | endif "{{{2 -if !exists("g:vikiHide") | let g:vikiHide = '' | endif "{{{2 -if !exists("g:vikiFolds") | let g:vikiFolds = 'h' | endif "{{{2 -if !exists("g:vikiIndex") | let g:vikiIndex = 'Index' | endif "{{{2 -if !exists("g:vikiFeedbackMin") | let g:vikiFeedbackMin = 5 | endif "{{{2 -if !exists("g:vikiMapLeader") | let g:vikiMapLeader = 'v' | endif "{{{2 - -if !exists("g:vikiMapFunctionality") "{{{2 - " c ... follow link (c-cr) - " f ... follow link (v) - " m[fb] ... map mouse (depends on f or b) - " b ... go back - " e ... edit - " q ... quote - " F ... find - " tF ... tab as find - " i ... check for inexistant destinations - " I ... map keys in g:vikiMapKeys and g:vikiMapQParaKeys - let g:vikiMapFunctionality = 'mfmbtFcqeiI' -endif -if !exists("g:vikiMapFunctionalityMinor") "{{{2 - let g:vikiMapFunctionalityMinor = 'mfmbtFcqei' -endif - -if !exists("g:vikiOpenFileWith_ANY") "{{{2 - if has("win32") - let g:vikiOpenFileWith_ANY = "exec 'silent !cmd /c start '. escape('%{FILE}', ' &!%')" - elseif $GNOME_DESKTOP_SESSION_ID != "" - let g:vikiOpenFileWith_ANY = "exec 'silent !gnome-open '. escape('%{FILE}', ' &!%')" - elseif $KDEDIR != "" - let g:vikiOpenFileWith_ANY = "exec 'silent !kfmclient exec '. escape('%{FILE}', ' &!%')" - endif -endif - -if !exists('*VikiOpenSpecialFile') "{{{2 - fun! VikiOpenSpecialFile(file) "{{{3 - let proto = tolower(matchstr(a:file, '\c\.\zs[a-z]\+$')) - if exists('g:vikiOpenFileWith_'. proto) - let prot = g:vikiOpenFileWith_{proto} - elseif exists('g:vikiOpenFileWith_ANY') - let prot = g:vikiOpenFileWith_ANY - else - let prot = '' - endif - if prot != '' - let openFile = VikiSubstituteArgs(prot, 'FILE', a:file) - exec openFile - else - throw 'Viki: Please define g:vikiOpenFileWith_'. proto .' or g:vikiOpenFileWith_ANY!' - endif - endf -endif - -if !exists('g:vikiOpenUrlWith_mailbox') "{{{2 - let g:vikiOpenUrlWith_mailbox="call VikiOpenMailbox('%{URL}')" - fun! VikiOpenMailbox(url) "{{{3 - exec VikiDecomposeUrl(strpart(a:url, 10)) - let idx = matchstr(args, 'number=\zs\d\+$') - if filereadable(filename) - call VikiOpenLink(filename, '', 0, 'go '.idx) - else - throw 'Viki: Can't find mailbox url: '.filename - endif - endf -endif - -" Possible values: special*, query, normal -if !exists("g:vikiUrlFileAs") | let g:vikiUrlFileAs = 'special' | endif "{{{2 - -if !exists("g:vikiOpenUrlWith_file") "{{{2 - let g:vikiOpenUrlWith_file="call VikiOpenFileUrl('%{URL}')" - fun! VikiOpenFileUrl(url) "{{{3 - if VikiIsSpecialFile(a:url) - if g:vikiUrlFileAs == 'special' - let as_special = 1 - elseif g:vikiUrlFileAs == 'query' - echo a:url - let as_special = input('Treat URL as special file? (Y/n) ') - let as_special = (as_special[0] !=? 'n') - else - let as_special = 0 - endif - if as_special - call VikiOpenSpecialFile(a:url) - return - endif - endif - exec VikiDecomposeUrl(strpart(a:url, 7)) - if filereadable(filename) - call VikiOpenLink(filename, anchor) - else - throw 'Viki: Can't find file url: '.filename - endif - endf -endif - -if !exists("g:vikiOpenUrlWith_ANY") "{{{2 - if has("win32") - let g:vikiOpenUrlWith_ANY = "exec 'silent !rundll32 url.dll,FileProtocolHandler '. escape('%{URL}', ' !&%')" - elseif $GNOME_DESKTOP_SESSION_ID != "" - let g:vikiOpenUrlWith_ANY = "exec 'silent !gnome-open '. escape('%{URL}', ' !&%')" - elseif $KDEDIR != "" - let g:vikiOpenUrlWith_ANY = "exec 'silent !kfmclient exec '. escape('%{URL}', ' !&%')" - endif -endif - -if !exists("*VikiOpenSpecialProtocol") "{{{2 - fun! VikiOpenSpecialProtocol(url) "{{{3 - let proto = tolower(matchstr(a:url, '\c^[a-z]\{-}\ze:')) - let prot = 'g:vikiOpenUrlWith_'. proto - let protp = exists(prot) - if !protp - let prot = 'g:vikiOpenUrlWith_ANY' - let protp = exists(prot) - endif - if protp - exec 'let openURL = '. prot - let openURL = VikiSubstituteArgs(openURL, 'URL', a:url) - exec openURL - else - throw 'Viki: Please define g:vikiOpenUrlWith_'. proto .' or g:vikiOpenUrlWith_ANY!' - endif - endf -endif - -fun! ResetSavedCursorPosition() "{{{3 - let s:cursorSet = -1 - let s:cursorCol = -1 - let s:cursorVCol = -1 - let s:cursorLine = -1 - let s:cursorWinTLine = -1 - let s:cursorEol = 0 - let s:lazyredraw = &lazyredraw -endf - -call ResetSavedCursorPosition() - -let s:InterVikiRx = '^\(['. g:vikiUpperCharacters .']\+\)::\(.*\)$' -let s:InterVikis = '' - -" VikiDefine(name, prefix, ?suffix="*", ?index="Index.${suffix}") -" suffix == "*" -> g:vikiNameSuffix -fun! VikiDefine(name, prefix, ...) "{{{3 - if a:name =~ '[^A-Z]' - throw 'Invalid interviki name: '. a:name - endif - let s:InterVikis = s:InterVikis . a:name ."::\n" - let g:vikiInter{a:name} = a:prefix - let g:vikiInter{a:name}_suffix = a:0 >= 1 && a:1 != '*' ? a:1 : g:vikiNameSuffix - let index = a:0 >= 2 && a:2 != '' ? a:2 : g:vikiIndex - let findex = g:vikiInter{a:name} .'/'. index . g:vikiInter{a:name}_suffix - if filereadable(findex) - let vname = VikiMakeName(a:name, index) - else - " let vname = '[['. a:name .'::]]' - let vname = a:name .'::' - end - let vname = escape(vname, ' \%#') - exec 'command! '. a:name .' VikiEdit! '. vname - if g:vikiMenuPrefix != '' - exec 'amenu '. g:vikiMenuPrefix . a:name .' :VikiEdit! '. vname .'' - endif -endf - -command! -nargs=+ VikiDefine call VikiDefine() - -if g:vikiMenuPrefix != '' "{{{2 - exec 'amenu '. g:vikiMenuPrefix .'Home :VikiHome' - exec 'amenu '. g:vikiMenuPrefix .'-SepViki1- :' -endif - -fun! AddToRegexp(regexp, pattern) "{{{3 - if a:pattern == '' - return a:regexp - elseif a:regexp == '' - return a:pattern - else - return a:regexp .'\|'. a:pattern - endif -endf - -fun! CanonicFilename(fname) "{{{3 - return substitute(simplify(a:fname), '[\/]\+', '/', 'g') -endf - -fun! VikiFindRx() "{{{3 - let rx = AddToRegexp('', b:vikiSimpleNameSimpleRx) - let rx = AddToRegexp(rx, b:vikiExtendedNameSimpleRx) - let rx = AddToRegexp(rx, b:vikiUrlSimpleRx) - return rx -endf - -fun! EditWrapper(cmd, fname) "{{{3 - let fname = escape(simplify(a:fname), ' ') - if a:cmd =~ g:vikiNoWrapper - exec a:cmd .' '. a:fname - else - try - if g:vikiHide == 'hide' - exec 'hide '. a:cmd .' '. a:fname - elseif g:vikiHide == 'update' - update - exec a:cmd .' '. a:fname - else - exec a:cmd .' '. a:fname - endif - catch /^Vim\%((\a\+)\)\=:E37/ - echoerr "Vim raised E37: You tried to abondon a dirty buffer (see :h E37)" - echoerr "Viki: You may want to reconsider your g:vikiHide or 'hidden' settings" - catch /^Vim\%((\a\+)\)\=:E325/ - endtry - endif -endf - -" VikiFind(flag, ?count=0, ?rx=nil) -fun! VikiFind(flag, ...) "{{{3 - let rx = (a:0 >= 2 && a:2 != '') ? a:2 : VikiFindRx() - if rx != "" - let i = a:0 >= 1 ? a:1 : 0 - while i >= 0 - call search(rx, a:flag) - let i = i - 1 - endwh - endif -endf - -command! -count VikiFindNext call VikiDispatchOnFamily('VikiFind', '', '', ) -command! -count VikiFindPrev call VikiDispatchOnFamily('VikiFind', '', 'b', ) - -" IsSupportedType(type, ?types=b:vikiNameTypes) -fun! IsSupportedType(type, ...) "{{{3 - if a:0 >= 1 - let types = a:1 - elseif exists('b:vikiNameTypes') - let types = b:vikiNameTypes - else - let types = g:vikiNameTypes - end - if types == '' - return 1 - else - " return stridx(b:vikiNameTypes, a:type) >= 0 - return types =~# '['. a:type .']' - endif -endf - -fun! VikiRxFromCollection(coll) "{{{3 - " let rx = strpart(a:coll, 0, strlen(a:coll) - 1) - " let rx = substitute(rx, "\n", '\\|', "g") - let rx = substitute(a:coll, '\\|$', '', '') - if rx == '' - return '' - else - return '\V\('. rx .'\)' - endif -endf - -" VikiMarkInexistent(line1, line2, ?maxcol, ?quick) -" maxcol ... check only up to maxcol -" quick ... check only if the cursor is located after a link -fun! VikiMarkInexistent(line1, line2, ...) "{{{3 - if !b:vikiMarkInexistent - return - endif - if s:cursorCol == -1 - " let cursorRestore = 1 - let li0 = line('.') - let co0 = col('.') - let co1 = co0 - 1 - else - " let cursorRestore = 0 - let li0 = s:cursorLine - let co0 = s:cursorCol - let co1 = co0 - 2 - end - if a:0 >= 2 && a:2 > 0 && synIDattr(synID(li0, co1, 1), 'name') !~ '^viki.*Link$' - return - endif - - let lazyredraw = &lazyredraw - set lazyredraw - - let maxcol = a:0 >= 1 ? (a:1 == -1 ? 9999999 : a:1) : 9999999 - - if a:line1 > 0 - keepjumps call cursor(a:line1, 1) - let min = a:line1 - else - go - let min = 1 - endif - let max = a:line2 > 0 ? a:line2 : line('$') - - if line('.') == 1 && line('$') == max - let b:vikiNamesNull = '' - let b:vikiNamesOk = '' - else - if !exists('b:vikiNamesNull') | let b:vikiNamesNull = '' | endif - if !exists('b:vikiNamesOk') | let b:vikiNamesOk = '' | endif - endif - - let feedback = (max - min) > b:vikiFeedbackMin - try - if feedback - let sl = &statusline - let rng = min .'-'. max - let &statusline='Viki: checking line '. rng - let rng = ' ('. min .'-'. max .')' - redrawstatus - endif - - if line('.') == 1 - keepjumps norm! G$ - else - keepjumps norm! k$ - endif - - let rx = VikiFindRx() - let pp = 0 - let ll = 0 - let cc = 0 - keepjumps let li = search(rx, 'w') - let co = col('.') - while li != 0 && !(ll == li && cc == co) && li >= min && li <= max && co <= maxcol - if feedback - " if li % 10 == 0 && li != ll - if li % 10 == 0 - let &statusline='Viki: checking line '. li . rng - redrawstatus - " let ll = li - endif - endif - let ll = li - let def = VikiGetLink('-', 1, '', co) - if def == '-' - echom 'Internal error: VikiMarkInexistent: '. def - else - exec VikiSplitDef(def) - " let v_dest = MvElementAt(def, g:vikiDefSep, 1) - " let v_part = MvElementAt(def, g:vikiDefSep, 3) - if v_part =~ '^'. b:vikiSimpleNameSimpleRx .'$' - let check = 1 - let partx = escape(v_part, "'\"\\/") - if partx !~ '^\[' - let partx = '\<'.partx - endif - if partx !~ '\]$' - let partx = partx.'\>' - endif - elseif v_dest =~ '^'. b:vikiUrlSimpleRx .'$' - let check = 0 - let partx = escape(v_part, "'\"\\/") - let b:vikiNamesNull = MvRemoveElementAll(b:vikiNamesNull, '\\|', partx, '\|') - let b:vikiNamesOk = MvPushToFront(b:vikiNamesOk, '\\|', partx, '\|') - elseif v_part =~ b:vikiExtendedNameSimpleRx - if v_dest =~ '^'. g:vikiSpecialProtocols .':' - let check = 0 - else - let check = 1 - let partx = escape(v_part, "'\"\\/") - endif - " elseif v_part =~ b:vikiCmdSimpleRx - " <+TBD+> - else - let check = 0 - endif - if check && v_dest != "" && v_dest != g:vikiSelfRef && !isdirectory(v_dest) - if filereadable(v_dest) - let b:vikiNamesNull = MvRemoveElementAll(b:vikiNamesNull, '\\|', partx, '\|') - let b:vikiNamesOk = MvPushToFront(b:vikiNamesOk, '\\|', partx, '\|') - else - let b:vikiNamesNull = MvPushToFront(b:vikiNamesNull, '\\|', partx, '\|') - let b:vikiNamesOk = MvRemoveElementAll(b:vikiNamesOk, '\\|', partx, '\|') - endif - endif - endif - keepjumps let li = search(rx, 'W') - let co = col('.') - endwh - call VikiHighlightInexistent() - let b:vikiCheckInexistent = 0 - finally - " if cursorRestore && !s:cursorSet - " call VikiRestoreCursorPosition(li0, co0) - " endif - if feedback - let &statusline = sl - endif - let &lazyredraw = lazyredraw - endtry -endf - -fun! VikiHighlightInexistent() "{{{3 - if b:vikiMarkInexistent == 1 - if exists('b:vikiNamesNull') - exe 'syntax clear '. b:vikiInexistentHighlight - let rx = VikiRxFromCollection(b:vikiNamesNull) - if rx != '' - exe 'syntax match '. b:vikiInexistentHighlight .' /'. rx .'/' - endif - endif - elseif b:vikiMarkInexistent == 2 - if exists('b:vikiNamesOk') - syntax clear vikiOkLink - syntax clear vikiExtendedOkLink - let rx = VikiRxFromCollection(b:vikiNamesOk) - if rx != '' - exe 'syntax match vikiOkLink /'. rx .'/' - endif - endif - endif -endf - -" command! -nargs=* -range=% VikiMarkInexistent -" \ call VikiSaveCursorPosition() -" \ | call VikiMarkInexistent(, , ) -" \ | call VikiRestoreCursorPosition() -" \ | call ResetSavedCursorPosition() - -command! -nargs=* -range=% VikiMarkInexistent call VikiMarkInexistentInRange(, ) - -fun! VikiMarkInexistentInLineQuick() "{{{3 -"arrowzhang -"fun! VikiMarkInexistentInLineQuick() "{{{3 - call VikiMarkInexistent(line("."), line("."), (col('.') + 1), 1) -endf - -fun! VikiMarkInexistentInDocument() "{{{3 -"arrowzhang -"fun! VikiMarkInexistentInDocument() "{{{3 - call VikiMarkInexistent(1, line("$")) -endf - -fun! VikiMarkInexistentInElement(elt) "{{{3 - let lr = &lazyredraw - set lazyredraw - call VikiSaveCursorPosition() - lockmarks call VikiMarkInexistentIn{a:elt}() - call VikiRestoreCursorPosition() - call ResetSavedCursorPosition() - let &lazyredraw = lr - return '' -endf - -fun! VikiMarkInexistentInRange(line1, line2) "{{{3 - call VikiSaveCursorPosition() - call VikiMarkInexistent(a:line1, a:line2) - call VikiRestoreCursorPosition() - call ResetSavedCursorPosition() -endf - -fun! VikiMarkInexistentInParagraph() "{{{3 - "arrowzhang -"fun! VikiMarkInexistentInParagraph() "{{{3 - if getline('.') =~ '\S' - call VikiMarkInexistent(line("'{"), line("'}")) - endif -endf - - -fun! VikiMarkInexistentInParagraphQuick() "{{{3 - call VikiMarkInexistent(line("'{"), line("'}"), -1, 1) -endf - -fun! VikiMarkInexistentInLine() "{{{3 - call VikiMarkInexistent(line("."), line(".")) -endf - - -fun! VikiCheckInexistent() "{{{3 - if g:vikiEnabled && exists("b:vikiCheckInexistent") && b:vikiCheckInexistent > 0 - call VikiMarkInexistentInRange(b:vikiCheckInexistent, b:vikiCheckInexistent) - endif -endf - -autocmd BufEnter * call VikiMinorModeReset() -autocmd BufEnter * call VikiCheckInexistent() -autocmd VimLeavePre * let g:vikiEnabled = 0 - -fun! VikiSetBufferVar(name, ...) "{{{3 - if !exists('b:'.a:name) - if a:0 > 0 - let i = 1 - while i <= a:0 - exe 'let altVar = a:'. i - if altVar[0] == '*' - exe 'let b:'.a:name.' = '. strpart(altVar, 1) - return - elseif exists(altVar) - exe 'let b:'.a:name.' = '. altVar - return - endif - let i = i + 1 - endwh - throw 'VikiSetBuffer: Couldn't set '. a:name - else - exe 'let b:'.a:name.' = g:'.a:name - endif - endif -endf - -fun! VikiLetVar(name, var) "{{{3 - if exists('b:'.a:var) - return 'let '.a:name.' = b:'.a:var - elseif exists('g:'.a:var) - return 'let '.a:name.' = g:'.a:var - else - return '' - endif -endf - -" VikiDispatchOnFamily(fn, ?family='', *args) -fun! VikiDispatchOnFamily(fn, ...) "{{{3 - let fam = a:0 >= 1 && a:1 != '' ? a:1 : Family() - if fam == '' || !exists('*'.a:fn.fam) - let cmd = a:fn - else - let cmd = a:fn.fam - endif - - let i = 2 - let args = '' - while i <= a:0 - " exe "let val = 'a:".i."'" - " let val = "'". a:{i} ."'" - let val = '"'. escape(a:{i}, '"\') .'"' - if args == '' - let args = val - else - let args = args . ', '. val - endif - let i = i + 1 - endwh - " echom "DBG ". fam .' '. cmd . '(' . args . ')' - exe 'return '. cmd . '(' . args . ')' -endf - -" VikiSetupBuffer(state, ?dontSetup='') -fun! VikiSetupBuffer(state, ...) "{{{3 - if !g:vikiEnabled - return - endif - " echom "DBG ". expand('%') .': '. (exists('b:vikiFamily') ? b:vikiFamily : 'default') - - let dontSetup = a:0 > 0 ? a:1 : "" - let noMatch = "" - - if exists("b:vikiNoSimpleNames") && b:vikiNoSimpleNames - let b:vikiNameTypes = substitute(b:vikiNameTypes, '\Cs', '', 'g') - endif - if exists("b:vikiDisableType") && b:vikiDisableType != "" - let b:vikiNameTypes = substitute(b:vikiNameTypes, '\C'. b:vikiDisableType, '', 'g') - endif - - call VikiSetBufferVar("vikiAnchorMarker") - call VikiSetBufferVar("vikiSpecialProtocols") - call VikiSetBufferVar("vikiSpecialProtocolsExceptions") - call VikiSetBufferVar("vikiMarkInexistent") - call VikiSetBufferVar("vikiTextstylesVer") - call VikiSetBufferVar("vikiTextstylesVer") - call VikiSetBufferVar("vikiLowerCharacters") - call VikiSetBufferVar("vikiUpperCharacters") - call VikiSetBufferVar("vikiFeedbackMin") - - if a:state == 1 - call VikiSetBufferVar("vikiCommentStart", - \ "b:commentStart", "b:ECcommentOpen", "b:EnhCommentifyCommentOpen", - \ "*matchstr(&commentstring, '^\\zs.*\\ze%s')") - call VikiSetBufferVar("vikiCommentEnd", - \ "b:commentEnd", "b:ECcommentClose", "b:EnhCommentifyCommentClose", - \ "*matchstr(&commentstring, '%s\\zs.*\\ze$')") - endif - - let b:vikiSimpleNameQuoteChars = '^][:*/&?<>|\"' - - let b:vikiSimpleNameQuoteBeg = '\[-' - let b:vikiSimpleNameQuoteEnd = '-\]' - let b:vikiQuotedSelfRef = "^". b:vikiSimpleNameQuoteBeg . b:vikiSimpleNameQuoteEnd ."$" - let b:vikiQuotedRef = "^". b:vikiSimpleNameQuoteBeg .'.\+'. b:vikiSimpleNameQuoteEnd ."$" - - let b:vikiAnchorNameRx = '['. b:vikiLowerCharacters .']['. - \ b:vikiLowerCharacters . b:vikiUpperCharacters .'_0-9]*' - - let interviki = '\<['. b:vikiUpperCharacters .']\+::' - - if IsSupportedType("sSc") && !(dontSetup =~? "s") - if IsSupportedType("S") && !(dontSetup =~# "S") - let quotedVikiName = b:vikiSimpleNameQuoteBeg - \ .'['. b:vikiSimpleNameQuoteChars .']' - \ .'\{-}'. b:vikiSimpleNameQuoteEnd - else - let quotedVikiName = "" - endif - if IsSupportedType("c") && !(dontSetup =~# "c") - let simpleWikiName = VikiGetSimpleRx4SimpleWikiName() - if quotedVikiName != "" - let quotedVikiName = quotedVikiName .'\|' - endif - else - let simpleWikiName = "" - endif - let b:vikiSimpleNameRx = '\C\(\('. interviki .'\)\?'. - \ '\('. quotedVikiName . simpleWikiName .'\)\)'. - \ '\(#\('. b:vikiAnchorNameRx .'\)\>\)\?' - let b:vikiSimpleNameSimpleRx = '\C\(\<['.b:vikiUpperCharacters.']\+::\)\?'. - \ '\('. quotedVikiName . simpleWikiName .'\)'. - \ '\(#'. b:vikiAnchorNameRx .'\>\)\?' - let b:vikiSimpleNameNameIdx = 1 - let b:vikiSimpleNameDestIdx = 0 - let b:vikiSimpleNameAnchorIdx = 5 - let b:vikiSimpleNameCompound = 'let erx="'. escape(b:vikiSimpleNameRx, '\"') - \ .'" | let nameIdx='. b:vikiSimpleNameNameIdx - \ .' | let destIdx='. b:vikiSimpleNameDestIdx - \ .' | let anchorIdx='. b:vikiSimpleNameAnchorIdx - else - let b:vikiSimpleNameRx = noMatch - let b:vikiSimpleNameSimpleRx = noMatch - let b:vikiSimpleNameNameIdx = 0 - let b:vikiSimpleNameDestIdx = 0 - let b:vikiSimpleNameAnchorIdx = 0 - endif - - if IsSupportedType("u") && !(dontSetup =~# "u") - let urlChars = 'A-Za-z0-9.,:%?=&_~@$/|+-' - let b:vikiUrlRx = '\<\(\('.b:vikiSpecialProtocols.'\):['. urlChars .']\+\)'. - \ '\(#\([A-Za-z0-9]*\)\)\?' - let b:vikiUrlSimpleRx = '\<\('. b:vikiSpecialProtocols .'\):['. urlChars .']\+'. - \ '\(#[A-Za-z0-9]*\)\?' - let b:vikiUrlNameIdx = 0 - let b:vikiUrlDestIdx = 1 - let b:vikiUrlAnchorIdx = 4 - let b:vikiUrlCompound = 'let erx="'. escape(b:vikiUrlRx, '\"') - \ .'" | let nameIdx='. b:vikiUrlNameIdx - \ .' | let destIdx='. b:vikiUrlDestIdx - \ .' | let anchorIdx='. b:vikiUrlAnchorIdx - else - let b:vikiUrlRx = noMatch - let b:vikiUrlSimpleRx = noMatch - let b:vikiUrlNameIdx = 0 - let b:vikiUrlDestIdx = 0 - let b:vikiUrlAnchorIdx = 0 - endif - - if IsSupportedType("x") && !(dontSetup =~# "x") - let b:vikiCmdRx = '\({\S\+\|#['. b:vikiUpperCharacters .']\w*\)\(.\{-}\):\s*\(.\{-}\)\($\|}\)' - let b:vikiCmdSimpleRx = '\({\S\+\|#['. b:vikiUpperCharacters .']\w*\).\{-}\($\|}\)' - let b:vikiCmdNameIdx = 1 - let b:vikiCmdDestIdx = 3 - let b:vikiCmdAnchorIdx = 2 - let b:vikiCmdCompound = 'let erx="'. escape(b:vikiCmdRx, '\"') - \ .'" | let nameIdx='. b:vikiCmdNameIdx - \ .' | let destIdx='. b:vikiCmdDestIdx - \ .' | let anchorIdx='. b:vikiCmdAnchorIdx - else - let b:vikiCmdRx = noMatch - let b:vikiCmdSimpleRx = noMatch - let b:vikiCmdNameIdx = 0 - let b:vikiCmdDestIdx = 0 - let b:vikiCmdAnchorIdx = 0 - endif - - if IsSupportedType("e") && !(dontSetup =~# "e") - let b:vikiExtendedNameRx = - \ '\[\[\(\('.b:vikiSpecialProtocols.'\)://[^]]\+\|[^]#]\+\)\?'. - \ '\(#\([^]]*\)\)\?\]\(\[\([^]]\+\)\]\)\?\([!~*\-]*\)\]' - " \ '\(#\('. b:vikiAnchorNameRx .'\)\)\?\]\(\[\([^]]\+\)\]\)\?[!~*\-]*\]' - let b:vikiExtendedNameSimpleRx = - \ '\[\[\('. b:vikiSpecialProtocols .'://[^]]\+\|[^]#]\+\)\?'. - \ '\(#[^]]*\)\?\]\(\[[^]]\+\]\)\?[!~*\-]*\]' - " \ '\(#'. b:vikiAnchorNameRx .'\)\?\]\(\[[^]]\+\]\)\?[!~*\-]*\]' - let b:vikiExtendedNameNameIdx = 6 - let b:vikiExtendedNameModIdx = 7 - let b:vikiExtendedNameDestIdx = 1 - let b:vikiExtendedNameAnchorIdx = 4 - let b:vikiExtendedNameCompound = 'let erx="'. escape(b:vikiExtendedNameRx, '\"') - \ .'" | let nameIdx='. b:vikiExtendedNameNameIdx - \ .' | let destIdx='. b:vikiExtendedNameDestIdx - \ .' | let anchorIdx='. b:vikiExtendedNameAnchorIdx - else - let b:vikiExtendedNameRx = noMatch - let b:vikiExtendedNameSimpleRx = noMatch - let b:vikiExtendedNameNameIdx = 0 - let b:vikiExtendedNameDestIdx = 0 - let b:vikiExtendedNameAnchorIdx = 0 - endif - - let b:vikiInexistentHighlight = "vikiInexistentLink" -endf - -fun! VikiDefineMarkup(state) "{{{3 - if IsSupportedType("sS") && b:vikiSimpleNameSimpleRx != "" - exe "syntax match vikiLink /" . b:vikiSimpleNameSimpleRx . "/" - endif - if IsSupportedType("e") && b:vikiExtendedNameSimpleRx != "" - exe "syntax match vikiExtendedLink '" . b:vikiExtendedNameSimpleRx . "' skipnl" - endif - if IsSupportedType("u") && b:vikiUrlSimpleRx != "" - exe "syntax match vikiURL /" . b:vikiUrlSimpleRx . "/" - endif -endf - -fun! VikiGetSimpleRx4SimpleWikiName() "{{{3 - let upper = UpperCharacters() - let lower = LowerCharacters() - let simpleWikiName = '\<['.upper.']['.lower.']\+\(['.upper.']['.lower.'0-9]\+\)\+\>' - return simpleWikiName -endf - -fun! VikiMakeName(iviki, name) "{{{3 - let name = a:name - if name !~ '\C'. VikiGetSimpleRx4SimpleWikiName() - let name = '[-'. name .'-]' - endif - if a:iviki != '' - let name = a:iviki .'::'. name - endif - return name -endf - -fun! UpperCharacters() "{{{3 - return exists('b:vikiUpperCharacters') ? b:vikiUpperCharacters : g:vikiUpperCharacters -endf - -fun! LowerCharacters() "{{{3 - return exists('b:vikiLowerCharacters') ? b:vikiLowerCharacters : g:vikiLowerCharacters -endf - -fun! StripBackslash(string) "{{{3 - return substitute(a:string, '\\\(.\)', '\1', 'g') -endf - -fun! VikiDefineHighlighting(state) "{{{3 - if version < 508 - command! -nargs=+ VikiHiLink hi link - else - command! -nargs=+ VikiHiLink hi def link - endif - - exe "hi vikiInexistentLink term=bold,underline cterm=bold,underline gui=bold,underline". - \ " ctermfg=". VikiInexistentColor() ." guifg=". VikiInexistentColor() - exe "hi vikiHyperLink term=bold,underline cterm=bold,underline gui=bold,underline". - \ " ctermfg=". VikiHyperLinkColor() ." guifg=". VikiHyperLinkColor() - - if IsSupportedType("sS") - VikiHiLink vikiLink vikiHyperLink - VikiHiLink vikiOkLink vikiHyperLink - VikiHiLink vikiRevLink Normal - endif - if IsSupportedType("e") - VikiHiLink vikiExtendedLink vikiHyperLink - VikiHiLink vikiExtendedOkLink vikiHyperLink - VikiHiLink vikiRevExtendedLink Normal - endif - if IsSupportedType("u") - VikiHiLink vikiURL vikiHyperLink - endif - delcommand VikiHiLink -endf - -fun! MapMarkInexistent(key, element) "{{{3 - if a:key == "\n" - let key = '' - elseif a:key == ' ' - let key = '' - else - let key = a:key - endif - let arg = maparg(key, 'i') - if arg == '' - let arg = key - endif - let map = '=VikiMarkInexistentInElement("'. a:element .'")' - let map = stridx(g:vikiMapBeforeKeys, a:key) != -1 ? arg.map : map.arg - exe 'inoremap '. key .' '. map -endf - -" VikiRestoreCursorPosition(?line, ?VCol, ?EOL, ?Winline) -fun! VikiRestoreCursorPosition(...) "{{{3 - " let li = a:0 >= 1 && a:1 != '' ? a:1 : s:cursorLine - " " let co = a:0 >= 2 && a:2 != '' ? a:2 : s:cursorVCol - " let co = a:0 >= 2 && a:2 != '' ? a:2 : s:cursorCol - " " let eol = a:0 >= 3 && a:3 != '' ? a:3 : s:cursorEol - " let wli = a:0 >= 4 && a:4 != '' ? a:4 : s:cursorWinTLine - let li = s:cursorLine - let co = s:cursorCol - let wli = s:cursorWinTLine - if li >= 0 - let ve = &virtualedit - set virtualedit=all - if wli > 0 - exe 'keepjumps norm! '. wli .'zt' - endif - call cursor(li, co) - let &virtualedit = ve - endif -endf - -fun! VikiSaveCursorPosition() "{{{3 - let ve = &virtualedit - set virtualedit=all - " let s:lazyredraw = &lazyredraw - " set nolazyredraw - let s:cursorSet = 1 - let s:cursorCol = col('.') - let s:cursorEol = (col('.') == col('$')) - let s:cursorVCol = virtcol('.') - if s:cursorEol - let s:cursorVCol = s:cursorVCol + 1 - endif - let s:cursorLine = line('.') - keepjumps norm! H - let s:cursorWinTLine = line('.') - call cursor(s:cursorLine, s:cursorCol) - let &virtualedit = ve - " call VikiDebugCursorPosition() - return '' -endf - -fun! VikiDebugCursorPosition(...) "{{{3 - let msg = 'DBG ' - if a:0 >= 1 && a:1 != '' - let msg = msg . a:1 .' ' - endif - let msg = msg . "s:cursorCol=". s:cursorCol - \ ." s:cursorEol=". s:cursorEol - \ ." ($=". col('$') .')' - \ ." s:cursorVCol=". s:cursorVCol - \ ." s:cursorLine=". s:cursorLine - \ ." s:cursorWinTLine=". s:cursorWinTLine - if a:0 >= 2 && a:2 - echo msg - else - echom msg - endif -endf - -fun! VikiMapKeys(state) "{{{3 - if exists('b:vikiDidMapKeys') - return - endif - if a:state == 1 - if exists('b:vikiMapFunctionalityMinor') && b:vikiMapFunctionalityMinor - let mf = b:vikiMapFunctionalityMinor - else - let mf = g:vikiMapFunctionalityMinor - endif - elseif exists('b:vikiMapFunctionality') && b:vikiMapFunctionality - let mf = b:vikiMapFunctionality - else - let mf = g:vikiMapFunctionality - endif - - " if !hasmapto('VikiMaybeFollowLink') - if mf =~# 'c' - nnoremap :call VikiMaybeFollowLink(0,1) - inoremap :call VikiMaybeFollowLink(0,1) - " nnoremap :call VikiMaybeFollowLink(0,1,-1) - endif - if mf =~# 'f' - " nnoremap :call VikiMaybeFollowLink(0,1) - " inoremap :call VikiMaybeFollowLink(0,1) - " nnoremap :call VikiMaybeFollowLink(0,1,-1) - exec 'nnoremap '. g:vikiMapLeader .'f :call VikiMaybeFollowLink(0,1)' - exec 'nnoremap '. g:vikiMapLeader .'s :call VikiMaybeFollowLink(0,1,-1)' - exec 'nnoremap '. g:vikiMapLeader .'v :call VikiMaybeFollowLink(0,1,-2)' - exec 'nnoremap '. g:vikiMapLeader .'1 :call VikiMaybeFollowLink(0,1,1)' - exec 'nnoremap '. g:vikiMapLeader .'2 :call VikiMaybeFollowLink(0,1,2)' - exec 'nnoremap '. g:vikiMapLeader .'3 :call VikiMaybeFollowLink(0,1,3)' - exec 'nnoremap '. g:vikiMapLeader .'4 :call VikiMaybeFollowLink(0,1,4)' - endif - if mf =~# 'mf' - " && !hasmapto("VikiMaybeFollowLink") - nnoremap :call VikiMaybeFollowLink(0,1) - inoremap :call VikiMaybeFollowLink(0,1) - endif - " endif - - " if !hasmapto('VikiMarkInexistent') - if mf =~# 'i' - exec 'noremap '. g:vikiMapLeader .'d :call VikiMarkInexistentInElement("Document")' - exec 'noremap '. g:vikiMapLeader .'p :call VikiMarkInexistentInElement("Paragraph")' - endif - if mf =~# 'I' - if g:vikiMapInexistent - let i = 0 - let m = strlen(g:vikiMapKeys) - while i < m - let k = g:vikiMapKeys[i] - call MapMarkInexistent(k, "LineQuick") - let i = i + 1 - endwh - let i = 0 - let m = strlen(g:vikiMapQParaKeys) - while i < m - let k = g:vikiMapQParaKeys[i] - call MapMarkInexistent(k, "Paragraph") - let i = i + 1 - endwh - endif - endif - " endif - - if mf =~# 'e' - " && !hasmapto("VikiEdit") - exec 'noremap '. g:vikiMapLeader .'e :VikiEdit ' - endif - - if mf =~# 'q' && exists("*VEnclose") - " && !hasmapto("VikiQuote") - exec 'vnoremap '. g:vikiMapLeader .'q :VikiQuote:call VikiMarkInexistentInElement("LineQuick")' - exec 'nnoremap '. g:vikiMapLeader .'q viw:VikiQuote:call VikiMarkInexistentInElement("LineQuick")' - exec 'inoremap '. g:vikiMapLeader .'q viw:VikiQuote:call VikiMarkInexistentInElement("LineQuick")i' - endif - - if mf =~# 'b' - " && !hasmapto("VikiGoBack") - exec 'nnoremap '. g:vikiMapLeader .'b :call VikiGoBack()' - endif - if mf =~# 'mb' - nnoremap :call VikiGoBack(0) - inoremap :call VikiGoBack(0) - endif - - if mf =~# 'F' - " && !hasmapto(":VikiFind") - exec 'nnoremap '. g:vikiMapLeader .'n :VikiFindNext' - exec 'nnoremap '. g:vikiMapLeader .'N :VikiFindPrev' - endif - if mf =~# 'tF' - " && !hasmapto(":VikiFind") - nnoremap :VikiFindNext - nnoremap :VikiFindPrev - endif - let b:vikiDidMapKeys = 1 -endf - -"state ... no-op:0, minor:1, major:2 -fun! VikiMinorMode(state) "{{{3 - if !g:vikiEnabled - return 0 - endif - if a:state == 0 - return 0 - endif - let state = a:state < 0 ? -a:state : a:state - let vf = Family(1) - " c ... CamelCase - " s ... Simple viki name - " S ... Simple quoted viki name - " e ... Extended viki name - " u ... URL - " i ... InterViki - " call VikiSetBufferVar('vikiNameTypes', 'g:vikiNameTypes', "*'csSeui'") - call VikiSetBufferVar('vikiNameTypes') - call VikiDispatchOnFamily('VikiSetupBuffer', vf, state) - call VikiDispatchOnFamily('VikiDefineMarkup', vf, state) - call VikiDispatchOnFamily('VikiDefineHighlighting', vf, state) - call VikiDispatchOnFamily('VikiMapKeys', vf, state) - if !exists('b:vikiEnabled') || b:vikiEnabled < state - let b:vikiEnabled = state - endif - " call VikiDispatchOnFamily('VikiDefineMarkup', vf, state) - " call VikiDispatchOnFamily('VikiDefineHighlighting', vf, state) - return 1 -endf - -fun! VikiMinorModeReset() "{{{3 - if exists("b:vikiEnabled") && b:vikiEnabled == 1 - call VikiMinorMode(1) - endif -endf - -command! VikiMinorMode call VikiMinorMode(1) -command! VikiMinorModeMaybe echom "Deprecated command: VikiMinorModeMaybe" | call VikiMinorMode(1) -" this requires imaps to be installed -command! -range VikiQuote :call VEnclose("[-", "-]", "[-", "-]") - -fun! VikiMode(state) "{{{3 - if exists("b:vikiEnabled") - if b:vikiEnabled - return 0 - endif - " if b:vikiEnabled && a:state < 0 - " return 0 - " endif - " echom "VIKI: Viki mode already set." - endif - set filetype=viki -endf - -command! VikiMode call VikiMode(2) -command! VikiModeMaybe echom "Deprecated command: VikiModeMaybe" | call VikiMode(2) -" command! VikiModeMaybe call VikiMode(-2) - -fun! AddVarToMultVal(var, val) "{{{3 - if exists(a:var) - exe "let i = MvIndexOfElement(". a:var .", '". g:vikiDefSep ."', ". a:val .")" - exe "let ". a:var ."=MvPushToFront(". a:var .", '". g:vikiDefSep ."', ". a:val .")" - return i - else - exe "let ". a:var ."=MvAddElement('', '". g:vikiDefSep ."', ". a:val .")" - return -1 - endif -endf - -fun! VikiIsInRegion(line) "{{{3 - let i = 0 - let max = col('$') - while i < max - if synIDattr(synID(a:line, i, 1), "name") == "vikiRegion" - return 1 - endif - let i = i + 1 - endw - return 0 -endf - -fun! VikiSetBackRef(file, li, co) "{{{3 - let i = AddVarToMultVal("b:VikiBackFile", "'". a:file ."'") - if i >= 0 - let b:VikiBackLine = MvPushToFrontElementAt(b:VikiBackLine, g:vikiDefSep, i) - let b:VikiBackCol = MvPushToFrontElementAt(b:VikiBackCol, g:vikiDefSep, i) - else - call AddVarToMultVal("b:VikiBackLine", a:li) - call AddVarToMultVal("b:VikiBackCol", a:co) - endif -endf - -fun! VikiSelect(array, seperator, queryString) "{{{3 - let n = MvNumberOfElements(a:array, a:seperator) - if n == 1 - return 0 - elseif n > 1 - let i = 0 - let nn = 0 - while i <= n - let f = MvElementAt(a:array, a:seperator, i) - if f != "" - if i == 0 - echomsg i ."* ". f - else - echomsg i ." ". f - endif - let nn = i - endif - let i = i + 1 - endwh - if nn == 0 - let this = 0 - else - let this = input(a:queryString ." [0-".nn."]: ", "0") - endif - if this >= 0 && this <= nn - return this - endif - endif - return -1 -endf - -fun! VikiSelectThisBackRef(n) "{{{3 - return "let vbf = '". MvElementAt(b:VikiBackFile, g:vikiDefSep, a:n) ."'". - \ " | let vbl = ". MvElementAt(b:VikiBackLine, g:vikiDefSep, a:n) . - \ " | let vbc = ". MvElementAt(b:VikiBackCol, g:vikiDefSep, a:n) -endf - -fun! VikiSelectBackRef(...) "{{{3 - if exists("b:VikiBackFile") && exists("b:VikiBackLine") && exists("b:VikiBackCol") - if a:0 >= 1 && a:1 >= 0 - let s = a:1 - else - let s = VikiSelect(b:VikiBackFile, g:vikiDefSep, "Select Back Reference") - endif - if s >= 0 - return VikiSelectThisBackRef(s) - endif - endif - return "" -endf - -if g:vikiSaveHistory && exists("*GetPersistentVar") && exists("*PutPersistentVar") "{{{2 - fun! VikiGetSimplifiedBufferName() "{{{3 - return substitute( expand("%:p"), "[^a-zA-Z0-9]", "_", "g") - endf - - fun! VikiSaveBackReferences() "{{{3 - if exists("b:VikiBackFile") && b:VikiBackFile != "" - call PutPersistentVar("VikiBackFile", VikiGetSimplifiedBufferName(), b:VikiBackFile) - call PutPersistentVar("VikiBackLine", VikiGetSimplifiedBufferName(), b:VikiBackLine) - call PutPersistentVar("VikiBackCol", VikiGetSimplifiedBufferName(), b:VikiBackCol) - endif - endf - - fun! VikiRestoreBackReferences() "{{{3 - if exists("b:vikiEnabled") && !exists("b:VikiBackFile") - let b:VikiBackFile = GetPersistentVar("VikiBackFile", VikiGetSimplifiedBufferName(), "") - let b:VikiBackLine = GetPersistentVar("VikiBackLine", VikiGetSimplifiedBufferName(), "") - let b:VikiBackCol = GetPersistentVar("VikiBackCol", VikiGetSimplifiedBufferName(), "") - endif - endf - - au BufEnter * call VikiRestoreBackReferences() - au BufLeave * call VikiSaveBackReferences() -endif - -fun! VikiGoBack(...) "{{{3 - let s = (a:0 >= 1) ? a:1 : -1 - let br = VikiSelectBackRef(s) - if br == "" - echomsg "Viki: No back reference defined? (". s ."/". br .")" - else - exe br - let buf = bufnr("^". vbf ."$") - if buf >= 0 - call EditWrapper('buffer', buf) - else - call EditWrapper('edit', vbf) - endif - if vbf == expand("%:p") - call cursor(vbl, vbc) - else - throw "Viki: Couldn't open file: ". b:VikiBackFile - endif - endif -endf - -command! -narg=? VikiGoBack call VikiGoBack() - -fun! VikiSubstituteArgs(str, ...) "{{{3 - let i = 1 - " let rv = escape(a:str, '\') - let rv = a:str - while a:0 >= i - exec "let lab = a:". i - exec "let val = a:". (i+1) - let rv = substitute(rv, '\C\(^\|[^%]\)\zs%{'. lab .'}', escape(val, '\&'), "g") - " let rv = escape(rv, '\') - let i = i + 2 - endwh - let rv = substitute(rv, '%%', "%", "g") - return rv -endf - -if !exists('*VikiAnchor_l') "{{{2 - fun! VikiAnchor_l(arg) "{{{3 - if a:arg =~ '^\d\+$' - exec a:arg - endif - endf -endif - -if !exists('*VikiAnchor_line') "{{{2 - fun! VikiAnchor_line(arg) "{{{3 - call VikiAnchor_l(a:arg) - endf -endif - -if !exists('*VikiAnchor_rx') "{{{2 - fun! VikiAnchor_rx(arg) "{{{3 - let arg = escape(StripBackslash(a:arg), '/') - exec 'keepjumps norm! gg/'. arg .' ' - endf -endif - -if !exists('*VikiAnchor_vim') "{{{2 - fun! VikiAnchor_vim(arg) "{{{3 - exec StripBackslash(a:arg) - endf -endif - -fun! VikiFindAnchor(anchor) "{{{3 - if a:anchor == g:vikiDefNil || a:anchor == '' - return - endif - let mode = matchstr(a:anchor, '^\(l\(ine\)\?\|rx\|vim\)\ze=') - if exists('*VikiAnchor_'. mode) - let arg = matchstr(a:anchor, '=\zs.\+$') - call VikiAnchor_{mode}(arg) - else - let co = col('.') - let li = line('.') - let anchorRx = '\^\s\*\('. b:vikiCommentStart .'\)\?\s\*'. b:vikiAnchorMarker . a:anchor - if exists('b:vikiAnchorRx') - " !!! b:vikiAnchorRx must be a very nomagic (\V) regexp - " expression - let varx = VikiSubstituteArgs(b:vikiAnchorRx, 'ANCHOR', a:anchor) - let anchorRx = '\('.anchorRx.'\|'. varx .'\)' - endif - keepjumps norm! $ - let found = search('\V'. anchorRx, 'w') - if !found - call cursor(li, co) - if g:vikiFreeMarker - call search('\c\V'. escape(a:anchor, '\'), 'w') - endif - endif - endif -endf - -fun! VikiGetWinNr(...) "{{{3 - let winNr = a:0 >= 1 ? a:1 : 0 - if winNr == 0 - if exists('b:vikiSplit') - let winNr = b:vikiSplit - elseif exists('g:vikiSplit') - let winNr = g:vikiSplit - else - let winNr = 0 - endif - endif - return winNr -endf - -fun! VikiSetWindow(winNr) "{{{3 - let winNr = VikiGetWinNr(a:winNr) - if winNr != 0 - let wm = HowManyWindows() - if winNr == -2 - wincmd v - elseif wm == 1 || winNr == -1 - wincmd s - else - exec winNr ."wincmd w" - end - endif -endf - -" VikiOpenLink(filename, anchor, ?create=0, ?postcmd='', ?wincmd=0) -fun! VikiOpenLink(filename, anchor, ...) "{{{3 - let create = a:0 >= 1 ? a:1 : 0 - let postcmd = a:0 >= 2 ? a:2 : '' - if a:0 >= 3 - let winNr = a:3 - elseif exists('b:vikiNextWindow') - let winNr = b:vikiNextWindow - endif - - let li = line('.') - let co = col('.') - let fi = expand('%:p') - - let filename = exists('*simplify') ? simplify(a:filename) : a:filename - let buf = bufnr('^'. filename .'$') - call VikiSetWindow(winNr) - if buf >= 0 - call EditLocalFile('buffer', buf, fi, li, co, a:anchor) - elseif create && exists('b:createVikiPage') - call EditLocalFile(b:createVikiPage, filename, fi, li, co, g:vikiDefNil) - elseif exists('b:editVikiPage') - call EditLocalFile(b:editVikiPage, filename, fi, li, co, g:vikiDefNil) - elseif isdirectory(filename) - call EditLocalFile(g:vikiExplorer, filename, fi, li, co, g:vikiDefNil) - else - call EditLocalFile('edit', filename, fi, li, co, a:anchor) - endif - if postcmd != '' - exec postcmd - endif -endf - -fun! EditLocalFile(cmd, fname, fi, li, co, anchor) "{{{3 - let vf = Family() - let cb = bufnr('%') - call EditWrapper(a:cmd, a:fname) - if cb != bufnr('%') - set buflisted - endif - if vf != '' - let b:vikiFamily = vf - endif - call VikiSetBackRef(a:fi, a:li, a:co) - if !exists('b:vikiEnabled') || !b:vikiEnabled - call VikiDispatchOnFamily('VikiMinorMode', vf, 1) - endif - call VikiDispatchOnFamily('VikiFindAnchor', vf, a:anchor) -endf - -fun! Family(...) "{{{3 - let anyway = a:0 >= 1 ? a:1 : 0 - if (anyway || (exists('b:vikiEnabled') && b:vikiEnabled)) && exists('b:vikiFamily') - return b:vikiFamily - else - return g:vikiFamily - endif -endf - -fun! HowManyWindows() "{{{3 - let i = 1 - while winbufnr(i) > 0 - let i = i + 1 - endwh - return i - 1 -endf - -fun! VikiDecomposeUrl(dest) "{{{3 - let dest = substitute(a:dest, '^\c/*\([a-z]\)|', '\1:', "") - let rv = "" - let i = 0 - while 1 - let in = match(dest, '%\d\d', i) - if in >= 0 - let c = "0x".strpart(dest, in + 1, 2) - let rv = rv. strpart(dest, i, in - i) . nr2char(c) - let i = in + 3 - else - break - endif - endwh - let rv = rv. strpart(dest, i) - let uend = match(rv, '[?#]') - if uend >= 0 - let args = matchstr(rv, '?\zs.\+$', uend) - let anchor = matchstr(rv, '#\zs.\+$', uend) - let rv = strpart(rv, 0, uend) - else - let args = "" - let anchor = "" - let rv = rv - end - return "let filename='". rv ."'|let anchor='". anchor ."'|let args='". args ."'" -endf - -fun! GetSpecialFilesSuffixes() "{{{3 - if exists("b:vikiSpecialFiles") - return b:vikiSpecialFiles .'\|'. g:vikiSpecialFiles - else - return g:vikiSpecialFiles - endif -endf - -fun! VikiIsSpecialFile(dest) "{{{3 - let vikiSpecialFiles = GetSpecialFilesSuffixes() - return (a:dest =~ '\.\('. vikiSpecialFiles .'\)$' && - \ (g:vikiSpecialFilesExceptions == "" || - \ !(a:dest =~ g:vikiSpecialFilesExceptions))) -endf - -fun! VikiIsSpecialProtocol(dest) "{{{3 - return a:dest =~ '^\('.b:vikiSpecialProtocols.'\):' && - \ (b:vikiSpecialProtocolsExceptions == "" || - \ !(a:dest =~ b:vikiSpecialProtocolsExceptions)) -endf - -fun! VikiIsSpecial(dest) "{{{3 - return VikiIsSpecialProtocol(a:dest) || - \ VikiIsSpecialFile(a:dest) || - \ isdirectory(a:dest) -endf - -fun! VikiFollowLink(def, ...) "{{{3 - let winNr = a:0 >= 1 ? a:1 : 0 - exec VikiSplitDef(a:def) - if winNr == 0 && exists('v_winnr') - let winNr = v_winnr - endif - let inter = GuessInterViki(a:def) - let bn = bufnr('%') - if v_name == g:vikiSelfRef || v_dest == g:vikiSelfRef - call VikiDispatchOnFamily('VikiFindAnchor', '', v_anchor) - elseif v_dest == g:vikiDefNil - throw 'No target? '.a:def - else - let b:vikiNextWindow = winNr - try - if VikiIsSpecialProtocol(v_dest) - call VikiOpenSpecialProtocol(v_dest) - elseif VikiIsSpecialFile(v_dest) - call VikiOpenSpecialFile(v_dest) - elseif isdirectory(v_dest) - exec g:vikiExplorer .' '. v_dest - elseif filereadable(v_dest) "reference to a local, already existing file - call VikiOpenLink(v_dest, v_anchor, 0, '', winNr) - elseif bufexists(v_dest) - call EditWrapper('buffer', v_dest) - else - let ok = input("File doesn't exists. Create '".v_dest."'? (Y/n) ", "y") - if ok != "" && ok != "n" - let b:vikiCheckInexistent = line(".") - call VikiOpenLink(v_dest, v_anchor, 1, '', winNr) - endif - endif - finally - let b:vikiNextWindow = 0 - endtry - endif - if exists('b:vikiEnabled') && b:vikiEnabled && inter != '' && !exists('b:vikiInter') - let b:vikiInter = inter - endif - return "" -endf - -fun! GuessInterViki(def) "{{{3 - exec VikiSplitDef(a:def) - if v_type == 's' - let exp = v_name - elseif v_type == 'e' - let exp = v_dest - else - return '' - endif - if exp =~# s:InterVikiRx - return substitute(exp, s:InterVikiRx, '\1', '') - else - return '' - endif -endf - -fun! MakeVikiDefPart(txt) "{{{3 - if a:txt == "" - return g:vikiDefNil - else - return a:txt - endif -endf - -fun! VikiMakeDef(v_name, v_dest, v_anchor, v_part, v_type) "{{{3 - if a:v_name =~ g:vikiDefSep || a:v_dest =~ g:vikiDefSep || a:v_anchor =~ g:vikiDefSep - \ || a:v_part =~ g:vikiDefSep - throw "Viki: A viki definition must not include ".g:vikiDefSep - \ .": ".a:v_name.", ".a:v_dest.", ".a:v_anchor ." (". a:v_part .")" - else - let arr = MvAddElement("", g:vikiDefSep, MakeVikiDefPart(a:v_name)) - let arr = MvAddElement(arr, g:vikiDefSep, MakeVikiDefPart(a:v_dest)) - let arr = MvAddElement(arr, g:vikiDefSep, MakeVikiDefPart(a:v_anchor)) - let arr = MvAddElement(arr, g:vikiDefSep, MakeVikiDefPart(a:v_part)) - let arr = MvAddElement(arr, g:vikiDefSep, MakeVikiDefPart(a:v_type)) - return arr - endif -endf - -fun! VikiSplitDef(def) "{{{3 - let v_name = escape(MvElementAt(a:def, g:vikiDefSep, 0), '"\') - let v_dest = escape(MvElementAt(a:def, g:vikiDefSep, 1), '"\') - let v_anchor = escape(MvElementAt(a:def, g:vikiDefSep, 2), '"\') - let v_part = escape(MvElementAt(a:def, g:vikiDefSep, 3), '"\') - let v_type = escape(MvElementAt(a:def, g:vikiDefSep, 4), '"\') - let rv = 'let v_name="'. v_name .'"' - \ .'|let v_dest="'. v_dest .'"' - \ .'|let v_anchor="'. v_anchor .'"' - \ .'|let v_part="'. v_part .'"' - \ .'|let v_type="'. v_type .'"' - if v_type == 'e' - let mod = ExtendedModifier(v_part) - if mod =~# '*' - let rv = rv . '|let v_winnr=-1' - endif - endif - return rv -endf - -fun! GetVikiNamePart(txt, erx, idx, errorMsg) "{{{3 - if a:idx - let rv = substitute(a:txt, '^\C'. a:erx ."$", '\'.a:idx, "") - if rv == "" - return g:vikiDefNil - else - return rv - endif - else - return g:vikiDefNil - endif -endf - -fun! VikiLinkDefinition(txt, col, compound, ignoreSyntax, type) "{{{3 - exe a:compound - if erx != "" - let ebeg = -1 - let cont = match(a:txt, erx, 0) - while (ebeg >= 0 || (0 <= cont) && (cont <= a:col)) - let contn = matchend(a:txt, erx, cont) - if (cont <= a:col) && (a:col < contn) - let ebeg = match(a:txt, erx, cont) - let elen = contn - ebeg - break - else - let cont = match(a:txt, erx, contn) - endif - endwh - if ebeg >= 0 - let part = strpart(a:txt, ebeg, elen) - let name = GetVikiNamePart(part, erx, nameIdx, "no name") - let dest = GetVikiNamePart(part, erx, destIdx, "no destination") - let anchor = GetVikiNamePart(part, erx, anchorIdx, "no anchor") - return VikiMakeDef(name, dest, anchor, part, a:type) - elseif a:ignoreSyntax - return "" - else - throw "Viki: Malformed viki v_name: " . a:txt . " (". erx .")" - endif - else - return "" - endif -endf - -fun! VikiGetSuffix() "{{{3 - if exists("b:vikiNameSuffix") - return b:vikiNameSuffix - endif - if g:vikiUseParentSuffix - let sfx = expand("%:e") - if sfx != "" - return ".".sfx - endif - endif - return g:vikiNameSuffix -endf - -fun! VikiExpandSimpleName(dest, name, suffix) "{{{3 - if a:name == '' - return a:dest - else - return a:dest . g:vikiDirSeparator . a:name . - \ (a:suffix == g:vikiDefSep ? VikiGetSuffix() : a:suffix) - endif -endf - -fun! VikiCompleteSimpleNameDef(def) "{{{3 - exec VikiSplitDef(a:def) - if v_name == g:vikiDefNil - throw "Viki: Malformed simple viki name (no name): ".a:def - endif - - if !(v_dest == g:vikiDefNil) - throw "Viki: Malformed simple viki name (destination=".v_dest."): ". a:def - endif - - let useSuffix = g:vikiDefSep - if IsSupportedType("i") && v_name =~# s:InterVikiRx - let ow = substitute(v_name, s:InterVikiRx, '\1', "") - let vd = VikiLetVar("v_dest", "vikiInter".ow) - if vd != '' - exec vd - let v_dest = expand(v_dest) - let v_name = substitute(v_name, s:InterVikiRx, '\2', "") - exec VikiLetVar("useSuffix", "vikiInter".ow."_suffix") - else - " throw "Viki: InterViki is not defined: ".ow - echoerr "Viki: InterViki is not defined: ".ow - endif - else - let v_dest = expand("%:p:h") - endif - - if IsSupportedType("S") - if v_name =~ b:vikiQuotedSelfRef - let v_name = g:vikiSelfRef - elseif v_name =~ b:vikiQuotedRef - let v_name = matchstr(v_name, "^". b:vikiSimpleNameQuoteBeg .'\zs.\+\ze'. b:vikiSimpleNameQuoteEnd ."$") - endif - elseif !IsSupportedType("c") - throw "Viki: CamelCase names not allowed" - endif - - if v_name != g:vikiSelfRef - let rdest = VikiExpandSimpleName(v_dest, v_name, useSuffix) - else - let rdest = g:vikiDefNil - endif - let v_type = v_type == g:vikiDefNil ? 's' : v_type - return VikiMakeDef(v_name, rdest, v_anchor, v_part, v_type) -endf - -fun! ExtendedModifier(part) - let mod = substitute(a:part, b:vikiExtendedNameRx, '\'.b:vikiExtendedNameModIdx, '') - if mod != a:part - return mod - else - return '' - endif -endf - -fun! VikiCompleteExtendedNameDef(def) "{{{3 - exec VikiSplitDef(a:def) - if v_dest == g:vikiDefNil - if v_anchor == g:vikiDefNil - throw "Viki: Malformed extended viki name (no destination): ".a:def - else - let v_dest = g:vikiSelfRef - endif - elseif IsSupportedType("i") && v_dest =~? '^['. UpperCharacters() .']\+::' " an Interviki name - let ow = substitute(v_dest, s:InterVikiRx, '\1', "") - exec VikiLetVar("idest", "vikiInter".ow) - if exists("idest") - let idest = expand(idest) - let v_dest = substitute(v_dest, s:InterVikiRx, '\2', "") - exec VikiLetVar("useSuffix", "vikiInter".ow."_suffix") - let v_dest = VikiExpandSimpleName(idest, v_dest, useSuffix) - else - " throw "Viki: InterViki is not defined: ".ow - echom "Viki: InterViki is not defined: ".ow - endif - else - if v_dest =~? '^[a-z]:' " an absolute dos path - elseif v_dest =~? '^\/' " an absolute unix path - elseif v_dest =~? '^'.b:vikiSpecialProtocols.':' " some protocol - elseif v_dest =~ '^\~' " user home - " let v_dest = $HOME . strpart(v_dest, 1) - let v_dest = fnamemodify(v_dest, ':p') - let v_dest = CanonicFilename(v_dest) - else " a relative path - let v_dest = expand("%:p:h") .g:vikiDirSeparator. v_dest - let v_dest = CanonicFilename(v_dest) - endif - " if v_dest != '' && v_dest != g:vikiSelfRef && fnamemodify(v_dest, ":p:h") == expand("%:p:h") - if v_dest != '' && v_dest != g:vikiSelfRef && !VikiIsSpecial(v_dest) - let mod = ExtendedModifier(v_part) - if fnamemodify(v_dest, ':e') == '' && mod !~# '!' - let v_dest = v_dest.VikiGetSuffix() - endif - endif - endif - if v_name == g:vikiDefNil - let v_name = fnamemodify(v_dest, ':t:r') - endif - let v_type = v_type == g:vikiDefNil ? 'e' : v_type - return VikiMakeDef(v_name, v_dest, v_anchor, v_part, v_type) -endf - -fun! FindFileWithSuffix(filename, suffixes) "{{{3 - if filereadable(a:filename) - return a:filename - else - let suffixes = a:suffixes - while 1 - let elt = MvElementAt(suffixes, '\\|', 0) - if elt != "" - let fn = a:filename .".". elt - if filereadable(fn) - return fn - else - let suffixes = MvRemoveElement(suffixes, '\\|', elt) - endif - else - return g:vikiDefNil - endif - endwh - endif - return g:vikiDefNil -endf - -fun! VikiCompleteCmdDef(def) "{{{3 - exec VikiSplitDef(a:def) - let args = v_anchor - let v_anchor = g:vikiDefNil - if v_name ==# "#IMG" || v_name =~# "{img" - let vikiSpecialFiles = GetSpecialFilesSuffixes() - let v_dest = FindFileWithSuffix(v_dest, vikiSpecialFiles) - elseif v_name ==# "#Img" - let id = matchstr(args, '\sid=\zs\w\+') - if id != "" - let vikiSpecialFiles = GetSpecialFilesSuffixes() - let v_dest = FindFileWithSuffix(id, vikiSpecialFiles) - endif - elseif v_name =~ "^#INC" - " <+TBD+> Search path? - else - " throw "Viki: Unknown command: ". v_name - let v_name = g:vikiDefNil - let v_dest = g:vikiDefNil - " let v_anchor = g:vikiDefNil - endif - let v_type = v_type == g:vikiDefNil ? 'cmd' : v_type - return VikiMakeDef(v_name, v_dest, v_anchor, v_part, v_type) -endf - -fun! VikiLinkNotFoundEtc(oldmap, ignoreSyntax) "{{{3 - if a:oldmap == "" - echomsg "Viki: Show me the way to the next viki name or I have to ... ".a:ignoreSyntax.":".getline(".") - elseif a:oldmap == 1 - return "\" - else - return a:oldmap - endif -endf - -" VikiGetLink(oldmap, ignoreSyntax, ?txt, ?col=0, ?supported=b:vikiNameTypes) -fun! VikiGetLink(oldmap, ignoreSyntax, ...) "{{{3 - let col = a:0 >= 2 ? a:2 : 0 - let types = a:0 >= 3 ? a:3 : b:vikiNameTypes - if a:0 >= 1 && a:1 != '' - let txt = a:1 - let vikiType = a:ignoreSyntax - let tryAll = 1 - else - let synName = synIDattr(synID(line('.'), col('.'), 0), 'name') - if synName ==# 'vikiLink' - let vikiType = 1 - let tryAll = 0 - elseif synName ==# 'vikiExtendedLink' - let vikiType = 2 - let tryAll = 0 - elseif synName ==# 'vikiURL' - let vikiType = 3 - let tryAll = 0 - elseif synName ==# 'vikiCommand' || synName ==# 'vikiMacro' - let vikiType = 4 - let tryAll = 0 - elseif a:ignoreSyntax - let vikiType = a:ignoreSyntax - let tryAll = 1 - else - return '' - endif - let txt = getline('.') - let col = col('.') - 1 - endif - if (tryAll || vikiType == 1) && IsSupportedType('s', types) - if exists('b:getVikiLink') - exe 'let def = ' . b:getVikiLink.'()' - else - let def = VikiLinkDefinition(txt, col, b:vikiSimpleNameCompound, a:ignoreSyntax, 's') - endif - if def != '' - return VikiDispatchOnFamily('VikiCompleteSimpleNameDef', '', def) - endif - endif - if (tryAll || vikiType == 2) && IsSupportedType('e', types) - if exists('b:getExtVikiLink') - exe 'let def = ' . b:getExtVikiLink.'()' - else - let def = VikiLinkDefinition(txt, col, b:vikiExtendedNameCompound, a:ignoreSyntax, 'e') - endif - if def != '' - return VikiDispatchOnFamily('VikiCompleteExtendedNameDef', '', def) - endif - endif - if (tryAll || vikiType == 3) && IsSupportedType('u', types) - if exists('b:getURLViki') - exe 'let def = ' . b:getURLViki . '()' - else - let def = VikiLinkDefinition(txt, col, b:vikiUrlCompound, a:ignoreSyntax, 'u') - endif - if def != '' - return VikiDispatchOnFamily('VikiCompleteExtendedNameDef', '', def) - endif - endif - if (tryAll || vikiType == 4) && IsSupportedType('x', types) - if exists('b:getCmdViki') - exe 'let def = ' . b:getCmdViki . '()' - else - let def = VikiLinkDefinition(txt, col, b:vikiCmdCompound, a:ignoreSyntax, 'x') - endif - if def != '' - return VikiDispatchOnFamily('VikiCompleteCmdDef', '', def) - endif - endif - return '' -endf - -" VikiMaybeFollowLink(oldmap, ignoreSyntax, ?winNr=0) -fun! VikiMaybeFollowLink(oldmap, ignoreSyntax, ...) "{{{3 - let winNr = a:0 >= 1 ? a:1 : 0 - let def = VikiGetLink(a:oldmap, a:ignoreSyntax) - if def != '' - return VikiFollowLink(def, winNr) - else - return VikiLinkNotFoundEtc(a:oldmap, a:ignoreSyntax) - endif -endf -command! VikiJump call VikiMaybeFollowLink(0,1) - -" VikiEdit(name, ?bang='', ?winNr=0) -fun! VikiEdit(name, ...) "{{{3 - let bang = a:0 >= 1 ? a:1 : '' - let winNr = a:0 >= 2 ? a:2 : 0 - if exists('b:vikiEnabled') && bang != '' && - \ (!exists('b:vikiFamily') || b:vikiFamily != '') - if g:vikiHomePage != '' - call VikiOpenLink(g:vikiHomePage, '', '', '', winNr) - else - call EditWrapper('buffer', 1) - endif - endif - if a:name == '*' - let name = g:vikiHomePage - else - let name = a:name - end - let name = substitute(name, '[\\]', '/', 'g') - if !exists('b:vikiNameTypes') - call VikiSetBufferVar('vikiNameTypes') - call VikiDispatchOnFamily('VikiSetupBuffer', '', 0) - endif - let def = VikiGetLink('', 1, '[['. name .']]', 0, '') - if def != '' - exec VikiSplitDef(def) - call VikiOpenLink(v_dest, '', '', '', winNr) - else - call VikiLinkNotFoundEtc('', 1) - endif -endf - -fun! VikiEditCompleteAgent(interviki, afname, fname) "{{{3 - if isdirectory(a:afname) - return '' - else - if exists('g:vikiInter'. a:interviki .'_suffix') - let sfx = g:vikiInter{a:interviki}_suffix - else - let sfx = VikiGetSuffix() - endif - if sfx != '' && sfx == '.'. fnamemodify(a:fname, ':e') - let name = fnamemodify(a:fname, ':t:r') - else - let name = a:fname - endif - if name !~ '\C'. VikiGetSimpleRx4SimpleWikiName() - let name = '[-'. a:fname .'-]' - endif - if a:interviki != '' - let name = a:interviki .'::'. name - endif - return name - endif -endf - -fun! VikiEditComplete(ArgLead, CmdLine, CursorPos) "{{{3 - let i = matchstr(a:ArgLead, '^\zs.\{-}\ze::') - if exists('g:vikiInter'. i .'_suffix') - let sfx = g:vikiInter{i}_suffix - else - let sfx = VikiGetSuffix() - endif - if i != '' && exists('g:vikiInter'. i) - let d = substitute(g:vikiInter{i}, '\', '/', 'g') - let f = matchstr(a:ArgLead, '::\(\[-\)\?\zs.*$') - let rv = glob(d .'/'. f .'*'.sfx) - let rv = substitute(rv."\n", '\V\('.escape(d, '\').'/\(\[^\n]\{-}\)\)'.sfx.'\ze\n', "\\=VikiEditCompleteAgent('".i."', submatch(1), submatch(2))", 'g') - else - let rv = glob('*'.sfx) - let rv = substitute(rv."\n", '\V\n\?\zs\(\[^\n]\{-}\)\ze\n', "\\=VikiEditCompleteAgent('".i."', submatch(1), submatch(1))", 'g') - " let rv = s:InterVikis."\n".rv - let rv = rv."\n".s:InterVikis - endif - let rv = substitute(rv, '\n\n\+', '\n', 'g') - return rv -endf - -fun! VikiIndex() "{{{3 - if exists('b:vikiIndex') - let fname = b:vikiIndex . VikiGetSuffix() - else - let fname = g:vikiIndex . VikiGetSuffix() - endif - if filereadable(fname) - return VikiOpenLink(fname, '') - else - echom "Index page not found: ". fname - endif -endf - -command! VikiIndex :call VikiIndex() - -command! -nargs=1 -bang -complete=custom,VikiEditComplete VikiEdit :call VikiEdit(, "") -command! -nargs=1 -bang -complete=custom,VikiEditComplete VikiEditInWin1 :call VikiEdit(, "", 1) -command! -nargs=1 -bang -complete=custom,VikiEditComplete VikiEditInWin2 :call VikiEdit(, "", 2) -command! -nargs=1 -bang -complete=custom,VikiEditComplete VikiEditInWin3 :call VikiEdit(, "", 3) -command! -nargs=1 -bang -complete=custom,VikiEditComplete VikiEditInWin4 :call VikiEdit(, "", 4) - -command! VikiHome :call VikiEdit('*', '!') - -finish "{{{1 -_____________________________________________________________________________________ - -* Change Log -1.0 -- Extended names: For compatibility reasons with other wikis, the anchor is -now in the reference part. -- For compatibility reasons with other wikis, prepending an anchor with -b:commentStart is optional. -- g:vikiUseParentSuffix -- Renamed variables & functions (basically s/Wiki/Viki/g) -- added a ftplugin stub, moved the description to a help file -- "[--]" is reference to current file -- Folding support (at section level) -- Intervikis -- More highlighting -- g:vikiFamily, b:vikiFamily -- VikiGoBack() (persistent history data) -- rudimentary LaTeX support ("soft" viki names) - -1.1 -- g:vikiExplorer (for viewing directories) -- preliminary support for "soft" anchors (b:vikiAnchorRx) -- improved VikiOpenSpecialProtocol(url); g:vikiOpenUrlWith_{PROTOCOL}, -g:vikiOpenUrlWith_ANY -- improved VikiOpenSpecialFile(file); g:vikiOpenFileWith_{SUFFIX}, -g:vikiOpenFileWith_ANY -- anchors may contain upper characters (but must begin with a lower char) -- some support for Mozilla ThunderBird mailbox-URLs (this requires spaces to -be encoded as %20) -- changed g:vikiDefSep to '???' - -1.2 -- syntax file: fix nested regexp problem -- deplate: conversion to html/latex; download from -http://sourceforge.net/projects/deplate/ -- made syntax a little bit more restrictive (*WORD* now matches /\*\w+\*/ -instead of /\*\S+\*/) -- interviki definitions can now be buffer local variables, too -- fixed DecodeFileUrl(dest) -- some kind of compiler plugin (uses deplate) -- removed g/b:vikiMarkupEndsWithNewline variable -- saved all files in unix format (thanks to Grant Bowman for the hint) -- removed international characters from g:vikiLowerCharacters and -g:vikiUpperCharacters because of difficulties with different encodings (thanks -to Grant Bowman for pointing out this problem); non-english-speaking users have -to set these variables in their vimrc file - -1.3 -- basic ctags support (see |viki-tags|) -- mini-ftplugin for bibtex files (use record labels as anchors) -- added mapping : follow link in other window (if any) -- disabled the highlighting of italic char styles (i.e., /text/) -- the ftplugin doesn't set deplate as the compiler; renamed the compiler plugin to deplate -- syntax: sync minlines=50 -- fix: VikiFoldLevel() - -1.3.1 -- fixed bug when VikiBack was called without a definitiv back-reference -- fixed problems with latin-1 characters - -1.4 -- fixed problem with table highlighting that could cause vim to hang -- it is now possible to selectivly disable simple or quoted viki names -- indent plugin - -1.5 -- distinguish between links to existing and non-existing files -- added key bindings vs (split) and vv (split vertically) -- added key bindings v1 through to v4: open the viki link under cursor -in the windows 1 to 4 -- handle variables g:vikiSplit, b:vikiSplit -- don't indent regions -- regions can be indented -- When a file doesn't exist, ESC or "n" aborts creation - -1.5.1 -- depends on multvals >= 3.8.0 -- new viki family "AnyWord" (see |viki-any-word|), which turns any word into a -potential viki link -- vq, VikiQuote: mark selected text as a quoted viki name -(requires imaps.vim, vimscript #244 or vimscript #475) -- check for null links when pressing , , ], and some other keys -(defined in g:vikiMapKeys) -- a global suffix for viki files can be defined by g:vikiNameSuffix -- fix syntax problem when checking for links to inexistent files - -1.5.2 -- changed default markup of textstyles: __emphasize__, ''code''; the -previous markup can be re-enabled by setting g:vikiTextstylesVer to 1) -- fixed problem with VikiQuote -- on follow link check for yet unsaved buffers too - -1.6 -- b:vikiInverseFold: Inverse folding of subsections -- support for some regions/commands/macros: #INC/#INCLUDE, #IMG, #Img -(requires an id to be defined), {img} -- g:vikiFreeMarker: Search for the plain anchor text if no explicitly marked -anchor could be found. -- new command: VikiEdit NAME ... allows editing of arbitrary viki names (also -understands extended and interviki formats) -- setting the b:vikiNoSimpleNames to true prevents viki from recognizing -simple viki names -- made some script local functions global so that it should be easier to -integrate viki with other plugins -- fixed moving cursor on VikiMarkInexistent() -- fixed typo in b:VikiEnabled, which should be b:vikiEnabled (thanks to Ned -Konz) - -1.6.1 -- removed forgotten debug message -- fixed indentation bug - -1.6.2 -- b:vikiDisableType -- Put AnyWord-related stuff into a file of its own. -- indentation for notices (!!!, ??? etc.) - -1.6.3 -- When creating a new file by following a link, the desired window number was -ignored -- (VikiOpenSpecialFile) Escape blanks in the filename -- Set &include and &define (ftplugin) -- Set g:vikiFolds to '' to avoid using Headings for folds (which may cause a -major slowdown on slower machines) -- renamed DecodeFileUrl(dest) to VikiDecomposeUrl() -- fixed problem with table highlighting -- file type URLs (file://) are now treated like special files -- indent: if g:vikiIndentDesc is '::', align a definition's description to the -first non-blank position after the '::' separator - -1.7 -- g:vikiHomePage: If you call VikiEdit! (with "bang"), the homepage is opened -first so that its customizations are in effect. Also, if you call :VikiHome or -:VikiEdit *, the homepage is opened. -- basic highlighting & indentation of emacs-planner style task lists (sort of) -- command line completion for :VikiEdit -- new command/function VikiDefine for defining intervikis -- added ve map for :VikiEdit -- fixed problem in VikiEdit (when the cursor was on a valid viki link, the -text argument was ignored) -- fixed opening special files/urls in a designated window -- fixed highlighting of comments -- vikiLowerCharacters and vikiUpperCharacters can be buffer local -- fixed problem when an url contained an ampersand -- fixed error message when the &hidden option wasn't set (see g:vikiHide) - -1.8 -- Fold lists too (see also g:vikiFolds) -- Allow interviki names in extended viki names (e.g., -[[WIKI::WikiName][Display Name]]) -- Renamed GetSimpleRx4SimpleWikiName() to -VikiGetSimpleRx4SimpleWikiName() (required in some occasions; increased the -version number so that we can check against it) -- Fix: Problem with urls/fnames containing '!' and other special characters -(which now have to be escaped by the handler; so if you defined a custom -handler, e.g. g:vikiOpenFileWith_ANY, please adapt its definition) -- Fix: VikiEdit! opens the homepage only when b:vikiEnabled is defined in the -current buffer (we assume that for the homepage the global configuration is in -effect) -- Fix: Problem when g:vikiMarkInexistent was false/0 -- Fix: Removed \c from the regular expression for extended names, which caused -FindNext to malfunction and caused a serious slowdown when matching of -bad/unknown links -- Fix: Re-set viki minor mode after entering a buffer -- The state argument in Viki(Minor)Mode is now mostly ignored -- Fix: A simple name's anchor was ignored - -1.9 -- Register mp3, ogg and some other multimedia related suffixes as -special files -- Add a menu of Intervikis if g:vikiMenuPrefix is != '' -- g:vikiMapKeys can contain "\n" and " " (supplement g:vikiMapKeys with -the variables g:vikiMapQParaKeys and g:vikiMapBeforeKeys) -- FIX: IsSupportedType -- FIX: Only the first inexistent link in a line was highlighted -- FIX: Set &buflisted when editing an existing buffer -- FIX: VikiDefine: Non-viki index names weren't quoted -- FIX: In "minor mode", vikiFamily wasn't correctly set in some -situations; other problems related to b:vikiFamily -- FIX: AnyWord works again -- Removed: VikiMinorModeMaybe -- VikiDefine now takes an optional fourth argument (an index file; -default=Index) and automatically creates a vim command with the name of -the interviki that opens this index file - -1.10 -- Pseudo anchors (not supported by deplate): --- Jump to a line number, e.g. [[file#l=10]] or [[file#line=10]] --- Find an regexp, e.g. [[file#rx=\\d]] --- Execute some vim code, e.g. [[file#vim=call Whatever()]] --- You can define your own handlers: VikiAnchor_{type}(arg) -- g:vikiFolds: new 'b' flag: the body has a higher level than all -headings (gives you some kind of outliner experience; the default value -for g:vikiFolds was changed to 'h') -- FIX: VikiFindAnchor didn't work properly in some situations -- FIX: Escape blanks when following a link (this could cause problems in -some situations, not always) -- FIX: Don't try to mark inexistent links when pressing enter if the current -line is empty. -- FIX: Restore vertical cursor position in window after looking for -inexistent links. -- FIX: Backslashes got lost in some situations. - -1.11 -- Enable [[INTERVIKI::]] -- VikiEdit also creates commands for intervikis that have no index -- Respect "!" and "*" modifiers in extended viki links -- New g:vikiMapFunctionalityMinor variable -- New g:vikiMapLeader variable -- CHANGE: Don't map VikiMarkInexistent in minor mode (see -g:vikiMapFunctionalityMinor) -- CHANGE: new attributes for g:vikiMapFunctionality: c, m[fb], i, I -- SYNTAX: cterm support for todo lists, emphasize -- FIX: Erroneous cursor movement -- FIX: VikiEdit didn't check if a file was already opened, which caused -a file to be opened in two buffers under certain conditions -- FIX: Error in MapMarkInexistent() -- FIX: VikiEdit: Non-viki names were not quoted -- FIX: Use fnamemodify() to expand tildes in filenames -- FIX: Inexistent quoted viki names with an interviki prefix weren't -properly highlighted -- FIX: Minor problem with suffixes & extended viki names -- FIX: Use keepjumps -- FIX: Catch E325 -- FIX: Don't catch errors in EditWrapper() if the command matches -g:vikiNoWrapper (due to possible compatibility problems eg with :Explore -in vim 6.4) -- OBSOLETE: Negative arguments to VikiMode or VikiMinorMode are obsolete -(or they became the default to be precise) -- OBSOLETE: g:vikiMapMouse -- REMOVED: mapping to -- DEPRECATED: VikiModeMaybe - -" vim: ff=unix +" Viki.vim -- Some kind of personal wiki for Vim +" @Author: Thomas Link (micathom AT gmail com?subject=vim) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 08-Dec-2003. +" @Last Change: 2008-06-22. +" @Revision: 3.7.2563 +" +" GetLatestVimScripts: 861 1 viki.vim +" +" Short Description: +" This plugin adds wiki-like hypertext capabilities to any document. Just +" type :VikiMinorMode and all wiki names will be highlighted. If you press +" (or vf) when the cursor is over a wiki name, you +" jump to (or create) the referred page. When invoked via :set ft=viki, +" additional highlighting is provided. +" +" Requirements: +" - tlib.vim (vimscript #1863) +" +" Optional Enhancements: +" - imaps.vim (vimscript #244 or #475 for |:VimQuote|) +" - kpsewhich (not a vim plugin :-) for vikiLaTeX +" +" TODO: +" - File names containing # (the # is interpreted as URL component) +" - Per Interviki simple name patterns +" - Allow Wiki links like ::Word or even ::word (not in minor mode due +" possible conflict with various programming languages?) +" - :VikiRename command: rename links/files (requires a cross-plattform grep +" or similar; or one could a global register) +" - don't know how to deal with viki names that span several lines (e.g. in +" LaTeX mode) + +if &cp || exists("loaded_viki") "{{{2 + finish +endif +if !exists('g:loaded_tlib') || g:loaded_tlib < 15 + runtime plugin/02tlib.vim + if !exists('g:loaded_tlib') || g:loaded_tlib < 15 + echoerr 'tlib >= 0.15 is required' + finish + endif +endif +let loaded_viki = 308 + +" This is what we consider nil, in the absence of nil in vimscript +let g:vikiDefNil = '' + +" In a previous version this was used as list separator and as nil too +let g:vikiDefSep = "\n" + +" let s:vikiSelfEsc = '\' + +" In extended viki links this is considered as a reference to the current +" document. This is likely to go away. +let g:vikiSelfRef = '.' + +" let s:vikiEnabledID = loaded_viki .'_'. strftime('%c') + + +" Configuration {{{1 +" If zero, viki is disabled, though the code is loaded. +if !exists("g:vikiEnabled") "{{{2 + let g:vikiEnabled = 1 +endif + +" Support for the taglist plugin. +if !exists("tlist_viki_settings") "{{{2 + let tlist_viki_settings="deplate;s:structure" +endif + +" A simple viki name is made from a series of upper and lower characters +" (i.e. CamelCase-names). These two variables define what is considered as +" upper and lower-case characters. We don't rely on the builtin +" functionality for this. +if !exists("g:vikiUpperCharacters") "{{{2 + let g:vikiUpperCharacters = "A-Z" +endif +if !exists("g:vikiLowerCharacters") "{{{2 + let g:vikiLowerCharacters = "a-z" +endif + +" The prefix for the menu of intervikis. Set to '' in order to remove the +" menu. +if !exists("g:vikiMenuPrefix") "{{{2 + let g:vikiMenuPrefix = "Plugin.Viki." +endif + +" Make submenus for N letters of the interviki names. +if !exists('g:vikiMenuLevel') + let g:vikiMenuLevel = 1 "{{{2 +endif + +" URLs matching these protocols are handled by VikiOpenSpecialProtocol() +if !exists("g:vikiSpecialProtocols") "{{{2 + let g:vikiSpecialProtocols = 'https\?\|ftps\?\|nntp\|mailto\|mailbox\|file' +endif + +" Exceptions from g:vikiSpecialProtocols +if !exists("g:vikiSpecialProtocolsExceptions") "{{{2 + let g:vikiSpecialProtocolsExceptions = "" +endif + +" Files matching these suffixes are handled by viki#OpenSpecialFile() +if !exists("g:vikiSpecialFiles") "{{{2 + let g:vikiSpecialFiles = [ + \ 'aac', + \ 'aif', + \ 'aiff', + \ 'au', + \ 'avi', + \ 'bmp', + \ 'dia', + \ 'doc', + \ 'dvi', + \ 'eps', + \ 'eps', + \ 'gif', + \ 'htm', + \ 'html', + \ 'jpeg', + \ 'jpg', + \ 'm3u', + \ 'mp1', + \ 'mp2', + \ 'mp3', + \ 'mp4', + \ 'mpeg', + \ 'mpg', + \ 'odg', + \ 'ods', + \ 'odt', + \ 'ogg', + \ 'pdf', + \ 'png', + \ 'ppt', + \ 'ps', + \ 'rtf', + \ 'voc', + \ 'wav', + \ 'wma', + \ 'wmf', + \ 'wmv', + \ 'xhtml', + \ 'xls', + \ ] +endif + +" Exceptions from g:vikiSpecialFiles +if !exists("g:vikiSpecialFilesExceptions") "{{{2 + let g:vikiSpecialFilesExceptions = "" +endif + +if !exists('g:viki_highlight_hyperlink_light') "{{{2 + " let g:viki_highlight_hyperlink_light = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=DarkBlue guifg=DarkBlue' + let g:viki_highlight_hyperlink_light = 'term=underline cterm=underline gui=underline ctermfg=DarkBlue guifg=DarkBlue' +endif +if !exists('g:viki_highlight_hyperlink_dark') "{{{2 + " let g:viki_highlight_hyperlink_dark = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=DarkBlue guifg=LightBlue' + let g:viki_highlight_hyperlink_dark = 'term=underline cterm=underline gui=underline ctermfg=LightBlue guifg=#bfbfff' +endif + +if !exists('g:viki_highlight_inexistent_light') "{{{2 + " let g:viki_highlight_inexistent_light = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=DarkRed guifg=DarkRed' + let g:viki_highlight_inexistent_light = 'term=underline cterm=underline gui=underline ctermfg=DarkRed guifg=DarkRed' +endif +if !exists('g:viki_highlight_inexistent_dark') "{{{2 + " let g:viki_highlight_inexistent_dark = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=Red guifg=Red' + let g:viki_highlight_inexistent_dark = 'term=underline cterm=underline gui=underline ctermfg=Red guifg=Red' +endif + +" If set to true, any files loaded by viki will become viki enabled (in +" minor mode); this was the default behaviour in earlier versions +if !exists('g:vikiPromote') "{{{2 + let g:vikiPromote = 0 +endif + +" If non-nil, use the parent document's suffix. +if !exists("g:vikiUseParentSuffix") | let g:vikiUseParentSuffix = 0 | endif "{{{2 + +" Default file suffix. +if !exists("g:vikiNameSuffix") | let g:vikiNameSuffix = "" | endif "{{{2 + +" Prefix for anchors +if !exists("g:vikiAnchorMarker") | let g:vikiAnchorMarker = "#" | endif "{{{2 + +" If non-nil, search anchors anywhere in the text too (without special +" markup) +if !exists("g:vikiFreeMarker") | let g:vikiFreeMarker = 0 | endif "{{{2 + +if !exists('g:vikiPostFindAnchor') "{{{2 + let g:vikiPostFindAnchor = 'norm! zz' +endif + +" List of enabled viki name types +" c ... Camel case +" s ... Simple names +" S ... Quoted simple names +" e ... Extended names +" u ... URLs +" i ... Intervikis +" x ... Commands +" w ... "hyperwords" +" f ... Filenames as "hyperwords" +if !exists("g:vikiNameTypes") | let g:vikiNameTypes = "csSeuixwf" | endif "{{{2 + +" Which directory explorer to use to edit directories +if !exists("g:vikiExplorer") | let g:vikiExplorer = "Sexplore" | endif "{{{2 +" if !exists("g:vikiExplorer") | let g:vikiExplorer = "split" | endif "{{{2 +" if !exists("g:vikiExplorer") | let g:vikiExplorer = "edit" | endif "{{{2 +" +" If hide or update: use the respective command when leaving a buffer +if !exists("g:vikiHide") | let g:vikiHide = '' | endif "{{{2 + +" Don't use g:vikiHide for commands matching this rx +if !exists("g:vikiNoWrapper") | let g:vikiNoWrapper = '\cexplore' | endif "{{{2 + +" Cache information about a document's inexistent names +if !exists("g:vikiCacheInexistent") | let g:vikiCacheInexistent = 0 | endif "{{{2 + +" Mark up inexistent names. +if !exists("g:vikiMarkInexistent") | let g:vikiMarkInexistent = 1 | endif "{{{2 + +" If non-nil, map keys that trigger the evaluation of inexistent names +if !exists("g:vikiMapInexistent") | let g:vikiMapInexistent = 1 | endif "{{{2 + +" Map these keys for g:vikiMapInexistent to LineQuick +if !exists("g:vikiMapKeys") | let g:vikiMapKeys = "]).,;:!?\"' " | endif "{{{2 + +" Map these keys for g:vikiMapInexistent to ParagraphVisible +if !exists("g:vikiMapQParaKeys") | let g:vikiMapQParaKeys = "\n" | endif "{{{2 + +" Install hooks for these conditions (requires hookcursormoved to be +" installed) +" "linechange" could cause some slowdown. +if !exists("g:vikiHCM") "{{{2 + let g:vikiHCM = ['syntaxleave_oneline'] +endif + +" Check the viki name before inserting this character +if !exists("g:vikiMapBeforeKeys") | let g:vikiMapBeforeKeys = ']' | endif "{{{2 + +" Some functions a gathered in families/classes. See vikiLatex.vim for +" an example. +if !exists("g:vikiFamily") | let g:vikiFamily = "" | endif "{{{2 + +" The directory separator +if !exists("g:vikiDirSeparator") | let g:vikiDirSeparator = "/" | endif "{{{2 + +" The version of Deplate markup +if !exists("g:vikiTextstylesVer") | let g:vikiTextstylesVer = 2 | endif "{{{2 + +" if !exists("g:vikiBasicSyntax") | let g:vikiBasicSyntax = 0 | endif "{{{2 +" If non-nil, display headings of different levels in different colors +if !exists("g:vikiFancyHeadings") | let g:vikiFancyHeadings = 0 | endif "{{{2 + +" Choose folding method version +if !exists("g:vikiFoldMethodVersion") | let g:vikiFoldMethodVersion = 4 | endif "{{{2 + +" What is considered for folding. +" This variable is only used if g:vikiFoldMethodVersion is 1. +if !exists("g:vikiFolds") | let g:vikiFolds = 'hf' | endif "{{{2 + +" Context lines for folds +if !exists("g:vikiFoldsContext") "{{{2 + let g:vikiFoldsContext = [2, 2, 2, 2] +endif + +" Consider fold levels bigger that this as text body, levels smaller +" than this as headings +" This variable is only used if g:vikiFoldMethodVersion is 1. +if !exists("g:vikiFoldBodyLevel") | let g:vikiFoldBodyLevel = 6 | endif "{{{2 + +" The default viki page (as absolute filename) +if !exists("g:vikiHomePage") | let g:vikiHomePage = '' | endif "{{{2 + +" The default filename for an interviki's index name +if !exists("g:vikiIndex") | let g:vikiIndex = 'index' | endif "{{{2 + +" How often the feedback is changed when marking inexisting links +if !exists("g:vikiFeedbackMin") | let g:vikiFeedbackMin = &lines | endif "{{{2 + +" The map leader for most viki key maps. +if !exists("g:vikiMapLeader") | let g:vikiMapLeader = 'v' | endif "{{{2 + +" If non-nil, anchors like #mX are turned into vim marks +if !exists("g:vikiAutoMarks") | let g:vikiAutoMarks = 1 | endif "{{{2 + +" if !exists("g:vikiOpenInWindow") | let g:vikiOpenInWindow = '' | endif "{{{2 +if !exists("g:vikiHighlightMath") | let g:vikiHighlightMath = '' | endif "{{{2 + +" If non-nil, cache back-links information +if !exists("g:vikiSaveHistory") | let g:vikiSaveHistory = 0 | endif "{{{2 + +" The variable that keeps back-links information +if !exists("g:VIKIBACKREFS") | let g:VIKIBACKREFS = {} | endif "{{{2 + +" A list of files that contain special viki names +if v:version >= 700 && !exists("g:vikiHyperWordsFiles") "{{{2 + let g:vikiHyperWordsFiles = [ + \ get(split(&rtp, ','), 0).'/vikiWords.txt', + \ './.vikiWords', + \ ] +endif + +" Definition of intervikis. (This variable won't be evaluated until +" autoload/viki.vim is loaded). +if !exists('g:viki_intervikis') + let g:viki_intervikis = {} "{{{2 +endif + +" Define which keys to map +if !exists("g:vikiMapFunctionality") "{{{2 + " b ... go back + " c ... follow link (c-cr) + " e ... edit + " F ... find + " f ... follow link (v) + " i ... check for inexistant destinations + " I ... map keys in g:vikiMapKeys and g:vikiMapQParaKeys + " m[fb] ... map mouse (depends on f or b) + " p ... edit parent (or backlink) + " q ... quote + " tF ... tab as find + " Files ... #Files related + " let g:vikiMapFunctionality = 'mf mb tF c q e i I Files' + let g:vikiMapFunctionality = 'ALL' +endif +" Define which keys to map in minor mode (invoked via :VikiMinorMode) +if !exists("g:vikiMapFunctionalityMinor") "{{{2 + " let g:vikiMapFunctionalityMinor = 'f b p mf mb tF c q e i' + let g:vikiMapFunctionalityMinor = 'f b p mf mb tF c q e' +endif + + +" Special file handlers {{{1 +if !exists('g:vikiOpenFileWith_ws') && exists(':WsOpen') "{{{2 + function! VikiOpenAsWorkspace(file) + exec 'WsOpen '. escape(a:file, ' &!%') + exec 'lcd '. escape(fnamemodify(a:file, ':p:h'), ' &!%') + endf + let g:vikiOpenFileWith_ws = "call VikiOpenAsWorkspace('%{FILE}')" + call add(g:vikiSpecialFiles, 'ws') +endif +if type(g:vikiSpecialFiles) != 3 + echoerr 'Viki: g:vikiSpecialFiles must be a list' +endif +" TAssert IsList(g:vikiSpecialFiles) + +if !exists("g:vikiOpenFileWith_ANY") "{{{2 + if exists('g:netrw_browsex_viewer') + let g:vikiOpenFileWith_ANY = "exec 'silent !'. g:netrw_browsex_viewer .' '. escape('%{FILE}', ' &!%')" + elseif has("win32") || has("win16") || has("win64") + let g:vikiOpenFileWith_ANY = "exec 'silent !cmd /c start '. escape('%{FILE}', ' &!%')" + elseif $GNOME_DESKTOP_SESSION_ID != "" + let g:vikiOpenFileWith_ANY = "exec 'silent !gnome-open '. escape('%{FILE}', ' &!%')" + elseif $KDEDIR != "" + let g:vikiOpenFileWith_ANY = "exec 'silent !kfmclient exec '. escape('%{FILE}', ' &!%')" + endif +endif + +if !exists('*VikiOpenSpecialFile') "{{{2 + function! VikiOpenSpecialFile(file) "{{{3 + " let proto = tolower(matchstr(a:file, '\c\.\zs[a-z]\+$')) + let proto = tolower(fnamemodify(a:file, ':e')) + if exists('g:vikiOpenFileWith_'. proto) + let prot = g:vikiOpenFileWith_{proto} + elseif exists('g:vikiOpenFileWith_ANY') + let prot = g:vikiOpenFileWith_ANY + else + let prot = '' + endif + if prot != '' + let openFile = viki#SubstituteArgs(prot, 'FILE', a:file) + " TLogVAR openFile + call viki#ExecExternal(openFile) + else + throw 'Viki: Please define g:vikiOpenFileWith_'. proto .' or g:vikiOpenFileWith_ANY!' + endif + endf +endif + + +" Special protocol handlers {{{1 +if !exists('g:vikiOpenUrlWith_mailbox') "{{{2 + let g:vikiOpenUrlWith_mailbox="call VikiOpenMailbox('%{URL}')" + function! VikiOpenMailbox(url) "{{{3 + exec viki#DecomposeUrl(strpart(a:url, 10)) + let idx = matchstr(args, 'number=\zs\d\+$') + if filereadable(filename) + call viki#OpenLink(filename, '', 0, 'go '.idx) + else + throw 'Viki: Can't find mailbox url: '.filename + endif + endf +endif + +" Possible values: special*, query, normal +if !exists("g:vikiUrlFileAs") | let g:vikiUrlFileAs = 'special' | endif "{{{2 + +if !exists("g:vikiOpenUrlWith_file") "{{{2 + let g:vikiOpenUrlWith_file="call VikiOpenFileUrl('%{URL}')" + function! VikiOpenFileUrl(url) "{{{3 + if viki#IsSpecialFile(a:url) + if g:vikiUrlFileAs == 'special' + let as_special = 1 + elseif g:vikiUrlFileAs == 'query' + echo a:url + let as_special = input('Treat URL as special file? (Y/n) ') + let as_special = (as_special[0] !=? 'n') + else + let as_special = 0 + endif + if as_special + call VikiOpenSpecialFile(a:url) + return + endif + endif + exec viki#DecomposeUrl(strpart(a:url, 7)) + if filereadable(filename) + call viki#OpenLink(filename, anchor) + else + throw 'Viki: Can't find file url: '.filename + endif + endf +endif + +if !exists("g:vikiOpenUrlWith_ANY") "{{{2 + " let g:vikiOpenUrlWith_ANY = "exec 'silent !". g:netrw_browsex_viewer ." '. escape('%{URL}', ' &!%')" + if has("win32") + let g:vikiOpenUrlWith_ANY = "exec 'silent !rundll32 url.dll,FileProtocolHandler '. escape('%{URL}', ' !&%')" + elseif $GNOME_DESKTOP_SESSION_ID != "" + let g:vikiOpenUrlWith_ANY = "exec 'silent !gnome-open '. escape('%{URL}', ' !&%')" + elseif $KDEDIR != "" + let g:vikiOpenUrlWith_ANY = "exec 'silent !kfmclient exec '. escape('%{URL}', ' !&%')" + endif +endif + +if !exists("*VikiOpenSpecialProtocol") "{{{2 + function! VikiOpenSpecialProtocol(url) "{{{3 + let proto = tolower(matchstr(a:url, '\c^[a-z]\{-}\ze:')) + let prot = 'g:vikiOpenUrlWith_'. proto + let protp = exists(prot) + if !protp + let prot = 'g:vikiOpenUrlWith_ANY' + let protp = exists(prot) + endif + if protp + exec 'let openURL = '. prot + let openURL = viki#SubstituteArgs(openURL, 'URL', a:url) + " TLogVAR openURL + call viki#ExecExternal(openURL) + else + throw 'Viki: Please define g:vikiOpenUrlWith_'. proto .' or g:vikiOpenUrlWith_ANY!' + endif + endf +endif + + +" This is mostly a legacy function. Using set ft=viki should work too. +" Set filetype=viki +function! VikiMode(...) "{{{3 + TVarArg 'family' + " if exists('b:vikiEnabled') + " if b:vikiEnabled + " return 0 + " endif + " " if b:vikiEnabled && a:state < 0 + " " return 0 + " " endif + " " echom "VIKI: Viki mode already set." + " endif + unlet! b:did_ftplugin + if !empty(family) + let b:vikiFamily = family + endif + set filetype=viki +endf + + +if g:vikiMenuPrefix != '' "{{{2 + exec 'amenu '. g:vikiMenuPrefix .'Home :VikiHome' + exec 'amenu '. g:vikiMenuPrefix .'-SepViki1- :' +endif + + +command! -nargs=+ VikiDefine call viki#Define() +command! -count VikiFindNext call viki#DispatchOnFamily('Find', '', '', ) +command! -count VikiFindPrev call viki#DispatchOnFamily('Find', '', 'b', ) + +" command! -nargs=* -range=% VikiMarkInexistent +" \ call VikiSaveCursorPosition() +" \ | call VikiMarkInexistent(, , ) +" \ | call VikiRestoreCursorPosition() +" \ | call ResetSavedCursorPosition() +command! -nargs=* -range=% VikiMarkInexistent call viki#MarkInexistentInRange(, ) + +command! -nargs=? -bar VikiMinorMode call viki#DispatchOnFamily('MinorMode', empty() && exists('b:vikiFamily') ? b:vikiFamily : , 1) +command! -nargs=? -bar VikiMinorModeMaybe echom "Deprecated command: VikiMinorModeMaybe" | VikiMinorMode +command! VikiMinorModeViki call viki_viki#MinorMode(1) +command! VikiMinorModeLaTeX call viki_latex#MinorMode(1) +command! VikiMinorModeAnyWord call viki_anyword#MinorMode(1) + +" this requires imaps to be installed +command! -range VikiQuote :call VEnclose("[-", "-]", "[-", "-]") + +command! -nargs=? -bar VikiMode call VikiMode() +command! -nargs=? -bar VikiModeMaybe echom "Deprecated command: VikiModeMaybe: Please use 'set ft=viki' instead" | call VikiMode() + +command! -narg=? VikiGoBack call viki#GoBack() + +command! VikiJump call viki#MaybeFollowLink(0,1) + +command! VikiIndex :call viki#Index() + +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEdit :call viki#Edit(, "") +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInVim :call viki#Edit(, "", 0, 1) +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditTab :call viki#Edit(, "", 'tab') +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin1 :call viki#Edit(, "", 1) +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin2 :call viki#Edit(, "", 2) +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin3 :call viki#Edit(, "", 3) +command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin4 :call viki#Edit(, "", 4) + +command! -nargs=1 -complete=customlist,viki#BrowseComplete VikiBrowse :call viki#Browse() + +command! VikiHome :call viki#Edit('*', '!') +command! VIKI :call viki#Edit('*', '!') + +command! VikiFilesUpdate call viki#FilesUpdate() +command! VikiFilesUpdateAll call viki#FilesUpdateAll() + +command! -nargs=* -bang -complete=command VikiFileExec call viki#FilesExec(, '', 1) +command! -nargs=* -bang -complete=command VikiFilesExec call viki#FilesExec(, '') +command! -nargs=* -bang VikiFilesCmd call viki#FilesCmd(, '') +command! -nargs=* -bang VikiFilesCall call viki#FilesCall(, '') + + +augroup viki + au! + autocmd BufEnter * call viki#MinorModeReset() + autocmd BufEnter * call viki#CheckInexistent() + autocmd BufLeave * if &filetype == 'viki' | let b:vikiCheckInexistent = line(".") | endif + autocmd BufWritePost,BufUnload * if &filetype == 'viki' | call viki#SaveCache() | endif + autocmd VimLeavePre * let g:vikiEnabled = 0 + if g:vikiSaveHistory + autocmd VimEnter * if exists('VIKIBACKREFS_STRING') | exec 'let g:VIKIBACKREFS = '. VIKIBACKREFS_STRING | unlet VIKIBACKREFS_STRING | endif + autocmd VimLeavePre * let VIKIBACKREFS_STRING = string(g:VIKIBACKREFS) + endif + " As viki uses its own styles, we have to reset &filetype. + autocmd ColorScheme * if &filetype == 'viki' | set filetype=viki | endif +augroup END + + +finish "{{{1 +______________________________________________________________________________ + +* Change Log +1.0 +- Extended names: For compatibility reasons with other wikis, the anchor is +now in the reference part. +- For compatibility reasons with other wikis, prepending an anchor with +b:commentStart is optional. +- g:vikiUseParentSuffix +- Renamed variables & functions (basically s/Wiki/Viki/g) +- added a ftplugin stub, moved the description to a help file +- "[--]" is reference to current file +- Folding support (at section level) +- Intervikis +- More highlighting +- g:vikiFamily, b:vikiFamily +- VikiGoBack() (persistent history data) +- rudimentary LaTeX support ("soft" viki names) + +1.1 +- g:vikiExplorer (for viewing directories) +- preliminary support for "soft" anchors (b:vikiAnchorRx) +- improved VikiOpenSpecialProtocol(url); g:vikiOpenUrlWith_{PROTOCOL}, +g:vikiOpenUrlWith_ANY +- improved VikiOpenSpecialFile(file); g:vikiOpenFileWith_{SUFFIX}, +g:vikiOpenFileWith_ANY +- anchors may contain upper characters (but must begin with a lower char) +- some support for Mozilla ThunderBird mailbox-URLs (this requires spaces to +be encoded as %20) +- changed g:vikiDefSep to '‡‡‡' + +1.2 +- syntax file: fix nested regexp problem +- deplate: conversion to html/latex; download from +http://sourceforge.net/projects/deplate/ +- made syntax a little bit more restrictive (*WORD* now matches /\*\w+\*/ +instead of /\*\S+\*/) +- interviki definitions can now be buffer local variables, too +- fixed DecodeFileUrl(dest) +- some kind of compiler plugin (uses deplate) +- removed g/b:vikiMarkupEndsWithNewline variable +- saved all files in unix format (thanks to Grant Bowman for the hint) +- removed international characters from g:vikiLowerCharacters and +g:vikiUpperCharacters because of difficulties with different encodings (thanks +to Grant Bowman for pointing out this problem); non-english-speaking users have +to set these variables in their vimrc file + +1.3 +- basic ctags support (see |viki-tags|) +- mini-ftplugin for bibtex files (use record labels as anchors) +- added mapping : follow link in other window (if any) +- disabled the highlighting of italic char styles (i.e., /text/) +- the ftplugin doesn't set deplate as the compiler; renamed the compiler plugin to deplate +- syntax: sync minlines=50 +- fix: VikiFoldLevel() + +1.3.1 +- fixed bug when VikiBack was called without a definitiv back-reference +- fixed problems with latin-1 characters + +1.4 +- fixed problem with table highlighting that could cause vim to hang +- it is now possible to selectivly disable simple or quoted viki names +- indent plugin + +1.5 +- distinguish between links to existing and non-existing files +- added key bindings vs (split) and vv (split vertically) +- added key bindings v1 through to v4: open the viki link under cursor +in the windows 1 to 4 +- handle variables g:vikiSplit, b:vikiSplit +- don't indent regions +- regions can be indented +- When a file doesn't exist, ESC or "n" aborts creation + +1.5.1 +- depends on multvals >= 3.8.0 +- new viki family "AnyWord" (see |viki-any-word|), which turns any word into a +potential viki link +- vq, VikiQuote: mark selected text as a quoted viki name +(requires imaps.vim, vimscript #244 or vimscript #475) +- check for null links when pressing , , ], and some other keys +(defined in g:vikiMapKeys) +- a global suffix for viki files can be defined by g:vikiNameSuffix +- fix syntax problem when checking for links to inexistent files + +1.5.2 +- changed default markup of textstyles: __emphasize__, ''code''; the +previous markup can be re-enabled by setting g:vikiTextstylesVer to 1) +- fixed problem with VikiQuote +- on follow link check for yet unsaved buffers too + +1.6 +- b:vikiInverseFold: Inverse folding of subsections +- support for some regions/commands/macros: #INC/#INCLUDE, #IMG, #Img +(requires an id to be defined), {img} +- g:vikiFreeMarker: Search for the plain anchor text if no explicitly marked +anchor could be found. +- new command: VikiEdit NAME ... allows editing of arbitrary viki names (also +understands extended and interviki formats) +- setting the b:vikiNoSimpleNames to true prevents viki from recognizing +simple viki names +- made some script local functions global so that it should be easier to +integrate viki with other plugins +- fixed moving cursor on VikiMarkInexistent() +- fixed typo in b:VikiEnabled, which should be b:vikiEnabled (thanks to Ned +Konz) + +1.6.1 +- removed forgotten debug message +- fixed indentation bug + +1.6.2 +- b:vikiDisableType +- Put AnyWord-related stuff into a file of its own. +- indentation for notices (!!!, ??? etc.) + +1.6.3 +- When creating a new file by following a link, the desired window number was +ignored +- (VikiOpenSpecialFile) Escape blanks in the filename +- Set &include and &define (ftplugin) +- Set g:vikiFolds to '' to avoid using Headings for folds (which may cause a +major slowdown on slower machines) +- renamed DecodeFileUrl(dest) to VikiDecomposeUrl() +- fixed problem with table highlighting +- file type URLs (file://) are now treated like special files +- indent: if g:vikiIndentDesc is '::', align a definition's description to the +first non-blank position after the '::' separator + +1.7 +- g:vikiHomePage: If you call VikiEdit! (with "bang"), the homepage is opened +first so that its customizations are in effect. Also, if you call :VikiHome or +:VikiEdit *, the homepage is opened. +- basic highlighting & indentation of emacs-planner style task lists (sort of) +- command line completion for :VikiEdit +- new command/function VikiDefine for defining intervikis +- added ve map for :VikiEdit +- fixed problem in VikiEdit (when the cursor was on a valid viki link, the +text argument was ignored) +- fixed opening special files/urls in a designated window +- fixed highlighting of comments +- vikiLowerCharacters and vikiUpperCharacters can be buffer local +- fixed problem when an url contained an ampersand +- fixed error message when the &hidden option wasn't set (see g:vikiHide) + +1.8 +- Fold lists too (see also g:vikiFolds) +- Allow interviki names in extended viki names (e.g., +[[WIKI::WikiName][Display Name]]) +- Renamed GetSimpleRx4SimpleWikiName() to +VikiGetSimpleRx4SimpleWikiName() (required in some occasions; increased the +version number so that we can check against it) +- Fix: Problem with urls/fnames containing '!' and other special characters +(which now have to be escaped by the handler; so if you defined a custom +handler, e.g. g:vikiOpenFileWith_ANY, please adapt its definition) +- Fix: VikiEdit! opens the homepage only when b:vikiEnabled is defined in the +current buffer (we assume that for the homepage the global configuration is in +effect) +- Fix: Problem when g:vikiMarkInexistent was false/0 +- Fix: Removed \c from the regular expression for extended names, which caused +FindNext to malfunction and caused a serious slowdown when matching of +bad/unknown links +- Fix: Re-set viki minor mode after entering a buffer +- The state argument in Viki(Minor)Mode is now mostly ignored +- Fix: A simple name's anchor was ignored + +1.9 +- Register mp3, ogg and some other multimedia related suffixes as +special files +- Add a menu of Intervikis if g:vikiMenuPrefix is != '' +- g:vikiMapKeys can contain "\n" and " " (supplement g:vikiMapKeys with +the variables g:vikiMapQParaKeys and g:vikiMapBeforeKeys) +- FIX: IsSupportedType +- FIX: Only the first inexistent link in a line was highlighted +- FIX: Set &buflisted when editing an existing buffer +- FIX: VikiDefine: Non-viki index names weren't quoted +- FIX: In "minor mode", vikiFamily wasn't correctly set in some +situations; other problems related to b:vikiFamily +- FIX: AnyWord works again +- Removed: VikiMinorModeMaybe +- VikiDefine now takes an optional fourth argument (an index file; +default=Index) and automatically creates a vim command with the name of +the interviki that opens this index file + +1.10 +- Pseudo anchors (not supported by deplate): +-- Jump to a line number, e.g. [[file#l=10]] or [[file#line=10]] +-- Find an regexp, e.g. [[file#rx=\\d]] +-- Execute some vim code, e.g. [[file#vim=call Whatever()]] +-- You can define your own handlers: VikiAnchor_{type}(arg) +- g:vikiFolds: new 'b' flag: the body has a higher level than all +headings (gives you some kind of outliner experience; the default value +for g:vikiFolds was changed to 'h') +- FIX: VikiFindAnchor didn't work properly in some situations +- FIX: Escape blanks when following a link (this could cause problems in +some situations, not always) +- FIX: Don't try to mark inexistent links when pressing enter if the current +line is empty. +- FIX: Restore vertical cursor position in window after looking for +inexistent links. +- FIX: Backslashes got lost in some situations. + +1.11 +- Enable [[INTERVIKI::]] +- VikiEdit also creates commands for intervikis that have no index +- Respect "!" and "*" modifiers in extended viki links +- New g:vikiMapFunctionalityMinor variable +- New g:vikiMapLeader variable +- CHANGE: Don't map VikiMarkInexistent in minor mode (see +g:vikiMapFunctionalityMinor) +- CHANGE: new attributes for g:vikiMapFunctionality: c, m[fb], i, I +- SYNTAX: cterm support for todo lists, emphasize +- FIX: Erroneous cursor movement +- FIX: VikiEdit didn't check if a file was already opened, which caused +a file to be opened in two buffers under certain conditions +- FIX: Error in MapMarkInexistent() +- FIX: VikiEdit: Non-viki names were not quoted +- FIX: Use fnamemodify() to expand tildes in filenames +- FIX: Inexistent quoted viki names with an interviki prefix weren't +properly highlighted +- FIX: Minor problem with suffixes & extended viki names +- FIX: Use keepjumps +- FIX: Catch E325 +- FIX: Don't catch errors in EditWrapper() if the command matches +g:vikiNoWrapper (due to possible compatibility problems eg with :Explore +in vim 6.4) +- OBSOLETE: Negative arguments to VikiMode or VikiMinorMode are obsolete +(or they became the default to be precise) +- OBSOLETE: g:vikiMapMouse +- REMOVED: mapping to +- DEPRECATED: VikiModeMaybe + +1.12 +- Define some keywords in syntax file (useful for omnicompletion) +- Define :VIKI command as an alias for :VikiHome +- FIX: Problem with names containing spaces +- FIX: Extended names with suffix & interviki +- FIX: Indentation of priority lists. +- FIX: VikiDefine created wrong (old-fashioned) VikiEdit commands under +certain conditions. +- FIX: Directories in extended viki names + interviki names were marked +as inexistent +- FIX: Syntax highlighting of regions or commands the headline of which +spanned several lines +- Added ppt to g:vikiSpecialFiles. + +1.13 +- Intervikis can now be defined as function ('*Function("%s")', this +breaks conversion via deplate) or format string ('%/foo/%s/bar', not yet +supported by deplate) +- Task lists take optional tags, eg #A [tag] foo; they may also be +tagged with the letters G-Z, which are highlighted as general task (not +supported by deplate) +- Automatically set marks for labels prefixed with "m" (eg #ma -> 'a, +#mB -> 'B) +- Two new g:vikiNameTypes: w = (Hyper)Words, f = File names in cwd as +hyperwords (experimental, not implemented in deplate) +- In extended viki names: add the suffix only if the destination hasn't +got one +- A buffer local b:vikiOpenInWindow allows links to be redirected to a +certain window (ie, if b:vikiOpenInWindow = 2, pressing behaves +like v2); this is useful if you use some kind of +directory/catalog metafile; possible values: absolute number, +/- +relative number, "last" +- Switched back to old regexp for simple names in order to avoid +highlighting of names like LaTeX +- VikiEdit opens the homepage only if b:vikiFamily is set +- Map vF to vnvf +- Improved syntax for (nested) macros +- Set &suffixesadd so that you can use vim's own gf in some situations +- SYNTAX: Allow empty lines as region delimiters (deplate 0.8.1) +- FIX: simple viki names with anchors where not recognised +- FIX: don't mark simple (inter)viki names as inexistent that expand to +links matching g:vikiSpecialProtocols +- FIX: file names containing % +- FIX: added a patch (VikiMarkInexistentInElement) by Kevin Kleinfelter +for compatibility with an unpatched vim70 (untested) +- FIX: disabling simple names (s) also properly disables the name types: +Scwf + +2.0 +- Got rid of multvals & genutils dependencies (use vim7 lists instead) +- New dependency: tlib.vim (vimscript #1863) +- INCOMPATIBLE CHANGE: The format of g:vikiMapFunctionality has changed. +- INCOMPATIBLE CHANGE: g:vikiSpecialFiles is now a list! +- Viki now has a special #Files region that can be automatically +updated. This way we can start thinking about using viki for as +project/file management tool. This is for vim only and not supported yet +in deplate. New related maps & commands: :VikiFilesUpdate (vu), +:VikiFilesUpdateAll (vU), :VikiFilesCmd, :VikiFilesCall, +:VikiFilesExec (vx), and VikiFileExec. +- VikiGoParent() (mapped to v or v): If b:vikiParent is +defined, open this viki name, otherwise follow the backlink. +- New :VikiEditTab command. +- Map vt to open in tab. +- Map v to open go back. +- Keys listed in g:vikiMapQParaKeys are now mapped to +s:VikiMarkInexistentInParagraphVisible() which checks only the visible +area and thus avoids scrolling. +- Highlight lines containing blanks (which vim doesn't treat as +paragraph separators) +- When following a link, check if it is an special viki name before +assuming it's a simple one. +- Map [[, ]], [], ][ +- If an interviki has an index file, a viki name like [[INTERVIKI::]] +will now open the index file. In order to browse the directory, use +[[INTERVIKI::.]]. If no index file is defined, the directory will be +opened either way. +- Set the default value of g:vikiFeedbackMin to &lines. +- Added ws as special files to be opened with :WsOpen if existent. +- Replaced most occurences of with s: +- Use tlib#input#List() for selecting back references. +- g:vikiOpenFileWith_ANY now uses g:netrw_browsex_viewer by default. +- CHANGE: g:vikiSaveHistory: We now rely on viminfo's "!" option to save +back-references. +- FIX: VikiEdit now works properly with protocols that are to be opened +with an external viewer +- FIX: VikiEdit completion, which is more usable now + +2.1 +- Cache inexistent patterns (experimental) +- s:EditWrapper: Don't escape ' '. +- FIX: VikiMode(): Error message about b:did_ftplugin not being defined +- FIX: Check if g:netrw_browsex_viewer is defined (thanks to Erik Olsson +for pointing this and some other problems out) +- ftplugin/viki.vim: FIX: Problem with heading in the last line. +Disabled vikiFolds type 's' (until I find out what this was about) +- Always check the current line for inexistent links when re-entering a +viki buffer + +2.2 +- Re-Enabled the previously (2.1) made and then disabled change +concerning re-entering a viki buffer +- Don't try to use cached values for buffers that have no file attached +yet (thanks to Erik Olsson) +- Require tlib >= 0.8 + +2.3 +- Require tlib >= 0.9 +- FIX: Use absolute file names when editing a local file (avoid problem +when opening a file in a different window with a different CWD). +- New folding routine. Use the old folding method by setting +g:vikiFoldMethodVersion to 1. + +2.4 +- The shortcuts automatically defined by VikiDefine may now take an +optional argument (the file on an interviki) (:WIKI thus is the same as +:VikiEdit WIKI:: and supports the same command-line completion) +- Read ".vikiWords" in parent directories (top-down); +g:vikiHyperWordsFiles: Changed order (read global words first) +- In .vikiWords: destination can be an interviki name (if not, it is +assumed to be a relative filename); if destination is -, the word will +be removed from the jump table; blanks in "hyperwords" will be replaced +with \s\+ in the regular expression. +- New :VikiBrowse command. +- FIX: wrong value for &comments +- FIX: need to reset filetype on color-scheme change (because of viki's +own styles) +- FIX: Caching of inexistent viki names. +- In minor mode, don't map keys that trigger a check for inexistent +links. +- Don't highlight textstyles (emphasized, typewriter) in comments. +- Removed configuration by: VikiInexistentColor(), +g:vikiInexistentColor, VikiHyperLinkColor(), g:vikiHyperLinkColor; use +g:viki_highlight_hyperlink_light, g:viki_highlight_hyperlink_dark, +g:viki_highlight_inexistent_light, g:viki_highlight_inexistent_dark +instead. By default, links are no longer made bold. +- The new default fold expression (g:vikiFoldMethodVersion=4) support +only hH folds (normal and inverse headings based; see g:vikiFolds). +Previous fold methods can be used by setting g:vikiFoldMethodVersion. + +3.0 +- VikiFolds() rev4: The text body is set to max heading level + 1 in +order to avoid lookups and thus speed-up the code. +- g:vikiPromote: Don't set viki minor modes for any files opened via +viki, unless this variable is set +- Added support for 'l' vikiFolds to the default fold expression. +- Added support for the {ref} macro (the referenced label has to be in +the same file though) +- INCOMPATIBLE CHANGE: Moved most function to autoload/viki.vim; moved +support for deplate/viki markup to vikiDeplate.vim. +- The argument of the VikiMode() has changed. (But this function +shouldn't be used anyway.) +- With g:vikiFoldMethodVersion=4 (the default), the text body is at the +level of the heading. This uses "=" for the body, which can be a problem +on slow machines. With g:vikiFoldMethodVersion=5, the body is below the +lowest heading, which can cause other problem. +- :VikiEditInVim ... edit special files in vim +- Set the default value for g:vikiCacheInexistent in order not to +surprise users with the abundance of cached data. +- Require tlib 0.15 +- Use tlib#progressbar +- Improved (poor-man's) tex/math syntax highlighting +- Removed norm! commands form s:MarkInexistent(). +- FIX: Wrong value for b:vikiSimpleNameAnchorIdx when simple viki names +weren't disabled. +- Optionally use hookcursormoved for improved detection of hyperlinks to +inexistent sources. If this plugin causes difficulties, please tell me +and temporarily remove it. +- Use matchlist() instead of substitute(), which could speed things up a +little. + +3.1 +- Slightly improved performance of s:MarkInexistent() and +viki#HookCheckPreviousPosition(). + +3.2 +- viki_viki.vim: Wrong value for b:vikiCmdDestIdx and +b:vikiCmdAnchorIdx. +- Moved :VikiMinorModeViki, :VikiMinorModeLaTeX, and +:VikiMinorModeAnyWord to plugin/viki.vim + +3.3 +- Use hookcursormoved >= 0.3 +- Backslash-save command-line completion +- Mark unknown intervikis as inexistent + +3.4 +- Promote anchors to VikiOpenSpecialProtocol(). +- viki_viki: Enabled #INCLUDE +- Put the poor-man's math highlighting into syntax/texmath.vim so that +it can be included from other syntax files. +- Cascade menu of intervikis +- FIX: don't register viki names as known/unknown more than once + +3.5 +- Don't try to append an empty anchor to an url (Thanks RM Schmid). +- New variable g:viki_intervikis to define intervikis in ~/.vimrc. +- Minor updates to the help file. + +3.6 +- Forgot to define a default value for g:viki_intervikis. + +3.7 +- In a file that doesn't contain headings, return 0 instead of '=' as +default value if g:vikiFoldMethodVersion == 4. +- FIX: "=" in if expressions in certain versions of VikiFoldLevel() + +3.8 +- FIX: viki#MarkInexistentInElement() for pre 7.0.009 vim (thanks to M +Brandmeyer) +- FIX: Make sure tlib is loaded even if it is installed in a different +rtp-directory (thanks to M Brandmeyer) +- Added dia to g:vikiSpecialFiles +- FIX: Scrambled window when opening an url from vim (thanks A Moell) + +" +" vim: ff=unix diff --git a/conf_slk120/vim/_vim/plugin/vikiLatex.vim b/conf_slk120/vim/_vim/plugin/vikiLatex.vim deleted file mode 100755 index c6f75df..0000000 --- a/conf_slk120/vim/_vim/plugin/vikiLatex.vim +++ /dev/null @@ -1,127 +0,0 @@ -" vikiLatex.vim -- viki add-on for LaTeX -" @Author: Thomas Link (samul AT web.de) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 28-Jän-2004. -" @Last Change: 04-Mrz-2006. -" @Revision: 0.164 - -if &cp || exists("s:loaded_vikiLatex") - finish -endif -let s:loaded_vikiLatex = 1 - -fun! VikiSetupBufferLaTeX(state, ...) - let noMatch = "" - let b:vikiNameSuffix = '.tex' - call VikiSetupBuffer(a:state, "sSic") - let b:vikiAnchorRx = '\\label{%{ANCHOR}}' - let b:vikiNameTypes = substitute(b:vikiNameTypes, '\C[Sicx]', "", "g") - let b:vikiLaTeXCommands = 'viki\|include\|input\|usepackage\|psfig\|includegraphics\|bibliography\|ref' - if exists("g:vikiLaTeXUserCommands") - let b:vikiLaTeXCommands = b:vikiLaTeXCommands .'\|'. g:vikiLaTeXUserCommands - endif - if b:vikiNameTypes =~# "s" - let b:vikiSimpleNameRx = '\(\\\('. b:vikiLaTeXCommands .'\)\(\[\(.\{-}\)\]\)\?{\(.\{-}\)}\)' - let b:vikiSimpleNameSimpleRx = '\\\('. b:vikiLaTeXCommands .'\)\(\[.\{-}\]\)\?{.\{-}}' - let b:vikiSimpleNameNameIdx = 2 - let b:vikiSimpleNameDestIdx = 5 - let b:vikiSimpleNameAnchorIdx = 4 - let b:vikiSimpleNameCompound = 'let erx="'. escape(b:vikiSimpleNameRx, '\"') - \ .'" | let nameIdx='. b:vikiSimpleNameNameIdx - \ .' | let destIdx='. b:vikiSimpleNameDestIdx - \ .' | let anchorIdx='. b:vikiSimpleNameAnchorIdx - else - let b:vikiSimpleNameRx = noMatch - let b:vikiSimpleNameSimpleRx = noMatch - let b:vikiSimpleNameNameIdx = 0 - let b:vikiSimpleNameDestIdx = 0 - let b:vikiSimpleNameAnchorIdx = 0 - endif -endf - -fun! VikiLatexCheckFilename(filename, ...) - if a:filename != "" - """ search in the current directory - let i = 1 - while i <= a:0 - exe "let fn = '".a:filename."'.a:". i - if filereadable(fn) - return fn - endif - let i = i + 1 - endwh - - """ use kpsewhich - let i = 1 - while i <= a:0 - exe "let fn = '".a:filename."'.a:". i - exe "let rv = system('kpsewhich ". fn ."')" - if rv != "" - return substitute(rv, "\n", "", "g") - endif - let i = i + 1 - endwh - endif - return "" -endfun - - -fun! VikiCompleteSimpleNameDefLaTeX(def) - let cmd = MvElementAt(a:def, g:vikiDefSep, 0) - if cmd == g:vikiDefNil - throw "Viki: Malformed command (no name): ".a:def - endif - let dest = MvElementAt(a:def, g:vikiDefSep, 1) - let opts = MvElementAt(a:def, g:vikiDefSep, 2) - let part = MvElementAt(a:def, g:vikiDefSep, 3) - let anchor = g:vikiDefNil - let useSuffix = g:vikiDefSep - - if cmd == "input" - let dest = VikiLatexCheckFilename(dest, "", ".tex", ".sty") - elseif cmd == "usepackage" - let dest = VikiLatexCheckFilename(dest, ".sty") - elseif cmd == "include" - let dest = VikiLatexCheckFilename(dest, ".tex") - elseif cmd == "viki" - let dest = VikiLatexCheckFilename(dest, ".tex") - let anchor = opts - elseif cmd == "psfig" - let f == matchstr(dest, "figure=\zs.\{-}\ze[,}]") - let dest = VikiLatexCheckFilename(dest, "") - elseif cmd == "includegraphics" - let dest = VikiLatexCheckFilename(dest, "", - \ ".eps", ".ps", ".pdf", ".png", ".jpeg", ".jpg", ".gif", ".wmf") - elseif cmd == "bibliography" - let n = VikiSelect(dest, ",", "Select Bibliography") - if n >= 0 - let f = MvElementAt(dest, ",", n) - let dest = VikiLatexCheckFilename(f, ".bib") - else - let dest = "" - endif - elseif cmd == "ref" - let anchor = dest - let dest = g:vikiSelfRef - elseif exists("*VikiLaTeX_".cmd) - exe VikiLaTeX_{cmd}(dest, opts) - else - throw "Viki LaTeX: unsupported command: ". cmd - endif - - if dest == "" - throw "Viki LaTeX: can't find: ". cmd ." ". a:def - else - return VikiMakeDef(cmd, dest, anchor, part, 'simple') - endif -endfun - -fun! VikiMinorModeLaTeX(state) - let b:vikiFamily = "LaTeX" - call VikiMinorMode(a:state) -endf - -command! VikiMinorModeLaTeX call VikiMinorModeLaTeX(1) -" au FileType tex let b:vikiFamily="LaTeX" - -" vim: ff=unix diff --git a/conf_slk120/vim/_vim/syntax/texmath.vim b/conf_slk120/vim/_vim/syntax/texmath.vim new file mode 100644 index 0000000..49afbe8 --- /dev/null +++ b/conf_slk120/vim/_vim/syntax/texmath.vim @@ -0,0 +1,62 @@ +" texmath.vim +" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-11-15. +" @Last Change: 2008-01-23. +" @Revision: 0.0.15 + +" Use only as embedded syntax to be included from other syntax files. + +" if version < 600 +" syntax clear +" elseif exists("b:current_syntax") +" finish +" endif +if exists(':HiLink') + let s:delhilink = 0 +else + let s:delhilink = 1 + if version < 508 + command! -nargs=+ HiLink hi link + else + command! -nargs=+ HiLink hi def link + endif +endif + + +" syn match texmathArgDelimiters /[{}\[\]]/ contained containedin=texmathMath +syn match texmathCommand /\\[[:alnum:]]\+/ contained containedin=texmath +syn match texmathMathFont /\\\(math[[:alnum:]]\+\|Bbb\|frak\)/ contained containedin=texmath +syn match texmathMathWord /[[:alnum:].]\+/ contained containedin=texmathMath +syn match texmathUnword /\(\\\\\|[^[:alnum:]${}()[\]^_\\]\+\)/ contained containedin=texmath +syn match texmathPairs /\([<>()[\]]\|\\[{}]\|\\[lr]\(brace\|vert\|Vert\|angle\|ceil\|floor\|group\|moustache\)\)/ + \ contained containedin=texmath +syn match texmathSub /_/ contained containedin=texmathMath +syn match texmathSup /\^/ contained containedin=texmathMath +syn region texmathText matchgroup=Statement + \ start=/\\text{/ end=/}/ skip=/\\[{}]/ + \ contained containedin=texmath +syn region texmathArgDelimiters matchgroup=Delimiter + \ start=/\\\@\|<=\+>\|<\~\+>\|<-\+\|-\+>\|<=\+\|=\+>\|<\~\+\|\~\+>\|\.\.\.\)/ -syn match vikiSymbols /\V\(--\|!=\|==\+\|~~\+\|<-\+>\|<=\+>\|<~\+>\|<-\+\|-\+>\|<=\+\|=\+>\|<~\+\|~\+>\|...\)/ +syn match vikiSymbols /\V\(--\|!=\|==\+\|~~\+\|<-\+>\|<=\+>\|<~\+>\|<-\+\|-\+>\|<=\+\|=\+>\|<~\+\|~\+>\|...\|&\(#\d\+\|\w\+\);\)/ syn cluster vikiHyperLinks contains=vikiLink,vikiExtendedLink,vikiURL,vikiInexistentLink @@ -60,7 +60,8 @@ endif syn cluster vikiText contains=@vikiTextstyles,@vikiHyperLinks,vikiMarkers " exe 'syn match vikiComment /\V\^\[[:blank:]]\*'. escape(b:vikiCommentStart, '\/') .'\.\*/ contains=@vikiText' -syn match vikiComment /^[[:blank:]]*%.*$/ contains=@vikiText +" syn match vikiComment /^[[:blank:]]*%.*$/ contains=@vikiText +syn match vikiComment /^[[:blank:]]*%.*$/ contains=@vikiHyperLinks,vikiMarkers,vikiEscapedChar " syn region vikiString start=+^[[:blank:]]\+"\|"+ end=+"[.?!]\?[[:blank:]]\+$\|"+ contains=@vikiText " syn region vikiString start=+^"\|\s"\|[({\[]\zs"+ end=+"+ contains=@vikiText @@ -82,13 +83,16 @@ endif syn match vikiList /^[[:blank:]]\+\([-+*#?@]\|[0-9#]\+\.\|[a-zA-Z?]\.\)\ze[[:blank:]]/ syn match vikiDescription /^[[:blank:]]\+\(\\\n\|.\)\{-1,}[[:blank:]]::\ze[[:blank:]]/ contains=@vikiHyperLinks,vikiEscapedChar,vikiComment -syn match vikiPriorityListTodoA /^[[:blank:]]\+\zs#\(T: \+.\{-}A.\{-}:\|\d*A\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\ze / -syn match vikiPriorityListTodoB /^[[:blank:]]\+\zs#\(T: \+.\{-}B.\{-}:\|\d*B\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\ze / -syn match vikiPriorityListTodoC /^[[:blank:]]\+\zs#\(T: \+.\{-}C.\{-}:\|\d*C\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\ze / -syn match vikiPriorityListTodoD /^[[:blank:]]\+\zs#\(T: \+.\{-}D.\{-}:\|\d*D\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\ze / -syn match vikiPriorityListTodoE /^[[:blank:]]\+\zs#\(T: \+.\{-}E.\{-}:\|\d*E\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\ze / -syn match vikiPriorityListTodoF /^[[:blank:]]\+\zs#\(T: \+.\{-}F.\{-}:\|\d*F\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\ze / +" \( \+#\S\+\)\? +syn match vikiPriorityListTodoGen /^[[:blank:]]\+\zs#\(T: \+.\{-}\u.\{-}:\|\d*\u\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListTodoA /^[[:blank:]]\+\zs#\(T: \+.\{-}A.\{-}:\|\d*A\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListTodoB /^[[:blank:]]\+\zs#\(T: \+.\{-}B.\{-}:\|\d*B\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListTodoC /^[[:blank:]]\+\zs#\(T: \+.\{-}C.\{-}:\|\d*C\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListTodoD /^[[:blank:]]\+\zs#\(T: \+.\{-}D.\{-}:\|\d*D\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListTodoE /^[[:blank:]]\+\zs#\(T: \+.\{-}E.\{-}:\|\d*E\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListTodoF /^[[:blank:]]\+\zs#\(T: \+.\{-}F.\{-}:\|\d*F\d*\( \+\(_\|[0-9%-]\+\)\)\?\)\( \+\[[^[].\{-}\]\)\?\ze / +syn match vikiPriorityListDoneGen /^[[:blank:]]\+\zs#\(T: \+x\([0-9%-]\+\)\?.\{-}\u.\{-}:\|\(T: \+\)\?\d*\u\d* \+x[0-9%-]*\):\? .*/ syn match vikiPriorityListDoneA /^[[:blank:]]\+\zs#\(T: \+x\([0-9%-]\+\)\?.\{-}A.\{-}:\|\(T: \+\)\?\d*A\d* \+x[0-9%-]*\):\? .*/ syn match vikiPriorityListDoneB /^[[:blank:]]\+\zs#\(T: \+x\([0-9%-]\+\)\?.\{-}B.\{-}:\|\(T: \+\)\?\d*B\d* \+x[0-9%-]*\):\? .*/ syn match vikiPriorityListDoneC /^[[:blank:]]\+\zs#\(T: \+x\([0-9%-]\+\)\?.\{-}C.\{-}:\|\(T: \+\)\?\d*C\d* \+x[0-9%-]*\):\? .*/ @@ -97,18 +101,90 @@ syn match vikiPriorityListDoneE /^[[:blank:]]\+\zs#\(T: \+x\([0-9%-]\+\)\?.\{-}E syn match vikiPriorityListDoneF /^[[:blank:]]\+\zs#\(T: \+x\([0-9%-]\+\)\?.\{-}F.\{-}:\|\(T: \+\)\?\d*F\d* \+x[0-9%-]*\):\? .*/ syn match vikiTableRowSep /||\?/ contained containedin=vikiTableRow,vikiTableHead -syn region vikiTableHead start=/^[[:blank:]]*|| / skip=/\\\n/ end=/\(^\| \)||[[:blank:]]*$/ contains=ALLBUT,vikiTableRow,vikiTableHead transparent keepend -syn region vikiTableRow start=/^[[:blank:]]*| / skip=/\\\n/ end=/\(^\| \)|[[:blank:]]*$/ contains=ALLBUT,vikiTableRow,vikiTableHead transparent keepend +syn region vikiTableHead start=/^[[:blank:]]*|| / skip=/\\\n/ end=/\(^\| \)||[[:blank:]]*$/ + \ transparent keepend + " \ contains=ALLBUT,vikiTableRow,vikiTableHead +syn region vikiTableRow start=/^[[:blank:]]*| / skip=/\\\n/ end=/\(^\| \)|[[:blank:]]*$/ + \ transparent keepend + " \ contains=ALLBUT,vikiTableRow,vikiTableHead -syn region vikiMacro matchgroup=vikiMacroDelim start=/{[^:{}]\+:\?/ end=/}/ transparent +syn keyword vikiCommandNames + \ #CAP #CAPTION #LANG #LANGUAGE #INC #INCLUDE #DOC #VAR #KEYWORDS #OPT + \ #PUT #CLIP #SET #GET #XARG #XVAL #ARG #VAL #BIB #TITLE #TI #AUTHOR + \ #AU #AUTHORNOTE #AN #DATE #IMG #IMAGE #FIG #FIGURE #MAKETITLE + \ #MAKEBIB #LIST #DEFLIST #REGISTER #DEFCOUNTER #COUNTER #TABLE #IDX + \ #AUTOIDX #NOIDX #DONTIDX #WITH #ABBREV #MODULE #MOD #LTX #INLATEX + \ #PAGE #NOP + \ contained containedin=vikiCommand + +syn keyword vikiRegionNames + \ #Doc #Var #Native #Ins #Write #Code #Inlatex #Ltx #Img #Image #Fig + \ #Figure #Footnote #Fn #Foreach #Table #Verbatim #Verb #Abstract + \ #Quote #Qu #R #Ruby #Clip #Put #Set #Header #Footer #Swallow #Skip + \ contained containedin=vikiMacroDelim,vikiRegion,vikiRegionWEnd,vikiRegionAlt + +syn keyword vikiMacroNames + \ {fn {cite {attr {attrib {date {doc {var {arg {val {xarg {xval {opt + \ {msg {clip {get {ins {native {ruby {ref {anchor {label {lab {nl {ltx + \ {math {$ {list {item {term {, {sub {^ {sup {super {% {stacked {: + \ {text {plain {\\ {em {emph {_ {code {verb {img {cmt {pagenumber + \ {pagenum {idx {let {counter + \ contained containedin=vikiMacro,vikiMacroDelim + +syn match vikiSkeleton /{{\_.\{-}[^\\]}}/ + +syn region vikiMacro matchgroup=vikiMacroDelim start=/{\W\?[^:{}]*:\?/ end=/}/ + \ transparent contains=@vikiText,vikiMacroNames,vikiMacro -syn match vikiCommand /^\C[[:blank:]]*#\([A-Z]\{2,}\)\>\(\\\n\|.\)*/ syn region vikiRegion matchgroup=vikiMacroDelim - \ start=/^[[:blank:]]*#\([A-Z]\([a-z][A-Za-z]*\)\?\>\|!!!\).\{-}<<\z(.\+\)$/ end=/^[[:blank:]]*\z1[[:blank:]]*$/ contains=@vikiText + \ start=/^[[:blank:]]*#\([A-Z]\([a-z][A-Za-z]*\)\?\>\|!!!\)\(\\\n\|.\)\{-}<<\z(.*\)$/ + \ end=/^[[:blank:]]*\z1[[:blank:]]*$/ + \ contains=@vikiText,vikiRegionNames syn region vikiRegionWEnd matchgroup=vikiMacroDelim - \ start=/^[[:blank:]]*#\([A-Z]\([a-z][A-Za-z]*\)\?\>\|!!!\).\{-}:[[:blank:]]*$/ end=/^[[:blank:]]*#End[[:blank:]]*$/ contains=@vikiText + \ start=/^[[:blank:]]*#\([A-Z]\([a-z][A-Za-z]*\)\?\>\|!!!\)\(\\\n\|.\)\{-}:[[:blank:]]*$/ + \ end=/^[[:blank:]]*#End[[:blank:]]*$/ + \ contains=@vikiText,vikiRegionNames syn region vikiRegionAlt matchgroup=vikiMacroDelim - \ start=/^[[:blank:]]*\z(=\{4,}\)[[:blank:]]*\([A-Z][a-z]*\>\|!!!\).\{-}$/ end=/^[[:blank:]]*\z1\([[:blank:]].*\)\?$/ contains=@vikiText + \ start=/^[[:blank:]]*\z(=\{4,}\)[[:blank:]]*\([A-Z][a-z]*\>\|!!!\)\(\\\n\|.\)\{-}$/ + \ end=/^[[:blank:]]*\z1\([[:blank:]].*\)\?$/ + \ contains=@vikiText,vikiRegionNames + +syn match vikiCommand /^\C[[:blank:]]*#\([A-Z]\{2,}\)\>\(\\\n\|.\)*/ + \ contains=vikiCommandNames + +syn match vikiFilesMarkers /\[\[\([^\/]\+\/\)*\|\]!\]/ contained containedin=vikiFiles +syn match vikiFilesIndicators /{.\{-}}/ contained containedin=vikiFiles +syn match vikiFiles /^\s*\[\[.\{-}\]!\].*$/ + \ contained containedin=vikiFilesRegion contains=vikiFilesMarkers,vikiFilesIndicators +syn region vikiFilesRegion matchgroup=vikiMacroDelim + \ start=/^[[:blank:]]*#Files\>\(\\\n\|.\)\{-}<<\z(.*\)$/ + \ end=/^[[:blank:]]*\z1[[:blank:]]*$/ + \ contains=vikiFiles + + +if g:vikiHighlightMath == 'latex' + syn region vikiTexFormula matchgroup=Comment + \ start=/\$/ end=/\$/ + \ contains=@texmathMath + syn sync match vikiTexFormula grouphere NONE /^\s*$/ +endif + +syn region vikiTexRegion matchgroup=vikiMacroDelim + \ start=/^[[:blank:]]*#Ltx\>\(\\\n\|.\)\{-}<<\z(.*\)$/ + \ end=/^[[:blank:]]*\z1[[:blank:]]*$/ + \ contains=@texmathMath +syn region vikiTexMacro matchgroup=vikiMacroDelim + \ start=/{\(ltx\)\([^:{}]*:\)\?/ end=/}/ + \ transparent contains=vikiMacroNames,@texmath +syn region vikiTexMathMacro matchgroup=vikiMacroDelim + \ start=/{\(math\>\|\$\)\([^:{}]*:\)\?/ end=/}/ + \ transparent contains=vikiMacroNames,@texmathMath + + +syntax sync minlines=2 +" syntax sync maxlines=50 +" syntax sync match vikiParaBreak /^\s*$/ +" syntax sync linecont /\\$/ " Define the default highlighting. @@ -116,10 +192,10 @@ syn region vikiRegionAlt matchgroup=vikiMacroDelim " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_viki_syntax_inits") if version < 508 - let did_viki_syntax_inits = 1 - command! -nargs=+ HiLink hi link + let did_viki_syntax_inits = 1 + command! -nargs=+ HiLink hi link else - command! -nargs=+ HiLink hi def link + command! -nargs=+ HiLink hi def link endif if &background == "light" @@ -141,7 +217,8 @@ if version >= 508 || !exists("did_viki_syntax_inits") else let s:twfont = "" endif - + + HiLink vikiSemiParagraph NonText HiLink vikiEscapedChars Normal exe "hi vikiEscape ctermfg=". s:cm2 ."grey guifg=". s:cm2 ."grey" exe "hi vikiList term=bold cterm=bold gui=bold ctermfg=". s:cm1 ."Cyan guifg=". s:cm1 ."Cyan" @@ -169,6 +246,7 @@ if version >= 508 || !exists("did_viki_syntax_inits") endif let vikiPriorityListTodo = ' term=bold,underline cterm=bold gui=bold guifg=Black ctermfg=Black ' + exec 'hi vikiPriorityListTodoGen'. vikiPriorityListTodo .'ctermbg=LightRed guibg=LightRed' exec 'hi vikiPriorityListTodoA'. vikiPriorityListTodo .'ctermbg=Red guibg=Red' exec 'hi vikiPriorityListTodoB'. vikiPriorityListTodo .'ctermbg=Brown guibg=Orange' exec 'hi vikiPriorityListTodoC'. vikiPriorityListTodo .'ctermbg=Yellow guibg=Yellow' @@ -189,6 +267,7 @@ if version >= 508 || !exists("did_viki_syntax_inits") HiLink vikiPriorityListDoneD Comment HiLink vikiPriorityListDoneE Comment HiLink vikiPriorityListDoneF Comment + HiLink vikiPriorityListDoneGen Comment exe "hi vikiTableRowSep term=bold cterm=bold gui=bold ctermbg=". s:cm2 ."Grey guibg=". s:cm2 ."Grey" @@ -213,17 +292,39 @@ if version >= 508 || !exists("did_viki_syntax_inits") HiLink vikiMacroHead Statement HiLink vikiMacroDelim Identifier + HiLink vikiSkeleton Special HiLink vikiCommand Statement HiLink vikiRegion Statement HiLink vikiRegionWEnd vikiRegion HiLink vikiRegionAlt vikiRegion - + HiLink vikiFilesRegion Statement + HiLink vikiFiles Constant + HiLink vikiFilesMarkers Ignore + HiLink vikiFilesIndicators Special + " HiLink vikiCommandNames Constant + " HiLink vikiRegionNames Constant + " HiLink vikiMacroNames Constant + HiLink vikiCommandNames Identifier + HiLink vikiRegionNames Identifier + HiLink vikiMacroNames Identifier + + " Statement PreProc + HiLink vikiTexSup Type + HiLink vikiTexSub Type + " HiLink vikiTexArgDelimiters Comment + HiLink vikiTexCommand Statement + HiLink vikiTexText Normal + HiLink vikiTexMathFont Type + HiLink vikiTexMathWord Identifier + HiLink vikiTexUnword Constant + HiLink vikiTexPairs PreProc + delcommand HiLink endif " if g:vikiMarkInexistent && !exists("b:vikiCheckInexistent") if g:vikiMarkInexistent - call VikiMarkInexistentInElement('Document') + call viki#MarkInexistentInitial() endif let b:current_syntax = 'viki' diff --git a/conf_slk120/vim/_vim/syntax/wiki.vim b/conf_slk120/vim/_vim/syntax/wiki.vim new file mode 100644 index 0000000..9b838b1 --- /dev/null +++ b/conf_slk120/vim/_vim/syntax/wiki.vim @@ -0,0 +1,77 @@ +" Vim syntax file +" Language: wiki +" Maintainer: Andreas Kneib +" Improved By: Mathias Panzenböck +" Last Change: 2003 Aug 05 + +" Little syntax file to use a wiki-editor with VIM +" (if your browser allow this action) +" To use this syntax file: +" 1. mkdir ~/.vim/syntax +" 2. mv ~/wiki.vim ~/.vim/syntax/wiki.vim +" 3. :set syntax=wiki +" + +" Quit if syntax file is already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +if version < 508 + command! -nargs=+ WikiHiLink hi link +else + command! -nargs=+ WikiHiLink hi def link +endif + +syn match wikiWord "\<[A-Z][^A-Z ]\+[A-Z][^A-Z ][^A-Z ]*\>" +syn match wikiLine "^----$" +syn region wikiLink start=+\[+hs=s+1 end=+\]+he=e-1 + +"" This RegEx don't work very well. But I'm to clueless, to make it better. ;) +"syn region wikiExtLink start=+\([^\[]\|^\)\[[^\[]+hs=s+1 end=+[^\]]\]\([^\]\|$]\)+he=e-1 +"syn region wikiLink start=+\([^\[]\|^\)\[\[[^\[]+hs=s+1 end=+[^\]]\]\]\([^\]\|$]\)+he=e-1 + +syn match wikiStar "[*]" +syn region wikiCurly start="{\{3\}" end="}\{3\}" +syn region wikiHead start="^= " end="[=] *" +syn region wikiSubhead start="^== " end="==[ ]*" +syn match wikiCurlyError "}" + +syn region wikiBold start=+'''+ end=+'''+ contains=wikiBoldItalic +syn region wikiBoldItalic contained start=+\([^']\|^\)''[^']+ end=+[^']''\([^']\|$\)+ + +syn region wikiItalic start=+\([^']\|^\)''[^']+hs=s+1 end=+[^']''\([^']\|$\)+he=e-1 contains=wikiItalicBold +syn region wikiItalicBold contained start=+'''+ end=+'''+ + +" The default highlighting. +if version >= 508 || !exists("did_wiki_syn_inits") + if version < 508 + let did_wiki_syn_inits = 1 + endif + + WikiHiLink wikiCurlyError Error + WikiHiLink wikiHead Type + WikiHiLink wikiSubhead PreProc + WikiHiLink wikiCurly Statement + WikiHiLink wikiStar String + WikiHiLink wikiExtLink Special + WikiHiLink wikiLink Special + WikiHiLink wikiLine PreProc + WikiHiLink wikiWord Keyword + hi def wikiBold term=bold cterm=bold gui=bold + hi def wikiBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic + hi def wikiItalic term=italic cterm=italic gui=italic + hi def wikiItalicBold term=bold,italic cterm=bold,italic gui=bold,italic +endif + +delcommand WikiHiLink + +let b:current_syntax = "wiki" + +"EOF vim: tw=78:ft=vim:ts=8 + + + + diff --git a/conf_slk120/vim/_vim/test/tlib.vim b/conf_slk120/vim/_vim/test/tlib.vim new file mode 100644 index 0000000..81ff380 --- /dev/null +++ b/conf_slk120/vim/_vim/test/tlib.vim @@ -0,0 +1,213 @@ +" tLib.vim +" @Author: Thomas Link (mailto:micathom AT gmail com?subject=vim-tLib) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2006-12-17. +" @Last Change: 2008-06-15. +" @Revision: 125 + +if !exists("loaded_tassert") + echoerr 'tAssert (vimscript #1730) is required' +endif + + +TAssertBegin! "tlib" + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf +TAssert IsEqual(tlib#list#Inject([], 0, function('Add')), 0) +TAssert IsEqual(tlib#list#Inject([1,2,3], 0, function('Add')), 6) +delfunction Add + +TAssert IsEqual(tlib#list#Compact([]), []) +TAssert IsEqual(tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3]) + +TAssert IsEqual(tlib#list#Flatten([]), []) +TAssert IsEqual(tlib#list#Flatten([1,2,3]), [1,2,3]) +TAssert IsEqual(tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3]) +TAssert IsEqual(tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""]) + +TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3]) +TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30]) + +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2'), 2) +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20) +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10) + +TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 2'), 1) +TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 5'), 0) + +TAssert IsEqual(tlib#list#All([1,2,3], 'v:val < 5'), 1) +TAssert IsEqual(tlib#list#All([1,2,3], 'v:val >= 2'), 0) + +TAssert IsEqual(tlib#list#Remove([1,2,1,2], 2), [1,1,2]) +TAssert IsEqual(tlib#list#RemoveAll([1,2,1,2], 2), [1,1]) + +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]]) + + +" Vars {{{2 +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +TAssert IsEqual(tlib#var#Get('bar', 'bg'), 3) +TAssert IsEqual(tlib#var#Get('bar', 'g'), 2) +TAssert IsEqual(tlib#var#Get('foo', 'bg'), 1) +TAssert IsEqual(tlib#var#Get('foo', 'g'), 1) +TAssert IsEqual(tlib#var#Get('none', 'l'), '') + +TAssert IsEqual(eval(tlib#var#EGet('bar', 'bg')), 3) +TAssert IsEqual(eval(tlib#var#EGet('bar', 'g')), 2) +" TAssert IsEqual(eval(tlib#var#EGet('bar', 'sg')), 4) +TAssert IsEqual(eval(tlib#var#EGet('foo', 'bg')), 1) +TAssert IsEqual(eval(tlib#var#EGet('foo', 'g')), 1) +TAssert IsEqual(eval(tlib#var#EGet('none', 'l')), '') + +unlet g:foo +unlet g:bar +unlet b:bar + + + +" Filenames {{{2 +TAssert IsEqual(tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt']) +TAssert IsEqual(tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt']) +TAssert IsEqual(tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt']) + +TAssert IsEqual(tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt') + +TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt') +TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt') + + + +" Prototype-based programming {{{2 +let test = tlib#Test#New() +TAssert test.IsA('Test') +TAssert !test.IsA('foo') +TAssert test.RespondTo('RespondTo') +TAssert !test.RespondTo('RespondToNothing') +let test1 = tlib#Test#New() +TAssert test.IsRelated(test1) +let testworld = tlib#World#New() +TAssert !test.IsRelated(testworld) + +let testc = tlib#TestChild#New() +TAssert IsEqual(testc.Dummy(), 'TestChild.vim') +TAssert IsEqual(testc.Super('Dummy', []), 'Test.vim') + + + +" Optional arguments {{{2 +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +TAssert IsEqual(TestGetArg(), 1) +TAssert IsEqual(TestGetArg(''), '') +TAssert IsEqual(TestGetArg(2), 2) +TAssert IsEqual(TestGetArg1(), 1) +TAssert IsEqual(TestGetArg1(''), 1) +TAssert IsEqual(TestGetArg1(2), 2) + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs(), 'oo') +TAssert IsEqual(TestArgs('a'), 'aa') +TAssert IsEqual(TestArgs('a', 3), 'aaa') + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs1(), '') +TAssert IsEqual(TestArgs1('a'), 'aa') +TAssert IsEqual(TestArgs1('a', 3), 'aaa') + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs2(), '1') +TAssert IsEqual(TestArgs2('a'), 'a') +TAssert IsEqual(TestArgs2('a', 3), 'aaa') + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +TAssert IsEqual(TestArgs3(), '1') +TAssert IsEqual(TestArgs3('a'), 'a') +TAssert IsEqual(TestArgs3('a', 3), 'a3') + +delfunction TestGetArg +delfunction TestGetArg1 +delfunction TestArgs +delfunction TestArgs1 +delfunction TestArgs2 +delfunction TestArgs3 + + + +" Strings {{{2 +TAssert IsString(tlib#string#RemoveBackslashes('foo bar')) +TAssert IsEqual(tlib#string#RemoveBackslashes('foo bar'), 'foo bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar') + + + +" Regexp {{{2 +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + TAssert (s =~ '\m^'. tlib#rx#Escape(s, 'm') .'$') + TAssert (s =~ '\M^'. tlib#rx#Escape(s, 'M') .'$') + TAssert (s =~ '\v^'. tlib#rx#Escape(s, 'v') .'$') + TAssert (s =~ '\V\^'. tlib#rx#Escape(s, 'V') .'\$') +endfor + + +" Encode, decode +TAssert IsEqual(tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar') +TAssert IsEqual(tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.') + +TAssert IsEqual(tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar') +TAssert IsEqual(tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.') + +TAssertEnd test test1 testc testworld + + +finish "{{{1 + + +" Input {{{2 +echo tlib#input#List('s', 'Test', ['barfoobar', 'barFoobar']) +echo tlib#input#List('s', 'Test', ['barfoobar', 'bar foo bar', 'barFoobar']) +echo tlib#input#List('s', 'Test', ['barfoobar', 'bar1Foo1bar', 'barFoobar']) +echo tlib#input#EditList('Test', ['bar1', 'bar2', 'bar3', 'foo1', 'foo2', 'foo3']) + + diff --git a/conf_slk120/vim/_vimrc b/conf_slk120/vim/_vimrc index ae40592..2ecbf0d 100755 --- a/conf_slk120/vim/_vimrc +++ b/conf_slk120/vim/_vimrc @@ -150,7 +150,7 @@ if has("gui_running") syntax on set hlsearch set foldcolumn=0 - set guioptions=aegimlLtb + set guioptions=aegilLtb " set guioptions=aegimlLtTb " set guioptions=aegirLtb " set guioptions=aegimrLtb @@ -256,8 +256,14 @@ au FileType viki compiler deplate let g:vikiNameSuffix=".viki" autocmd! BufRead,BufNewFile *.viki set filetype=viki autocmd! BufRead,BufNewFile $HOME/viki/* set filetype=viki + +syntax on +au BufRead,BufNewFile *.viki set ft=viki + set mousehide " Hide the mouse when typing text set mousemodel=extend "set helplang=cn set path=.,include,/usr/include,, set wildmenu +set wildmode=list:full +let g:vimwiki_home = "~/wiki/" diff --git a/conf_slk120/xinit/.xinitrc b/conf_slk120/xinit/.xinitrc index 88a9778..451c95d 100644 --- a/conf_slk120/xinit/.xinitrc +++ b/conf_slk120/xinit/.xinitrc @@ -9,7 +9,20 @@ export QT_IM_MODULE=scim export GDK_USE_XFT=1 export LANG=zh_CN.UTF-8 export LC_ALL=zh_CN.UTF-8 -scim -d & +XDM_PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/kde/bin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/opt/qt/bin +ARROW_PATH=$HOME/.bin/shell:/usr/local/bin:/usr/local/sbin:/bin:/usr/games +A_TOOL_PATH=/work/.opt/mv_tools/bin +#A_TOOL_PATH=$TOOL_PATH:/opt/extra/bin/ +#A_TOOL_PATH=$TOOL_PATH:/opt/brcm/hndtools-mipsel-linux/bin +#A_TOOL_PATH=$TOOL_PATH:/opt/brcm/hndtools-mipsel-uclibc/bin +#A_TOOL_PATH=$TOOL_PATH:/opt/hardhat/devkit/mips/fp_le/bin +#A_TOOL_PATH=$TOOL_PATH:/opt/mipsel-linux-uclibc/bin +#A_TOOL_PATH=$TOOL_PATH:/opt/BRECIS/i686-pc-linux-gnu-x-mipsisa32-elf-newlib/bin +#A_TOOL_PATH=$TOOL_PATH:/work/.opt/build_arm_nofpu/staging_dir/bin/ +#A_TOOL_PATH=$TOOL_PATH:/work/.opt/virata/tools_v10.1c/redhat-3-x86/bin +#A_TOOL_PATH=$TOOL_PATH:/work/.opt/utils_work +#A_TOOL_PATH=$TOOL_PATH:/work/.opt/iad6358/bin/ +export PATH=$ARROW_PATH:$A_TOOL_PATH$XDM_PATH userresources=$HOME/.Xresources usermodmap=$HOME/.Xmodmap @@ -36,10 +49,14 @@ fi # start some nice programs xset s 90000 xset s noblank s 24000 2400 s expose -xsetroot -solid SteelBlue +#xsetroot -solid SteelBlue killall -9 ssh-agent ssh-agent > /tmp/.ssh_agent_q && source /tmp/.ssh_agent_q && rm -f /tmp/.ssh_agent_q -xv -root -quit ~/.wallpaper/a.png -fvwm2 +arrow-xinit & +#xv -root -quit ~/.wallpaper/a.png +#fvwm2 # fvwm-themes-start -# startkde +#startkde +#fvwm-themes-start +ion3 +#pwm3 -- 2.11.4.GIT