Browse Source

Initial commit

Alois Mahdal 11 years ago
parent
commit
ac4cfdecbe
57 changed files with 15045 additions and 0 deletions
  1. 26
    0
      dotfiles/bash/colors
  2. 35
    0
      dotfiles/bash/global-after.bashrc
  3. 34
    0
      dotfiles/bash/global-before.bashrc
  4. 30
    0
      dotfiles/bash/host/azzgoat.bashrc
  5. 26
    0
      dotfiles/bash/host/brn-mahdal.bashrc
  6. 24
    0
      dotfiles/bash/host/hugo.bashrc
  7. 18
    0
      dotfiles/bash/setup/bashrc.diff
  8. 5
    0
      dotfiles/bash/user/aloism.bashrc
  9. 7
    0
      dotfiles/bash/user/lennycz.bashrc
  10. 328
    0
      dotfiles/vim/autoload/pathogen.vim
  11. 1
    0
      dotfiles/vim/bundle/lh-vim-lib/.VimballRecord
  12. 150
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/askvim.vim
  13. 102
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/buffer.vim
  14. 271
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/buffer/dialog.vim
  15. 226
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/command.vim
  16. 97
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/common.vim
  17. 78
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/encoding.vim
  18. 78
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/env.vim
  19. 70
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/event.vim
  20. 120
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/float.vim
  21. 217
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/function.vim
  22. 179
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/graph/tsort.vim
  23. 95
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/icomplete.vim
  24. 376
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/list.vim
  25. 477
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/menu.vim
  26. 127
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/option.vim
  27. 366
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/path.vim
  28. 96
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/position.vim
  29. 153
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/syntax.vim
  30. 58
    0
      dotfiles/vim/bundle/lh-vim-lib/autoload/lh/visual.vim
  31. 1369
    0
      dotfiles/vim/bundle/lh-vim-lib/doc/lh-vim-lib.txt
  32. 139
    0
      dotfiles/vim/bundle/lh-vim-lib/doc/tags
  33. 6779
    0
      dotfiles/vim/bundle/lh-vim-lib/lh-vim-lib-3.1.1.vmb
  34. 10
    0
      dotfiles/vim/bundle/lh-vim-lib/lh-vim-lib-addon-info.txt
  35. 20
    0
      dotfiles/vim/bundle/lh-vim-lib/lh-vim-lib.README
  36. 87
    0
      dotfiles/vim/bundle/lh-vim-lib/macros/menu-map.vim
  37. 60
    0
      dotfiles/vim/bundle/lh-vim-lib/mkVba/mk-lh-vim-lib.vim
  38. 57
    0
      dotfiles/vim/bundle/lh-vim-lib/plugin/let.vim
  39. 48
    0
      dotfiles/vim/bundle/lh-vim-lib/plugin/lhvl.vim
  40. 490
    0
      dotfiles/vim/bundle/lh-vim-lib/plugin/ui-functions.vim
  41. 105
    0
      dotfiles/vim/bundle/lh-vim-lib/plugin/words_tools.vim
  42. 288
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/function.vim
  43. 167
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/list.vim
  44. 180
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/path.vim
  45. 85
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-Fargs2String.vim
  46. 67
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-askmenu.vim
  47. 69
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-command.vim
  48. 56
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-menu-map.vim
  49. 86
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-toggle-menu.vim
  50. 122
    0
      dotfiles/vim/bundle/lh-vim-lib/tests/lh/topological-sort.vim
  51. 187
    0
      dotfiles/vim/plugin/local_vimrc.vim
  52. 27
    0
      dotfiles/vim/syntax/ini.vim
  53. 535
    0
      dotfiles/vim/syntax/python.vim
  54. 93
    0
      dotfiles/vim/vimrc
  55. 49
    0
      mklinks
  56. 0
    0
      test_dotfiles/aaafile
  57. 0
    0
      test_dotfiles/bbbfile

+ 26
- 0
dotfiles/bash/colors View File

@@ -0,0 +1,26 @@
1
+#!/bin/sh
2
+
3
+# get some fancy colorz
4
+      black="\[\033[0;30m\]"
5
+        red="\[\033[0;31m\]"
6
+      green="\[\033[0;32m\]"
7
+     yellow="\[\033[0;33m\]"
8
+       blue="\[\033[0;34m\]"
9
+    magenta="\[\033[0;35m\]"
10
+       cyan="\[\033[0;36m\]"
11
+      white="\[\033[0;37m\]"
12
+     lblack="\[\033[1;30m\]"
13
+       lred="\[\033[1;31m\]"
14
+     lgreen="\[\033[1;32m\]"
15
+    lyellow="\[\033[1;33m\]"
16
+      lblue="\[\033[1;34m\]"
17
+   lmagenta="\[\033[1;35m\]"
18
+      lcyan="\[\033[1;36m\]"
19
+     lwhite="\[\033[1;37m\]"
20
+     normal="\[\033[1;0m\]"
21
+
22
+coldemo="colors demo: \n$black  black$red  red$green  green$yellow  yellow"
23
+coldemo="${coldemo}$blue  blue$magenta  magenta$cyan  cyan$white  white\n "
24
+coldemo="${coldemo}$lblack lblack$lred lred$lgreen lgreen$lyellow lyellow"
25
+coldemo="${coldemo}$lblue lblue$lmagenta lmagenta$lcyan lcyan$lwhite lwhite\n"
26
+coldemo="${coldemo}$normal normal\n"

+ 35
- 0
dotfiles/bash/global-after.bashrc View File

@@ -0,0 +1,35 @@
1
+#!/bin/bash
2
+
3
+######################################################
4
+### things to do AFTER host/user-specific settings ###
5
+######################################################
6
+
7
+### .... ###
8
+### BASH ###
9
+### '''' ###
10
+
11
+make_ps1() {
12
+    source "${HOME}/.bash/colors"
13
+    # these functions must be already defined by ~/.bash/user/*.bashrc
14
+    # and ~/.bash/host/*.bashrc
15
+    ps1u=$(make_ps1u)
16
+    ps1h=$(make_ps1h)
17
+    ps1w="$lblue\w$normal";
18
+    ps1G='$(__git_ps1 "(%s)")';
19
+    ps1g="$green$ps1G$normal";
20
+    echo "$ps1u@$ps1h:$ps1w$ps1g$normal\$ ";
21
+}
22
+
23
+make_ps2() {
24
+    source "${HOME}/.bash/colors"
25
+    echo "$white>$yellow>$lyellow>$normal ";
26
+}
27
+
28
+# and use to assemble own PS1
29
+export PS1=$(make_ps1)
30
+export PS2=$(make_ps2)
31
+
32
+### ...... ###
33
+### OTHERS ###
34
+### '''''' ###
35
+

+ 34
- 0
dotfiles/bash/global-before.bashrc View File

@@ -0,0 +1,34 @@
1
+#!/bin/bash
2
+
3
+#######################################################
4
+### things to do BEFORE host/user-specific settings ###
5
+#######################################################
6
+
7
+### .... ###
8
+### BASH ###
9
+### '''' ###
10
+
11
+export HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups
12
+export HISTIGNORE=$HISTIGNORE:ls:ll:la:cd
13
+export GLOBIGNORE=.:..
14
+
15
+# some more aliases
16
+alias ll='ls -lh'
17
+alias grep='grep -I'    # do not match binary files
18
+alias open='gnome-open'
19
+alias diff='diff -u'
20
+
21
+### ...... ###
22
+### OTHERS ###
23
+### '''''' ###
24
+
25
+# make green git bash trinket even cooler
26
+export GIT_PS1_SHOWDIRTYSTATE=true
27
+export GIT_PS1_SHOWUNTRACKEDFILES=true
28
+
29
+# disable mounting things like SFTP to ~/.gvfs when accessed
30
+# via GIO (used by nautilus etc.)
31
+export GVFS_DISABLE_FUSE=1
32
+
33
+# disable the terrible beep sound (only for X; for tty?, blacklist pcspkr)
34
+[[ ${!DISPLAY[@]} ]] &&  xset b off

+ 30
- 0
dotfiles/bash/host/azzgoat.bashrc View File

@@ -0,0 +1,30 @@
1
+#!/bin/bash
2
+
3
+### .... ###
4
+### BASH ###
5
+### '''' ###
6
+
7
+make_ps1h() {
8
+    echo "$rwd\h$normal";
9
+}
10
+
11
+# my tools as aliases
12
+alias          se="$HOME/bin/se"
13
+alias      mkexec="$HOME/bin/mkexec.pl"
14
+alias         cgo="$HOME/bin/cgo"
15
+alias opera-study="$HOME/bin/opera-study"
16
+alias  opera-dwww="$HOME/bin/opera-dwww"
17
+alias      winpdb="$HOME/local/winpdb/winpdb"
18
+alias        node="$HOME/local/node/bin/node"
19
+alias         npm="$HOME/local/node/bin/npm"
20
+alias         tap="./node_modules/tap/bin/tap.js"
21
+alias  tap-reader="./node_modules/tap/bin/tap-reader.js"
22
+
23
+alias diff="colordiff"
24
+
25
+
26
+### ...... ###
27
+### OTHERS ###
28
+### '''''' ###
29
+
30
+export PERL5LIB="$PERL5LIB:$HOME/lib/minions/lib"

+ 26
- 0
dotfiles/bash/host/brn-mahdal.bashrc View File

@@ -0,0 +1,26 @@
1
+#!/bin/bash
2
+
3
+### .... ###
4
+### BASH ###
5
+### '''' ###
6
+
7
+make_ps1h() {
8
+    echo "$cyan\h$normal";
9
+}
10
+
11
+# my tools as aliases
12
+alias        mkexec="$HOME/lib/minions/bin/mkexec.pl"
13
+alias opera-lennycz="opera -pd $HOME/.opera-lennycz"
14
+alias        winpdb="$HOME/local/winpdb/winpdb"
15
+
16
+alias diff="colordiff -u"
17
+alias gnucash="LANG=cs_CZ.utf8 gnucash"
18
+
19
+### ...... ###
20
+### OTHERS ###
21
+### '''''' ###
22
+
23
+export PERL5LIB="$PERL5LIB:$HOME/lib/minions/lib"
24
+
25
+export current_project=mobile-issues
26
+

+ 24
- 0
dotfiles/bash/host/hugo.bashrc View File

@@ -0,0 +1,24 @@
1
+#!/bin/bash
2
+
3
+### .... ###
4
+### BASH ###
5
+### '''' ###
6
+
7
+make_ps1h() {
8
+    echo "$lblack\h$normal";
9
+}
10
+
11
+# my tools as aliases
12
+alias tap="./node_modules/tap/bin/tap.js"
13
+alias tap-reader="./node_modules/tap/bin/tap-reader.js"
14
+alias diff="colordiff -u"
15
+alias git="git-achievements"
16
+
17
+
18
+### ...... ###
19
+### OTHERS ###
20
+### '''''' ###
21
+
22
+export PATH="$PATH:$HOME/bin/git-achievements/"
23
+export PERL5LIB="$PERL5LIB:$HOME/lib/minions/lib"
24
+export PERL5LIB="$PERL5LIB:$HOME/local/gnucash-importer/lib"

+ 18
- 0
dotfiles/bash/setup/bashrc.diff View File

@@ -0,0 +1,18 @@
1
+--- /etc/skel/.bashrc	2012-07-13 01:31:07.000000000 +0200
2
++++ /home/lennycz/.bashrc	2013-03-16 17:32:21.658612859 +0100
3
+@@ -108,3 +108,15 @@
4
+     . /etc/bash_completion
5
+   fi
6
+ fi
7
++
8
++if [ -x "${HOME}/.bash/user/$(whoami).bashrc" ]; then
9
++    source "${HOME}/.bash/user/$(whoami).bashrc";
10
++fi
11
++
12
++if [ -x "${HOME}/.bash/host/$(hostname).bashrc" ]; then
13
++    source "${HOME}/.bash/host/$(hostname).bashrc";
14
++fi
15
++
16
++if [ -x "${HOME}/.bash/global-after.bashrc" ]; then
17
++    source "${HOME}/.bash/global-after.bashrc";
18
++fi

+ 5
- 0
dotfiles/bash/user/aloism.bashrc View File

@@ -0,0 +1,5 @@
1
+#!/bin/bash
2
+
3
+make_ps1u() {
4
+    echo "$lyellow\u$normal";
5
+}

+ 7
- 0
dotfiles/bash/user/lennycz.bashrc View File

@@ -0,0 +1,7 @@
1
+#!/bin/bash
2
+
3
+make_ps1u() {
4
+    echo "$lyellow\u$normal";
5
+}
6
+
7
+export LC_TIME="cs_CZ.utf8"

+ 328
- 0
dotfiles/vim/autoload/pathogen.vim View File

@@ -0,0 +1,328 @@
1
+" pathogen.vim - path option manipulation
2
+" Maintainer:   Tim Pope <http://tpo.pe/>
3
+" Version:      2.2
4
+
5
+" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
6
+"
7
+" For management of individually installed plugins in ~/.vim/bundle (or
8
+" ~\vimfiles\bundle), adding `call pathogen#infect()` to the top of your
9
+" .vimrc is the only other setup necessary.
10
+"
11
+" The API is documented inline below.  For maximum ease of reading,
12
+" :set foldmethod=marker
13
+
14
+if exists("g:loaded_pathogen") || &cp
15
+  finish
16
+endif
17
+let g:loaded_pathogen = 1
18
+
19
+function! s:warn(msg)
20
+  if &verbose
21
+    echohl WarningMsg
22
+    echomsg a:msg
23
+    echohl NONE
24
+  endif
25
+endfunction
26
+
27
+" Point of entry for basic default usage.  Give a relative path to invoke
28
+" pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke
29
+" pathogen#surround().  For backwards compatibility purposes, a full path that
30
+" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories()
31
+" instead.
32
+function! pathogen#infect(...) abort " {{{1
33
+  for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}']
34
+    if path =~# '^[^\\/]\+$'
35
+      call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
36
+      call pathogen#incubate(path . '/{}')
37
+    elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$'
38
+      call pathogen#incubate(path)
39
+    elseif path =~# '[\\/]\%({}\|\*\)$'
40
+      call pathogen#surround(path)
41
+    else
42
+      call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
43
+      call pathogen#surround(path . '/{}')
44
+    endif
45
+  endfor
46
+  call pathogen#cycle_filetype()
47
+  return ''
48
+endfunction " }}}1
49
+
50
+" Split a path into a list.
51
+function! pathogen#split(path) abort " {{{1
52
+  if type(a:path) == type([]) | return a:path | endif
53
+  let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
54
+  return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
55
+endfunction " }}}1
56
+
57
+" Convert a list to a path.
58
+function! pathogen#join(...) abort " {{{1
59
+  if type(a:1) == type(1) && a:1
60
+    let i = 1
61
+    let space = ' '
62
+  else
63
+    let i = 0
64
+    let space = ''
65
+  endif
66
+  let path = ""
67
+  while i < a:0
68
+    if type(a:000[i]) == type([])
69
+      let list = a:000[i]
70
+      let j = 0
71
+      while j < len(list)
72
+        let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
73
+        let path .= ',' . escaped
74
+        let j += 1
75
+      endwhile
76
+    else
77
+      let path .= "," . a:000[i]
78
+    endif
79
+    let i += 1
80
+  endwhile
81
+  return substitute(path,'^,','','')
82
+endfunction " }}}1
83
+
84
+" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
85
+function! pathogen#legacyjoin(...) abort " {{{1
86
+  return call('pathogen#join',[1] + a:000)
87
+endfunction " }}}1
88
+
89
+" Remove duplicates from a list.
90
+function! pathogen#uniq(list) abort " {{{1
91
+  let i = 0
92
+  let seen = {}
93
+  while i < len(a:list)
94
+    if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
95
+      call remove(a:list,i)
96
+    elseif a:list[i] ==# ''
97
+      let i += 1
98
+      let empty = 1
99
+    else
100
+      let seen[a:list[i]] = 1
101
+      let i += 1
102
+    endif
103
+  endwhile
104
+  return a:list
105
+endfunction " }}}1
106
+
107
+" \ on Windows unless shellslash is set, / everywhere else.
108
+function! pathogen#separator() abort " {{{1
109
+  return !exists("+shellslash") || &shellslash ? '/' : '\'
110
+endfunction " }}}1
111
+
112
+" Convenience wrapper around glob() which returns a list.
113
+function! pathogen#glob(pattern) abort " {{{1
114
+  let files = split(glob(a:pattern),"\n")
115
+  return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
116
+endfunction "}}}1
117
+
118
+" Like pathogen#glob(), only limit the results to directories.
119
+function! pathogen#glob_directories(pattern) abort " {{{1
120
+  return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
121
+endfunction "}}}1
122
+
123
+" Turn filetype detection off and back on again if it was already enabled.
124
+function! pathogen#cycle_filetype() " {{{1
125
+  if exists('g:did_load_filetypes')
126
+    filetype off
127
+    filetype on
128
+  endif
129
+endfunction " }}}1
130
+
131
+" Check if a bundle is disabled.  A bundle is considered disabled if it ends
132
+" in a tilde or its basename or full name is included in the list
133
+" g:pathogen_disabled.
134
+function! pathogen#is_disabled(path) " {{{1
135
+  if a:path =~# '\~$'
136
+    return 1
137
+  elseif !exists("g:pathogen_disabled")
138
+    return 0
139
+  endif
140
+  let sep = pathogen#separator()
141
+  let blacklist = g:pathogen_disabled
142
+  return index(blacklist, strpart(a:path, strridx(a:path, sep)+1)) != -1 && index(blacklist, a:path) != 1
143
+endfunction "}}}1
144
+
145
+" Prepend the given directory to the runtime path and append its corresponding
146
+" after directory.  If the directory is already included, move it to the
147
+" outermost position.  Wildcards are added as is.  Ending a path in /{} causes
148
+" all subdirectories to be added (except those in g:pathogen_disabled).
149
+function! pathogen#surround(path) abort " {{{1
150
+  let sep = pathogen#separator()
151
+  let rtp = pathogen#split(&rtp)
152
+  if a:path =~# '[\\/]{}$'
153
+    let path = fnamemodify(a:path[0:-4], ':p:s?[\\/]\=$??')
154
+    let before = filter(pathogen#glob_directories(path.sep.'*'), '!pathogen#is_disabled(v:val)')
155
+    let after  = filter(reverse(pathogen#glob_directories(path.sep."*".sep."after")), '!pathogen#is_disabled(v:val[0:-7])')
156
+    call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
157
+  else
158
+    let path = fnamemodify(a:path, ':p:s?[\\/]\=$??')
159
+    let before = [path]
160
+    let after = [path . sep . 'after']
161
+    call filter(rtp, 'index(before + after, v:val) == -1')
162
+  endif
163
+  let &rtp = pathogen#join(before, rtp, after)
164
+  return &rtp
165
+endfunction " }}}1
166
+
167
+" Prepend all subdirectories of path to the rtp, and append all 'after'
168
+" directories in those subdirectories.  Deprecated.
169
+function! pathogen#runtime_prepend_subdirectories(path) " {{{1
170
+  call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#surround('.string(a:path.'/{}').')')
171
+  return pathogen#surround(a:path . pathogen#separator() . '{}')
172
+endfunction " }}}1
173
+
174
+" For each directory in the runtime path, add a second entry with the given
175
+" argument appended.  If the argument ends in '/{}', add a separate entry for
176
+" each subdirectory.  The default argument is 'bundle/{}', which means that
177
+" .vim/bundle/*, $VIM/vimfiles/bundle/*, $VIMRUNTIME/bundle/*,
178
+" $VIM/vim/files/bundle/*/after, and .vim/bundle/*/after will be added (on
179
+" UNIX).
180
+function! pathogen#incubate(...) abort " {{{1
181
+  let sep = pathogen#separator()
182
+  let name = a:0 ? a:1 : 'bundle/{}'
183
+  if "\n".s:done_bundles =~# "\\M\n".name."\n"
184
+    return ""
185
+  endif
186
+  let s:done_bundles .= name . "\n"
187
+  let list = []
188
+  for dir in pathogen#split(&rtp)
189
+    if dir =~# '\<after$'
190
+      if name =~# '{}$'
191
+        let list +=  filter(pathogen#glob_directories(substitute(dir,'after$',name[0:-3],'').'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
192
+      else
193
+        let list += [dir, substitute(dir, 'after$', '', '') . name . sep . 'after']
194
+      endif
195
+    else
196
+      if name =~# '{}$'
197
+        let list +=  [dir] + filter(pathogen#glob_directories(dir.sep.name[0:-3].'*[^~]'), '!pathogen#is_disabled(v:val)')
198
+      else
199
+        let list += [dir . sep . name, dir]
200
+      endif
201
+    endif
202
+  endfor
203
+  let &rtp = pathogen#join(pathogen#uniq(list))
204
+  return 1
205
+endfunction " }}}1
206
+
207
+" Deprecated alias for pathogen#incubate().
208
+function! pathogen#runtime_append_all_bundles(...) abort " {{{1
209
+  if a:0
210
+    call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#incubate('.string(a:1.'/{}').')')
211
+  else
212
+    call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#incubate()')
213
+  endif
214
+  return call('pathogen#incubate', map(copy(a:000),'v:val . "/{}"'))
215
+endfunction
216
+
217
+let s:done_bundles = ''
218
+" }}}1
219
+
220
+" Invoke :helptags on all non-$VIM doc directories in runtimepath.
221
+function! pathogen#helptags() abort " {{{1
222
+  let sep = pathogen#separator()
223
+  for glob in pathogen#split(&rtp)
224
+    for dir in split(glob(glob), "\n")
225
+      if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
226
+        helptags `=dir.'/doc'`
227
+      endif
228
+    endfor
229
+  endfor
230
+endfunction " }}}1
231
+
232
+command! -bar Helptags :call pathogen#helptags()
233
+
234
+" Execute the given command.  This is basically a backdoor for --remote-expr.
235
+function! pathogen#execute(...) abort " {{{1
236
+  for command in a:000
237
+    execute command
238
+  endfor
239
+  return ''
240
+endfunction " }}}1
241
+
242
+" Like findfile(), but hardcoded to use the runtimepath.
243
+function! pathogen#runtime_findfile(file,count) abort "{{{1
244
+  let rtp = pathogen#join(1,pathogen#split(&rtp))
245
+  let file = findfile(a:file,rtp,a:count)
246
+  if file ==# ''
247
+    return ''
248
+  else
249
+    return fnamemodify(file,':p')
250
+  endif
251
+endfunction " }}}1
252
+
253
+" Backport of fnameescape().
254
+function! pathogen#fnameescape(string) abort " {{{1
255
+  if exists('*fnameescape')
256
+    return fnameescape(a:string)
257
+  elseif a:string ==# '-'
258
+    return '\-'
259
+  else
260
+    return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
261
+  endif
262
+endfunction " }}}1
263
+
264
+if exists(':Vedit')
265
+  finish
266
+endif
267
+
268
+let s:vopen_warning = 0
269
+
270
+function! s:find(count,cmd,file,lcd) " {{{1
271
+  let rtp = pathogen#join(1,pathogen#split(&runtimepath))
272
+  let file = pathogen#runtime_findfile(a:file,a:count)
273
+  if file ==# ''
274
+    return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
275
+  endif
276
+  if !s:vopen_warning
277
+    let s:vopen_warning = 1
278
+    let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
279
+  else
280
+    let warning = ''
281
+  endif
282
+  if a:lcd
283
+    let path = file[0:-strlen(a:file)-2]
284
+    execute 'lcd `=path`'
285
+    return a:cmd.' '.pathogen#fnameescape(a:file) . warning
286
+  else
287
+    return a:cmd.' '.pathogen#fnameescape(file) . warning
288
+  endif
289
+endfunction " }}}1
290
+
291
+function! s:Findcomplete(A,L,P) " {{{1
292
+  let sep = pathogen#separator()
293
+  let cheats = {
294
+        \'a': 'autoload',
295
+        \'d': 'doc',
296
+        \'f': 'ftplugin',
297
+        \'i': 'indent',
298
+        \'p': 'plugin',
299
+        \'s': 'syntax'}
300
+  if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
301
+    let request = cheats[a:A[0]].a:A[1:-1]
302
+  else
303
+    let request = a:A
304
+  endif
305
+  let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
306
+  let found = {}
307
+  for path in pathogen#split(&runtimepath)
308
+    let path = expand(path, ':p')
309
+    let matches = split(glob(path.sep.pattern),"\n")
310
+    call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
311
+    call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
312
+    for match in matches
313
+      let found[match] = 1
314
+    endfor
315
+  endfor
316
+  return sort(keys(found))
317
+endfunction " }}}1
318
+
319
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve       :execute s:find(<count>,'edit<bang>',<q-args>,0)
320
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit    :execute s:find(<count>,'edit<bang>',<q-args>,0)
321
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen    :execute s:find(<count>,'edit<bang>',<q-args>,1)
322
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit   :execute s:find(<count>,'split',<q-args>,<bang>1)
323
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit  :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
324
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
325
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit   :execute s:find(<count>,'pedit',<q-args>,<bang>1)
326
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread    :execute s:find(<count>,'read',<q-args>,<bang>1)
327
+
328
+" vim:set et sw=2:

+ 1
- 0
dotfiles/vim/bundle/lh-vim-lib/.VimballRecord View File

@@ -0,0 +1 @@
1
+lh-vim-lib-3.1.1.vmb: call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/askvim.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/buffer.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/buffer/dialog.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/command.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/common.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/encoding.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/env.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/event.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/float.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/function.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/graph/tsort.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/icomplete.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/list.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/menu.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/option.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/path.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/position.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/syntax.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//autoload/lh/visual.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//doc/lh-vim-lib.txt')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//lh-vim-lib-addon-info.txt')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//lh-vim-lib.README')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//macros/menu-map.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//mkVba/mk-lh-vim-lib.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//plugin/let.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//plugin/lhvl.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//plugin/ui-functions.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//plugin/words_tools.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/function.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/list.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/path.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/test-Fargs2String.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/test-askmenu.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/test-command.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/test-menu-map.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/test-toggle-menu.vim')|call delete('/home/lennycz/Dropbox/Config/dotfiles/vim/bundle/lh-vim-lib/.//tests/lh/topological-sort.vim')

+ 150
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/askvim.vim View File

@@ -0,0 +1,150 @@
1
+"=============================================================================
2
+" $Id: askvim.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/askvim.vim                                    {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	17th Apr 2007
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (17th Apr 2007)
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Defines functions that asks vim what it is relinquish to tell us
14
+" 	- menu
15
+" 
16
+"------------------------------------------------------------------------
17
+" Installation:	
18
+" 	Drop it into {rtp}/autoload/lh/
19
+" 	Vim 7+ required.
20
+" History:	
21
+" 	v2.0.0:
22
+" 	v3.0.0: GPLv3
23
+" TODO:		«missing features»
24
+" }}}1
25
+"=============================================================================
26
+
27
+
28
+"=============================================================================
29
+let s:cpo_save=&cpo
30
+set cpo&vim
31
+
32
+"------------------------------------------------------------------------
33
+" ## Functions {{{1
34
+" # Debug {{{2
35
+function! lh#askvim#verbose(level)
36
+  let s:verbose = a:level
37
+endfunction
38
+
39
+function! s:Verbose(expr)
40
+  if exists('s:verbose') && s:verbose
41
+    echomsg a:expr
42
+  endif
43
+endfunction
44
+
45
+function! lh#askvim#debug(expr)
46
+  return eval(a:expr)
47
+endfunction
48
+
49
+"------------------------------------------------------------------------
50
+" # Public {{{2
51
+" Function: lh#askvim#exe(command) {{{3
52
+function! lh#askvim#Exe(command)
53
+  echomsg 'lh#askvim#Exe() is deprecated, use lh#askvim#exe()'
54
+  return lh#askvim#exe(a:command)
55
+endfunction
56
+
57
+function! lh#askvim#exe(command)
58
+  let save_a = @a
59
+  try 
60
+    silent! redir @a
61
+    silent! exe a:command
62
+    redir END
63
+  finally
64
+    " Always restore everything
65
+    let res = @a
66
+    let @a = save_a
67
+    return res
68
+  endtry
69
+endfunction
70
+
71
+
72
+" Function: lh#askvim#menu(menuid) {{{3
73
+function! s:AskOneMenu(menuact, res)
74
+  let sKnown_menus = lh#askvim#exe(a:menuact)
75
+  let lKnown_menus = split(sKnown_menus, '\n')
76
+  " echo string(lKnown_menus)
77
+
78
+  " 1- search for the menuid
79
+  " todo: fix the next line to correctly interpret "stuff\.stuff" and
80
+  " "stuff\\.stuff".
81
+  let menuid_parts = split(a:menuact, '\.')
82
+
83
+  let simplifiedKnown_menus = deepcopy(lKnown_menus)
84
+  call map(simplifiedKnown_menus, 'substitute(v:val, "&", "", "g")')
85
+  " let idx = lh#list#match(simplifiedKnown_menus, '^\d\+\s\+'.menuid_parts[-1])
86
+  let idx = match(simplifiedKnown_menus, '^\d\+\s\+'.menuid_parts[-1])
87
+  if idx == -1
88
+    " echo "not found"
89
+    return
90
+  endif
91
+  " echo "l[".idx."]=".lKnown_menus[idx]
92
+
93
+  if empty(a:res)
94
+    let a:res.priority = matchstr(lKnown_menus[idx], '\d\+\ze\s\+.*')
95
+    let a:res.name     = matchstr(lKnown_menus[idx], '\d\+\s\+\zs.*')
96
+    let a:res.actions  = {}
97
+  " else
98
+  "   what if the priority isn't the same?
99
+  endif
100
+
101
+  " 2- search for the menu definition
102
+  let idx += 1
103
+  while idx != len(lKnown_menus)
104
+    echo "l[".idx."]=".lKnown_menus[idx]
105
+    " should not happen
106
+    if lKnown_menus[idx] =~ '^\d\+' | break | endif
107
+
108
+    " :h showing-menus
109
+    " -> The format of the result of the call to Exe() seems to be:
110
+    "    ^ssssMns-sACTION$
111
+    "    s == 1 whitespace
112
+    "    M == mode (inrvcs)
113
+    "    n == noremap(*)/script(&)
114
+    "    - == disable(-)/of not
115
+    let act = {}
116
+    let menu_def = matchlist(lKnown_menus[idx],
117
+	  \ '^\s*\([invocs]\)\([&* ]\) \([- ]\) \(.*\)$')
118
+    if len(menu_def) > 4
119
+      let act.mode        = menu_def[1]
120
+      let act.nore_script = menu_def[2]
121
+      let act.disabled    = menu_def[3]
122
+      let act.action      = menu_def[4]
123
+    else
124
+      echomsg string(menu_def)
125
+      echoerr "lh#askvim#menu(): Cannot decode ``".lKnown_menus[idx]."''"
126
+    endif
127
+    
128
+    let a:res.actions["mode_" . act.mode] = act
129
+
130
+    let idx += 1
131
+  endwhile
132
+
133
+  " n- Return the result
134
+  return a:res
135
+endfunction
136
+
137
+function! lh#askvim#menu(menuid, modes)
138
+  let res = {}
139
+  let i = 0
140
+  while i != strlen(a:modes)
141
+    call s:AskOneMenu(a:modes[i].'menu '.a:menuid, res)
142
+    let i += 1
143
+  endwhile
144
+  return res
145
+endfunction
146
+" Functions }}}1
147
+"------------------------------------------------------------------------
148
+let &cpo=s:cpo_save
149
+"=============================================================================
150
+" vim600: set fdm=marker:

+ 102
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/buffer.vim View File

@@ -0,0 +1,102 @@
1
+"=============================================================================
2
+" $Id: buffer.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/buffer.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" Licence:      GPLv3
7
+" Version:	3.0.0
8
+" Created:	23rd Jan 2007
9
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
10
+"------------------------------------------------------------------------
11
+" Description:	
12
+" 	Defines functions that help finding windows and handling buffers.
13
+" 
14
+"------------------------------------------------------------------------
15
+" Installation:	
16
+" 	Drop it into {rtp}/autoload/lh/
17
+" 	Vim 7+ required.
18
+" History:	
19
+"	v1.0.0 First Version
20
+" 	(*) Functions moved from searchInRuntimeTime  
21
+" 	v2.2.0
22
+" 	(*) new function: lh#buffer#list()
23
+"       v3.0.0 GPLv3
24
+" TODO:	
25
+" }}}1
26
+"=============================================================================
27
+
28
+
29
+"=============================================================================
30
+let s:cpo_save=&cpo
31
+set cpo&vim
32
+
33
+" ## Functions {{{1
34
+"------------------------------------------------------------------------
35
+" # Debug {{{2
36
+function! lh#buffer#verbose(level)
37
+  let s:verbose = a:level
38
+endfunction
39
+
40
+function! s:Verbose(expr)
41
+  if exists('s:verbose') && s:verbose
42
+    echomsg a:expr
43
+  endif
44
+endfunction
45
+
46
+function! lh#buffer#debug(expr)
47
+  return eval(a:expr)
48
+endfunction
49
+
50
+"------------------------------------------------------------------------
51
+" # Public {{{2
52
+
53
+" Function: lh#buffer#find({filename}) {{{3
54
+" If {filename} is opened in a window, jump to this window, otherwise return -1
55
+" Moved from searchInRuntimeTime.vim
56
+function! lh#buffer#find(filename)
57
+  let b = bufwinnr(a:filename)
58
+  if b == -1 | return b | endif
59
+  exe b.'wincmd w'
60
+  return b
61
+endfunction
62
+function! lh#buffer#Find(filename)
63
+  return lh#buffer#find(a:filename)
64
+endfunction
65
+
66
+" Function: lh#buffer#jump({filename},{cmd}) {{{3
67
+function! lh#buffer#jump(filename, cmd)
68
+  if lh#buffer#find(a:filename) != -1 | return | endif
69
+  exe a:cmd . ' ' . a:filename
70
+endfunction
71
+function! lh#buffer#Jump(filename, cmd)
72
+  return lh#buffer#jump(a:filename, a:cmd)
73
+endfunction
74
+
75
+" Function: lh#buffer#scratch({bname},{where}) {{{3
76
+function! lh#buffer#scratch(bname, where)
77
+  try
78
+    silent exe a:where.' sp '.a:bname
79
+  catch /.*/
80
+    throw "Can't open a buffer named '".a:bname."'!"
81
+  endtry
82
+  setlocal bt=nofile bh=wipe nobl noswf ro
83
+endfunction
84
+function! lh#buffer#Scratch(bname, where)
85
+  return lh#buffer#scratch(a:bname, a:where)
86
+endfunction
87
+
88
+" Function: lh#buffer#list() {{{3
89
+function! lh#buffer#list()
90
+  let all = range(0, bufnr('$'))
91
+  " let res = lh#list#transform_if(all, [], 'v:1_', 'buflisted')
92
+  let res = lh#list#copy_if(all, [], 'buflisted')
93
+  return res
94
+endfunction
95
+" Ex: Names of the buffers listed
96
+"  -> echo lh#list#transform(lh#buffer#list(), [], "bufname")
97
+" Ex: wipeout empty buffers listed
98
+"  -> echo 'bw'.join(lh#list#copy_if(range(0, bufnr('$')), [], 'buflisted(v:1_) && empty(bufname(v:1_))'), ' ')
99
+"=============================================================================
100
+let &cpo=s:cpo_save
101
+"=============================================================================
102
+" vim600: set fdm=marker:

+ 271
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/buffer/dialog.vim View File

@@ -0,0 +1,271 @@
1
+"=============================================================================
2
+" $Id: dialog.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/buffer/dialog.vim                            {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	21st Sep 2007
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	«description»
13
+" 
14
+"------------------------------------------------------------------------
15
+" Installation:	
16
+" 	Drop it into {rtp}/autoload/lh/
17
+" 	Vim 7+ required.
18
+" History:	
19
+"	v1.0.0 First Version
20
+" 	(*) Functions imported from Mail_mutt_alias.vim
21
+"       v3.0.0  GPLv3
22
+" TODO:		
23
+" 	(*) --abort-- line
24
+" 	(*) custom messages
25
+" 	(*) do not mess with search history
26
+" 	(*) support any &magic
27
+" 	(*) syntax
28
+" 	(*) add number/letters
29
+" 	(*) tag with '[x] ' instead of '* '
30
+" }}}1
31
+"=============================================================================
32
+
33
+
34
+"=============================================================================
35
+let s:cpo_save=&cpo
36
+set cpo&vim
37
+
38
+
39
+
40
+"=============================================================================
41
+" ## Globals {{{1
42
+let s:LHdialog = {}
43
+
44
+"=============================================================================
45
+" ## Functions {{{1
46
+" # Debug {{{2
47
+function! lh#buffer#dialog#verbose(level)
48
+  let s:verbose = a:level
49
+endfunction
50
+
51
+function! s:Verbose(expr)
52
+  if exists('s:verbose') && s:verbose
53
+    echomsg a:expr
54
+  endif
55
+endfunction
56
+
57
+function! lh#buffer#dialog#debug(expr)
58
+  return eval(a:expr)
59
+endfunction
60
+
61
+
62
+"=============================================================================
63
+" # Dialog functions {{{2
64
+"------------------------------------------------------------------------
65
+function! s:Mappings(abuffer)
66
+  " map <enter> to edit a file, also dbl-click
67
+  exe "nnoremap <silent> <buffer> <esc>         :silent call ".a:abuffer.action."(-1, ".a:abuffer.id.")<cr>"
68
+  exe "nnoremap <silent> <buffer> q             :call lh#buffer#dialog#select(-1, ".a:abuffer.id.")<cr>"
69
+  exe "nnoremap <silent> <buffer> <cr>          :call lh#buffer#dialog#select(line('.'), ".a:abuffer.id.")<cr>"
70
+  " nnoremap <silent> <buffer> <2-LeftMouse> :silent call <sid>GrepEditFileLine(line("."))<cr>
71
+  " nnoremap <silent> <buffer> Q	  :call <sid>Reformat()<cr>
72
+  " nnoremap <silent> <buffer> <Left>	  :set tabstop-=1<cr>
73
+  " nnoremap <silent> <buffer> <Right>	  :set tabstop+=1<cr>
74
+  if a:abuffer.support_tagging
75
+    nnoremap <silent> <buffer> t	  :silent call <sid>ToggleTag(line("."))<cr>
76
+    nnoremap <silent> <buffer> <space>	  :silent call <sid>ToggleTag(line("."))<cr>
77
+  endif
78
+  nnoremap <silent> <buffer> <tab>	  :silent call <sid>NextChoice('')<cr>
79
+  nnoremap <silent> <buffer> <S-tab>	  :silent call <sid>NextChoice('b')<cr>
80
+  exe "nnoremap <silent> <buffer> h	  :silent call <sid>ToggleHelp(".a:abuffer.id.")<cr>"
81
+endfunction
82
+
83
+"----------------------------------------
84
+" Tag / untag the current choice {{{
85
+function! s:ToggleTag(lineNum)
86
+   if a:lineNum > s:Help_NbL()
87
+      " If tagged
88
+      if (getline(a:lineNum)[0] == '*')
89
+	let b:NbTags = b:NbTags - 1
90
+	silent exe a:lineNum.'s/^\* /  /e'
91
+      else
92
+	let b:NbTags = b:NbTags + 1
93
+	silent exe a:lineNum.'s/^  /* /e'
94
+      endif
95
+      " Move after the tag ; there is something with the two previous :s. They
96
+      " don't leave the cursor at the same position.
97
+      silent! normal! 3|
98
+      call s:NextChoice('') " move to the next choice
99
+    endif
100
+endfunction
101
+" }}}
102
+
103
+function! s:Help_NbL()
104
+  " return 1 + nb lines of BuildHelp
105
+  return 2 + len(b:dialog['help_'.b:dialog.help_type])
106
+endfunction
107
+"----------------------------------------
108
+" Go to the Next (/previous) possible choice. {{{
109
+function! s:NextChoice(direction)
110
+  " echomsg "next!"
111
+  call search('^[ *]\s*\zs\S\+', a:direction)
112
+endfunction
113
+" }}}
114
+
115
+"------------------------------------------------------------------------
116
+
117
+function! s:RedisplayHelp(dialog)
118
+  silent! 2,$g/^@/d_
119
+  normal! gg
120
+  for help in a:dialog['help_'.a:dialog.help_type]
121
+    silent put=help
122
+  endfor
123
+endfunction
124
+
125
+function! lh#buffer#dialog#update(dialog)
126
+  set noro
127
+  exe (s:Help_NbL()+1).',$d_'
128
+  for choice in a:dialog.choices
129
+    silent $put='  '.choice
130
+  endfor
131
+  set ro
132
+endfunction
133
+
134
+function! s:Display(dialog, atitle)
135
+  set noro
136
+  0 put = a:atitle
137
+  call s:RedisplayHelp(a:dialog)
138
+  for choice in a:dialog.choices
139
+    silent $put='  '.choice
140
+  endfor
141
+  set ro
142
+  exe s:Help_NbL()+1
143
+endfunction
144
+
145
+function! s:ToggleHelp(bufferId)
146
+  call lh#buffer#find(a:bufferId)
147
+  call b:dialog.toggle_help()
148
+endfunction
149
+
150
+function! lh#buffer#dialog#toggle_help() dict
151
+  let self.help_type 
152
+	\ = (self.help_type == 'short')
153
+	\ ? 'long'
154
+	\ : 'short'
155
+  call s:RedisplayHelp(self)
156
+endfunction
157
+
158
+function! lh#buffer#dialog#new(bname, title, where, support_tagging, action, choices)
159
+  " The ID will be the buffer id
160
+  let res = {}
161
+  let where_it_started = getpos('.')
162
+  let where_it_started[0] = bufnr('%')
163
+  let res.where_it_started = where_it_started
164
+
165
+  try
166
+    call lh#buffer#scratch(a:bname, a:where)
167
+  catch /.*/
168
+    echoerr v:exception
169
+    return res
170
+  endtry
171
+  let res.id              = bufnr('%')
172
+  let b:NbTags            = 0
173
+  let b:dialog            = res
174
+  let s:LHdialog[res.id]  = res
175
+  let res.help_long       = []
176
+  let res.help_short      = []
177
+  let res.help_type       = 'short'
178
+  let res.support_tagging = a:support_tagging
179
+  let res.action	  = a:action
180
+  let res.choices	  = a:choices
181
+
182
+  " Long help
183
+  call lh#buffer#dialog#add_help(res, '@| <cr>, <double-click>    : select this', 'long')
184
+  call lh#buffer#dialog#add_help(res, '@| <esc>, q                : Abort', 'long')
185
+  if a:support_tagging
186
+    call lh#buffer#dialog#add_help(res, '@| <t>, <space>            : Tag/Untag the current item', 'long')
187
+  endif
188
+  call lh#buffer#dialog#add_help(res, '@| <up>/<down>, <tab>, +/- : Move between entries', 'long')
189
+  call lh#buffer#dialog#add_help(res, '@|', 'long')
190
+  " call lh#buffer#dialog#add_help(res, '@| h                       : Toggle help', 'long')
191
+  call lh#buffer#dialog#add_help(res, '@+'.repeat('-', winwidth(bufwinnr(res.id))-3), 'long')
192
+  " Short Help
193
+  " call lh#buffer#dialog#add_help(res, '@| h                       : Toggle help', 'short')
194
+  call lh#buffer#dialog#add_help(res, '@+'.repeat('-', winwidth(bufwinnr(res.id))-3), 'short')
195
+
196
+  let res.toggle_help = function("lh#buffer#dialog#toggle_help")
197
+  let title = '@  ' . a:title
198
+  let helpstr = '| Toggle (h)elp'
199
+  let title = title 
200
+	\ . repeat(' ', winwidth(bufwinnr(res.id))-lh#encoding#strlen(title)-lh#encoding#strlen(helpstr)-1)
201
+	\ . helpstr
202
+  call s:Display(res, title)
203
+ 
204
+  call s:Mappings(res)
205
+  return res
206
+endfunction
207
+
208
+function! lh#buffer#dialog#add_help(abuffer, text, help_type)
209
+  call add(a:abuffer['help_'.a:help_type],a:text)
210
+endfunction
211
+
212
+"=============================================================================
213
+function! lh#buffer#dialog#quit()
214
+  let bufferId = b:dialog.where_it_started[0]
215
+  echohl WarningMsg
216
+  echo "Abort"
217
+  echohl None
218
+  quit
219
+  call lh#buffer#find(bufferId)
220
+endfunction
221
+
222
+" Function: lh#buffer#dialog#select(line, bufferId [,overriden-action])
223
+function! lh#buffer#dialog#select(line, bufferId, ...)
224
+  if a:line == -1
225
+    call lh#buffer#dialog#quit()
226
+    return
227
+  " elseif a:line <= s:Help_NbL() + 1
228
+  elseif a:line <= s:Help_NbL() 
229
+    echoerr "Unselectable item"
230
+    return 
231
+  else
232
+    let dialog = s:LHdialog[a:bufferId]
233
+    let results = { 'dialog' : dialog, 'selection' : []  }
234
+
235
+    if b:NbTags == 0
236
+      " -1 because first index is 0
237
+      " let results = [ dialog.choices[a:line - s:Help_NbL() - 1] ]
238
+      let results.selection = [ a:line - s:Help_NbL() - 1 ]
239
+    else
240
+      silent g/^* /call add(results.selection, line('.')-s:Help_NbL()-1)
241
+    endif
242
+  endif
243
+
244
+  if a:0 > 0 " action overriden
245
+    exe 'call '.dialog.action.'(results, a:000)'
246
+  else
247
+    exe 'call '.dialog.action.'(results)'
248
+  endif
249
+endfunction
250
+function! lh#buffer#dialog#Select(line, bufferId, ...)
251
+  echomsg "lh#buffer#dialog#Select() is deprecated, use lh#buffer#dialog#select() instead"
252
+  if a:0 > 0 " action overriden
253
+    exe 'call lh#buffer#dialog#select(a:line,  a:bufferId, a:1)'
254
+  else
255
+    exe 'call lh#buffer#dialog#select(a:line,  a:bufferId)'
256
+  endif
257
+endfunction
258
+
259
+function! Action(results)
260
+  let dialog = a:results.dialog
261
+  let choices = dialog.choices
262
+  for r in a:results.selection
263
+    echomsg '-> '.choices[r]
264
+  endfor
265
+endfunction
266
+
267
+
268
+"=============================================================================
269
+let &cpo=s:cpo_save
270
+"=============================================================================
271
+" vim600: set fdm=marker:

+ 226
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/command.vim View File

@@ -0,0 +1,226 @@
1
+"=============================================================================
2
+" $Id: command.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/command.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	08th Jan 2007
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (08th Jan 2007)
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Helpers to define commands that:
14
+" 	- support subcommands
15
+" 	- support autocompletion
16
+" 
17
+"------------------------------------------------------------------------
18
+" Installation:	
19
+" 	Drop it into {rtp}/autoload/lh/
20
+" 	Vim 7+ required.
21
+" History:	
22
+"       v3.0.0: GPLv3
23
+" 	v2.0.0: Code moved from other plugins
24
+" TODO:		«missing features»
25
+" }}}1
26
+"=============================================================================
27
+
28
+
29
+"=============================================================================
30
+let s:cpo_save=&cpo
31
+set cpo&vim
32
+
33
+" ## Debug {{{1
34
+function! lh#command#verbose(level)
35
+  let s:verbose = a:level
36
+endfunction
37
+
38
+function! s:Verbose(expr)
39
+  if exists('s:verbose') && s:verbose
40
+    echomsg a:expr
41
+  endif
42
+endfunction
43
+
44
+function! lh#command#debug(expr)
45
+  return eval(a:expr)
46
+endfunction
47
+
48
+"------------------------------------------------------------------------
49
+" ## Functions {{{1
50
+
51
+" Tool functions {{{2
52
+" Function: lh#command#Fargs2String(aList) {{{3
53
+" @param[in,out] aList list of params from <f-args>
54
+" @see tests/lh/test-Fargs2String.vim
55
+function! lh#command#Fargs2String(aList)
56
+  if empty(a:aList) | return '' | endif
57
+
58
+  let quote_char = a:aList[0][0] 
59
+  let res = a:aList[0]
60
+  call remove(a:aList, 0)
61
+  if quote_char !~ '["'."']"
62
+    return res
63
+  endif
64
+  " else
65
+  let end_string = '[^\\]\%(\\\\\)*'.quote_char.'$'
66
+  while !empty(a:aList) && res !~ end_string 
67
+    let res .= ' ' . a:aList[0]
68
+    call remove(a:aList, 0)
69
+  endwhile
70
+  return res
71
+endfunction
72
+
73
+"------------------------------------------------------------------------
74
+" ## Experimental Functions {{{1
75
+
76
+" Internal functions        {{{2
77
+" Function: s:SaveData({Data})                             {{{3
78
+" @param Data Command definition
79
+" Saves {Data} as s:Data{s:data_id++}. The definition will be used by
80
+" automatically generated commands.
81
+" @return s:data_id
82
+let s:data_id = 0
83
+function! s:SaveData(Data)
84
+  if has_key(a:Data, "command_id")
85
+    " Avoid data duplication
86
+    return a:Data.command_id
87
+  else
88
+    let s:Data{s:data_id} = a:Data
89
+    let id = s:data_id
90
+    let s:data_id += 1
91
+    let a:Data.command_id = id
92
+    return id
93
+  endif
94
+endfunction
95
+
96
+" BTWComplete(ArgLead, CmdLine, CursorPos):      Auto-complete {{{3
97
+function! lh#command#complete(ArgLead, CmdLine, CursorPos)
98
+  let tmp = substitute(a:CmdLine, '\s*\S*', 'Z', 'g')
99
+  let pos = strlen(tmp)
100
+  if 0
101
+    call confirm( "AL = ". a:ArgLead."\nCL = ". a:CmdLine."\nCP = ".a:CursorPos
102
+	  \ . "\ntmp = ".tmp."\npos = ".pos
103
+	  \, '&Ok', 1)
104
+  endif
105
+
106
+  if     2 == pos
107
+    " First argument: a command
108
+    return s:commands
109
+  elseif 3 == pos
110
+    " Second argument: first arg of the command
111
+    if     -1 != match(a:CmdLine, '^BTW\s\+echo')
112
+      return s:functions . "\n" . s:variables
113
+    elseif -1 != match(a:CmdLine, '^BTW\s\+\%(help\|?\)')
114
+    elseif -1 != match(a:CmdLine, '^BTW\s\+\%(set\|add\)\%(local\)\=')
115
+      " Adds a filter
116
+      " let files =         globpath(&rtp, 'compiler/BT-*')
117
+      " let files = files . globpath(&rtp, 'compiler/BT_*')
118
+      " let files = files . globpath(&rtp, 'compiler/BT/*')
119
+      let files = s:FindFilter('*')
120
+      let files = substitute(files,
121
+	    \ '\(^\|\n\).\{-}compiler[\\/]BTW[-_\\/]\(.\{-}\)\.vim\>\ze\%(\n\|$\)',
122
+	    \ '\1\2', 'g')
123
+      return files
124
+    elseif -1 != match(a:CmdLine, '^BTW\s\+remove\%(local\)\=')
125
+      " Removes a filter
126
+      return substitute(s:FiltersList(), ',', '\n', 'g')
127
+    endif
128
+  endif
129
+  " finally: unknown
130
+  echoerr 'BTW: unespected parameter ``'. a:ArgLead ."''"
131
+  return ''
132
+endfunction
133
+
134
+function! s:BTW(command, ...)
135
+  " todo: check a:0 > 1
136
+  if     'set'      == a:command | let g:BTW_build_tool = a:1
137
+    if exists('b:BTW_build_tool')
138
+      let b:BTW_build_tool = a:1
139
+    endif
140
+  elseif 'setlocal'     == a:command | let b:BTW_build_tool = a:1
141
+  elseif 'add'          == a:command | call s:AddFilter('g', a:1)
142
+  elseif 'addlocal'     == a:command | call s:AddFilter('b', a:1)
143
+    " if exists('b:BTW_filters_list') " ?????
144
+    " call s:AddFilter('b', a:1)
145
+    " endif
146
+  elseif 'remove'       == a:command | call s:RemoveFilter('g', a:1)
147
+  elseif 'removelocal'  == a:command | call s:RemoveFilter('b', a:1)
148
+  elseif 'rebuild'      == a:command " wait for s:ReconstructToolsChain()
149
+  elseif 'echo'         == a:command | exe "echo s:".a:1
150
+    " echo s:{a:f1} ## don't support «echo s:f('foo')»
151
+  elseif 'reloadPlugin' == a:command
152
+    let g:force_reload_BuildToolsWrapper = 1
153
+    let g:BTW_BTW_in_use = 1
154
+    exe 'so '.s:sfile
155
+    unlet g:force_reload_BuildToolsWrapper
156
+    unlet g:BTW_BTW_in_use
157
+    return
158
+  elseif a:command =~ '\%(help\|?\)'
159
+    call s:Usage()
160
+    return
161
+  endif
162
+  call s:ReconstructToolsChain()
163
+endfunction
164
+
165
+" ##############################################################
166
+" Public functions          {{{2
167
+
168
+function! s:FindSubcommand(definition, subcommand)
169
+  for arg in a:definition.arguments
170
+    if arg.name == a:subcommand
171
+      return arg
172
+    endif
173
+  endfor
174
+  throw "NF"
175
+endfunction
176
+
177
+function! s:execute_function(definition, params)
178
+    if len(a:params) < 1
179
+      throw "(lh#command) Not enough arguments"
180
+    endif
181
+  let l:Fn = a:definition.action
182
+  echo "calling ".string(l:Fn)
183
+  echo "with ".string(a:params)
184
+  " call remove(a:params, 0)
185
+  call l:Fn(a:params)
186
+endfunction
187
+
188
+function! s:execute_sub_commands(definition, params)
189
+  try
190
+    if len(a:params) < 1
191
+      throw "(lh#command) Not enough arguments"
192
+    endif
193
+    let subcommand = s:FindSubcommand(a:definition, a:params[0])
194
+    call remove(a:params, 0)
195
+    call s:int_execute(subcommand, a:params)
196
+  catch /NF.*/
197
+    throw "(lh#command) Unexpected subcommand `".a:params[0]."'."
198
+  endtry
199
+endfunction
200
+
201
+function! s:int_execute(definition, params)
202
+  echo "params=".string(a:params)
203
+  call s:execute_{a:definition.arg_type}(a:definition, a:params)
204
+endfunction
205
+
206
+function! s:execute(definition, ...)
207
+  try
208
+    let params = copy(a:000)
209
+    call s:int_execute(a:definition, params)
210
+  catch /(lh#command).*/
211
+    echoerr v:exception . " in `".a:definition.name.' '.join(a:000, ' ')."'"
212
+  endtry
213
+endfunction
214
+
215
+function! lh#command#new(definition)
216
+  let cmd_name = a:definition.name
217
+  " Save the definition as an internal script variable
218
+  let id = s:SaveData(a:definition)
219
+  exe "command! -nargs=* ".cmd_name." :call s:execute(s:Data".id.", <f-args>)"
220
+endfunction
221
+
222
+" Functions }}}1
223
+"------------------------------------------------------------------------
224
+let &cpo=s:cpo_save
225
+"=============================================================================
226
+" vim600: set fdm=marker:

+ 97
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/common.vim View File

@@ -0,0 +1,97 @@
1
+"=============================================================================
2
+" $Id: common.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/common.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	07th Oct 2006
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (08th Feb 2008)
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Some common functions for:
14
+" 	- displaying error messages
15
+" 	- checking dependencies
16
+" 
17
+"------------------------------------------------------------------------
18
+" Installation:	
19
+" 	Drop it into {rtp}/autoload/lh/
20
+" 	Vim 7+ required.
21
+" History:	
22
+"       v3.0.0
23
+"       - GPLv3
24
+" 	v2.1.1
25
+" 	- New function: lh#common#echomsg_multilines()
26
+" 	- lh#common#warning_msg() supports multilines messages
27
+"
28
+" 	v2.0.0:
29
+" 	- Code moved from other plugins
30
+" }}}1
31
+"=============================================================================
32
+
33
+
34
+"=============================================================================
35
+let s:cpo_save=&cpo
36
+set cpo&vim
37
+"------------------------------------------------------------------------
38
+" Functions {{{1
39
+
40
+" Function: lh#common#echomsg_multilines {{{2
41
+function! lh#common#echomsg_multilines(text)
42
+  let lines = split(a:text, "[\n\r]")
43
+  for line in lines
44
+    echomsg line
45
+  endfor
46
+endfunction
47
+function! lh#common#echomsgMultilines(text)
48
+  return lh#common#echomsg_multilines(a:text)
49
+endfunction
50
+
51
+" Function: lh#common#error_msg {{{2
52
+function! lh#common#error_msg(text)
53
+  if has('gui_running')
54
+    call confirm(a:text, '&Ok', '1', 'Error')
55
+  else
56
+    " echohl ErrorMsg
57
+    echoerr a:text
58
+    " echohl None
59
+  endif
60
+endfunction 
61
+function! lh#common#ErrorMsg(text)
62
+  return lh#common#error_msg(a:text)
63
+endfunction
64
+
65
+" Function: lh#common#warning_msg {{{2
66
+function! lh#common#warning_msg(text)
67
+  echohl WarningMsg
68
+  " echomsg a:text
69
+  call lh#common#echomsg_multilines(a:text)
70
+  echohl None
71
+endfunction 
72
+function! lh#common#WarningMsg(text)
73
+  return lh#common#warning_msg(a:text)
74
+endfunction
75
+
76
+" Dependencies {{{2
77
+function! lh#common#check_deps(Symbol, File, path, plugin) " {{{3
78
+  if !exists(a:Symbol)
79
+    exe "runtime ".a:path.a:File
80
+    if !exists(a:Symbol)
81
+      call lh#common#error_msg( a:plugin.': Requires <'.a:File.'>')
82
+      return 0
83
+    endif
84
+  endif
85
+  return 1
86
+endfunction
87
+
88
+function! lh#common#CheckDeps(Symbol, File, path, plugin) " {{{3
89
+  echomsg "lh#common#CheckDeps() is deprecated, use lh#common#check_deps() instead."
90
+  return lh#common#check_deps(a:Symbol, a:File, a:path, a:plugin)
91
+endfunction
92
+
93
+" Functions }}}1
94
+"------------------------------------------------------------------------
95
+let &cpo=s:cpo_save
96
+"=============================================================================
97
+" vim600: set fdm=marker:

+ 78
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/encoding.vim View File

@@ -0,0 +1,78 @@
1
+"=============================================================================
2
+" $Id: encoding.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/encoding.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	21st Feb 2008
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Defines functions that help managing various encodings
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	
17
+" 	Drop it into {rtp}/autoload/lh/
18
+" 	Vim 7+ required.
19
+" History:	
20
+"       v3.0.0:
21
+"       (*) GPLv3
22
+" 	v2.2.2:
23
+" 	(*) new mb_strings functions: strlen, strpart, at
24
+" 	v2.0.7:
25
+" 	(*) lh#encoding#Iconv() copied from map-tools
26
+" TODO:		«missing features»
27
+" }}}1
28
+"=============================================================================
29
+
30
+let s:cpo_save=&cpo
31
+set cpo&vim
32
+"------------------------------------------------------------------------
33
+" Exported functions {{{2
34
+" Function: lh#encoding#iconv(expr, from, to)  " {{{3
35
+" Unlike |iconv()|, this wrapper returns {expr} when we know no convertion can
36
+" be acheived.
37
+function! lh#encoding#iconv(expr, from, to)
38
+  " call Dfunc("s:ICONV(".a:expr.','.a:from.','.a:to.')')
39
+  if has('multi_byte') && 
40
+	\ ( has('iconv') || has('iconv/dyn') ||
41
+	\ ((a:from=~'latin1\|utf-8') && (a:to=~'latin1\|utf-8')))
42
+    " call confirm('encoding: '.&enc."\nto:".a:to, "&Ok", 1)
43
+    " call Dret("s:ICONV convert=".iconv(a:expr, a:from, a:to))
44
+    return iconv(a:expr,a:from,a:to)
45
+  else
46
+    " Cannot convert
47
+    " call Dret("s:ICONV  no convert=".a:expr)
48
+    return a:expr
49
+  endif
50
+endfunction
51
+
52
+
53
+" Function: lh#encoding#at(mb_string, i) " {{{3
54
+" @return i-th character in a mb_string
55
+" @parem mb_string multi-bytes string
56
+" @param i 0-indexed position
57
+function! lh#encoding#at(mb_string, i)
58
+  return matchstr(a:mb_string, '.', 0, a:i+1)
59
+endfunction
60
+
61
+" Function: lh#encoding#strpart(mb_string, pos, length) " {{{3
62
+" @return {length} extracted characters from {position} in multi-bytes string.
63
+" @parem mb_string multi-bytes string
64
+" @param p 0-indexed position
65
+" @param l length of the string to extract
66
+function! lh#encoding#strpart(mb_string, p, l)
67
+  return matchstr(a:mb_string, '.\{'.a:l.'}', 0, a:p+1)
68
+endfunction
69
+
70
+" Function: lh#encoding#strlen(mb_string) " {{{3
71
+" @return the length of the multi-bytes string.
72
+function! lh#encoding#strlen(mb_string)
73
+  return strlen(substitute(a:mb_string, '.', 'a', 'g'))
74
+endfunction
75
+"------------------------------------------------------------------------
76
+let &cpo=s:cpo_save
77
+"=============================================================================
78
+" vim600: set fdm=marker:

+ 78
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/env.vim View File

@@ -0,0 +1,78 @@
1
+"=============================================================================
2
+" $Id: env.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:         autoload/lh/env.vim                               {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      19th Jul 2010
10
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:
13
+"       Functions related to environment (variables)
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:
17
+"       Drop this file into {rtp}/autoload/lh
18
+"       Requires Vim7+
19
+" History:      
20
+" 	v2.2.1: First Version
21
+"       v3.0.0: GPLv3
22
+" TODO:         «missing features»
23
+" }}}1
24
+"=============================================================================
25
+
26
+let s:cpo_save=&cpo
27
+set cpo&vim
28
+"------------------------------------------------------------------------
29
+" ## Misc Functions     {{{1
30
+" # Version {{{2
31
+let s:k_version = 300
32
+function! lh#env#version()
33
+  return s:k_version
34
+endfunction
35
+
36
+" # Debug   {{{2
37
+let s:verbose = 0
38
+function! lh#env#verbose(...)
39
+  if a:0 > 0 | let s:verbose = a:1 | endif
40
+  return s:verbose
41
+endfunction
42
+
43
+function! s:Verbose(expr)
44
+  if s:verbose
45
+    echomsg a:expr
46
+  endif
47
+endfunction
48
+
49
+function! lh#env#debug(expr)
50
+  return eval(a:expr)
51
+endfunction
52
+
53
+
54
+"------------------------------------------------------------------------
55
+" ## Exported functions {{{1
56
+function! lh#env#expand_all(string)
57
+  let res = ''
58
+  let tail = a:string
59
+  while !empty(tail)
60
+    let [ all, head, var, tail; dummy ] = matchlist(tail, '\(.\{-}\)\%(${\(.\{-}\)}\)\=\(.*\)')
61
+    if empty(var)
62
+      let res .= tail
63
+      break
64
+    else
65
+      let res .= head
66
+      let val = eval('$'.var)
67
+      let res .= val
68
+    endif
69
+  endwhile
70
+  return res
71
+endfunction
72
+"------------------------------------------------------------------------
73
+" ## Internal functions {{{1
74
+
75
+"------------------------------------------------------------------------
76
+let &cpo=s:cpo_save
77
+"=============================================================================
78
+" vim600: set fdm=marker:

+ 70
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/event.vim View File

@@ -0,0 +1,70 @@
1
+"=============================================================================
2
+" $Id: event.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/event.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	15th Feb 2008
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Function to help manage vim |autocommand-events|
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:
17
+" 	Drop it into {rtp}/autoload/lh/
18
+" 	Vim 7+ required.
19
+" History:
20
+" 	v2.0.6: Creation
21
+"       v3.0.0: GPLv3
22
+" TODO:		
23
+" }}}1
24
+"=============================================================================
25
+
26
+let s:cpo_save=&cpo
27
+set cpo&vim
28
+
29
+"------------------------------------------------------------------------
30
+" ## Functions {{{1
31
+" # Debug {{{2
32
+function! lh#event#verbose(level)
33
+  let s:verbose = a:level
34
+endfunction
35
+
36
+function! s:Verbose(expr)
37
+  if exists('s:verbose') && s:verbose
38
+    echomsg a:expr
39
+  endif
40
+endfunction
41
+
42
+function! lh#event#debug(expr)
43
+  return eval(a:expr)
44
+endfunction
45
+
46
+"------------------------------------------------------------------------
47
+" # Event Registration {{{2
48
+function! s:RegisteredOnce(cmd, group)
49
+  " We can't delete the current augroup autocommand => increment a counter
50
+  if !exists('s:'.a:group) || s:{a:group} == 0 
51
+    let s:{a:group} = 1
52
+    exe a:cmd
53
+  endif
54
+endfunction
55
+
56
+function! lh#event#register_for_one_execution_at(event, cmd, group)
57
+  let group = a:group.'_once'
58
+  let s:{group} = 0
59
+  exe 'augroup '.group
60
+  au!
61
+  exe 'au '.a:event.' '.expand('%:p').' call s:RegisteredOnce('.string(a:cmd).','.string(group).')'
62
+  augroup END
63
+endfunction
64
+function! lh#event#RegisterForOneExecutionAt(event, cmd, group)
65
+  return lh#event#register_for_one_execution_at(a:event, a:cmd, a:group)
66
+endfunction
67
+"------------------------------------------------------------------------
68
+let &cpo=s:cpo_save
69
+"=============================================================================
70
+" vim600: set fdm=marker:

+ 120
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/float.vim View File

@@ -0,0 +1,120 @@
1
+"=============================================================================
2
+" $Id: float.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:         autoload/lh/float.vim                             {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      16th Nov 2010
10
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:
13
+"       Defines functions related to |expr-float| numbers
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:
17
+"       Drop this file into {rtp}/autoload/lh
18
+"       Requires Vim7+
19
+" History:     
20
+"       v2.0.0: first version
21
+"       v3.0.0: GPLv3
22
+" TODO:
23
+" }}}1
24
+"=============================================================================
25
+
26
+let s:cpo_save=&cpo
27
+set cpo&vim
28
+"------------------------------------------------------------------------
29
+" ## Misc Functions     {{{1
30
+" # Version {{{2
31
+let s:k_version = 300
32
+function! lh#float#version()
33
+  return s:k_version
34
+endfunction
35
+
36
+" # Debug   {{{2
37
+let s:verbose = 0
38
+function! lh#float#verbose(...)
39
+  if a:0 > 0 | let s:verbose = a:1 | endif
40
+  return s:verbose
41
+endfunction
42
+
43
+function! s:Verbose(expr)
44
+  if s:verbose
45
+    echomsg a:expr
46
+  endif
47
+endfunction
48
+
49
+function! lh#float#debug(expr)
50
+  return eval(a:expr)
51
+endfunction
52
+
53
+
54
+"------------------------------------------------------------------------
55
+" ## Exported functions {{{1
56
+
57
+" # lh#float#min(list) {{{2
58
+function! lh#float#min(list)
59
+  let am = lh#float#arg_min(a:list)
60
+  return a:list[am]
61
+endfunction
62
+
63
+function! lh#float#arg_min(list)
64
+  if empty(a:list) | return -1 | endif
65
+  let m = type(a:list[0]) == type(0.0) ? a:list[0] : str2float(a:list[0])
66
+  let p = 0
67
+  let i = 1
68
+  while i != len(a:list)
69
+    let e = a:list[i]
70
+    if type(e) != type(0.0) |
71
+      let v = str2float(e)
72
+    else
73
+      let v = e
74
+    endif
75
+    if v < m
76
+      let m = v
77
+      let p = i
78
+    endif
79
+    let i += 1
80
+  endwhile
81
+  return p
82
+endfunction
83
+
84
+
85
+" # lh#float#max(list) {{{2
86
+function! lh#float#max(list)
87
+  let am = lh#float#arg_max(a:list)
88
+  return a:list[am]
89
+endfunction
90
+
91
+function! lh#float#arg_max(list)
92
+  if empty(a:list) | return -1 | endif
93
+  let m = type(a:list[0]) == type(0.0) ? a:list[0] : str2float(a:list[0])
94
+  let p = 0
95
+  let i = 1
96
+  while i != len(a:list)
97
+    let e = a:list[i]
98
+    if type(e) != type(0.0) |
99
+      let v = str2float(e)
100
+    else
101
+      let v = e
102
+    endif
103
+    if v > m
104
+      let m = v
105
+      let p = i
106
+    endif
107
+    let i += 1
108
+  endwhile
109
+  return p
110
+endfunction
111
+
112
+
113
+
114
+"------------------------------------------------------------------------
115
+" ## Internal functions {{{1
116
+
117
+"------------------------------------------------------------------------
118
+let &cpo=s:cpo_save
119
+"=============================================================================
120
+" vim600: set fdm=marker:

+ 217
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/function.vim View File

@@ -0,0 +1,217 @@
1
+"=============================================================================
2
+" $Id: function.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/function.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	03rd Nov 2008
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Implements:
14
+" 	- lh#function#bind()
15
+" 	- lh#function#execute()
16
+" 	- lh#function#prepare()
17
+" 	- a binded function type
18
+" 
19
+"------------------------------------------------------------------------
20
+" Installation:	
21
+" 	Drop it into {rtp}/autoload/lh/
22
+" 	Vim 7+ required.
23
+" History:	
24
+"       v2.2.0: first implementation
25
+"       v3.0.0: GPLv3
26
+" TODO:		«missing features»
27
+" }}}1
28
+"=============================================================================
29
+
30
+let s:cpo_save=&cpo
31
+set cpo&vim
32
+"------------------------------------------------------------------------
33
+
34
+" ## Functions {{{1
35
+" # Debug {{{2
36
+function! lh#function#verbose(level)
37
+  let s:verbose = a:level
38
+endfunction
39
+
40
+function! s:Verbose(expr)
41
+  if exists('s:verbose') && s:verbose
42
+    echomsg a:expr
43
+  endif
44
+endfunction
45
+
46
+function! lh#function#debug(expr)
47
+  return eval(a:expr)
48
+endfunction
49
+
50
+" # Function: s:Join(arguments...) {{{2
51
+function! s:Join(args)
52
+  let res = ''
53
+  if len(a:args) > 0
54
+    let res = string(a:args[0])
55
+    let i = 1
56
+    while i != len(a:args)
57
+      let res.=','.string(a:args[i])
58
+      let i += 1
59
+    endwhile
60
+  endif
61
+  return res
62
+endfunction
63
+
64
+" # Function: s:DoBindList(arguments...) {{{2
65
+function! s:DoBindList(formal, real)
66
+  let args = []
67
+  for arg in a:formal
68
+    if type(arg)==type('string') && arg =~ '^v:\d\+_$'
69
+      let new = a:real[matchstr(arg, 'v:\zs\d\+\ze_')-1]
70
+    elseif type(arg)==type('string')
71
+      let new = eval(s:DoBindEvaluatedString(arg, a:real))
72
+    else
73
+      let new = arg
74
+    endif
75
+    call add(args, new)
76
+    unlet new
77
+    unlet arg
78
+  endfor
79
+  return args
80
+endfunction
81
+
82
+" # Function: s:DoBindString(arguments...) {{{2
83
+function! s:DoBindString(expr, real)
84
+  let expr = substitute(a:expr, '\<v:\(\d\+\)_\>', a:real.'[\1-1]', 'g')
85
+  return expr
86
+endfunction
87
+
88
+function! s:ToString(expr)
89
+  return  type(a:expr) != type('')
90
+	\ ? string(a:expr)
91
+	\ : (a:expr)
92
+endfunction
93
+
94
+function! s:DoBindEvaluatedString(expr, real)
95
+  let expr = a:expr
96
+  let p = 0
97
+  while 1
98
+    let p = match(expr, '\<v:\d\+_\>', p)
99
+    if -1 == p | break | endif
100
+    let e = matchend(expr, '\<v:\d\+_\>', p)
101
+    let n = eval(expr[p+2 : e-2])
102
+    " let new = (type(a:real[n-1])==type('') && a:real[n-1]=~ '\<v:\d\+_\>')
103
+	  " \ ? a:real[n-1]
104
+	  " \ : string(a:real[n-1])
105
+    let new = s:ToString(a:real[n-1])
106
+    " let new = string(a:real[n-1]) " -> bind_counpound vars
107
+    let expr = ((p>0) ? (expr[0:p-1]) : '') . new . expr[e : -1]
108
+    " echo expr
109
+    let p += len(new)
110
+    " silent! unlet new
111
+  endwhile
112
+
113
+  return expr
114
+endfunction
115
+
116
+" # Function: s:Execute(arguments...) {{{2
117
+function! s:Execute(args) dict
118
+  if type(self.function) == type(function('exists'))
119
+    let args = s:DoBindList(self.args, a:args)
120
+    " echomsg '##'.string(self.function).'('.join(args, ',').')'
121
+    let res = eval(string(self.function).'('.s:Join(args).')')
122
+  elseif type(self.function) == type('string')
123
+    let expr = s:DoBindString(self.function, 'a:args')
124
+    let res = eval(expr)
125
+  elseif type(self.function) == type({})
126
+    return self.function.execute(a:args)
127
+  else
128
+    throw "lh#functor#execute: unpected function type: ".type(self.function)
129
+  endif
130
+  return res
131
+endfunction
132
+
133
+" # Function: lh#function#prepare(function, arguments_list) {{{2
134
+function! lh#function#prepare(Fn, arguments_list)
135
+  if     type(a:Fn) == type(function('exists'))
136
+    let expr = string(a:Fn).'('.s:Join(a:arguments_list).')'
137
+    return expr
138
+  elseif type(a:Fn) == type('string')
139
+    if a:Fn =~ '^[a-zA-Z0-9_#]\+$'
140
+      let expr = string(function(a:Fn)).'('.s:Join(a:arguments_list).')'
141
+      return expr
142
+    else
143
+      let expr = s:DoBindString(a:Fn, 'a:000')
144
+      return expr
145
+    endif
146
+  else
147
+    throw "lh#function#prepare(): {Fn} argument of type ".type(a:Fn). " is unsupported"
148
+  endif
149
+endfunction
150
+
151
+" # Function: lh#function#execute(function, arguments...) {{{2
152
+function! lh#function#execute(Fn, ...)
153
+  if type(a:Fn) == type({}) && has_key(a:Fn, 'execute')
154
+    return a:Fn.execute(a:000)
155
+  else
156
+    let expr = lh#function#prepare(a:Fn, a:000)
157
+    return eval(expr)
158
+  endif
159
+endfunction
160
+
161
+" # Function: lh#function#bind(function, arguments...) {{{2
162
+function! lh#function#bind(Fn, ...)
163
+  let args = copy(a:000)
164
+  if type(a:Fn) == type('string') && a:Fn =~ '^[a-zA-Z0-9_#]\+$'
165
+	\ && exists('*'.a:Fn)
166
+    let Fn = function(a:Fn)
167
+  elseif type(a:Fn) == type({})
168
+    " echo string(a:Fn).'('.string(a:000).')'
169
+    " Rebinding another binded function
170
+    " TASSERT has_key(a:Fn, 'function')
171
+    " TASSERT has_key(a:Fn, 'execute')
172
+    " TASSERT has_key(a:Fn, 'args')
173
+    let Fn = a:Fn.function
174
+    let N = len(a:Fn.args)
175
+    if N != 0 " args to rebind
176
+      let i = 0
177
+      let t_args = [] " necessary to avoid type changes
178
+      while i != N
179
+	silent! unlet arg
180
+	let arg = a:Fn.args[i]
181
+	if arg =~ 'v:\d\+_$'
182
+	  let arg2 = eval(s:DoBindString(arg, string(args)))
183
+	  " echo arg."-(".string(args).")->".string(arg2)
184
+	  unlet arg
185
+	  let arg = arg2
186
+	  unlet arg2
187
+	endif
188
+	call add(t_args, arg)
189
+	let i += 1
190
+      endwhile
191
+      unlet a:Fn.args
192
+      let a:Fn.args = t_args
193
+    else " expression to fix
194
+      " echo Fn
195
+      " echo s:DoBindString(Fn, string(args))
196
+      " echo eval(string(s:DoBindString(Fn, string(args))))
197
+      let Fn = (s:DoBindEvaluatedString(Fn, args))
198
+    endif
199
+    let args = a:Fn.args
200
+  else
201
+    let Fn = a:Fn
202
+  endif
203
+
204
+  let binded_fn = {
205
+	\ 'function': Fn,
206
+	\ 'args':     args,
207
+	\ 'execute':  function('s:Execute')
208
+	\}
209
+  return binded_fn
210
+endfunction
211
+
212
+" }}1
213
+"------------------------------------------------------------------------
214
+let &cpo=s:cpo_save
215
+"=============================================================================
216
+" vim600: set fdm=marker:
217
+" Vim: let g:UTfiles='tests/lh/function.vim'

+ 179
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/graph/tsort.vim View File

@@ -0,0 +1,179 @@
1
+"=============================================================================
2
+" $Id: tsort.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/tsort.vim                        {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	21st Apr 2008
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	Library functions for Topological Sort
13
+" 
14
+"------------------------------------------------------------------------
15
+" 	Drop the file into {rtp}/autoload/lh/graph
16
+" History:	«history»
17
+" TODO:		«missing features»
18
+" }}}1
19
+"=============================================================================
20
+
21
+let s:cpo_save=&cpo
22
+set cpo&vim
23
+
24
+"------------------------------------------------------------------------
25
+" ## Debug {{{1
26
+function! lh#graph#tsort#verbose(level)
27
+  let s:verbose = a:level
28
+endfunction
29
+
30
+function! s:Verbose(expr)
31
+  if exists('s:verbose') && s:verbose
32
+    echomsg a:expr
33
+  endif
34
+endfunction
35
+
36
+function! lh#graph#tsort#debug(expr)
37
+  return eval(a:expr)
38
+endfunction
39
+
40
+"------------------------------------------------------------------------
41
+"## Helper functions                         {{{1
42
+"# s:Successors_fully_defined(node)          {{{2
43
+function! s:Successors_fully_defined(node) dict
44
+  if has_key(self.table, a:node)
45
+    return self.table[a:node]
46
+  else
47
+    return []
48
+  endif
49
+endfunction
50
+
51
+"# s:Successors_lazy(node)                   {{{2
52
+function! s:Successors_lazy(node) dict
53
+  if !has_key(self.table, a:node)
54
+    let nodes = self.fetch(a:node)
55
+    let self.table[a:node] = nodes
56
+    " if len(nodes) > 0
57
+      " let self.nb += 1
58
+    " endif
59
+    return nodes
60
+  else
61
+    return self.table[a:node]
62
+  endif
63
+endfunction
64
+
65
+"# s:PrepareDAG(dag)                         {{{2
66
+function! s:PrepareDAG(dag)
67
+  if type(a:dag) == type(function('has_key'))
68
+    let dag = { 
69
+	  \ 'successors': function('s:Successors_lazy'),
70
+	  \ 'fetch'     : a:dag,
71
+	  \ 'table' 	: {}
72
+	  \}
73
+  else
74
+    let dag = { 
75
+	  \ 'successors': function('s:Successors_fully_defined'),
76
+	  \ 'table' 	: deepcopy(a:dag)
77
+	  \}
78
+  endif
79
+  return dag
80
+endfunction
81
+
82
+"## Depth-first search (recursive)           {{{1
83
+" Do not detect cyclic graphs
84
+
85
+"# lh#graph#tsort#depth(dag, start_nodes)    {{{2
86
+function! lh#graph#tsort#depth(dag, start_nodes)
87
+  let dag = s:PrepareDAG(a:dag)
88
+  let results = []
89
+  let visited_nodes = { 'Visited':function('s:Visited')}
90
+  call s:RecursiveDTSort(dag, a:start_nodes, results, visited_nodes)
91
+  call reverse(results)
92
+  return results
93
+endfunction
94
+
95
+"# The real, recursive, T-Sort               {{{2
96
+"see boost.graph for a non recursive implementation
97
+function! s:RecursiveDTSort(dag, start_nodes, results, visited_nodes)
98
+  for node in a:start_nodes
99
+    let visited = a:visited_nodes.Visited(node)
100
+    if     visited == 1 | continue " done
101
+    elseif visited == 2 | throw "Tsort: cyclic graph detected: ".node
102
+    endif
103
+    let a:visited_nodes[node] = 2 " visiting
104
+    let succs = a:dag.successors(node)
105
+    try
106
+      call s:RecursiveDTSort(a:dag, succs, a:results, a:visited_nodes)
107
+    catch /Tsort:/
108
+      throw v:exception.'>'.node
109
+    endtry
110
+    let a:visited_nodes[node] = 1 " visited
111
+    call add(a:results, node)
112
+  endfor
113
+endfunction
114
+
115
+function! s:Visited(node) dict 
116
+  return has_key(self, a:node) ? self[a:node] : 0
117
+endfunction
118
+
119
+"## Breadth-first search (non recursive)     {{{1
120
+"# lh#graph#tsort#breadth(dag, start_nodes)  {{{2
121
+" warning: This implementation does not work with lazy dag, but only with fully
122
+" defined ones
123
+function! lh#graph#tsort#breadth(dag, start_nodes)
124
+  let result = []
125
+  let dag = s:PrepareDAG(a:dag)
126
+  let queue = deepcopy(a:start_nodes)
127
+
128
+  while len(queue) > 0
129
+    let node = remove(queue, 0)
130
+    " echomsg "result <- ".node
131
+    call add(result, node)
132
+    let successors = dag.successors(node)
133
+    while len(successors) > 0
134
+      let m = s:RemoveEdgeFrom(dag, node)
135
+      " echomsg "graph loose ".node."->".m
136
+      if !s:HasIncomingEgde(dag, m)
137
+	" echomsg "queue <- ".m
138
+        call add(queue, m)
139
+      endif
140
+    endwhile
141
+  endwhile
142
+  if !s:Empty(dag)
143
+    throw "Tsort: cyclic graph detected: "
144
+  endif
145
+  return result
146
+endfunction
147
+
148
+function! s:HasIncomingEgde(dag, node)
149
+  for node in keys(a:dag.table)
150
+    if type(a:dag.table[node]) != type([])
151
+      continue
152
+    endif
153
+    if index(a:dag.table[node], a:node) != -1
154
+      return 1
155
+    endif
156
+  endfor
157
+  return 0
158
+endfunction
159
+function! s:RemoveEdgeFrom(dag, node)
160
+  let successors = a:dag.successors(a:node)
161
+  if len(successors) > 0
162
+    let successor = remove(successors, 0)
163
+    if len(successors) == 0
164
+      " echomsg "finished with ->".a:node
165
+      call remove(a:dag.table, a:node)
166
+    endif
167
+    return successor
168
+  endif
169
+  throw "No more edges from ".a:node
170
+endfunction
171
+function! s:Empty(dag)
172
+  " echomsg "len="len(a:dag.table)
173
+  return len(a:dag.table) == 0
174
+endfunction
175
+" }}}1
176
+"------------------------------------------------------------------------
177
+let &cpo=s:cpo_save
178
+"=============================================================================
179
+" vim600: set fdm=marker

+ 95
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/icomplete.vim View File

@@ -0,0 +1,95 @@
1
+"=============================================================================
2
+" $Id$
3
+" File:         autoload/lh/icomplete.vim                         {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      03rd Jan 2011
10
+" Last Update:  $Date$
11
+"------------------------------------------------------------------------
12
+" Description:
13
+"       Helpers functions to build |ins-completion-menu|
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:
17
+"       Drop this file into {rtp}/autoload/lh
18
+"       Requires Vim7+
19
+" History:
20
+"       v3.0.0: GPLv3
21
+" 	v2.2.4: first version
22
+" TODO:
23
+" 	- We are not able to detect the end of the completion mode. As a
24
+" 	consequence we can't prevent c/for<space> to trigger an abbreviation
25
+" 	instead of the right template file.
26
+" 	In an ideal world, there would exist an event post |complete()|
27
+" }}}1
28
+"=============================================================================
29
+
30
+let s:cpo_save=&cpo
31
+set cpo&vim
32
+"------------------------------------------------------------------------
33
+" ## Misc Functions     {{{1
34
+" # Version {{{2
35
+let s:k_version = 300
36
+function! lh#icomplete#version()
37
+  return s:k_version
38
+endfunction
39
+
40
+" # Debug   {{{2
41
+let s:verbose = 0
42
+function! lh#icomplete#verbose(...)
43
+  if a:0 > 0 | let s:verbose = a:1 | endif
44
+  return s:verbose
45
+endfunction
46
+
47
+function! s:Verbose(expr)
48
+  if s:verbose
49
+    echomsg a:expr
50
+  endif
51
+endfunction
52
+
53
+function! lh#icomplete#debug(expr)
54
+  return eval(a:expr)
55
+endfunction
56
+
57
+
58
+"------------------------------------------------------------------------
59
+" ## Exported functions {{{1
60
+" Function: lh#icomplete#run(startcol, matches, Hook) {{{2
61
+function! lh#icomplete#run(startcol, matches, Hook)
62
+  call lh#icomplete#_register_hook(a:Hook)
63
+  call complete(a:startcol, a:matches)
64
+  return ''
65
+endfunction
66
+
67
+"------------------------------------------------------------------------
68
+" ## Internal functions {{{1
69
+" Function: lh#icomplete#_clear_key_bindings() {{{2
70
+function! lh#icomplete#_clear_key_bindings()
71
+  iunmap <cr>
72
+  iunmap <c-y>
73
+  iunmap <esc>
74
+  " iunmap <space>
75
+  " iunmap <tab>
76
+endfunction
77
+
78
+" Function: lh#icomplete#_register_hook(Hook) {{{2
79
+function! lh#icomplete#_register_hook(Hook)
80
+  exe 'inoremap <silent> <cr> <cr><c-\><c-n>:call' .a:Hook . '()<cr>'
81
+  exe 'inoremap <silent> <c-y> <c-y><c-\><c-n>:call' .a:Hook . '()<cr>'
82
+  " <c-o><Nop> doesn't work as expected... 
83
+  " To stay in INSERT-mode:
84
+  " inoremap <silent> <esc> <c-e><c-o>:<cr>
85
+  " To return into NORMAL-mode:
86
+  inoremap <silent> <esc> <c-e><esc>
87
+
88
+  call lh#event#register_for_one_execution_at('InsertLeave',
89
+	\ ':call lh#icomplete#_clear_key_bindings()', 'CompleteGroup')
90
+endfunction
91
+
92
+"------------------------------------------------------------------------
93
+let &cpo=s:cpo_save
94
+"=============================================================================
95
+" vim600: set fdm=marker:

+ 376
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/list.vim View File

@@ -0,0 +1,376 @@
1
+"=============================================================================
2
+" $Id: list.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:         autoload/lh/list.vim                                      {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"               <URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      17th Apr 2007
10
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (17th Apr 2007)
11
+"------------------------------------------------------------------------
12
+" Description:  
13
+"       Defines functions related to |Lists|
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation: 
17
+"       Drop it into {rtp}/autoload/lh/
18
+"       Vim 7+ required.
19
+" History:      
20
+"       v3.0.0:
21
+"       (*) GPLv3
22
+"       v2.2.2:
23
+"       (*) new functions: lh#list#remove(), lh#list#matches(),
24
+"           lh#list#not_found().
25
+"       v2.2.1:
26
+"       (*) use :unlet in :for loop to support heterogeneous lists
27
+"       (*) binary search algorithms (upper_bound, lower_bound, equal_range)
28
+"       v2.2.0:
29
+"       (*) new functions: lh#list#accumulate, lh#list#transform,
30
+"           lh#list#transform_if, lh#list#find_if, lh#list#copy_if,
31
+"           lh#list#subset, lh#list#intersect
32
+"       (*) the functions are compatible with lh#function functors
33
+"       v2.1.1: 
34
+"       (*) unique_sort
35
+"       v2.0.7:
36
+"       (*) Bug fix: lh#list#Match()
37
+"       v2.0.6:
38
+"       (*) lh#list#Find_if() supports search predicate, and start index
39
+"       (*) lh#list#Match() supports start index
40
+"       v2.0.0:
41
+" TODO:         «missing features»
42
+" }}}1
43
+"=============================================================================
44
+
45
+
46
+"=============================================================================
47
+let s:cpo_save=&cpo
48
+set cpo&vim
49
+
50
+"------------------------------------------------------------------------
51
+" ## Functions {{{1
52
+" # Debug {{{2
53
+function! lh#list#verbose(level)
54
+  let s:verbose = a:level
55
+endfunction
56
+
57
+function! s:Verbose(expr)
58
+  if exists('s:verbose') && s:verbose
59
+    echomsg a:expr
60
+  endif
61
+endfunction
62
+
63
+function! lh#list#debug(expr)
64
+  return eval(a:expr)
65
+endfunction
66
+
67
+"------------------------------------------------------------------------
68
+" # Public {{{2
69
+" Function: lh#list#Transform(input, output, action) {{{3
70
+" deprecated version
71
+function! lh#list#Transform(input, output, action)
72
+  let new = map(copy(a:input), a:action)
73
+  let res = extend(a:output,new)
74
+  return res
75
+
76
+  for element in a:input
77
+    let action = substitute(a:action, 'v:val','element', 'g')
78
+    let res = eval(action)
79
+    call add(a:output, res)
80
+    unlet element " for heterogeneous lists
81
+  endfor
82
+  return a:output
83
+endfunction
84
+
85
+function! lh#list#transform(input, output, action)
86
+  for element in a:input
87
+    let res = lh#function#execute(a:action, element)
88
+    call add(a:output, res)
89
+    unlet element " for heterogeneous lists
90
+  endfor
91
+  return a:output
92
+endfunction
93
+
94
+function! lh#list#transform_if(input, output, action, predicate)
95
+  for element in a:input
96
+    if lh#function#execute(a:predicate, element)
97
+      let res = lh#function#execute(a:action, element)
98
+      call add(a:output, res)
99
+    endif
100
+    unlet element " for heterogeneous lists
101
+  endfor
102
+  return a:output
103
+endfunction
104
+
105
+function! lh#list#copy_if(input, output, predicate)
106
+  for element in a:input
107
+    if lh#function#execute(a:predicate, element)
108
+      call add(a:output, element)
109
+    endif
110
+    unlet element " for heterogeneous lists
111
+  endfor
112
+  return a:output
113
+endfunction
114
+
115
+function! lh#list#accumulate(input, transformation, accumulator)
116
+  let transformed = lh#list#transform(a:input, [], a:transformation)
117
+  let res = lh#function#execute(a:accumulator, transformed)
118
+  return res
119
+endfunction
120
+
121
+" Function: lh#list#match(list, to_be_matched [, idx]) {{{3
122
+function! lh#list#match(list, to_be_matched, ...)
123
+  let idx = (a:0>0) ? a:1 : 0
124
+  while idx < len(a:list)
125
+    if match(a:list[idx], a:to_be_matched) != -1
126
+      return idx
127
+    endif
128
+    let idx += 1
129
+  endwhile
130
+  return -1
131
+endfunction
132
+function! lh#list#Match(list, to_be_matched, ...)
133
+  let idx = (a:0>0) ? a:1 : 0
134
+  return lh#list#match(a:list, a:to_be_matched, idx)
135
+endfunction
136
+
137
+" Function: lh#list#matches(list, to_be_matched [,idx]) {{{3
138
+" Return the list of indices that match {to_be_matched}
139
+function! lh#list#matches(list, to_be_matched, ...)
140
+  let res = []
141
+  let idx = (a:0>0) ? a:1 : 0
142
+  while idx < len(a:list)
143
+    if match(a:list[idx], a:to_be_matched) != -1
144
+      let res += [idx]
145
+    endif
146
+    let idx += 1
147
+  endwhile
148
+  return res
149
+endfunction
150
+
151
+" Function: lh#list#Find_if(list, predicate [, predicate-arguments] [, start-pos]) {{{3
152
+function! lh#list#Find_if(list, predicate, ...)
153
+  " Parameters
154
+  let idx = 0
155
+  let args = []
156
+  if a:0 == 2
157
+    let idx = a:2
158
+    let args = a:1
159
+  elseif a:0 == 1
160
+    if type(a:1) == type([])
161
+      let args = a:1
162
+    elseif type(a:1) == type(42)
163
+      let idx = a:1
164
+    else
165
+      throw "lh#list#Find_if: unexpected argument type"
166
+    endif
167
+  elseif a:0 != 0
168
+      throw "lh#list#Find_if: unexpected number of arguments: lh#list#Find_if(list, predicate [, predicate-arguments] [, start-pos])"
169
+  endif
170
+
171
+  " The search loop
172
+  while idx != len(a:list)
173
+    let predicate = substitute(a:predicate, 'v:val', 'a:list['.idx.']', 'g')
174
+    let predicate = substitute(predicate, 'v:\(\d\+\)_', 'args[\1-1]', 'g')
175
+    let res = eval(predicate)
176
+    " echomsg string(predicate) . " --> " . res
177
+    if res | return idx | endif
178
+    let idx += 1
179
+  endwhile
180
+  return -1
181
+endfunction
182
+
183
+" Function: lh#list#find_if(list, predicate [, predicate-arguments] [, start-pos]) {{{3
184
+function! lh#list#find_if(list, predicate, ...)
185
+  " Parameters
186
+  let idx = 0
187
+  let args = []
188
+  if a:0 == 1
189
+    let idx = a:1
190
+  elseif a:0 != 0
191
+      throw "lh#list#find_if: unexpected number of arguments: lh#list#find_if(list, predicate [, start-pos])"
192
+  endif
193
+
194
+  " The search loop
195
+  while idx != len(a:list)
196
+    " let predicate = substitute(a:predicate, 'v:val', 'a:list['.idx.']', 'g')
197
+    let res = lh#function#execute(a:predicate, a:list[idx])
198
+    if res | return idx | endif
199
+    let idx += 1
200
+  endwhile
201
+  return -1
202
+endfunction
203
+
204
+" Function: lh#list#lower_bound(sorted_list, value  [, first[, last]]) {{{3
205
+function! lh#list#lower_bound(list, val, ...)
206
+  let first = 0
207
+  let last = len(a:list)
208
+  if a:0 >= 1     | let first = a:1
209
+  elseif a:0 >= 2 | let last = a:2
210
+  elseif a:0 > 2
211
+      throw "lh#list#lower_bound: unexpected number of arguments: lh#list#lower_bound(sorted_list, value  [, first[, last]])"
212
+  endif
213
+
214
+  let len = last - first
215
+
216
+  while len > 0
217
+    let half = len / 2
218
+    let middle = first + half
219
+    if a:list[middle] < a:val
220
+      let first = middle + 1
221
+      let len -= half + 1
222
+    else
223
+      let len = half
224
+    endif
225
+  endwhile
226
+  return first
227
+endfunction
228
+
229
+" Function: lh#list#upper_bound(sorted_list, value  [, first[, last]]) {{{3
230
+function! lh#list#upper_bound(list, val, ...)
231
+  let first = 0
232
+  let last = len(a:list)
233
+  if a:0 >= 1     | let first = a:1
234
+  elseif a:0 >= 2 | let last = a:2
235
+  elseif a:0 > 2
236
+      throw "lh#list#upper_bound: unexpected number of arguments: lh#list#upper_bound(sorted_list, value  [, first[, last]])"
237
+  endif
238
+
239
+  let len = last - first
240
+
241
+  while len > 0
242
+    let half = len / 2
243
+    let middle = first + half
244
+    if a:val < a:list[middle]
245
+      let len = half
246
+    else
247
+      let first = middle + 1
248
+      let len -= half + 1
249
+    endif
250
+  endwhile
251
+  return first
252
+endfunction
253
+
254
+" Function: lh#list#equal_range(sorted_list, value  [, first[, last]]) {{{3
255
+" @return [f, l], where
256
+"   f : First position where {value} could be inserted
257
+"   l : Last position where {value} could be inserted
258
+function! lh#list#equal_range(list, val, ...)
259
+  let first = 0
260
+  let last = len(a:list)
261
+
262
+  " Parameters
263
+  if a:0 >= 1     | let first = a:1
264
+  elseif a:0 >= 2 | let last  = a:2
265
+  elseif a:0 > 2
266
+      throw "lh#list#equal_range: unexpected number of arguments: lh#list#equal_range(sorted_list, value  [, first[, last]])"
267
+  endif
268
+
269
+  " The search loop ( == STLPort's equal_range)
270
+
271
+  let len = last - first
272
+  while len > 0
273
+    let half = len / 2
274
+    let middle = first + half
275
+    if a:list[middle] < a:val
276
+      let first = middle + 1
277
+      let len -= half + 1
278
+    elseif a:val < a:list[middle]
279
+      let len = half
280
+    else
281
+      let left = lh#list#lower_bound(a:list, a:val, first, middle)
282
+      let right = lh#list#upper_bound(a:list, a:val, middle+1, first+len)
283
+      return [left, right]
284
+    endif
285
+
286
+    " let predicate = substitute(a:predicate, 'v:val', 'a:list['.idx.']', 'g')
287
+    " let res = lh#function#execute(a:predicate, a:list[idx])
288
+  endwhile
289
+  return [first, first]
290
+endfunction
291
+
292
+" Function: lh#list#not_found(range) {{{3
293
+" @return whether the range returned from equal_range is empty (i.e. element not fount)
294
+function! lh#list#not_found(range)
295
+  return a:range[0] == a:range[1]
296
+endfunction
297
+
298
+" Function: lh#list#unique_sort(list [, func]) {{{3
299
+" See also http://vim.wikia.com/wiki/Unique_sorting
300
+"
301
+" Works like sort(), optionally taking in a comparator (just like the
302
+" original), except that duplicate entries will be removed.
303
+" todo: support another argument that act as an equality predicate
304
+function! lh#list#unique_sort(list, ...)
305
+  let dictionary = {}
306
+  for i in a:list
307
+    let dictionary[string(i)] = i
308
+  endfor
309
+  let result = []
310
+  " echo join(values(dictionary),"\n")
311
+  if ( exists( 'a:1' ) )
312
+    let result = sort( values( dictionary ), a:1 )
313
+  else
314
+    let result = sort( values( dictionary ) )
315
+  endif
316
+  return result
317
+endfunction
318
+
319
+function! lh#list#unique_sort2(list, ...)
320
+  let list = copy(a:list)
321
+  if ( exists( 'a:1' ) )
322
+    call sort(list, a:1 )
323
+  else
324
+    call sort(list)
325
+  endif
326
+  if len(list) <= 1 | return list | endif
327
+  let result = [ list[0] ]
328
+  let last = list[0]
329
+  let i = 1
330
+  while i < len(list)
331
+    if last != list[i]
332
+      let last = list[i]
333
+      call add(result, last)
334
+    endif
335
+    let i += 1
336
+  endwhile
337
+  return result
338
+endfunction
339
+
340
+" Function: lh#list#subset(list, indices) {{{3
341
+function! lh#list#subset(list, indices)
342
+  let result=[]
343
+  for e in a:indices
344
+    call add(result, a:list[e])
345
+  endfor
346
+  return result
347
+endfunction
348
+
349
+" Function: lh#list#remove(list, indices) {{{3
350
+function! lh#list#remove(list, indices)
351
+  " assert(is_sorted(indices))
352
+  let idx = reverse(copy(a:indices))
353
+  for i in idx
354
+    call remove(a:list, i)
355
+  endfor
356
+  return a:list
357
+endfunction
358
+
359
+" Function: lh#list#intersect(list1, list2) {{{3
360
+function! lh#list#intersect(list1, list2)
361
+  let result = copy(a:list1)
362
+  call filter(result, 'index(a:list2, v:val) >= 0')
363
+  return result
364
+
365
+  for e in a:list1
366
+    if index(a:list2, e) > 0
367
+      call result(result, e)
368
+    endif
369
+  endfor
370
+endfunction
371
+
372
+" Functions }}}1
373
+"------------------------------------------------------------------------
374
+let &cpo=s:cpo_save
375
+"=============================================================================
376
+" vim600: set fdm=marker:

+ 477
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/menu.vim View File

@@ -0,0 +1,477 @@
1
+"=============================================================================
2
+" $Id: menu.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/menu.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	13th Oct 2006
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (07th Dec 2010)
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Defines the global function lh#menu#def_menu
14
+" 	Aimed at (ft)plugin writers.
15
+" 
16
+"------------------------------------------------------------------------
17
+" Installation:	
18
+" 	Drop this file into {rtp}/autoload/lh/
19
+" 	Requires Vim 7+
20
+" History:	
21
+" 	v2.0.0:	Moving to vim7
22
+" 	v2.0.1:	:Toggle echoes the new value
23
+" 	v2.2.0: Support environment variables
24
+" 	        Only one :Toggle command is defined.
25
+" 	v2.2.3: :Toggle can directly set the final value
26
+" 	       (prefer this way of proceeding to update the menu to the new
27
+" 	       value)
28
+" 	       :Toggle suports auto-completion on possible values
29
+" 	v2.2.6: Toggle menus are silent, but not the actions executed
30
+"       v3.0.0: GPLv3
31
+" TODO:		
32
+" 	* Should the argument to :Toggle be simplified to use the variable name
33
+" 	instead ? May be a banged :Toggle! could work on the real variable
34
+" 	name, and on the real value.
35
+" 	* show all possible values in a sub menu (on demand)
36
+" }}}1
37
+"=============================================================================
38
+
39
+
40
+"=============================================================================
41
+let s:cpo_save=&cpo
42
+set cpo&vim
43
+"------------------------------------------------------------------------
44
+" ## Internal Variables {{{1
45
+let s:k_Toggle_cmd = 'Toggle'
46
+if !exists('s:toggle_commands')
47
+  let s:toggle_commands = {}
48
+endif
49
+
50
+"------------------------------------------------------------------------
51
+" ## Functions {{{1
52
+" # Version {{{2
53
+let s:k_version = 300
54
+function! lh#menu#version()
55
+  return s:k_version
56
+endfunction
57
+
58
+" # Debug   {{{2
59
+let s:verbose = 0
60
+function! lh#menu#verbose(...)
61
+  if a:0 > 0 | let s:verbose = a:1 | endif
62
+  return s:verbose
63
+endfunction
64
+
65
+function! s:Verbose(expr)
66
+  if exists('s:verbose') && s:verbose
67
+    echomsg a:expr
68
+  endif
69
+endfunction
70
+
71
+function! lh#menu#debug(expr)
72
+  return eval(a:expr)
73
+endfunction
74
+
75
+
76
+"------------------------------------------------------------------------
77
+" # Common stuff       {{{2
78
+" Function: lh#menu#text({text})                             {{{3
79
+" @return a text to be used in menus where "\" and spaces have been escaped.
80
+function! lh#menu#text(text)
81
+  return escape(a:text, '\ ')
82
+endfunction
83
+
84
+" # Toggling menu item {{{2
85
+" Function: s:Fetch({Data},{key})                          {{{3
86
+" @param[in] Data Menu-item definition
87
+" @param[in] key  Table table from which the result will be fetched
88
+" @return the current value, or text, whose index is Data.idx_crt_value.
89
+function! s:Fetch(Data, key)
90
+  let len = len(a:Data[a:key])
91
+  if a:Data.idx_crt_value >= len | let a:Data.idx_crt_value = 0 | endif
92
+  let value = a:Data[a:key][a:Data.idx_crt_value]
93
+  return value
94
+endfunction
95
+
96
+" Function: s:Search({Data},{value})                       {{{3
97
+" Searches for the index of {value} in {Data.values} list. Return 0 if not
98
+" found.
99
+function! s:Search(Data, value)
100
+  let idx = index(a:Data.values, a:value)
101
+  " echo a:Data.variable . "[".idx."] == " . a:value
102
+  return idx > 0 ? idx : 0 " default is first element
103
+endfunction
104
+
105
+" Function: s:SearchText({Data},{value})                   {{{3
106
+" Searches for the index of {value} in {Data.values/text} list.
107
+" Returns -1 if not found.
108
+function! s:SearchText(Data, value)
109
+  let labels_key = s:MenuKey(a:Data)
110
+  let list = a:Data[labels_key]
111
+  let idx = index(list, a:value)
112
+  return idx
113
+endfunction
114
+
115
+" Function: s:Set({Data})                                  {{{3
116
+" @param[in,out] Data Menu item definition
117
+"
118
+" Sets the global variable associated to the menu item according to the item's
119
+" current value.
120
+function! s:Set(Data)
121
+  let value = a:Data.values[a:Data.idx_crt_value]
122
+  let variable = a:Data.variable
123
+  if variable[0] == '$' " environment variabmes
124
+    exe "let ".variable." = ".string(value)
125
+  else
126
+    let g:{variable} = value
127
+  endif
128
+  if has_key(a:Data, "actions")
129
+    let l:Action = a:Data.actions[a:Data.idx_crt_value]
130
+    if type(l:Action) == type(function('tr'))
131
+      call l:Action()
132
+    else
133
+      exe l:Action
134
+    endif
135
+  endif
136
+  if has_key(a:Data, "hook")
137
+    let l:Action = a:Data.hook
138
+    if type(l:Action) == type(function('tr'))
139
+      call a:Data.hook()
140
+    else
141
+      exe l:Action
142
+    endif
143
+  endif
144
+  return value
145
+endfunction
146
+
147
+" Function: s:MenuKey({Data})                              {{{3
148
+" @return the table name from which the current value name (to dsplay in the
149
+" menu) must be fetched. 
150
+" Priority is given to the optional "texts" table over the madatory "values" table.
151
+function! s:MenuKey(Data)
152
+  if has_key(a:Data, "texts")
153
+    let menu_id = "texts"
154
+  else
155
+    let menu_id = "values"
156
+  endif
157
+  return menu_id
158
+endfunction
159
+
160
+" Function: s:SetTextValue({Data},{TextValue})             {{{3
161
+" Force the value of the variable to the one associated to the {TextValue}
162
+" The menu, and the variable are updated in consequence.
163
+function! s:SetTextValue(Data, text)
164
+  " Where the texts for values must be fetched
165
+  let labels_key = s:MenuKey(a:Data)
166
+  " Fetch the old current value 
167
+  let old = s:Fetch(a:Data, labels_key)
168
+  let new_idx = s:SearchText(a:Data, a:text)
169
+  if -1 == new_idx
170
+    throw "toggle-menu: unsupported value for {".(a:Data.variable)."}"
171
+  endif
172
+  if a:Data.idx_crt_value == new_idx
173
+    " value unchanged => abort
174
+    return 
175
+  endif
176
+
177
+  " Remove the entry from the menu
178
+  call s:ClearMenu(a:Data.menu, old)
179
+
180
+  " Cycle/increment the current value
181
+  let a:Data.idx_crt_value = new_idx
182
+  " Fetch it
183
+  let new = s:Fetch(a:Data,labels_key)
184
+  " Add the updated entry in the menu
185
+  call s:UpdateMenu(a:Data.menu, new, a:Data.command)
186
+  " Update the binded global variable
187
+  let value = s:Set(a:Data)
188
+  echo a:Data.variable.'='.value
189
+endfunction
190
+
191
+" Function: s:NextValue({Data})                            {{{3
192
+" Change the value of the variable to the next in the list of value.
193
+" The menu, and the variable are updated in consequence.
194
+function! s:NextValue(Data)
195
+  " Where the texts for values must be fetched
196
+  let labels_key = s:MenuKey(a:Data)
197
+  " Fetch the old current value 
198
+  let old = s:Fetch(a:Data, labels_key)
199
+
200
+  " Remove the entry from the menu
201
+  call s:ClearMenu(a:Data.menu, old)
202
+
203
+  " Cycle/increment the current value
204
+  let a:Data.idx_crt_value += 1
205
+  " Fetch it
206
+  let new = s:Fetch(a:Data,labels_key)
207
+  " Add the updated entry in the menu
208
+  call s:UpdateMenu(a:Data.menu, new, a:Data.command)
209
+  " Update the binded global variable
210
+  let value = s:Set(a:Data)
211
+  echo a:Data.variable.'='.value
212
+endfunction
213
+
214
+" Function: s:ClearMenu({Menu}, {text})                    {{{3
215
+" Removes a menu item
216
+"
217
+" @param[in] Menu.priority Priority of the new menu-item
218
+" @param[in] Menu.name     Name of the new menu-item
219
+" @param[in] text          Text of the previous value of the variable binded
220
+function! s:ClearMenu(Menu, text)
221
+  if has('gui_running')
222
+    let name = substitute(a:Menu.name, '&', '', 'g')
223
+    let cmd = 'unmenu '.lh#menu#text(name.'<tab>('.a:text.')')
224
+    silent! exe cmd
225
+  endif
226
+endfunction
227
+
228
+" Function: s:UpdateMenu({Menu}, {text}, {command})        {{{3
229
+" Adds a new menu item, with the text associated to the current value in
230
+" braces.
231
+"
232
+" @param[in] Menu.priority Priority of the new menu-item
233
+" @param[in] Menu.name     Name of the new menu-item
234
+" @param[in] text          Text of the current value of the variable binded to
235
+"                          the menu-item
236
+" @param[in] command       Toggle command to execute when the menu-item is selected
237
+function! s:UpdateMenu(Menu, text, command)
238
+  if has('gui_running')
239
+    let cmd = 'nnoremenu <silent> '.a:Menu.priority.' '.
240
+	  \ lh#menu#text(a:Menu.name.'<tab>('.a:text.')').
241
+	  \ ' :'.s:k_Toggle_cmd.' '.a:command."\<cr>"
242
+    silent! exe cmd
243
+  endif
244
+endfunction
245
+
246
+" Function: s:SaveData({Data})                             {{{3
247
+" @param Data Menu-item definition
248
+" Saves {Data} as s:Data{s:data_id++}. The definition will be used by
249
+" automatically generated commands.
250
+" @return s:data_id
251
+let s:data_id = 0
252
+function! s:SaveData(Data)
253
+  let s:Data{s:data_id} = a:Data
254
+  let id = s:data_id
255
+  let s:data_id += 1
256
+  return id
257
+endfunction
258
+
259
+" Function: lh#menu#def_toggle_item({Data})                  {{{3
260
+" @param Data.idx_crt_value
261
+" @param Data.definitions == [ {value:, menutext: } ]
262
+" @param Data.menu        == { name:, position: }
263
+"
264
+" Sets a toggle-able menu-item defined by {Data}.
265
+"
266
+function! lh#menu#def_toggle_item(Data)
267
+  " Save the menu data as an internal script variable
268
+  let id = s:SaveData(a:Data)
269
+
270
+  " If the index of the current value hasn't been set, fetch it from the
271
+  " associated variable
272
+  if !has_key(a:Data, "idx_crt_value")
273
+    " Fetch the value of the associated variable
274
+    let value = lh#option#get(a:Data.variable, 0, 'g')
275
+    " echo a:Data.variable . " <- " . value
276
+    " Update the index of the current value
277
+    let a:Data.idx_crt_value  = s:Search(a:Data, value)
278
+  endif
279
+
280
+  " Name of the auto-matically generated toggle command
281
+  let cmdName = substitute(a:Data.menu.name, '[^a-zA-Z_]', '', 'g')
282
+  " Lazy definition of the command
283
+  if 2 != exists(':'.s:k_Toggle_cmd) 
284
+    exe 'command! -nargs=+ -complete=custom,lh#menu#_toggle_complete '
285
+	  \ . s:k_Toggle_cmd . ' :call s:Toggle(<f-args>)'
286
+  endif
287
+  " silent exe 'command! -nargs=0 '.cmdName.' :call s:NextValue(s:Data'.id.')'
288
+  let s:toggle_commands[cmdName] = eval('s:Data'.id)
289
+  let a:Data["command"] = cmdName
290
+
291
+  " Add the menu entry according to the current value
292
+  call s:UpdateMenu(a:Data.menu, s:Fetch(a:Data, s:MenuKey(a:Data)), cmdName)
293
+  " Update the associated global variable
294
+  call s:Set(a:Data)
295
+endfunction
296
+
297
+
298
+"------------------------------------------------------------------------
299
+function! s:Toggle(cmdName, ...)
300
+  if !has_key(s:toggle_commands, a:cmdName)
301
+    throw "toggle-menu: unknown toggable variable ".a:cmdName
302
+  endif
303
+  let data = s:toggle_commands[a:cmdName]
304
+  if a:0 > 0
305
+    call s:SetTextValue(data, a:1)
306
+  else
307
+    call s:NextValue(data)
308
+  endif
309
+endfunction
310
+
311
+function! lh#menu#_toggle_complete(ArgLead, CmdLine, CursorPos)
312
+  let cmdline = split(a:CmdLine)
313
+  " echomsg "cmd line: " . string(cmdline)." # ". (a:CmdLine =~ ' $')
314
+  let nb_args = len(cmdline)
315
+  if (a:CmdLine !~ ' $')
316
+    let nb_args -= 1
317
+  endif
318
+  " echomsg "nb args: ". nb_args
319
+  if nb_args < 2 
320
+    return join(keys(s:toggle_commands),"\n")
321
+  elseif nb_args == 2
322
+    let variable = cmdline[1]
323
+    if !has_key(s:toggle_commands, variable)
324
+      throw "toggle-menu: unknown toggable variable ".variable
325
+    endif
326
+    let data = s:toggle_commands[variable]
327
+    let labels_key = s:MenuKey(data)
328
+    " echomsg "keys: ".string(data[labels_key])
329
+    return join(data[labels_key], "\n")
330
+  else
331
+    return ''
332
+  endif
333
+endfunction
334
+
335
+"------------------------------------------------------------------------
336
+" # IVN Menus          {{{2
337
+" Function: s:CTRL_O({cmd})                                {{{3
338
+" Build the command (sequence of ':ex commands') to be executed from
339
+" INSERT-mode.
340
+function! s:CTRL_O(cmd)
341
+  return substitute(a:cmd, '\(^\|<CR>\):', '\1\<C-O>:', 'g')
342
+endfunction
343
+
344
+" Function: lh#menu#is_in_visual_mode()                    {{{3
345
+function! lh#menu#is_in_visual_mode()
346
+  return exists('s:is_in_visual_mode') && s:is_in_visual_mode
347
+endfunction
348
+
349
+" Function: lh#menu#_CMD_and_clear_v({cmd})                 {{{3
350
+" Internal function that executes the command and then clears the @v buffer
351
+" todo: save and restore @v, 
352
+function! lh#menu#_CMD_and_clear_v(cmd)
353
+  try 
354
+    let s:is_in_visual_mode = 1
355
+    exe a:cmd
356
+  finally
357
+    let @v=''
358
+    silent! unlet s:is_in_visual_mode
359
+  endtry
360
+endfunction
361
+
362
+" Function: s:Build_CMD({prefix},{cmd})                    {{{3
363
+" build the exact command to execute regarding the mode it is dedicated
364
+function! s:Build_CMD(prefix, cmd)
365
+  if a:cmd[0] != ':' | return ' ' . a:cmd
366
+  endif
367
+  if     a:prefix[0] == "i"  | return ' ' . <SID>CTRL_O(a:cmd)
368
+  elseif a:prefix[0] == "n"  | return ' ' . a:cmd
369
+  elseif a:prefix[0] == "v" 
370
+    if match(a:cmd, ":VCall") == 0
371
+      return substitute(a:cmd, ':VCall', ' :call', ''). "\<cr>gV"
372
+      " gV exit select-mode if we where in it!
373
+    else
374
+      return
375
+	    \ " \"vy\<C-C>:call lh#menu#_CMD_and_clear_v('" . 
376
+	    \ substitute(a:cmd, "<CR>$", '', '') ."')\<cr>"
377
+    endif
378
+  elseif a:prefix[0] == "c"  | return " \<C-C>" . a:cmd
379
+  else                       | return ' ' . a:cmd
380
+  endif
381
+endfunction
382
+
383
+" Function: lh#menu#map_all({map_type}, [{map args}...)   {{{3
384
+" map the command to all the modes required
385
+function! lh#menu#map_all(map_type,...)
386
+  let nore   = (match(a:map_type, '[aincv]*noremap') != -1) ? "nore" : ""
387
+  let prefix = matchstr(substitute(a:map_type, nore, '', ''), '[aincv]*')
388
+  if a:1 == "<buffer>" | let i = 3 | let binding = a:1 . ' ' . a:2
389
+  else                 | let i = 2 | let binding = a:1
390
+  endif
391
+  let binding = '<silent> ' . binding
392
+  let cmd = a:{i}
393
+  let i +=  1
394
+  while i <= a:0
395
+    let cmd .=  ' ' . a:{i}
396
+    let i +=  1
397
+  endwhile
398
+  let build_cmd = nore . 'map ' . binding
399
+  while strlen(prefix)
400
+    if prefix[0] == "a" | let prefix = "incv"
401
+    else
402
+      execute prefix[0] . build_cmd . <SID>Build_CMD(prefix[0],cmd)
403
+      let prefix = strpart(prefix, 1)
404
+    endif
405
+  endwhile
406
+endfunction
407
+
408
+" Function: lh#menu#make({prefix},{code},{text},{binding},...) {{{3
409
+" Build the menu and map its associated binding to all the modes required
410
+function! lh#menu#make(prefix, code, text, binding, ...)
411
+  let nore   = (match(a:prefix, '[aincv]*nore') != -1) ? "nore" : ""
412
+  let prefix = matchstr(substitute(a:prefix, nore, '', ''), '[aincv]*')
413
+  let b = (a:1 == "<buffer>") ? 1 : 0
414
+  let i = b + 1 
415
+  let cmd = a:{i}
416
+  let i += 1
417
+  while i <= a:0
418
+    let cmd .=  ' ' . a:{i}
419
+    let i += 1
420
+  endwhile
421
+  let build_cmd = nore . "menu <silent> " . a:code . ' ' . lh#menu#text(a:text) 
422
+  if strlen(a:binding) != 0
423
+    let build_cmd .=  '<tab>' . 
424
+	  \ substitute(lh#menu#text(a:binding), '&', '\0\0', 'g')
425
+    if prefix == 'i' && exists('*IMAP')
426
+      if b != 0
427
+        call IMAP(a:binding, cmd, &ft)
428
+      else
429
+        call IMAP(a:binding, cmd)
430
+      endif
431
+    else
432
+      if b != 0
433
+        call lh#menu#map_all(prefix.nore."map", ' <buffer> '.a:binding, cmd)
434
+      else
435
+        call lh#menu#map_all(prefix.nore."map", a:binding, cmd)
436
+      endif
437
+    endif
438
+  endif
439
+  if has("gui_running")
440
+    while strlen(prefix)
441
+      execute <SID>BMenu(b).prefix[0].build_cmd.<SID>Build_CMD(prefix[0],cmd)
442
+      let prefix = strpart(prefix, 1)
443
+    endwhile
444
+  endif
445
+endfunction
446
+
447
+" Function: s:BMenu({b})                                   {{{3
448
+" If <buffermenu.vim> is installed and the menu should be local, then the
449
+" apropriate string is returned.
450
+function! s:BMenu(b)
451
+  let res = (a:b && exists(':Bmenu') 
452
+	\     && (1 == lh#option#get("want_buffermenu_or_global_disable", 1, "bg"))
453
+	\) ? 'B' : ''
454
+  " call confirm("BMenu(".a:b.")=".res, '&Ok', 1)
455
+  return res
456
+endfunction
457
+
458
+" Function: lh#menu#IVN_make(...)                          {{{3
459
+function! lh#menu#IVN_make(code, text, binding, i_cmd, v_cmd, n_cmd, ...)
460
+  " nore options
461
+  let nore_i = (a:0 > 0) ? ((a:1 != 0) ? 'nore' : '') : ''
462
+  let nore_v = (a:0 > 1) ? ((a:2 != 0) ? 'nore' : '') : ''
463
+  let nore_n = (a:0 > 2) ? ((a:3 != 0) ? 'nore' : '') : ''
464
+  " 
465
+  call lh#menu#make('i'.nore_i,a:code,a:text, a:binding, '<buffer>', a:i_cmd)
466
+  call lh#menu#make('v'.nore_v,a:code,a:text, a:binding, '<buffer>', a:v_cmd)
467
+  if strlen(a:n_cmd) != 0
468
+    call lh#menu#make('n'.nore_n,a:code,a:text, a:binding, '<buffer>', a:n_cmd)
469
+  endif
470
+endfunction
471
+
472
+"
473
+" Functions }}}1
474
+"------------------------------------------------------------------------
475
+let &cpo=s:cpo_save
476
+"=============================================================================
477
+" vim600: set fdm=marker:

+ 127
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/option.vim View File

@@ -0,0 +1,127 @@
1
+"=============================================================================
2
+" $Id: option.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/option.vim                                    {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	24th Jul 2004
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (07th Oct 2006)
11
+"------------------------------------------------------------------------
12
+" Description:
13
+" 	Defines the global function lh#option#get().
14
+"       Aimed at (ft)plugin writers.
15
+" 
16
+"------------------------------------------------------------------------
17
+" Installation:
18
+" 	Drop this file into {rtp}/autoload/lh/
19
+" 	Requires Vim 7+
20
+" History:	
21
+"       v3.0.0
22
+"       (*) GPLv3
23
+" 	v2.0.6
24
+" 	(*) lh#option#add() add values to a vim list |option|
25
+" 	v2.0.5
26
+" 	(*) lh#option#get_non_empty() manages Lists and Dictionaries
27
+" 	(*) lh#option#get() doesn't test emptyness anymore
28
+" 	v2.0.0
29
+" 		Code moved from {rtp}/macros/ 
30
+" }}}1
31
+"=============================================================================
32
+
33
+
34
+"=============================================================================
35
+let s:cpo_save=&cpo
36
+set cpo&vim
37
+
38
+"------------------------------------------------------------------------
39
+" ## Functions {{{1
40
+" # Debug {{{2
41
+function! lh#option#verbose(level)
42
+  let s:verbose = a:level
43
+endfunction
44
+
45
+function! s:Verbose(expr)
46
+  if exists('s:verbose') && s:verbose
47
+    echomsg a:expr
48
+  endif
49
+endfunction
50
+
51
+function! lh#option#debug(expr)
52
+  return eval(a:expr)
53
+endfunction
54
+
55
+" # Public {{{2
56
+" Function: lh#option#get(name, default [, scope])            {{{3
57
+" @return b:{name} if it exists, or g:{name} if it exists, or {default}
58
+" otherwise
59
+" The order of the variables checked can be specified through the optional
60
+" argument {scope}
61
+function! lh#option#get(name,default,...)
62
+  let scope = (a:0 == 1) ? a:1 : 'bg'
63
+  let name = a:name
64
+  let i = 0
65
+  while i != strlen(scope)
66
+    if exists(scope[i].':'.name)
67
+      " \ && (0 != strlen({scope[i]}:{name}))
68
+      return {scope[i]}:{name}
69
+    endif
70
+    let i += 1
71
+  endwhile 
72
+  return a:default
73
+endfunction
74
+function! lh#option#Get(name,default,...)
75
+  let scope = (a:0 == 1) ? a:1 : 'bg'
76
+  return lh#option#get(a:name, a:default, scope)
77
+endfunction
78
+
79
+function! s:IsEmpty(variable)
80
+  if     type(a:variable) == type('string') | return 0 == strlen(a:variable)
81
+  elseif type(a:variable) == type(42)       | return 0 == a:variable
82
+  elseif type(a:variable) == type([])       | return 0 == len(a:variable)
83
+  elseif type(a:variable) == type({})       | return 0 == len(a:variable)
84
+  else                                      | return false
85
+  endif
86
+endfunction
87
+
88
+" Function: lh#option#get_non_empty(name, default [, scope])  {{{3
89
+" @return of b:{name}, g:{name}, or {default} the first which exists and is not empty 
90
+" The order of the variables checked can be specified through the optional
91
+" argument {scope}
92
+function! lh#option#get_non_empty(name,default,...)
93
+  let scope = (a:0 == 1) ? a:1 : 'bg'
94
+  let name = a:name
95
+  let i = 0
96
+  while i != strlen(scope)
97
+    if exists(scope[i].':'.name) && !s:IsEmpty({scope[i]}:{name})
98
+      return {scope[i]}:{name}
99
+    endif
100
+    let i += 1
101
+  endwhile 
102
+  return a:default
103
+endfunction
104
+function! lh#option#GetNonEmpty(name,default,...)
105
+  let scope = (a:0 == 1) ? a:1 : 'bg'
106
+  return lh#option#get_non_empty(a:name, a:default, scope)
107
+endfunction
108
+
109
+" Function: lh#option#add(name, values)                       {{{3
110
+" Add fields to a vim option.
111
+" @param values list of values to add
112
+" @example let lh#option#add('l:tags', ['.tags'])
113
+function! lh#option#add(name,values)
114
+  let values = type(a:values) == type([])
115
+        \ ? copy(a:values)
116
+        \ : [a:values]
117
+  let old = split(eval('&'.a:name), ',')
118
+  let new = filter(values, 'match(old, v:val) < 0')
119
+  let val = join(old+new, ',')
120
+  exe 'let &'.a:name.' = val'
121
+endfunction
122
+
123
+" Functions }}}1
124
+"------------------------------------------------------------------------
125
+let &cpo=s:cpo_save
126
+"=============================================================================
127
+" vim600: set fdm=marker:

+ 366
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/path.vim View File

@@ -0,0 +1,366 @@
1
+"=============================================================================
2
+" $Id: path.vim 606 2012-05-31 17:09:46Z luc.hermitte@gmail.com $
3
+" File:		autoload/lh/path.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.1.1
9
+" Created:	23rd Jan 2007
10
+" Last Update:	$Date
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+"       Functions related to the handling of pathnames
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	
17
+" 	Drop this file into {rtp}/autoload/lh
18
+" 	Requires Vim7+
19
+" History:	
20
+"	v 1.0.0 First Version
21
+" 	(*) Functions moved from searchInRuntimeTime  
22
+" 	v 2.0.1
23
+" 	(*) lh#path#Simplify() becomes like |simplify()| except for trailing
24
+" 	v 2.0.2
25
+" 	(*) lh#path#SelectOne() 
26
+" 	(*) lh#path#ToRelative() 
27
+" 	v 2.0.3
28
+" 	(*) lh#path#GlobAsList() 
29
+" 	v 2.0.4
30
+" 	(*) lh#path#StripStart()
31
+" 	v 2.0.5
32
+" 	(*) lh#path#StripStart() interprets '.' as getcwd()
33
+" 	v 2.2.0
34
+" 	(*) new functions: lh#path#common(), lh#path#to_dirname(),
35
+" 	    lh#path#depth(), lh#path#relative_to(), lh#path#to_regex(),
36
+" 	    lh#path#find()
37
+" 	(*) lh#path#simplify() fixed
38
+" 	(*) lh#path#to_relative() use simplify()
39
+" 	v 2.2.2
40
+" 	(*) lh#path#strip_common() fixed
41
+" 	(*) lh#path#simplify() new optional parameter: make_relative_to_pwd
42
+" 	v 2.2.5
43
+" 	(*) fix lh#path#to_dirname('') -> return ''
44
+" 	v 2.2.6
45
+" 	(*) fix lh#path#glob_as_list() does not return the same path several
46
+" 	    times
47
+" 	v 2.2.7
48
+" 	(*) fix lh#path#strip_start() to strip as much as possible.
49
+" 	(*) lh#path#glob_as_list() changed to handle **
50
+"       v 3.0.0
51
+"       (*) GPLv3
52
+"       v 3.1.0
53
+"       (*) lh#path#glob_as_list accepts a new option: mustSort which value
54
+"       true by default.
55
+"       v 3.1.1
56
+"       (*) lh#path#strip_start() shall support very big lists of dirnames now.
57
+" TODO:
58
+"       (*) Decide what #depth('../../bar') shall return
59
+"       (*) Fix #simplify('../../bar')
60
+" }}}1
61
+"=============================================================================
62
+
63
+
64
+"=============================================================================
65
+" Avoid global reinclusion {{{1
66
+let s:cpo_save=&cpo
67
+set cpo&vim
68
+
69
+"=============================================================================
70
+" ## Functions {{{1
71
+" # Version {{{2
72
+let s:k_version = 310
73
+function! lh#path#version()
74
+  return s:k_version
75
+endfunction
76
+
77
+" # Debug {{{2
78
+let s:verbose = 0
79
+function! lh#path#verbose(...)
80
+  if a:0 > 0 | let s:verbose = a:1 | endif
81
+  return s:verbose
82
+endfunction
83
+
84
+function! s:Verbose(expr)
85
+  if s:verbose
86
+    echomsg a:expr
87
+  endif
88
+endfunction
89
+
90
+function! lh#path#debug(expr)
91
+  return eval(a:expr)
92
+endfunction
93
+
94
+"=============================================================================
95
+" # Public {{{2
96
+" Function: lh#path#simplify({pathname}, [make_relative_to_pwd=true]) {{{3
97
+" Like |simplify()|, but also strip the leading './'
98
+" It seems unable to simplify '..\' when compiled without +shellslash
99
+function! lh#path#simplify(pathname, ...)
100
+  let make_relative_to_pwd = a:0 == 0 || a:1 == 1
101
+  let pathname = simplify(a:pathname)
102
+  let pathname = substitute(pathname, '^\%(\.[/\\]\)\+', '', '')
103
+  let pathname = substitute(pathname, '\([/\\]\)\%(\.[/\\]\)\+', '\1', 'g')
104
+  if make_relative_to_pwd
105
+    let pwd = getcwd().'/'
106
+    let pathname = substitute(pathname, '^'.lh#path#to_regex(pwd), '', 'g')
107
+  endif
108
+  return pathname
109
+endfunction
110
+function! lh#path#Simplify(pathname)
111
+  return lh#path#simplify(a:pathname)
112
+endfunction
113
+
114
+" Function: lh#path#common({pathnames}) {{{3
115
+" Find the common leading path between all pathnames
116
+function! lh#path#common(pathnames)
117
+  " assert(len(pathnames)) > 1
118
+  let common = a:pathnames[0]
119
+  let i = 1
120
+  while i < len(a:pathnames)
121
+    let fcrt = a:pathnames[i]
122
+    " pathnames should not contain @
123
+    " let common = matchstr(common.'@@'.fcrt, '^\zs\(.*[/\\]\)\ze.\{-}@@\1.*$')
124
+    let common = matchstr(common.'@@'.fcrt, '^\zs\(.*\>\)\ze.\{-}@@\1\>.*$')
125
+    if strlen(common) == 0
126
+      " No need to further checks
127
+      break
128
+    endif
129
+    let i += 1
130
+  endwhile
131
+  return common
132
+endfunction
133
+
134
+" Function: lh#path#strip_common({pathnames}) {{{3
135
+" Find the common leading path between all pathnames, and strip it
136
+function! lh#path#strip_common(pathnames)
137
+  " assert(len(pathnames)) > 1
138
+  let common = lh#path#common(a:pathnames)
139
+  let common = lh#path#to_dirname(common)
140
+  let l = strlen(common)
141
+  if l == 0
142
+    return a:pathnames
143
+  else
144
+  let pathnames = a:pathnames
145
+  call map(pathnames, 'strpart(v:val, '.l.')' )
146
+  return pathnames
147
+  endif
148
+endfunction
149
+function! lh#path#StripCommon(pathnames)
150
+  return lh#path#strip_common(a:pathnames)
151
+endfunction
152
+
153
+" Function: lh#path#is_absolute_path({path}) {{{3
154
+function! lh#path#is_absolute_path(path)
155
+  return a:path =~ '^/'
156
+	\ . '\|^[a-zA-Z]:[/\\]'
157
+	\ . '\|^[/\\]\{2}'
158
+  "    Unix absolute path 
159
+  " or Windows absolute path
160
+  " or UNC path
161
+endfunction
162
+function! lh#path#IsAbsolutePath(path)
163
+  return lh#path#is_absolute_path(a:path)
164
+endfunction
165
+
166
+" Function: lh#path#is_url({path}) {{{3
167
+function! lh#path#is_url(path)
168
+  " todo: support UNC paths and other urls
169
+  return a:path =~ '^\%(https\=\|s\=ftp\|dav\|fetch\|file\|rcp\|rsynch\|scp\)://'
170
+endfunction
171
+function! lh#path#IsURL(path)
172
+  return lh#path#is_url(a:path)
173
+endfunction
174
+
175
+" Function: lh#path#select_one({pathnames},{prompt}) {{{3
176
+function! lh#path#select_one(pathnames, prompt)
177
+  if len(a:pathnames) > 1
178
+    let simpl_pathnames = deepcopy(a:pathnames) 
179
+    let simpl_pathnames = lh#path#strip_common(simpl_pathnames)
180
+    let simpl_pathnames = [ '&Cancel' ] + simpl_pathnames
181
+    " Consider guioptions+=c is case of difficulties with the gui
182
+    let selection = confirm(a:prompt, join(simpl_pathnames,"\n"), 1, 'Question')
183
+    let file = (selection == 1) ? '' : a:pathnames[selection-2]
184
+    return file
185
+  elseif len(a:pathnames) == 0
186
+    return ''
187
+  else
188
+    return a:pathnames[0]
189
+  endif
190
+endfunction
191
+function! lh#path#SelectOne(pathnames, prompt)
192
+  return lh#path#select_one(a:pathnames, a:prompt)
193
+endfunction
194
+
195
+" Function: lh#path#to_relative({pathname}) {{{3
196
+function! lh#path#to_relative(pathname)
197
+  let newpath = fnamemodify(a:pathname, ':p:.')
198
+  let newpath = simplify(newpath)
199
+  return newpath
200
+endfunction
201
+function! lh#path#ToRelative(pathname)
202
+  return lh#path#to_relative(a:pathname)
203
+endfunction
204
+
205
+" Function: lh#path#to_dirname({dirname}) {{{3
206
+" todo: use &shellslash
207
+function! lh#path#to_dirname(dirname)
208
+  let dirname = a:dirname . (empty(a:dirname) || a:dirname[-1:] =~ '[/\\]' ? '' : '/')
209
+  return dirname
210
+endfunction
211
+
212
+" Function: lh#path#depth({dirname}) {{{3
213
+" todo: make a choice about "negative" paths like "../../foo"
214
+function! lh#path#depth(dirname)
215
+  if empty(a:dirname) | return 0 | endif
216
+  let dirname = lh#path#to_dirname(a:dirname)
217
+  let dirname = lh#path#simplify(dirname)
218
+  if lh#path#is_absolute_path(dirname)
219
+    let dirname = matchstr(dirname, '.\{-}[/\\]\zs.*')
220
+  endif
221
+  let depth = len(substitute(dirname, '[^/\\]\+[/\\]', '#', 'g'))
222
+  return depth
223
+endfunction
224
+
225
+" Function: lh#path#relative_to({from}, {to}) {{{3
226
+" @param two directories
227
+" @return a directories delta that ends with a '/' (may depends on
228
+" &shellslash)
229
+function! lh#path#relative_to(from, to)
230
+  " let from = fnamemodify(a:from, ':p')
231
+  " let to   = fnamemodify(a:to  , ':p')
232
+  let from = lh#path#to_dirname(a:from)
233
+  let to   = lh#path#to_dirname(a:to  )
234
+  let [from, to] = lh#path#strip_common([from, to])
235
+  let nb_up =  lh#path#depth(from)
236
+  return repeat('../', nb_up).to
237
+
238
+  " cannot rely on :cd (as it alters things, and doesn't work with
239
+  " non-existant paths)
240
+  let pwd = getcwd()
241
+  exe 'cd '.a:to
242
+  let res = lh#path#to_relative(a:from)
243
+  exe 'cd '.pwd
244
+  return res
245
+endfunction
246
+
247
+" Function: lh#path#glob_as_list({pathslist}, {expr} [, mustSort=1]) {{{3
248
+function! s:GlobAsList(pathslist, expr,  mustSort)
249
+  let pathslist = type(a:pathslist) == type([]) ? join(a:pathslist, ',') : a:pathslist
250
+  let sResult = globpath(pathslist, a:expr)
251
+  let lResult = split(sResult, '\n')
252
+  " workaround a non feature of wildignore: it does not ignore directories
253
+  for ignored_pattern in split(&wildignore,',')
254
+    if stridx(ignored_pattern,'/') != -1
255
+      call filter(lResult, 'v:val !~ '.string(ignored_pattern))
256
+    endif
257
+  endfor
258
+  return a:mustSort ? lh#list#unique_sort(lResult) : lResult
259
+endfunction
260
+
261
+function! lh#path#glob_as_list(pathslist, expr, ...)
262
+  let mustSort = (a:0 > 0) ? (a:1) : 0
263
+  if type(a:expr) == type('string')
264
+    return s:GlobAsList(a:pathslist, a:expr, mustSort)
265
+  elseif type(a:expr) == type([])
266
+    let res = []
267
+    for expr in a:expr
268
+      call extend(res, s:GlobAsList(a:pathslist, expr, mustSort))
269
+    endfor
270
+    return res
271
+  else
272
+    throw "Unexpected type for a:expression"
273
+  endif
274
+endfunction
275
+function! lh#path#GlobAsList(pathslist, expr)
276
+  return lh#path#glob_as_list(a:pathslist, a:expr)
277
+endfunction
278
+
279
+" Function: lh#path#strip_start({pathname}, {pathslist}) {{{3
280
+" Strip occurrence of paths from {pathslist} in {pathname}
281
+" @param[in] {pathname} name to simplify
282
+" @param[in] {pathslist} list of pathname (can be a |string| of pathnames
283
+" separated by ",", of a |List|).
284
+function! lh#path#strip_start(pathname, pathslist)
285
+  if type(a:pathslist) == type('string')
286
+    " let strip_re = escape(a:pathslist, '\\.')
287
+    " let strip_re = '^' . substitute(strip_re, ',', '\\|^', 'g')
288
+    let pathslist = split(a:pathslist, ',')
289
+  elseif type(a:pathslist) == type([])
290
+    let pathslist = deepcopy(a:pathslist)
291
+  else
292
+    throw "Unexpected type for a:pathname"
293
+  endif
294
+
295
+  " apply a realpath like operation
296
+  let nb_paths = len(pathslist) " set before the loop
297
+  let i = 0
298
+  while i != nb_paths
299
+    if pathslist[i] =~ '^\.\%(/\|$\)'
300
+      let path2 = getcwd().pathslist[i][1:]
301
+      call add(pathslist, path2)
302
+    endif
303
+    let i += 1
304
+  endwhile
305
+  " replace path separators by a regex that can match them
306
+  call map(pathslist, 'substitute(v:val, "[\\\\/]", "[\\\\/]", "g")')
307
+  " echomsg string(pathslist)
308
+  " escape .
309
+  call map(pathslist, '"^".escape(v:val, ".")')
310
+  " handle "**" as anything
311
+  call map(pathslist, 'substitute(v:val, "\\*\\*", "\\\\%([^\\\\/]*[\\\\/]\\\\)*", "g")')
312
+  " reverse the list to use the real best match, which is "after"
313
+  call reverse(pathslist)
314
+  if 0
315
+    " build the strip regex
316
+    let strip_re = join(pathslist, '\|')
317
+    " echomsg strip_re
318
+    let best_match = substitute(a:pathname, '\%('.strip_re.'\)[/\\]\=', '', '')
319
+  else
320
+    let best_match = ''
321
+    for path in pathslist
322
+      let a_match = substitute(a:pathname, '\%('.path.'\)[/\\]\=', '', '')
323
+      if len(a_match) < len(best_match) || empty(best_match)
324
+        let best_match = a_match
325
+      endif
326
+    endfor
327
+  endif
328
+  return best_match
329
+endfunction
330
+function! lh#path#StripStart(pathname, pathslist)
331
+  return lh#path#strip_start(a:pathname, a:pathslist)
332
+endfunction
333
+
334
+" Function: lh#path#to_regex({pathname}) {{{3
335
+function! lh#path#to_regex(path)
336
+  let regex = substitute(a:path, '[/\\]', '[/\\\\]', 'g')
337
+  return regex
338
+endfunction
339
+
340
+" Function: lh#path#find({pathname}, {regex}) {{{3
341
+function! lh#path#find(paths, regex)
342
+  let paths = (type(a:paths) == type([]))
343
+	\ ? (a:paths) 
344
+	\ : split(a:paths,',')
345
+  for path in paths
346
+    if match(path ,a:regex) != -1
347
+      return path
348
+    endif
349
+  endfor
350
+  return ''
351
+endfunction
352
+
353
+" Function: lh#path#vimfiles() {{{3
354
+function! lh#path#vimfiles()
355
+  let expected_win = $HOME . '/vimfiles'
356
+  let expected_nix = $HOME . '/.vim'
357
+  let what =  lh#path#to_regex($HOME.'/').'\(vimfiles\|.vim\)'
358
+  " Comment what
359
+  let z = lh#path#find(&rtp,what)
360
+  return z
361
+endfunction
362
+" }}}1
363
+"=============================================================================
364
+let &cpo=s:cpo_save
365
+"=============================================================================
366
+" vim600: set fdm=marker:

+ 96
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/position.vim View File

@@ -0,0 +1,96 @@
1
+"=============================================================================
2
+" $Id: position.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		autoload/lh/position.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	05th Sep 2007
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (05th Sep 2007)
11
+"------------------------------------------------------------------------
12
+" Description:	«description»
13
+" 
14
+"------------------------------------------------------------------------
15
+" Installation:
16
+" 	Drop it into {rtp}/autoload/lh/
17
+" 	Vim 7+ required.
18
+" History:	«history»
19
+" 	v1.0.0:
20
+" 		Creation
21
+"       v3.0.0: GPLv3
22
+" TODO:		
23
+" }}}1
24
+"=============================================================================
25
+
26
+
27
+"=============================================================================
28
+let s:cpo_save=&cpo
29
+set cpo&vim
30
+"------------------------------------------------------------------------
31
+" ## Functions {{{1
32
+" # Debug {{{2
33
+function! lh#position#verbose(level)
34
+  let s:verbose = a:level
35
+endfunction
36
+
37
+function! s:Verbose(expr)
38
+  if exists('s:verbose') && s:verbose
39
+    echomsg a:expr
40
+  endif
41
+endfunction
42
+
43
+function! lh#position#debug(expr)
44
+  return eval(a:expr)
45
+endfunction
46
+
47
+
48
+"------------------------------------------------------------------------
49
+" # Public {{{2
50
+" Function: lh#position#is_before {{{3
51
+" @param[in] positions as those returned from |getpos()|
52
+" @return whether lhs_pos is before rhs_pos
53
+function! lh#position#is_before(lhs_pos, rhs_pos)
54
+  if a:lhs_pos[0] != a:rhs_pos[0]
55
+    throw "Positions from incompatible buffers can't be ordered"
56
+  endif
57
+  "1 test lines
58
+  "2 test cols
59
+  let before 
60
+	\ = (a:lhs_pos[1] == a:rhs_pos[1])
61
+	\ ? (a:lhs_pos[2] < a:rhs_pos[2])
62
+	\ : (a:lhs_pos[1] < a:rhs_pos[1])
63
+  return before
64
+endfunction
65
+function! lh#position#IsBefore(lhs_pos, rhs_pos)
66
+  return lh#position#is_before(a:lhs_pos, a:rhs_pos)
67
+endfunction
68
+
69
+
70
+" Function: lh#position#char_at_mark {{{3
71
+" @return the character at a given mark (|mark|)
72
+function! lh#position#char_at_mark(mark)
73
+  let c = getline(a:mark)[col(a:mark)-1]
74
+  return c
75
+endfunction
76
+function! lh#position#CharAtMark(mark)
77
+return lh#position#char_at_mark(a:mark)
78
+endfunction
79
+
80
+" Function: lh#position#char_at_pos {{{3
81
+" @return the character at a given position (|getpos()|)
82
+function! lh#position#char_at_pos(pos)
83
+  let c = getline(a:pos[1])[(a:pos[2])-1]
84
+  return c
85
+endfunction
86
+function! lh#position#CharAtPos(pos)
87
+  return  lh#position#char_at_pos(a:pos)
88
+endfunction
89
+
90
+
91
+
92
+" Functions }}}1
93
+"------------------------------------------------------------------------
94
+let &cpo=s:cpo_save
95
+"=============================================================================
96
+" vim600: set fdm=marker:

+ 153
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/syntax.vim View File

@@ -0,0 +1,153 @@
1
+"=============================================================================
2
+" $Id: syntax.vim 558 2012-04-10 08:00:00Z luc.hermitte $
3
+" File:		autoload/lh/syntax.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.1.0
9
+" Created:	05th Sep 2007
10
+" Last Update:	$Date: 2012-04-10 10:00:00 +0200 (mar 10 avr 2012) $ (05th Sep 2007)
11
+"------------------------------------------------------------------------
12
+" Description:	«description»
13
+" 
14
+"------------------------------------------------------------------------
15
+" Installation:
16
+" 	Drop it into {rtp}/autoload/lh/
17
+" 	Vim 7+ required.
18
+" History:	«history»
19
+" 	v1.0.0:
20
+" 		Creation ;
21
+" 		Functions moved from lhVimSpell
22
+"       v3.0.0: GPLv3
23
+"       v3.1.0: lh#syntax#is_a_comment()
24
+" TODO:
25
+" 	function, to inject "contained", see lhVimSpell approach
26
+" }}}1
27
+"=============================================================================
28
+
29
+
30
+"=============================================================================
31
+let s:cpo_save=&cpo
32
+set cpo&vim
33
+"------------------------------------------------------------------------
34
+" ## Functions {{{1
35
+" # Debug {{{2
36
+function! lh#syntax#verbose(level)
37
+  let s:verbose = a:level
38
+endfunction
39
+
40
+function! s:Verbose(expr)
41
+  if exists('s:verbose') && s:verbose
42
+    echomsg a:expr
43
+  endif
44
+endfunction
45
+
46
+function! lh#syntax#debug(expr)
47
+  return eval(a:expr)
48
+endfunction
49
+
50
+" # Public {{{2
51
+" Functions: Show name of the syntax kind of a character {{{3
52
+function! lh#syntax#name_at(l,c, ...)
53
+  let what = a:0 > 0 ? a:1 : 0
54
+  return synIDattr(synID(a:l, a:c, what),'name')
55
+endfunction
56
+function! lh#syntax#NameAt(l,c, ...)
57
+  let what = a:0 > 0 ? a:1 : 0
58
+  return lh#syntax#name_at(a:l, a:c, what)
59
+endfunction
60
+
61
+function! lh#syntax#name_at_mark(mark, ...)
62
+  let what = a:0 > 0 ? a:1 : 0
63
+  return lh#syntax#name_at(line(a:mark), col(a:mark), what)
64
+endfunction
65
+function! lh#syntax#NameAtMark(mark, ...)
66
+  let what = a:0 > 0 ? a:1 : 0
67
+  return lh#syntax#name_at_mark(a:mark, what)
68
+endfunction
69
+
70
+" Functions: skip string, comment, character, doxygen {{{3
71
+func! lh#syntax#skip_at(l,c)
72
+  return lh#syntax#name_at(a:l,a:c) =~? 'string\|comment\|character\|doxygen'
73
+endfun
74
+func! lh#syntax#SkipAt(l,c)
75
+  return lh#syntax#skip_at(a:l,a:c)
76
+endfun
77
+
78
+func! lh#syntax#skip()
79
+  return lh#syntax#skip_at(line('.'), col('.'))
80
+endfun
81
+func! lh#syntax#Skip()
82
+  return lh#syntax#skip()
83
+endfun
84
+
85
+func! lh#syntax#skip_at_mark(mark)
86
+  return lh#syntax#skip_at(line(a:mark), col(a:mark))
87
+endfun
88
+func! lh#syntax#SkipAtMark(mark)
89
+  return lh#syntax#skip_at_mark(a:mark)
90
+endfun
91
+
92
+" Command: :SynShow Show current syntax kind                      {{{3
93
+command! SynShow echo 'hi<'.lh#syntax#name_at_mark('.',1).'> trans<'
94
+      \ lh#syntax#name_at_mark('.',0).'> lo<'.
95
+      \ synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name').'>   ## '
96
+      \ lh#list#transform(synstack(line("."), col(".")), [], 'synIDattr(v:1_, "name")')
97
+
98
+
99
+" Function: lh#syntax#list_raw(name) : string                     {{{3
100
+function! lh#syntax#list_raw(name)
101
+  let a_save = @a
102
+  try
103
+    redir @a
104
+    exe 'silent! syn list '.a:name
105
+    redir END
106
+    let res = @a
107
+  finally
108
+    let @a = a_save
109
+  endtry
110
+  return res
111
+endfunction
112
+
113
+" Function: lh#syntax#list(name) : List                           {{{3
114
+function! lh#syntax#list(name)
115
+  let raw = lh#syntax#list_raw(a:name)
116
+  let res = [] 
117
+  let lines = split(raw, '\n')
118
+  let started = 0
119
+  for l in lines
120
+    if started
121
+      let li = (l =~ 'links to') ? '' : l
122
+    elseif l =~ 'xxx'
123
+      let li = matchstr(l, 'xxx\s*\zs.*')
124
+      let started = 1
125
+    else
126
+      let li = ''
127
+    endif
128
+    if strlen(li) != 0
129
+      let li = substitute(li, 'contained\S*\|transparent\|nextgroup\|skipwhite\|skipnl\|skipempty', '', 'g')
130
+      let kinds = split(li, '\s\+')
131
+      call extend(res, kinds)
132
+    endif
133
+  endfor
134
+  return res
135
+endfunction
136
+
137
+" Function: lh#syntax#is_a_comment(mark) : bool                   {{{3
138
+function! lh#syntax#is_a_comment(mark)
139
+  let stack = synstack(line(a:mark), col(a:mark))
140
+  for syn in stack
141
+    if synIDattr(syn, 'name') =~? 'comment'
142
+      return 1
143
+    endif
144
+  endfor
145
+  return 0
146
+endfunction
147
+
148
+
149
+" Functions }}}1
150
+"------------------------------------------------------------------------
151
+let &cpo=s:cpo_save
152
+"=============================================================================
153
+" vim600: set fdm=marker:

+ 58
- 0
dotfiles/vim/bundle/lh-vim-lib/autoload/lh/visual.vim View File

@@ -0,0 +1,58 @@
1
+"=============================================================================
2
+" $Id$
3
+" File:		autoload/lh/visual.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	08th Sep 2008
10
+" Last Update:	$Date$
11
+"------------------------------------------------------------------------
12
+" 	Helpers functions releated to the visual mode
13
+" 
14
+"------------------------------------------------------------------------
15
+" 	Drop it into {rtp}/autoload/lh/
16
+" 	Vim 7+ required.
17
+" History:	
18
+"       v3.0.0: GPLv3
19
+" 	v2.2.5: lh#visual#cut()
20
+" 	v2.0.6: First appearance
21
+" TODO:		«missing features»
22
+" }}}1
23
+"=============================================================================
24
+
25
+let s:cpo_save=&cpo
26
+set cpo&vim
27
+"------------------------------------------------------------------------
28
+" Functions {{{1
29
+
30
+" Function: lh#visual#selection()                              {{{3
31
+" @return the text currently selected
32
+function! lh#visual#selection()
33
+  try
34
+    let a_save = @a
35
+    normal! gv"ay
36
+    return @a
37
+  finally
38
+    let @a = a_save
39
+  endtry
40
+endfunction
41
+
42
+" Function: lh#visual#cut()                                    {{{3
43
+" @return and delete the text currently selected
44
+function! lh#visual#cut()
45
+  try
46
+    let a_save = @a
47
+    normal! gv"ad
48
+    return @a
49
+  finally
50
+    let @a = a_save
51
+  endtry
52
+endfunction
53
+
54
+" Functions }}}1
55
+"------------------------------------------------------------------------
56
+let &cpo=s:cpo_save
57
+"=============================================================================
58
+" vim600: set fdm=marker:

+ 1369
- 0
dotfiles/vim/bundle/lh-vim-lib/doc/lh-vim-lib.txt
File diff suppressed because it is too large
View File


+ 139
- 0
dotfiles/vim/bundle/lh-vim-lib/doc/tags View File

@@ -0,0 +1,139 @@
1
+[gb]:want_buffermenu_or_global_disable	lh-vim-lib.txt	/*[gb]:want_buffermenu_or_global_disable*
2
+lh#askvim#Exe()	lh-vim-lib.txt	/*lh#askvim#Exe()*
3
+lh#askvim#exe()	lh-vim-lib.txt	/*lh#askvim#exe()*
4
+lh#askvim#menu()	lh-vim-lib.txt	/*lh#askvim#menu()*
5
+lh#buffer#Find()	lh-vim-lib.txt	/*lh#buffer#Find()*
6
+lh#buffer#Jump()	lh-vim-lib.txt	/*lh#buffer#Jump()*
7
+lh#buffer#Scratch()	lh-vim-lib.txt	/*lh#buffer#Scratch()*
8
+lh#buffer#dialog#	lh-vim-lib.txt	/*lh#buffer#dialog#*
9
+lh#buffer#dialog#add_help()	lh-vim-lib.txt	/*lh#buffer#dialog#add_help()*
10
+lh#buffer#dialog#new()	lh-vim-lib.txt	/*lh#buffer#dialog#new()*
11
+lh#buffer#dialog#quit()	lh-vim-lib.txt	/*lh#buffer#dialog#quit()*
12
+lh#buffer#dialog#select()	lh-vim-lib.txt	/*lh#buffer#dialog#select()*
13
+lh#buffer#dialog#update()	lh-vim-lib.txt	/*lh#buffer#dialog#update()*
14
+lh#buffer#find()	lh-vim-lib.txt	/*lh#buffer#find()*
15
+lh#buffer#jump()	lh-vim-lib.txt	/*lh#buffer#jump()*
16
+lh#buffer#list()	lh-vim-lib.txt	/*lh#buffer#list()*
17
+lh#buffer#scratch()	lh-vim-lib.txt	/*lh#buffer#scratch()*
18
+lh#command#Fargs2String()	lh-vim-lib.txt	/*lh#command#Fargs2String()*
19
+lh#command#complete()	lh-vim-lib.txt	/*lh#command#complete()*
20
+lh#command#new()	lh-vim-lib.txt	/*lh#command#new()*
21
+lh#common#CheckDeps()	lh-vim-lib.txt	/*lh#common#CheckDeps()*
22
+lh#common#ErrorMsg()	lh-vim-lib.txt	/*lh#common#ErrorMsg()*
23
+lh#common#WarningMsg()	lh-vim-lib.txt	/*lh#common#WarningMsg()*
24
+lh#common#check_deps()	lh-vim-lib.txt	/*lh#common#check_deps()*
25
+lh#common#echomsgMultilines()	lh-vim-lib.txt	/*lh#common#echomsgMultilines()*
26
+lh#common#echomsg_multilines()	lh-vim-lib.txt	/*lh#common#echomsg_multilines()*
27
+lh#common#error_msg()	lh-vim-lib.txt	/*lh#common#error_msg()*
28
+lh#common#warning_msg()	lh-vim-lib.txt	/*lh#common#warning_msg()*
29
+lh#encoding#at()	lh-vim-lib.txt	/*lh#encoding#at()*
30
+lh#encoding#iconv()	lh-vim-lib.txt	/*lh#encoding#iconv()*
31
+lh#encoding#strlen()	lh-vim-lib.txt	/*lh#encoding#strlen()*
32
+lh#encoding#strpart()	lh-vim-lib.txt	/*lh#encoding#strpart()*
33
+lh#event#RegisterForOneExecutionAt()	lh-vim-lib.txt	/*lh#event#RegisterForOneExecutionAt()*
34
+lh#event#register_for_one_execution_at()	lh-vim-lib.txt	/*lh#event#register_for_one_execution_at()*
35
+lh#float#arg_max()	lh-vim-lib.txt	/*lh#float#arg_max()*
36
+lh#float#arg_min()	lh-vim-lib.txt	/*lh#float#arg_min()*
37
+lh#float#max()	lh-vim-lib.txt	/*lh#float#max()*
38
+lh#float#min()	lh-vim-lib.txt	/*lh#float#min()*
39
+lh#function#bind()	lh-vim-lib.txt	/*lh#function#bind()*
40
+lh#function#execute()	lh-vim-lib.txt	/*lh#function#execute()*
41
+lh#function#prepare()	lh-vim-lib.txt	/*lh#function#prepare()*
42
+lh#graph#tsort#breadth()	lh-vim-lib.txt	/*lh#graph#tsort#breadth()*
43
+lh#graph#tsort#depth()	lh-vim-lib.txt	/*lh#graph#tsort#depth()*
44
+lh#icomplete#run()	lh-vim-lib.txt	/*lh#icomplete#run()*
45
+lh#list#Find_if()	lh-vim-lib.txt	/*lh#list#Find_if()*
46
+lh#list#Match()	lh-vim-lib.txt	/*lh#list#Match()*
47
+lh#list#Transform()	lh-vim-lib.txt	/*lh#list#Transform()*
48
+lh#list#accumulate()	lh-vim-lib.txt	/*lh#list#accumulate()*
49
+lh#list#copy_if()	lh-vim-lib.txt	/*lh#list#copy_if()*
50
+lh#list#equal_range()	lh-vim-lib.txt	/*lh#list#equal_range()*
51
+lh#list#find_if()	lh-vim-lib.txt	/*lh#list#find_if()*
52
+lh#list#intersect()	lh-vim-lib.txt	/*lh#list#intersect()*
53
+lh#list#lower_bound()	lh-vim-lib.txt	/*lh#list#lower_bound()*
54
+lh#list#match()	lh-vim-lib.txt	/*lh#list#match()*
55
+lh#list#matches()	lh-vim-lib.txt	/*lh#list#matches()*
56
+lh#list#not_found()	lh-vim-lib.txt	/*lh#list#not_found()*
57
+lh#list#remove()	lh-vim-lib.txt	/*lh#list#remove()*
58
+lh#list#subset()	lh-vim-lib.txt	/*lh#list#subset()*
59
+lh#list#transform()	lh-vim-lib.txt	/*lh#list#transform()*
60
+lh#list#transform_if()	lh-vim-lib.txt	/*lh#list#transform_if()*
61
+lh#list#unique_sort()	lh-vim-lib.txt	/*lh#list#unique_sort()*
62
+lh#list#unique_sort2()	lh-vim-lib.txt	/*lh#list#unique_sort2()*
63
+lh#list#upper_bound()	lh-vim-lib.txt	/*lh#list#upper_bound()*
64
+lh#menu#IVN_make()	lh-vim-lib.txt	/*lh#menu#IVN_make()*
65
+lh#menu#def_toggle_item()	lh-vim-lib.txt	/*lh#menu#def_toggle_item()*
66
+lh#menu#is_in_visual_mode()	lh-vim-lib.txt	/*lh#menu#is_in_visual_mode()*
67
+lh#menu#make()	lh-vim-lib.txt	/*lh#menu#make()*
68
+lh#menu#make()_modes	lh-vim-lib.txt	/*lh#menu#make()_modes*
69
+lh#menu#map_all()	lh-vim-lib.txt	/*lh#menu#map_all()*
70
+lh#menu#text()	lh-vim-lib.txt	/*lh#menu#text()*
71
+lh#option#Get()	lh-vim-lib.txt	/*lh#option#Get()*
72
+lh#option#GetNonEmpty()	lh-vim-lib.txt	/*lh#option#GetNonEmpty()*
73
+lh#option#get()	lh-vim-lib.txt	/*lh#option#get()*
74
+lh#option#get_non_empty()	lh-vim-lib.txt	/*lh#option#get_non_empty()*
75
+lh#path#GlobAsList()	lh-vim-lib.txt	/*lh#path#GlobAsList()*
76
+lh#path#IsAbsolutePath()	lh-vim-lib.txt	/*lh#path#IsAbsolutePath()*
77
+lh#path#IsURL()	lh-vim-lib.txt	/*lh#path#IsURL()*
78
+lh#path#SelectOne()	lh-vim-lib.txt	/*lh#path#SelectOne()*
79
+lh#path#Simplify()	lh-vim-lib.txt	/*lh#path#Simplify()*
80
+lh#path#StripCommon()	lh-vim-lib.txt	/*lh#path#StripCommon()*
81
+lh#path#StripStart()	lh-vim-lib.txt	/*lh#path#StripStart()*
82
+lh#path#ToRelative()	lh-vim-lib.txt	/*lh#path#ToRelative()*
83
+lh#path#common()	lh-vim-lib.txt	/*lh#path#common()*
84
+lh#path#depth()	lh-vim-lib.txt	/*lh#path#depth()*
85
+lh#path#dirname()	lh-vim-lib.txt	/*lh#path#dirname()*
86
+lh#path#find()	lh-vim-lib.txt	/*lh#path#find()*
87
+lh#path#glob_as_list()	lh-vim-lib.txt	/*lh#path#glob_as_list()*
88
+lh#path#is_absolute_path()	lh-vim-lib.txt	/*lh#path#is_absolute_path()*
89
+lh#path#is_url()	lh-vim-lib.txt	/*lh#path#is_url()*
90
+lh#path#relative_to()	lh-vim-lib.txt	/*lh#path#relative_to()*
91
+lh#path#select_one()	lh-vim-lib.txt	/*lh#path#select_one()*
92
+lh#path#simplify()	lh-vim-lib.txt	/*lh#path#simplify()*
93
+lh#path#strip_common()	lh-vim-lib.txt	/*lh#path#strip_common()*
94
+lh#path#strip_start()	lh-vim-lib.txt	/*lh#path#strip_start()*
95
+lh#path#to_regex()	lh-vim-lib.txt	/*lh#path#to_regex()*
96
+lh#path#to_relative()	lh-vim-lib.txt	/*lh#path#to_relative()*
97
+lh#position#CharAtMark()	lh-vim-lib.txt	/*lh#position#CharAtMark()*
98
+lh#position#CharAtPos()	lh-vim-lib.txt	/*lh#position#CharAtPos()*
99
+lh#position#IsBefore()	lh-vim-lib.txt	/*lh#position#IsBefore()*
100
+lh#position#char_at_mark()	lh-vim-lib.txt	/*lh#position#char_at_mark()*
101
+lh#position#char_at_pos()	lh-vim-lib.txt	/*lh#position#char_at_pos()*
102
+lh#position#is_before()	lh-vim-lib.txt	/*lh#position#is_before()*
103
+lh#syntax#NameAt()	lh-vim-lib.txt	/*lh#syntax#NameAt()*
104
+lh#syntax#NameAtMark()	lh-vim-lib.txt	/*lh#syntax#NameAtMark()*
105
+lh#syntax#Skip()	lh-vim-lib.txt	/*lh#syntax#Skip()*
106
+lh#syntax#SkipAt()	lh-vim-lib.txt	/*lh#syntax#SkipAt()*
107
+lh#syntax#SkipAtMark()	lh-vim-lib.txt	/*lh#syntax#SkipAtMark()*
108
+lh#syntax#is_a_comment()	lh-vim-lib.txt	/*lh#syntax#is_a_comment()*
109
+lh#syntax#list()	lh-vim-lib.txt	/*lh#syntax#list()*
110
+lh#syntax#list_raw()	lh-vim-lib.txt	/*lh#syntax#list_raw()*
111
+lh#syntax#name_at()	lh-vim-lib.txt	/*lh#syntax#name_at()*
112
+lh#syntax#name_at_mark()	lh-vim-lib.txt	/*lh#syntax#name_at_mark()*
113
+lh#syntax#skip()	lh-vim-lib.txt	/*lh#syntax#skip()*
114
+lh#syntax#skip_at()	lh-vim-lib.txt	/*lh#syntax#skip_at()*
115
+lh#syntax#skip_at_mark()	lh-vim-lib.txt	/*lh#syntax#skip_at_mark()*
116
+lh#visual#cut()	lh-vim-lib.txt	/*lh#visual#cut()*
117
+lh#visual#selection()	lh-vim-lib.txt	/*lh#visual#selection()*
118
+lh-vim-lib.txt	lh-vim-lib.txt	/*lh-vim-lib.txt*
119
+lhvl#buffer	lh-vim-lib.txt	/*lhvl#buffer*
120
+lhvl#command	lh-vim-lib.txt	/*lhvl#command*
121
+lhvl#completion	lh-vim-lib.txt	/*lhvl#completion*
122
+lhvl#function	lh-vim-lib.txt	/*lhvl#function*
123
+lhvl#functor	lh-vim-lib.txt	/*lhvl#functor*
124
+lhvl#graph	lh-vim-lib.txt	/*lhvl#graph*
125
+lhvl#list	lh-vim-lib.txt	/*lhvl#list*
126
+lhvl#menu	lh-vim-lib.txt	/*lhvl#menu*
127
+lhvl#misc	lh-vim-lib.txt	/*lhvl#misc*
128
+lhvl#path	lh-vim-lib.txt	/*lhvl#path*
129
+lhvl#syntax	lh-vim-lib.txt	/*lhvl#syntax*
130
+lhvl-:Toggle	lh-vim-lib.txt	/*lhvl-:Toggle*
131
+lhvl-contents	lh-vim-lib.txt	/*lhvl-contents*
132
+lhvl-dialog	lh-vim-lib.txt	/*lhvl-dialog*
133
+lhvl-dialog-select-callback	lh-vim-lib.txt	/*lhvl-dialog-select-callback*
134
+lhvl-functions	lh-vim-lib.txt	/*lhvl-functions*
135
+lhvl-presentation	lh-vim-lib.txt	/*lhvl-presentation*
136
+s:PostInit()	lh-vim-lib.txt	/*s:PostInit()*
137
+scratch	lh-vim-lib.txt	/*scratch*
138
+v:1_	lh-vim-lib.txt	/*v:1_*
139
+v:2_	lh-vim-lib.txt	/*v:2_*

+ 6779
- 0
dotfiles/vim/bundle/lh-vim-lib/lh-vim-lib-3.1.1.vmb
File diff suppressed because it is too large
View File


+ 10
- 0
dotfiles/vim/bundle/lh-vim-lib/lh-vim-lib-addon-info.txt View File

@@ -0,0 +1,10 @@
1
+{
2
+  "name" : "lh-vim-lib",
3
+  "version" : "dev",
4
+  "author" : "Luc Hermitte <http://code.google.com/p/lh-vim/wiki/contact>",
5
+  "maintainer" : "Luc Hermitte <http://code.google.com/p/lh-vim/wiki/contact>",
6
+  "repository" : {"type": "svn", "url": "http://lh-vim.googlecode.com/svn/vim-lib/trunk"},
7
+  "dependencies" : {},
8
+  "description" : "Library of VimL functions",
9
+  "homepage" : "http://code.google.com/p/lh-vim/wiki/lhVimLib"
10
+}

+ 20
- 0
dotfiles/vim/bundle/lh-vim-lib/lh-vim-lib.README View File

@@ -0,0 +1,20 @@
1
+			   ------------------
2
+			    lh-vim-lib 3.1.0
3
+			   ------------------
4
+
5
+lh-vim-lib is a library plugin for vim v7+. It is just a collection of
6
+functions that are meant to be used by script writers.
7
+
8
+Audience      : Vim script writers
9
+Requirements  : Vim 7.1, Vim 7.3 for some functions
10
+Required by   : Just a few other plugins for the moment
11
+Author        : Luc Hermitte
12
+License       : GPLv3 with exceptions
13
+                http://code.google.com/p/lh-vim/wiki/License
14
+More Help At  : http://code.google.com/p/lh-vim/wiki/lhVimLib
15
+Vim script#214: http://www.vim.org/scripts/script.php?script_id=214
16
+Repository    :
17
+	svn checkout http://lh-vim.googlecode.com/svn/vim-lib/trunk lh-vim-lib
18
+VAM           :
19
+	http://code.google.com/p/lh-vim/source/browse/vim-lib/trunk/lh-vim-lib-addon-info.txt
20
+

+ 87
- 0
dotfiles/vim/bundle/lh-vim-lib/macros/menu-map.vim View File

@@ -0,0 +1,87 @@
1
+"===========================================================================
2
+" $Id: menu-map.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		macros/menu-map.vim
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+" 		<URL:http://code.google.com/p/lh-vim/>
6
+"
7
+" Purpose:	Define functions to build mappings and menus at the same time
8
+"
9
+" License:      GPLv3 with exceptions
10
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
11
+" Version:	3.0.0
12
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (02nd Dec 2006)
13
+"
14
+" Last Changes: {{{
15
+"       Version 3.0.0:
16
+"               GPLv3
17
+" 	Version 2.0.0:
18
+" 		Moved to vim7, 
19
+" 		Functions moved to {rtp}/autoload/
20
+" 	Version 1.6.2: 
21
+" 		(*) Silent mappings and menus
22
+" 	Version 1.6. : 
23
+" 		(*) Uses has('gui_running') instead of has('gui') to check if
24
+" 		we can generate the menu.
25
+" 	Version 1.5. : 
26
+" 		(*) visual mappings launched from select-mode don't end with
27
+" 		    text still selected -- applied to :VCalls
28
+" 	Version 1.4. : 
29
+" 		(*) address obfuscated for spammers
30
+" 		(*) support the local option 
31
+" 		    b:want_buffermenu_or_global_disable if we don't want
32
+" 		    buffermenu to be used systematically.
33
+" 		    0 -> buffer menu not used
34
+" 		    1 -> buffer menu used
35
+" 		    2 -> the VimL developper will use a global disable.
36
+" 		    cf.:   tex-maps.vim:: s:SimpleMenu()
37
+" 		       and texmenus.vim
38
+" 	Version 1.3. :
39
+"		(*) add continuation lines support ; cf 'cpoptions'
40
+" 	Version 1.2. :
41
+" 		(*) Code folded.
42
+" 		(*) Take advantage of buffermenu.vim if present for local
43
+" 		    menus.
44
+" 		(*) If non gui is available, the menus won't be defined
45
+" 	Version 1.1. :
46
+"               (*) Bug corrected : 
47
+"                   vnore(map\|menu) does not imply v+n(map\|menu) any more
48
+" }}}
49
+"
50
+" Inspired By:	A function from Benji Fisher
51
+"
52
+" TODO:		(*) no menu if no gui.
53
+"
54
+"===========================================================================
55
+
56
+if exists("g:loaded_menu_map") | finish | endif
57
+let g:loaded_menu_map = 1  
58
+
59
+"" line continuation used here ??
60
+let s:cpo_save = &cpo
61
+set cpo&vim
62
+
63
+"=========================================================================
64
+" Commands {{{
65
+command! -nargs=+ -bang      MAP      map<bang> <args>
66
+command! -nargs=+           IMAP     imap       <args>
67
+command! -nargs=+           NMAP     nmap       <args>
68
+command! -nargs=+           CMAP     cmap       <args>
69
+command! -nargs=+           VMAP     vmap       <args>
70
+command! -nargs=+           AMAP
71
+      \       call lh#menu#map_all('amap', <f-args>)
72
+
73
+command! -nargs=+ -bang  NOREMAP  noremap<bang> <args>
74
+command! -nargs=+       INOREMAP inoremap       <args>
75
+command! -nargs=+       NNOREMAP nnoremap       <args>
76
+command! -nargs=+       CNOREMAP cnoremap       <args>
77
+command! -nargs=+       VNOREMAP vnoremap       <args>
78
+command! -nargs=+       ANOREMAP
79
+      \       call lh#menu#map_all('anoremap', <f-args>)
80
+" }}}
81
+
82
+" End !
83
+let &cpo = s:cpo_save
84
+finish
85
+
86
+"=========================================================================
87
+" vim600: set fdm=marker:

+ 60
- 0
dotfiles/vim/bundle/lh-vim-lib/mkVba/mk-lh-vim-lib.vim View File

@@ -0,0 +1,60 @@
1
+"=============================================================================
2
+" $Id: mk-lh-vim-lib.vim 606 2012-05-31 17:09:46Z luc.hermitte@gmail.com $
3
+" File:		mkVba/mk-lh-lib.vim
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.1.1
9
+let s:version = '3.1.1'
10
+" Created:	06th Nov 2007
11
+" Last Update:	$Date: 2012-05-31 19:09:46 +0200 (jeu 31 mai 2012) $
12
+"------------------------------------------------------------------------
13
+cd <sfile>:p:h
14
+try 
15
+  let save_rtp = &rtp
16
+  let &rtp = expand('<sfile>:p:h:h').','.&rtp
17
+  exe '24,$MkVimball! lh-vim-lib-'.s:version
18
+  set modifiable
19
+  set buftype=
20
+finally
21
+  let &rtp = save_rtp
22
+endtry
23
+finish
24
+autoload/lh/askvim.vim
25
+autoload/lh/buffer.vim
26
+autoload/lh/buffer/dialog.vim
27
+autoload/lh/command.vim
28
+autoload/lh/common.vim
29
+autoload/lh/encoding.vim
30
+autoload/lh/env.vim
31
+autoload/lh/event.vim
32
+autoload/lh/float.vim
33
+autoload/lh/function.vim
34
+autoload/lh/graph/tsort.vim
35
+autoload/lh/icomplete.vim
36
+autoload/lh/list.vim
37
+autoload/lh/menu.vim
38
+autoload/lh/option.vim
39
+autoload/lh/path.vim
40
+autoload/lh/position.vim
41
+autoload/lh/syntax.vim
42
+autoload/lh/visual.vim
43
+doc/lh-vim-lib.txt
44
+lh-vim-lib-addon-info.txt
45
+lh-vim-lib.README
46
+macros/menu-map.vim
47
+mkVba/mk-lh-vim-lib.vim
48
+plugin/let.vim
49
+plugin/lhvl.vim
50
+plugin/ui-functions.vim
51
+plugin/words_tools.vim
52
+tests/lh/function.vim
53
+tests/lh/list.vim
54
+tests/lh/path.vim
55
+tests/lh/test-Fargs2String.vim
56
+tests/lh/test-askmenu.vim
57
+tests/lh/test-command.vim
58
+tests/lh/test-menu-map.vim
59
+tests/lh/test-toggle-menu.vim
60
+tests/lh/topological-sort.vim

+ 57
- 0
dotfiles/vim/bundle/lh-vim-lib/plugin/let.vim View File

@@ -0,0 +1,57 @@
1
+"=============================================================================
2
+" $Id: let.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:         plugin/let.vim                                    {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      31st May 2010
10
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:
13
+"       Defines a command :LetIfUndef that sets a variable if undefined
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:
17
+"       Drop this file into {rtp}/plugin
18
+"       Requires Vim7+
19
+" History:      
20
+" 	v2.2.1: first version of this command into lh-vim-lib
21
+" 	v3.0.0: GPLv3
22
+" TODO: 
23
+" }}}1
24
+"=============================================================================
25
+
26
+" Avoid global reinclusion {{{1
27
+let s:k_version = 300
28
+if &cp || (exists("g:loaded_let")
29
+      \ && (g:loaded_let >= s:k_version)
30
+      \ && !exists('g:force_reload_let'))
31
+  finish
32
+endif
33
+let g:loaded_let = s:k_version
34
+let s:cpo_save=&cpo
35
+set cpo&vim
36
+" Avoid global reinclusion }}}1
37
+"------------------------------------------------------------------------
38
+" Commands and Mappings {{{1
39
+command! -nargs=+ LetIfUndef call s:LetIfUndef(<f-args>)
40
+" Commands and Mappings }}}1
41
+"------------------------------------------------------------------------
42
+" Functions {{{1
43
+" Note: most functions are best placed into
44
+" autoload/«your-initials»/«let».vim
45
+" Keep here only the functions are are required when the plugin is loaded,
46
+" like functions that help building a vim-menu for this plugin.
47
+function! s:LetIfUndef(var, value)
48
+  if !exists(a:var)
49
+    let {a:var} = eval(a:value)
50
+  endif
51
+endfunction
52
+
53
+" Functions }}}1
54
+"------------------------------------------------------------------------
55
+let &cpo=s:cpo_save
56
+"=============================================================================
57
+" vim600: set fdm=marker:

+ 48
- 0
dotfiles/vim/bundle/lh-vim-lib/plugin/lhvl.vim View File

@@ -0,0 +1,48 @@
1
+"=============================================================================
2
+" $Id: lhvl.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		plugin/lhvl.vim                                   {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	27th Apr 2010
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+"       Non-function resources from lh-vim-lib
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	
17
+"       Drop the file into {rtp}/plugin
18
+" History:	
19
+"       v2.2.1  first version
20
+"       v3.0.0  GPLv3
21
+" TODO:		«missing features»
22
+" }}}1
23
+"=============================================================================
24
+
25
+" Avoid global reinclusion {{{1
26
+let s:k_version = 300
27
+if &cp || (exists("g:loaded_lhvl")
28
+      \ && (g:loaded_lhvl >= s:k_version)
29
+      \ && !exists('g:force_reload_lhvl'))
30
+  finish
31
+endif
32
+let g:loaded_lhvl = s:k_version
33
+let s:cpo_save=&cpo
34
+set cpo&vim
35
+" Avoid global reinclusion }}}1
36
+"------------------------------------------------------------------------
37
+" Commands and Mappings {{{1
38
+" Moved from lh-cpp
39
+command! PopSearch :call histdel('search', -1)| let @/=histget('search',-1)
40
+
41
+" Commands and Mappings }}}1
42
+"------------------------------------------------------------------------
43
+" Functions {{{1
44
+" Functions }}}1
45
+"------------------------------------------------------------------------
46
+let &cpo=s:cpo_save
47
+"=============================================================================
48
+" vim600: set fdm=marker:

+ 490
- 0
dotfiles/vim/bundle/lh-vim-lib/plugin/ui-functions.vim View File

@@ -0,0 +1,490 @@
1
+"=============================================================================
2
+" File:         plugin/ui-functions.vim                                  {{{1
3
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
4
+"               <URL:http://code.google.com/p/lh-vim/>
5
+" License:      GPLv3 with exceptions
6
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
7
+" Version:      3.0.0
8
+" Created:      18th nov 2002
9
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (19th Mar 2012)
10
+"------------------------------------------------------------------------
11
+" Description:  Functions for the interaction with a User Interface.
12
+"               The UI can be graphical or textual.
13
+"               At first, this was designed to ease the syntax of
14
+"               mu-template's templates.
15
+"
16
+" Option:       {{{2
17
+"       {[bg]:ui_type} 
18
+"               = "g\%[ui]", 
19
+"               = "t\%[ext]" ; the call must not be |:silent|
20
+"               = "f\%[te]"
21
+" }}}2
22
+"------------------------------------------------------------------------
23
+" Installation: Drop this into one of your {rtp}/plugin/ directories.
24
+" History:      {{{2
25
+"    v0.01 Initial Version
26
+"    v0.02
27
+"       (*) Code "factorisations" 
28
+"       (*) Help on <F1> enhanced.
29
+"       (*) Small changes regarding the parameter accepted
30
+"       (*) Function SWITCH
31
+"    v0.03
32
+"       (*) Small bug fix with INPUT()
33
+"    v0.04
34
+"       (*) New function: WHICH()
35
+"    v0.05
36
+"       (*) In vim7e, inputdialog() returns a trailing '\n'. INPUT() strips the
37
+"           NL character.
38
+"    v0.06
39
+"       (*) :s/echoerr/throw/ => vim7 only
40
+"    v2.2.0
41
+"       (*) menu to switch the ui_type
42
+"    v2.2.6
43
+"       (*) CONFIRM() and WHICH() accept lists of {choices}
44
+"    v3.0.0  GPLv3
45
+" 
46
+" TODO:         {{{2
47
+"       (*) Save the hl-User1..9 before using them
48
+"       (*) Possibility other than &statusline:
49
+"           echohl User1 |echon "bla"|echohl User2|echon "bli"|echohl None
50
+"       (*) Wraps too long choices-line (length > term-width)
51
+"       (*) Add to the documentation: "don't use CTRL-C to abort !!"
52
+"       (*) Look if I need to support 'wildmode'
53
+"       (*) 3rd mode: return string for FTE
54
+"       (*) 4th mode: interaction in a scratch buffer
55
+"
56
+" }}}1
57
+"=============================================================================
58
+" Avoid reinclusion {{{1
59
+" 
60
+if exists("g:loaded_ui_functions") && !exists('g:force_reload_ui_functions')
61
+  finish 
62
+endif
63
+let g:loaded_ui_functions = 1
64
+let s:cpo_save=&cpo
65
+set cpo&vim
66
+" }}}1
67
+"------------------------------------------------------------------------
68
+" External functions {{{1
69
+" Function: IF(var, then, else) {{{2
70
+function! IF(var,then, else)
71
+  let o = s:Opt_type() " {{{3
72
+  if     o =~ 'g\%[ui]\|t\%[ext]' " {{{4
73
+    return a:var ? a:then : a:else
74
+  elseif o =~ 'f\%[te]'           " {{{4
75
+    return s:if_fte(a:var, a:then, a:else)
76
+  else                    " {{{4
77
+    throw "UI-Fns::IF(): Unkonwn user-interface style (".o.")"
78
+  endif
79
+  " }}}3
80
+endfunction
81
+
82
+" Function: SWITCH(var, case, action [, case, action] [default_action]) {{{2
83
+function! SWITCH(var, ...)
84
+  let o = s:Opt_type() " {{{3
85
+  if     o =~ 'g\%[ui]\|t\%[ext]' " {{{4
86
+    let explicit_def = ((a:0 % 2) == 1)
87
+    let default      = explicit_def ? a:{a:0} : ''
88
+    let i = a:0 - 1 - explicit_def
89
+    while i > 0
90
+      if a:var == a:{i}
91
+        return a:{i+1}
92
+      endif
93
+      let i -=  2
94
+    endwhile
95
+    return default
96
+  elseif o =~ 'f\%[te]'           " {{{4
97
+    return s:if_fte(a:var, a:then, a:else)
98
+  else                    " {{{4
99
+    throw "UI-Fns::SWITCH(): Unkonwn user-interface style (".o.")"
100
+  endif
101
+  " }}}3
102
+endfunction
103
+
104
+" Function: CONFIRM(text [, choices [, default [, type]]]) {{{2
105
+function! CONFIRM(text, ...)
106
+  " 1- Check parameters {{{3
107
+  if a:0 > 4 " {{{4
108
+    throw "UI-Fns::CONFIRM(): too many parameters"
109
+    return 0
110
+  endif
111
+  " build the parameters string {{{4
112
+  let i = 1
113
+  while i <= a:0
114
+    if i == 1
115
+      if type(a:1) == type([])
116
+        let params = string(join(a:1, "\n"))
117
+      else
118
+        let params = 'a:{1}'
119
+      endif
120
+    else      | let params .= ',a:{'.i.'}'
121
+    endif
122
+    let i +=  1
123
+  endwhile
124
+  " 2- Choose the correct way to execute according to the option {{{3
125
+  let o = s:Opt_type()
126
+  if     o =~ 'g\%[ui]'  " {{{4
127
+    exe 'return confirm(a:text,'.params.')'
128
+  elseif o =~ 't\%[ext]' " {{{4
129
+    if !has('gui_running') && has('dialog_con')
130
+      exe 'return confirm(a:text,'.params.')'
131
+    else
132
+      exe 'return s:confirm_text("none", a:text,'.params.')'
133
+    endif
134
+  elseif o =~ 'f\%[te]'  " {{{4
135
+      exe 'return s:confirm_fte(a:text,'.params.')'
136
+  else               " {{{4
137
+    throw "UI-Fns::CONFIRM(): Unkonwn user-interface style (".o.")"
138
+  endif
139
+  " }}}3
140
+endfunction
141
+
142
+" Function: INPUT(prompt [, default ]) {{{2
143
+function! INPUT(prompt, ...)
144
+  " 1- Check parameters {{{3
145
+  if a:0 > 4 " {{{4
146
+    throw "UI-Fns::INPUT(): too many parameters"
147
+    return 0
148
+  endif
149
+  " build the parameters string {{{4
150
+  let i = 1 | let params = ''
151
+  while i <= a:0
152
+    if i == 1 | let params = 'a:{1}'
153
+    else      | let params .= ',a:{'.i.'}'
154
+    endif
155
+    let i +=  1
156
+  endwhile
157
+  " 2- Choose the correct way to execute according to the option {{{3
158
+  let o = s:Opt_type()
159
+  if     o =~ 'g\%[ui]'  " {{{4
160
+    exe 'return matchstr(inputdialog(a:prompt,'.params.'), ".\\{-}\\ze\\n\\=$")'
161
+  elseif o =~ 't\%[ext]' " {{{4
162
+    exe 'return input(a:prompt,'.params.')'
163
+  elseif o =~ 'f\%[te]'  " {{{4
164
+      exe 'return s:input_fte(a:prompt,'.params.')'
165
+  else               " {{{4
166
+    throw "UI-Fns::INPUT(): Unkonwn user-interface style (".o.")"
167
+  endif
168
+  " }}}3
169
+endfunction
170
+
171
+" Function: COMBO(prompt, choice [, ... ]) {{{2
172
+function! COMBO(prompt, ...)
173
+  " 1- Check parameters {{{3
174
+  if a:0 > 4 " {{{4
175
+    throw "UI-Fns::COMBO(): too many parameters"
176
+    return 0
177
+  endif
178
+  " build the parameters string {{{4
179
+  let i = 1
180
+  while i <= a:0
181
+    if i == 1 | let params = 'a:{1}'
182
+    else      | let params .=  ',a:{'.i.'}'
183
+    endif
184
+    let i +=  1
185
+  endwhile
186
+  " 2- Choose the correct way to execute according to the option {{{3
187
+  let o = s:Opt_type()
188
+  if     o =~ 'g\%[ui]'  " {{{4
189
+    exe 'return confirm(a:prompt,'.params.')'
190
+  elseif o =~ 't\%[ext]' " {{{4
191
+    exe 'return s:confirm_text("combo", a:prompt,'.params.')'
192
+  elseif o =~ 'f\%[te]'  " {{{4
193
+    exe 'return s:combo_fte(a:prompt,'.params.')'
194
+  else               " {{{4
195
+    throw "UI-Fns::COMBO(): Unkonwn user-interface style (".o.")"
196
+  endif
197
+  " }}}3
198
+endfunction
199
+
200
+" Function: WHICH(function, prompt, choice [, ... ]) {{{2
201
+function! WHICH(fn, prompt, ...)
202
+  " 1- Check parameters {{{3
203
+  " build the parameters string {{{4
204
+  let i = 1
205
+  while i <= a:0
206
+    if i == 1 
207
+      if type(a:1) == type([])
208
+        let choices = a:1
209
+      else
210
+        let choices = split(a:1, "\n")
211
+      endif
212
+      let params = 'a:{1}'
213
+    else      | let params .=  ',a:{'.i.'}'
214
+    endif
215
+    let i +=  1
216
+  endwhile
217
+  " 2- Execute the function {{{3
218
+  exe 'let which = '.a:fn.'(a:prompt,'.params.')'
219
+  if     0 >= which | return ''
220
+  else
221
+    return substitute(choices[which-1], '&', '', '')
222
+  endif
223
+  " }}}3
224
+endfunction
225
+
226
+" Function: CHECK(prompt, choice [, ... ]) {{{2
227
+function! CHECK(prompt, ...)
228
+  " 1- Check parameters {{{3
229
+  if a:0 > 4 " {{{4
230
+    throw "UI-Fns::CHECK(): too many parameters"
231
+    return 0
232
+  endif
233
+  " build the parameters string {{{4
234
+  let i = 1
235
+  while i <= a:0
236
+    if i == 1 | let params = 'a:{1}'
237
+    else      | let params .=  ',a:{'.i.'}'
238
+    endif
239
+    let i +=  1
240
+  endwhile
241
+  " 2- Choose the correct way to execute according to the option {{{3
242
+  let o = s:Opt_type()
243
+  if     o =~ 'g\%[ui]'  " {{{4
244
+    exe 'return s:confirm_text("check", a:prompt,'.params.')'
245
+  elseif o =~ 't\%[ext]' " {{{4
246
+    exe 'return s:confirm_text("check", a:prompt,'.params.')'
247
+  elseif o =~ 'f\%[te]'  " {{{4
248
+      exe 'return s:check_fte(a:prompt,'.params.')'
249
+  else               " {{{4
250
+    throw "UI-Fns::CHECK(): Unkonwn user-interface style (".o.")"
251
+  endif
252
+  " }}}3
253
+endfunction
254
+
255
+" }}}1
256
+"------------------------------------------------------------------------
257
+" Options setting {{{1
258
+let s:OptionData = {
259
+      \ "variable": "ui_type",
260
+      \ "idx_crt_value": 1,
261
+      \ "values": ['gui', 'text', 'fte'],
262
+      \ "menu": { "priority": '500.2700', "name": '&Plugin.&LH.&UI type'}
263
+      \}
264
+
265
+call lh#menu#def_toggle_item(s:OptionData)
266
+
267
+" }}}1
268
+"------------------------------------------------------------------------
269
+" Internal functions {{{1
270
+function! s:Option(name, default) " {{{2
271
+  if     exists('b:ui_'.a:name) | return b:ui_{a:name}
272
+  elseif exists('g:ui_'.a:name) | return g:ui_{a:name}
273
+  else                          | return a:default
274
+  endif
275
+endfunction
276
+
277
+
278
+function! s:Opt_type() " {{{2
279
+  return s:Option('type', 'gui')
280
+endfunction
281
+
282
+"
283
+" Function: s:status_line(current, hl [, choices] ) {{{2
284
+"     a:current: current item
285
+"     a:hl     : Generic, Warning, Error
286
+function! s:status_line(current, hl, ...)
287
+  " Highlightning {{{3
288
+  if     a:hl == "Generic"  | let hl = '%1*'
289
+  elseif a:hl == "Warning"  | let hl = '%2*'
290
+  elseif a:hl == "Error"    | let hl = '%3*'
291
+  elseif a:hl == "Info"     | let hl = '%4*'
292
+  elseif a:hl == "Question" | let hl = '%5*'
293
+  else                      | let hl = '%1*'
294
+  endif
295
+  
296
+  " Build the string {{{3
297
+  let sl_choices = '' | let i = 1
298
+  while i <= a:0
299
+    if i == a:current
300
+      let sl_choices .=  ' '. hl . 
301
+            \ substitute(a:{i}, '&\(.\)', '%6*\1'.hl, '') . '%* '
302
+    else
303
+      let sl_choices .=  ' ' . 
304
+            \ substitute(a:{i}, '&\(.\)', '%6*\1%*', '') . ' '
305
+    endif
306
+    let i +=  1
307
+  endwhile
308
+  " }}}3
309
+  return sl_choices
310
+endfunction
311
+
312
+
313
+" Function: s:confirm_text(box, text [, choices [, default [, type]]]) {{{2
314
+function! s:confirm_text(box, text, ...)
315
+  let help = "/<esc>/<s-tab>/<tab>/<left>/<right>/<cr>/<F1>"
316
+  " 1- Retrieve the parameters       {{{3
317
+  let choices = ((a:0>=1) ? a:1 : '&Ok')
318
+  let default = ((a:0>=2) ? a:2 : (('check' == a:box) ? 0 : 1))
319
+  let type    = ((a:0>=3) ? a:3 : 'Generic')
320
+  if     'none'  == a:box | let prefix = ''
321
+  elseif 'combo' == a:box | let prefix = '( )_'
322
+  elseif 'check' == a:box | let prefix = '[ ]_'
323
+    let help = '/ '.help
324
+  else                    | let prefix = ''
325
+  endif
326
+
327
+
328
+  " 2- Retrieve the proposed choices {{{3
329
+  " Prepare the hot keys
330
+  let i = 0
331
+  while i != 26
332
+    let hotkey_{nr2char(i+65)} = 0
333
+    let i += 1
334
+  endwhile
335
+  let hotkeys = '' | let help_k = '/'
336
+  " Parse the choices
337
+  let i = 0
338
+  while choices != ""
339
+    let i +=  1
340
+    let item    = matchstr(choices, "^.\\{-}\\ze\\(\n\\|$\\)")
341
+    let choices = matchstr(choices, "\n\\zs.*$")
342
+    " exe 'anoremenu ]'.a:text.'.'.item.' :let s:choice ='.i.'<cr>'
343
+    if ('check' == a:box) && (strlen(default)>=i) && (1 == default[i-1])
344
+      " let choice_{i} = '[X]' . substitute(item, '&', '', '')
345
+      let choice_{i} = '[X]_' . item
346
+    else
347
+      " let choice_{i} = prefix . substitute(item, '&', '', '')
348
+      let choice_{i} = prefix . item
349
+    endif
350
+    if i == 1
351
+      let list_choices = 'choice_{1}'
352
+    else
353
+      let list_choices .=  ',choice_{'.i.'}'
354
+    endif
355
+    " Update the hotkey.
356
+    let key = toupper(matchstr(choice_{i}, '&\zs.\ze'))
357
+    let hotkey_{key} = i
358
+    let hotkeys .=  tolower(key) . toupper(key)
359
+    let help_k .=  tolower(key)
360
+  endwhile
361
+  let nb_choices = i
362
+  if default > nb_choices | let default = nb_choices | endif
363
+
364
+  " 3- Run an interactive text menu  {{{3
365
+  " Note: emenu can not be used through ":exe" {{{4
366
+  " let wcm = &wcm
367
+  " set wcm=<tab>
368
+  " exe ':emenu ]'.a:text.'.'."<tab>"
369
+  " let &wcm = wcm
370
+  " 3.1- Preparations for the statusline {{{4
371
+  " save the statusline
372
+  let sl = &l:statusline
373
+  " Color schemes for selected item {{{5
374
+  :hi User1 term=inverse,bold cterm=inverse,bold ctermfg=Yellow 
375
+        \ guifg=Black guibg=Yellow
376
+  :hi User2 term=inverse,bold cterm=inverse,bold ctermfg=LightRed
377
+        \ guifg=Black guibg=LightRed
378
+  :hi User3 term=inverse,bold cterm=inverse,bold ctermfg=Red 
379
+        \ guifg=Black guibg=Red
380
+  :hi User4 term=inverse,bold cterm=inverse,bold ctermfg=Cyan
381
+        \ guifg=Black guibg=Cyan
382
+  :hi User5 term=inverse,bold cterm=inverse,bold ctermfg=LightYellow
383
+        \ guifg=Black guibg=LightYellow
384
+  :hi User6 term=inverse,bold cterm=inverse,bold ctermfg=LightGray
385
+        \ guifg=DarkRed guibg=LightGray
386
+  " }}}5
387
+
388
+  " 3.2- Interactive loop                {{{4
389
+  let help =  "\r-- Keys available (".help_k.help.")"
390
+  " item selected at the start
391
+  let i = ('check' != a:box) ? default : 1
392
+  let direction = 0 | let toggle = 0
393
+  while 1
394
+    if 'combo' == a:box
395
+      let choice_{i} = substitute(choice_{i}, '^( )', '(*)', '')
396
+    endif
397
+    " Colored statusline
398
+    " Note: unfortunately the 'statusline' is a global option, {{{
399
+    " not a local one. I the hope that may change, as it does not provokes any
400
+    " error, I use '&l:statusline'. }}}
401
+    exe 'let &l:statusline=s:status_line(i, type,'. list_choices .')'
402
+    if has(':redrawstatus')
403
+      redrawstatus!
404
+    else
405
+      redraw!
406
+    endif
407
+    " Echo the current selection
408
+    echo "\r". a:text.' '.substitute(choice_{i}, '&', '', '')
409
+    " Wait the user to hit a key
410
+    let key=getchar()
411
+    let complType=nr2char(key)
412
+    " If the key hit matched awaited keys ...
413
+    if -1 != stridx(" \<tab>\<esc>\<enter>".hotkeys,complType) ||
414
+          \ (key =~ "\<F1>\\|\<right>\\|\<left>\\|\<s-tab>")
415
+      if key           == "\<F1>"                       " Help      {{{5
416
+        redraw!
417
+        echohl StatusLineNC
418
+        echo help
419
+        echohl None
420
+        let key=getchar()
421
+        let complType=nr2char(key)
422
+      endif
423
+      " TODO: support CTRL-D
424
+      if     complType == "\<enter>"                    " Validate  {{{5
425
+        break
426
+      elseif complType == " "                           " check box {{{5
427
+        let toggle = 1
428
+      elseif complType == "\<esc>"                      " Abort     {{{5
429
+        let i = -1 | break
430
+      elseif complType == "\<tab>" || key == "\<right>" " Next      {{{5
431
+        let direction = 1
432
+      elseif key =~ "\<left>\\|\<s-tab>"                " Previous  {{{5
433
+        let direction = -1
434
+      elseif -1 != stridx(hotkeys, complType )          " Hotkeys     {{{5
435
+        if '' == complType  | continue | endif
436
+        let direction = hotkey_{toupper(complType)} - i
437
+        let toggle = 1
438
+      " else
439
+      endif
440
+      " }}}5
441
+    endif
442
+    if direction != 0 " {{{5
443
+      if 'combo' == a:box
444
+        let choice_{i} = substitute(choice_{i}, '^(\*)', '( )', '')
445
+      endif
446
+      let i +=  direction
447
+      if     i > nb_choices | let i = 1 
448
+      elseif i == 0         | let i = nb_choices
449
+      endif
450
+      let direction = 0
451
+    endif
452
+    if toggle == 1    " {{{5
453
+      if 'check' == a:box
454
+        let choice_{i} = ((choice_{i}[1] == ' ')? '[X]' : '[ ]') 
455
+              \ . strpart(choice_{i}, 3)
456
+      endif
457
+      let toggle = 0
458
+    endif
459
+  endwhile " }}}4
460
+  " 4- Terminate                     {{{3
461
+  " Clear screen
462
+  redraw!
463
+
464
+  " Restore statusline
465
+  let &l:statusline=sl
466
+  " Return
467
+  if (i == -1) || ('check' != a:box)
468
+    return i
469
+  else
470
+    let r = '' | let i = 1
471
+    while i <= nb_choices
472
+      let r .=  ((choice_{i}[1] == 'X') ? '1' : '0')
473
+      let i +=  1
474
+    endwhile
475
+    return r
476
+  endif
477
+endfunction
478
+" }}}1
479
+"------------------------------------------------------------------------
480
+" Functions that insert fte statements {{{1
481
+" Function: s:if_fte(var, then, else) {{{2
482
+" Function: s:confirm_fte(text, [, choices [, default [, type]]]) {{{2
483
+" Function: s:input_fte(prompt [, default]) {{{2
484
+" Function: s:combo_fte(prompt, choice [, ...]) {{{2
485
+" Function: s:check_fte(prompt, choice [, ...]) {{{2
486
+" }}}1
487
+"------------------------------------------------------------------------
488
+let &cpo=s:cpo_save
489
+"=============================================================================
490
+" vim600: set fdm=marker:

+ 105
- 0
dotfiles/vim/bundle/lh-vim-lib/plugin/words_tools.vim View File

@@ -0,0 +1,105 @@
1
+" File:		plugin/words_tools.vim
2
+" Author:	Luc Hermitte <hermitte {at} free {dot} fr>
3
+" 		<URL:http://code.google.com/p/lh-vim/>
4
+" License:      GPLv3 with exceptions
5
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
6
+" Version:      3.0.0
7
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (19th Mar 2012)
8
+" Purpose:	Define functions better than expand("<cword>")
9
+"
10
+" Note:		They are expected to be used in insert mode (thanks to <c-r>
11
+"               or <c-o>)
12
+"
13
+"===========================================================================
14
+
15
+" Return the current keyword, uses spaces to delimitate {{{1
16
+function! GetNearestKeyword()
17
+  let c = col ('.')-1
18
+  let ll = getline('.')
19
+  let ll1 = strpart(ll,0,c)
20
+  let ll1 = matchstr(ll1,'\k*$')
21
+  let ll2 = strpart(ll,c,strlen(ll)-c+1)
22
+  let ll2 = matchstr(ll2,'^\k*')
23
+  " let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))
24
+  return ll1.ll2
25
+endfunction
26
+
27
+" Return the current word, uses spaces to delimitate {{{1
28
+function! GetNearestWord()
29
+  let c = col ('.')-1
30
+  let l = line('.')
31
+  let ll = getline(l)
32
+  let ll1 = strpart(ll,0,c)
33
+  let ll1 = matchstr(ll1,'\S*$')
34
+  let ll2 = strpart(ll,c,strlen(ll)-c+1)
35
+  let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))
36
+  ""echo ll1.ll2
37
+  return ll1.ll2
38
+endfunction
39
+
40
+" Return the word before the cursor, uses spaces to delimitate {{{1
41
+" Rem : <cword> is the word under or after the cursor
42
+function! GetCurrentWord()
43
+  let c = col ('.')-1
44
+  let l = line('.')
45
+  let ll = getline(l)
46
+  let ll1 = strpart(ll,0,c)
47
+  let ll1 = matchstr(ll1,'\S*$')
48
+  if strlen(ll1) == 0
49
+    return ll1
50
+  else
51
+    let ll2 = strpart(ll,c,strlen(ll)-c+1)
52
+    let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))
53
+    return ll1.ll2
54
+  endif
55
+endfunction
56
+
57
+" Return the keyword before the cursor, uses \k to delimitate {{{1
58
+" Rem : <cword> is the word under or after the cursor
59
+function! GetCurrentKeyword()
60
+  let c = col ('.')-1
61
+  let l = line('.')
62
+  let ll = getline(l)
63
+  let ll1 = strpart(ll,0,c)
64
+  let ll1 = matchstr(ll1,'\k*$')
65
+  if strlen(ll1) == 0
66
+    return ll1
67
+  else
68
+    let ll2 = strpart(ll,c,strlen(ll)-c+1)
69
+    let ll2 = matchstr(ll2,'^\k*')
70
+    " let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))
71
+    return ll1.ll2
72
+  endif
73
+endfunction
74
+
75
+" Extract the word before the cursor,  {{{1
76
+" use keyword definitions, skip latter spaces (see "bla word_accepted ")
77
+function! GetPreviousWord()
78
+  let lig = getline(line('.'))
79
+  let lig = strpart(lig,0,col('.')-1)
80
+  return matchstr(lig, '\<\k*\>\s*$')
81
+endfunction
82
+
83
+" GetLikeCTRL_W() retrieves the characters that i_CTRL-W deletes. {{{1
84
+" Initial need by Hari Krishna Dara <hari_vim@yahoo.com>
85
+" Last ver:
86
+" Pb: "if strlen(w) ==  " --> ") ==  " instead of just "==  ".
87
+" There still exists a bug regarding the last char of a line. VIM bug ?
88
+function! GetLikeCTRL_W()
89
+  let lig = getline(line('.'))
90
+  let lig = strpart(lig,0,col('.')-1)
91
+  " treat ending spaces apart.
92
+  let s = matchstr(lig, '\s*$')
93
+  let lig = strpart(lig, 0, strlen(lig)-strlen(s))
94
+  " First case : last characters belong to a "word"
95
+  let w = matchstr(lig, '\<\k\+\>$')
96
+  if strlen(w) == 0
97
+    " otherwise, they belong to a "non word" (without any space)
98
+    let w = substitute(lig, '.*\(\k\|\s\)', '', 'g')
99
+  endif
100
+  return w . s
101
+endfunction
102
+
103
+" }}}1
104
+"========================================================================
105
+" vim60: set fdm=marker:

+ 288
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/function.vim View File

@@ -0,0 +1,288 @@
1
+"=============================================================================
2
+" $Id: function.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		tests/lh/function.vim                                   {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	03rd Nov 2008
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Tests for autoload/lh/function.vim
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	«install details»
17
+" History:	«history»
18
+" TODO:		«missing features»
19
+" }}}1
20
+"=============================================================================
21
+
22
+UTSuite [lh-vim-lib] Testing lh#function plugin
23
+
24
+runtime autoload/lh/function.vim
25
+
26
+let s:cpo_save=&cpo
27
+set cpo&vim
28
+"------------------------------------------------------------------------
29
+function! Test(...)
30
+  let nb = len(a:000)
31
+  " echo "test(".nb.':' .join(a:000, ' -- ')')'
32
+  let i =0
33
+  while i!= len(a:000)
34
+    echo "Test: type(".i.")=".type(a:000[i]).' --> '. string(a:000[i])
35
+    let i += 1
36
+  endwhile
37
+endfunction
38
+
39
+function! Print(...)
40
+  let res = lh#list#accumulate([1,2,'foo'], 'string', 'join(v:1_, " ## ")')
41
+  return res
42
+endfunction
43
+
44
+function! Id(...)
45
+  return copy(a:000)
46
+endfunction
47
+
48
+function! s:TestId()
49
+  let r = Id(1, 'string', [0], [[1]], {'ffo':42}, function('exists'), 1.2)
50
+  Assert! len(r) == 7
51
+  Assert! should#be#number (r[0])
52
+  Assert! should#be#string (r[1])
53
+  Assert! should#be#list   (r[2])
54
+  Assert! should#be#list   (r[3])
55
+  Assert! should#be#dict   (r[4])
56
+  Assert! should#be#funcref(r[5])
57
+  Assert! should#be#float  (r[6])
58
+  Assert r[0] == 1
59
+  Assert r[1] == 'string'
60
+  Assert r[2] == [0]
61
+  Assert r[3] == [[1]]
62
+  Assert r[4].ffo == 42
63
+  Assert r[5] == function('exists')
64
+  Assert r[6] == 1.2
65
+endfunction
66
+
67
+function! s:Test_bind()
68
+  " lh#function#bind + lh#function#execute
69
+  let rev4 = lh#function#bind(function('Id'), 'v:4_', 42, 'v:3_', 'v:2_', 'v:1_')
70
+  let r = lh#function#execute(rev4, 1,'two','three', [4,5])
71
+  Assert! len(r) == 5
72
+  Assert! should#be#list   (r[0])
73
+  Assert! should#be#number (r[1])
74
+  Assert! should#be#string (r[2])
75
+  Assert! should#be#string (r[3])
76
+  Assert! should#be#number (r[4])
77
+
78
+  Assert r[0] == [4,5]
79
+  Assert r[1] == 42
80
+  Assert r[2] == 'three'
81
+  Assert r[3] == 'two'
82
+  Assert r[4] == 1
83
+endfunction
84
+
85
+function! s:Test_bind_compound_vars()
86
+  " lh#function#bind + lh#function#execute
87
+  let rev4 = lh#function#bind(function('Id'), 'v:4_', 'v:1_ . v:2_', 'v:3_', 'v:2_', 'v:1_')
88
+  let r = lh#function#execute(rev4, 1,'two','three', [4,5])
89
+  Assert! len(r) == 5
90
+  Assert! should#be#list   (r[0])
91
+  Assert! should#be#string (r[1])
92
+  Assert! should#be#string (r[2])
93
+  Assert! should#be#string (r[3])
94
+  Assert! should#be#number (r[4])
95
+
96
+  Assert r[0] == [4,5]
97
+  Assert r[1] == '1two'
98
+  Assert r[2] == 'three'
99
+  Assert r[3] == 'two'
100
+  Assert r[4] == 1
101
+endfunction
102
+
103
+
104
+function! s:Test_execute_func_string_name()
105
+  " function name as string
106
+  let r = lh#function#execute('Id', 1,'two',3)
107
+  Assert! len(r) == 3
108
+  Assert! should#be#number (r[0])
109
+  Assert! should#be#string (r[1])
110
+  Assert! should#be#number (r[2])
111
+  Assert r[0] == 1
112
+  Assert r[1] == 'two'
113
+  Assert r[2] == 3
114
+endfunction
115
+
116
+function! s:Test_execute_string_expr()
117
+  " exp as binded-string
118
+  let r = lh#function#execute('Id(12,len(v:2_).v:2_, 42, v:3_, v:1_)', 1,'two',3)
119
+  Assert! len(r) == 5
120
+  Assert! should#be#number (r[0])
121
+  Assert! should#be#string (r[1])
122
+  Assert! should#be#number (r[2])
123
+  Assert! should#be#number (r[3])
124
+  Assert! should#be#number (r[4])
125
+  Assert r[0] == 12
126
+  Assert r[1] == len('two').'two'
127
+  Assert r[2] == 42
128
+  Assert r[3] == 3
129
+  Assert r[4] == 1
130
+endfunction
131
+
132
+function! s:Test_execute_func()
133
+  " calling a function() + bind
134
+  let r = lh#function#execute(function('Id'), 1,'two','v:1_',['a',42])
135
+  Assert! len(r) == 4
136
+  Assert! should#be#number (r[0])
137
+  Assert! should#be#string (r[1])
138
+  Assert! should#be#string (r[2])
139
+  Assert! should#be#list   (r[3])
140
+  Assert r[0] == 1
141
+  Assert r[1] == 'two'
142
+  Assert r[2] == 'v:1_'
143
+  Assert r[3] == ['a', 42]
144
+endfunction
145
+"------------------------------------------------------------------------
146
+function! s:Test_bind_func_string_name_AND_execute()
147
+  " function name as string
148
+  let rev3 = lh#function#bind('Id', 'v:3_', 12, 'v:2_', 'v:1_')
149
+  let r = lh#function#execute(rev3, 1,'two',3)
150
+
151
+  Assert! len(r) == 4
152
+  Assert! should#be#number (r[0])
153
+  Assert! should#be#number (r[1])
154
+  Assert! should#be#string (r[2])
155
+  Assert! should#be#number (r[3])
156
+  Assert r[0] == 3
157
+  Assert r[1] == 12
158
+  Assert r[2] == 'two'
159
+  Assert r[3] == 1
160
+endfunction
161
+
162
+function! s:Test_bind_string_expr_AND_execute()
163
+" expressions as string
164
+  let rev3 = lh#function#bind('Id(12,len(v:2_).v:2_, 42, v:3_, v:1_)')
165
+  let r = lh#function#execute(rev3, 1,'two',3)
166
+  Assert! len(r) == 5
167
+  Assert! should#be#number (r[0])
168
+  Assert! should#be#string (r[1])
169
+  Assert! should#be#number (r[2])
170
+  Assert! should#be#number (r[3])
171
+  Assert! should#be#number (r[4])
172
+  Assert r[0] == 12
173
+  Assert r[1] == len('two').'two'
174
+  Assert r[2] == 42
175
+  Assert r[3] == 3
176
+  Assert r[4] == 1
177
+endfunction
178
+
179
+function! s:Test_double_bind_func_name()
180
+  let f1 = lh#function#bind('Id', 1, 2, 'v:1_', 4, 'v:2_')
181
+  " Comment "f1=".string(f1)
182
+  let r = lh#function#execute(f1, 3, 5)
183
+  Assert! len(r) == 5
184
+  let i = 0
185
+  while i != len(r)
186
+    Assert! should#be#number (r[i])
187
+    Assert r[i] == i+1
188
+    let i += 1
189
+  endwhile
190
+
191
+  " f2
192
+  let f2 = lh#function#bind(f1, 'v:1_', 5)
193
+  " Comment "f2=f1(v:1_, 5)=".string(f2)
194
+  let r = lh#function#execute(f2, 3)
195
+  Assert! len(r) == 5
196
+  let i = 0
197
+  while i != len(r)
198
+    Assert! should#be#number (r[i])
199
+    " echo "?? ".(r[i])."==".(i+1)
200
+    Assert r[i] == i+1
201
+    let i += 1
202
+  endwhile
203
+endfunction
204
+
205
+function! s:Test_double_bind_func()
206
+  let f1 = lh#function#bind(function('Id'), 1, 2, 'v:1_', 4, 'v:2_')
207
+  " Comment "f1=".string(f1)
208
+  let r = lh#function#execute(f1, 3, 5)
209
+  Assert! len(r) == 5
210
+  let i = 0
211
+  while i != len(r)
212
+    Assert! should#be#number (r[i])
213
+    Assert r[i] == i+1
214
+    let i += 1
215
+  endwhile
216
+
217
+  " f2
218
+  let f2 = lh#function#bind(f1, 'v:1_', 5)
219
+  " Comment "f2=f1(v:1_, 5)=".string(f2)
220
+  let r = lh#function#execute(f2, 3)
221
+  Assert! len(r) == 5
222
+  let i = 0
223
+  while i != len(r)
224
+    Assert! should#be#number (r[i])
225
+    Assert r[i] == i+1
226
+    let i += 1
227
+  endwhile
228
+endfunction
229
+
230
+function! s:Test_double_bind_func_cplx()
231
+  let g:bar = "bar"
232
+  let f1 = lh#function#bind(function('Id'), 1, 2, 'v:1_', 4, 'v:2_', 'v:3_', 'v:4_', 'v:5_', 'v:6_', 'v:7_')
233
+  " Comment "2bcpl# f1=".string(f1)
234
+  let f2 = lh#function#bind(f1, 'len(g:bar.v:1_)+v:1_', [1,2], '[v:1_, v:2_]', 4,5,6,7)
235
+
236
+  " let f2 = lh#function#bind(f1, 'v:1_', 5, 'foo', g:bar, 'len(g:bar.v:1_)+v:1_', [1,2], '[v:1_, v:2_]')
237
+  " Comment "2bcpl# f2=f1(v:1_, 5)=".string(f2)
238
+
239
+  let r = lh#function#execute(f2, 42, "foo")
240
+  Assert! 0 && "not ready"
241
+  Comment "2bcpl# ".string(r)
242
+endfunction
243
+
244
+function! s:Test_double_bind_expr()
245
+  let f1 = lh#function#bind('Id(1, 2, v:1_, v:3_, v:2_)')
246
+  Comment "2be# f1=".string(f1)
247
+  let r = lh#function#execute(f1, 3, 5, 4)
248
+  Comment "2be# ".string(r)
249
+  Assert! len(r) == 5
250
+  let i = 0
251
+  while i != len(r)
252
+    Assert! should#be#number (r[i])
253
+    Assert r[i] == i+1
254
+    let i += 1
255
+  endwhile
256
+
257
+  " f2
258
+  let f2 = lh#function#bind(f1, 'v:1_', '"foo"', [])
259
+  Comment "2be# f2=f1(v:1_, 5)=".string(f2)
260
+  let r = lh#function#execute(f2, 3)
261
+  Comment "2be# ".string(r)
262
+  Assert! len(r) == 5
263
+  let i = 0
264
+  while i != len(r)-2
265
+    Assert! should#be#number (r[i])
266
+    Assert r[i] == i+1
267
+    let i += 1
268
+  endwhile
269
+
270
+  Assert! should#be#list (r[-2])
271
+  Assert r[-2] == []
272
+  Assert! should#be#string (r[-1])
273
+  Assert r[-1] == 'foo'
274
+endfunction
275
+
276
+"todo: write double-binded tests for all kind of binded parameters:
277
+" 'len(g:bar)'
278
+" 42
279
+" []
280
+" v:1_ + len(v:2_.v:3_)
281
+" '"foo"'
282
+" v:1_
283
+
284
+"------------------------------------------------------------------------
285
+
286
+let &cpo=s:cpo_save
287
+"=============================================================================
288
+" vim600: set fdm=marker:

+ 167
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/list.vim View File

@@ -0,0 +1,167 @@
1
+"=============================================================================
2
+" $Id: list.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		tests/lh/list.vim                                      {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	19th Nov 2008
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Tests for autoload/lh/list.vim
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	«install details»
17
+" History:	«history»
18
+" TODO:		«missing features»
19
+" }}}1
20
+"=============================================================================
21
+
22
+UTSuite [lh-vim-lib] Testing lh#list functions
23
+
24
+runtime autoload/lh/function.vim
25
+runtime autoload/lh/list.vim
26
+let s:cpo_save=&cpo
27
+set cpo&vim
28
+"------------------------------------------------------------------------
29
+" Find_if
30
+function! s:Test_Find_If_string_predicate()
31
+    :let b = { 'min': 12, 'max': 42 }
32
+    :let l = [ 1, 5, 48, 25, 5, 28, 6]
33
+    :let i = lh#list#Find_if(l, 'v:val>v:1_.min  && v:val<v:1_.max && v:val%v:2_==0', [b, 2] )
34
+    " echo i . '/' . len(l)
35
+    Assert i == 5
36
+    Assert l[i] == 28
37
+    " :echo l[i]
38
+endfunction
39
+
40
+function! s:Test_Find_If_functor_predicate()
41
+    :let l = [ 1, 5, 48, 25, 5, 28, 6]
42
+    :let i = lh#list#find_if(l, 'v:1_>12  && v:1_<42 && v:1_%2==0')
43
+    " echo i . '/' . len(l)
44
+    Assert i == 5
45
+    Assert l[i] == 28
46
+    " :echo l[i]
47
+endfunction
48
+
49
+function! s:Test_find_if_double_bind()
50
+    :let b = { 'min': 12, 'max': 42 }
51
+    :let l = [ 1, 5, 48, 25, 5, 28, 6]
52
+    :let f = lh#function#bind( 'v:3_>v:1_.min  && v:3_<v:1_.max && v:3_%v:2_==0') 
53
+    :let p = lh#function#bind(f, b,2,'v:1_') 
54
+    :let i = lh#list#find_if(l, p)
55
+    :echo l[i]
56
+endfunction
57
+" double bind is not yet operational
58
+UTIgnore Test_find_if_double_bind
59
+
60
+"------------------------------------------------------------------------
61
+" Unique Sorting
62
+function! CmpNumbers(lhs, rhs)
63
+  if     a:lhs < a:rhs  | return -1
64
+  elseif a:lhs == a:rhs | return 0
65
+  else              | return +1
66
+  endif
67
+endfunction
68
+
69
+function! s:Test_sort()
70
+    :let l = [ 1, 5, 48, 25, 5, 28, 6]
71
+    :let expected = [ 1, 5, 6, 25, 28, 48]
72
+    :let s = lh#list#unique_sort(l, "CmpNumbers") 
73
+    " Comment string(s)
74
+    Assert s == expected
75
+endfunction
76
+
77
+function! s:Test_sort2()
78
+    :let l = [ 1, 5, 48, 25, 5, 28, 6]
79
+    :let expected = [ 1, 5, 6, 25, 28, 48]
80
+    :let s = lh#list#unique_sort2(l, "CmpNumbers") 
81
+    " Comment string(s)
82
+    Assert s == expected
83
+endfunction
84
+
85
+"------------------------------------------------------------------------
86
+" Searchs
87
+function! s:TestBinarySearches()
88
+  let v1 = [ -3, -2, -1, -1, 0, 0, 1, 2, 3, 4, 6 ]
89
+  let i = lh#list#lower_bound(v1, 3)
90
+  Assert v1[i] == 3
91
+  let i = lh#list#upper_bound(v1, 3)
92
+  Assert v1[i] == 4
93
+  let r = lh#list#equal_range(v1, 3)
94
+  Assert v1[r[0]:r[1]-1] == [3]
95
+
96
+  let i = lh#list#lower_bound(v1, -1)
97
+  Assert v1[i] == -1
98
+  let i = lh#list#upper_bound(v1, -1)
99
+  Assert v1[i] == 0
100
+  let r = lh#list#equal_range(v1, -1)
101
+  Assert v1[r[0]:r[1]-1] == [-1, -1]
102
+
103
+  let i = lh#list#lower_bound(v1, 5)
104
+  Assert v1[i] == 6
105
+  let i = lh#list#upper_bound(v1, 5)
106
+  Assert v1[i] == 6
107
+  let r = lh#list#equal_range(v1, 5)
108
+  Assert v1[r[0]:r[1]-1] == []
109
+
110
+  Assert len(v1) == lh#list#lower_bound(v1, 10)
111
+  Assert len(v1) == lh#list#upper_bound(v1, 10)
112
+  Assert [len(v1), len(v1)] == lh#list#equal_range(v1, 10)
113
+endfunction
114
+
115
+"------------------------------------------------------------------------
116
+" accumulate
117
+
118
+function! s:Test_accumulate_len_strings()
119
+  let strings = [ 'foo', 'bar', 'toto' ]
120
+  let len = eval(lh#list#accumulate(strings, 'strlen', 'join(v:1_,  "+")'))
121
+  Assert len == 3+3+4
122
+endfunction
123
+
124
+function! s:Test_accumulate_join()
125
+  let ll = [ 1, 2, 'foo', ['bar'] ]
126
+  let res = lh#list#accumulate(ll, 'string', 'join(v:1_,  " ## ")')
127
+  Assert res == "1 ## 2 ## 'foo' ## ['bar']"
128
+  " This test will fail because it seems :for each loop cannot iterate on
129
+  " heterogeneous containers
130
+endfunction
131
+
132
+"------------------------------------------------------------------------
133
+" Copy_if
134
+function! s:Test_copy_if()
135
+    :let l = [ 1, 25, 5, 48, 25, 5, 28, 6]
136
+    :let expected = [ 25, 48, 25, 28, 6]
137
+    :let s = lh#list#copy_if(l, [], "v:1_ > 5") 
138
+    " Comment string(s)
139
+    Assert s == expected
140
+endfunction
141
+
142
+"------------------------------------------------------------------------
143
+" subset
144
+function! s:Test_subset()
145
+    :let l = [ 1, 25, 5, 48, 25, 5, 28, 6]
146
+    :let indices = [ 0, 5, 7, 3 ]
147
+    :let expected = [ 1, 5, 6, 48 ]
148
+    :let s = lh#list#subset(l, indices) 
149
+    " Comment string(s)
150
+    Assert s == expected
151
+endfunction
152
+
153
+"------------------------------------------------------------------------
154
+" intersect
155
+function! s:Test_intersect()
156
+    :let l1 = [ 1, 25, 7, 48, 26, 5, 28, 6]
157
+    :let l2 = [ 3, 8, 7, 25, 6 ]
158
+    :let expected = [ 25, 7, 6 ]
159
+    :let s = lh#list#intersect(l1, l2) 
160
+    " Comment string(s)
161
+    Assert s == expected
162
+endfunction
163
+
164
+"------------------------------------------------------------------------
165
+let &cpo=s:cpo_save
166
+"=============================================================================
167
+" vim600: set fdm=marker:

+ 180
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/path.vim View File

@@ -0,0 +1,180 @@
1
+"=============================================================================
2
+" $Id: path.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		tests/lh/path.vim                                      {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	28th May 2009
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:
13
+" 	Tests for autoload/lh/path.vim
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	«install details»
17
+" History:	«history»
18
+" TODO:		«missing features»
19
+" }}}1
20
+"=============================================================================
21
+
22
+UTSuite [lh-vim-lib] Testing lh#path functions
23
+
24
+runtime autoload/lh/path.vim
25
+let s:cpo_save=&cpo
26
+set cpo&vim
27
+"------------------------------------------------------------------------
28
+function! s:Test_simplify()
29
+  Assert lh#path#simplify('a/b/c') == 'a/b/c'
30
+  Assert lh#path#simplify('a/b/./c') == 'a/b/c'
31
+  Assert lh#path#simplify('./a/b/./c') == 'a/b/c'
32
+  Assert lh#path#simplify('./a/../b/./c') == 'b/c'
33
+  Assert lh#path#simplify('../a/../b/./c') == '../b/c'
34
+  Assert lh#path#simplify('a\b\c') == 'a\b\c'
35
+  Assert lh#path#simplify('a\b\.\c') == 'a\b\c'
36
+  Assert lh#path#simplify('.\a\b\.\c') == 'a\b\c'
37
+  if exists('+shellslash')
38
+    Assert lh#path#simplify('.\a\..\b\.\c') == 'b\c'
39
+    Assert lh#path#simplify('..\a\..\b\.\c') == '..\b\c'
40
+  endif
41
+endfunction
42
+
43
+function! s:Test_strip_common()
44
+  let paths = ['foo/bar/file', 'foo/file', 'foo/foo/file']
45
+  let expected = [ 'bar/file', 'file', 'foo/file']
46
+  Assert lh#path#strip_common(paths) == expected
47
+endfunction
48
+
49
+function! s:Test_common()
50
+  " Pick one ...
51
+  Assert 'foo/' == lh#path#common(['foo/bar/dir', 'foo'])
52
+  Assert 'foo/bar/' == lh#path#common(['foo/bar/dir', 'foo/bar'])
53
+  Assert 'foo/' == lh#path#common(['foo/bar/dir', 'foo/bar2'])
54
+
55
+  Assert 'foo' == lh#path#common(['foo/bar/dir', 'foo'])
56
+  Assert 'foo/bar' == lh#path#common(['foo/bar/dir', 'foo/bar'])
57
+  Assert 'foo' == lh#path#common(['foo/bar/dir', 'foo/bar2'])
58
+endfunction
59
+
60
+function! s:Test_strip_start()
61
+  let expected = 'template/bar.template'
62
+  Assert lh#path#strip_start($HOME.'/.vim/template/bar.template',
63
+	\ [ $HOME.'/.vim', $HOME.'/vimfiles', '/usr/local/share/vim' ]) 
64
+	\ == expected
65
+
66
+  Assert lh#path#strip_start($HOME.'/vimfiles/template/bar.template',
67
+	\ [ $HOME.'/.vim', $HOME.'/vimfiles', '/usr/local/share/vim' ]) 
68
+	\ == expected
69
+
70
+  Assert lh#path#strip_start('/usr/local/share/vim/template/bar.template',
71
+	\ [ $HOME.'/.vim', $HOME.'/vimfiles', '/usr/local/share/vim' ]) 
72
+	\ == expected
73
+endfunction
74
+
75
+function! s:Test_IsAbsolutePath()
76
+  " nix paths
77
+  Assert lh#path#is_absolute_path('/usr/local')
78
+  Assert lh#path#is_absolute_path($HOME)
79
+  Assert ! lh#path#is_absolute_path('./usr/local')
80
+  Assert ! lh#path#is_absolute_path('.usr/local')
81
+
82
+  " windows paths
83
+  Assert lh#path#is_absolute_path('e:\usr\local')
84
+  Assert ! lh#path#is_absolute_path('.\usr\local')
85
+  Assert ! lh#path#is_absolute_path('.usr\local')
86
+
87
+  " UNC paths
88
+  Assert lh#path#is_absolute_path('\\usr\local')
89
+  Assert lh#path#is_absolute_path('//usr/local')
90
+endfunction
91
+
92
+function! s:Test_IsURL()
93
+  " nix paths
94
+  Assert ! lh#path#is_url('/usr/local')
95
+  Assert ! lh#path#is_url($HOME)
96
+  Assert ! lh#path#is_url('./usr/local')
97
+  Assert ! lh#path#is_url('.usr/local')
98
+
99
+  " windows paths
100
+  Assert ! lh#path#is_url('e:\usr\local')
101
+  Assert ! lh#path#is_url('.\usr\local')
102
+  Assert ! lh#path#is_url('.usr\local')
103
+
104
+  " UNC paths
105
+  Assert ! lh#path#is_url('\\usr\local')
106
+  Assert ! lh#path#is_url('//usr/local')
107
+
108
+  " URLs
109
+  Assert lh#path#is_url('http://www.usr/local')
110
+  Assert lh#path#is_url('https://www.usr/local')
111
+  Assert lh#path#is_url('ftp://www.usr/local')
112
+  Assert lh#path#is_url('sftp://www.usr/local')
113
+  Assert lh#path#is_url('dav://www.usr/local')
114
+  Assert lh#path#is_url('fetch://www.usr/local')
115
+  Assert lh#path#is_url('file://www.usr/local')
116
+  Assert lh#path#is_url('rcp://www.usr/local')
117
+  Assert lh#path#is_url('rsynch://www.usr/local')
118
+  Assert lh#path#is_url('scp://www.usr/local')
119
+endfunction
120
+
121
+function! s:Test_ToRelative()
122
+  let pwd = getcwd()
123
+  Assert lh#path#to_relative(pwd.'/foo/bar') == 'foo/bar'
124
+  Assert lh#path#to_relative(pwd.'/./foo') == 'foo'
125
+  Assert lh#path#to_relative(pwd.'/foo/../bar') == 'bar'
126
+
127
+  " Does not work yet as it returns an absolute path it that case
128
+  Assert lh#path#to_relative(pwd.'/../bar') == '../bar'
129
+endfunction
130
+
131
+function! s:Test_relative_path()
132
+  Assert lh#path#relative_to('foo/bar/dir', 'foo') == '../../'
133
+  Assert lh#path#relative_to('foo', 'foo/bar/dir') == 'bar/dir/'
134
+  Assert lh#path#relative_to('foo/bar', 'foo/bar2/dir') == '../bar2/dir/'
135
+
136
+  let pwd = getcwd()
137
+  Assert lh#path#relative_to(pwd ,pwd.'/../bar') == '../bar/'
138
+endfunction
139
+
140
+function! s:Test_search_vimfiles()
141
+  let expected_win = $HOME . '/vimfiles'
142
+  let expected_nix = $HOME . '/.vim'
143
+  let what =  lh#path#to_regex($HOME.'/').'\(vimfiles\|.vim\)'
144
+  " Comment what
145
+  let z = lh#path#find(&rtp,what)
146
+  if has('win16')||has('win32')||has('win64')
147
+    Assert z == expected_win
148
+  else
149
+    Assert z == expected_nix
150
+  endif
151
+endfunction
152
+
153
+function! s:Test_path_depth()
154
+  Assert 0 == lh#path#depth('.')
155
+  Assert 0 == lh#path#depth('./')
156
+  Assert 0 == lh#path#depth('.\')
157
+  Assert 1 == lh#path#depth('toto')
158
+  Assert 1 == lh#path#depth('toto/')
159
+  Assert 1 == lh#path#depth('toto\')
160
+  Assert 1 == lh#path#depth('toto/.')
161
+  Assert 1 == lh#path#depth('toto\.')
162
+  Assert 1 == lh#path#depth('toto/./.')
163
+  Assert 1 == lh#path#depth('toto\.\.')
164
+  Assert 0 == lh#path#depth('toto/..')
165
+  if exists('+shellslash')
166
+    Assert 0 == lh#path#depth('toto\..')
167
+  endif
168
+  Assert 2 == lh#path#depth('toto/titi/')
169
+  Assert 2 == lh#path#depth('toto\titi\')
170
+  Assert 2 == lh#path#depth('/toto/titi/')
171
+  Assert 2 == lh#path#depth('c:/toto/titi/')
172
+  Assert 2 == lh#path#depth('c:\toto/titi/')
173
+" todo: make a choice about "negative" paths like "../../foo"
174
+  Assert -1 == lh#path#depth('../../foo')
175
+endfunction
176
+
177
+"------------------------------------------------------------------------
178
+let &cpo=s:cpo_save
179
+"=============================================================================
180
+" vim600: set fdm=marker:

+ 85
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-Fargs2String.vim View File

@@ -0,0 +1,85 @@
1
+"=============================================================================
2
+" $Id: test-Fargs2String.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		tests/lh/test-Fargs2String.vim                           {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	16th Apr 2007
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	Tests for lh-vim-lib . lh#command#Fargs2String
13
+" 
14
+"------------------------------------------------------------------------
15
+" Installation:	
16
+" 	Relies on the version «patched by myself|1?» of vim_units
17
+" History:	«history»
18
+" TODO:		«missing features»
19
+" }}}1
20
+"=============================================================================
21
+
22
+function! s:TestEmpty()
23
+  let empty = []
24
+  let res = lh#command#Fargs2String(empty)
25
+  call VUAssertEquals(len(empty), 0, 'Expected empty', 22)
26
+  call VUAssertEquals(res, '', 'Expected empty result', 23)
27
+endfunction
28
+
29
+function! s:TestSimpleText1()
30
+  let expected = 'text'
31
+  let one = [ expected ]
32
+  let res = lh#command#Fargs2String(one)
33
+  call VUAssertEquals(len(one), 0, 'Expected empty', 27)
34
+  call VUAssertEquals(res, expected, 'Expected a simple result', 28)
35
+endfunction
36
+
37
+function! s:TestSimpleTextN()
38
+  let expected = 'text'
39
+  let list = [ expected , 'stuff1', 'stuff2']
40
+  let res = lh#command#Fargs2String(list)
41
+  call VUAssertEquals(len(list), 2, 'Expected not empty', 38)
42
+  call VUAssertEquals(res, expected, 'Expected a simple result', 39)
43
+endfunction
44
+
45
+function! s:TestComposedN()
46
+  let expected = '"a several tokens string"'
47
+  let list = [ '"a', 'several', 'tokens', 'string"', 'stuff1', 'stuff2']
48
+  let res = lh#command#Fargs2String(list)
49
+  call VUAssertEquals(len(list), 2, 'Expected not empty', 46)
50
+  call VUAssertEquals(res, expected, 'Expected a composed string', 47)
51
+  call VUAssertEquals(list, ['stuff1', 'stuff2'], 'Expected a list', 48)
52
+  call VUAssertNotSame(list, ['stuff1', 'stuff2'], 'Expected different lists', 49)
53
+endfunction
54
+
55
+function! s:TestComposed1()
56
+  let expected = '"string"'
57
+  let list = [ '"string"', 'stuff1', 'stuff2']
58
+  let res = lh#command#Fargs2String(list)
59
+  call VUAssertEquals(len(list), 2, 'Expected not empty', 56)
60
+  call VUAssertEquals(res, expected, 'Expected a string', 57)
61
+  call VUAssertEquals(list, ['stuff1', 'stuff2'], 'Expected a list', 58)
62
+  call VUAssertNotSame(list, ['stuff1', 'stuff2'], 'Expected different lists', 59)
63
+endfunction
64
+
65
+function! s:TestInvalidString()
66
+  let expected = '"a string'
67
+  let list = [ '"a', 'string']
68
+  let res = lh#command#Fargs2String(list)
69
+  call VUAssertEquals(len(list), 0, 'Expected empty', 66)
70
+  call VUAssertEquals(res, expected, 'Expected an invalid string', 67)
71
+endfunction
72
+
73
+function! AllTests()
74
+  call s:TestEmpty()
75
+  call s:TestSimpleText1()
76
+  call s:TestSimpleTextN()
77
+  call s:TestComposed1()
78
+  call s:TestComposedN()
79
+endfunction
80
+
81
+" call VURunnerRunTest('AllTests')
82
+VURun % AllTests
83
+
84
+"=============================================================================
85
+" vim600: set fdm=marker:

+ 67
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-askmenu.vim View File

@@ -0,0 +1,67 @@
1
+"=============================================================================
2
+" $Id: test-askmenu.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		tests/test-buffer-menu.vim                                {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	18th Apr 2007
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	
13
+" 	Test units for buffermenu.vim
14
+" 
15
+"------------------------------------------------------------------------
16
+" Installation:	Requires:
17
+" 	(*) Vim 7.0+
18
+" 	(*) vim_units.vim v0.2/1.0?
19
+" 	    Vimscript # «???»
20
+" 	(*) lh-vim-lib (lh#ask#menu)
21
+"
22
+" User Manual:
23
+" 	Source this file.
24
+"
25
+" History:	
26
+" (*) 17th Apr 2007: First version 
27
+" TODO:		«missing features»
28
+" }}}1
29
+"=============================================================================
30
+
31
+
32
+
33
+"=============================================================================
34
+let s:cpo_save=&cpo
35
+"------------------------------------------------------------------------
36
+" Functions {{{1
37
+
38
+function! TestAskMenu()
39
+  imenu          42.40.10 &LH-Tests.&Menu.&ask.i       iask
40
+  inoremenu      42.40.10 &LH-Tests.&Menu.&ask.inore   inoreask
41
+  nmenu          42.40.10 &LH-Tests.&Menu.&ask.n       nask
42
+  nnoremenu      42.40.10 &LH-Tests.&Menu.&ask.nnore   nnoreask
43
+  nmenu <script> 42.40.10 &LH-Tests.&Menu.&ask.nscript nscriptask
44
+  nnoremenu <script> 42.40.10 &LH-Tests.&Menu.&ask.nnnscript nnscriptask
45
+
46
+  vmenu          42.40.10 &LH-Tests.&Menu.&ask.v     vask
47
+  vnoremenu      42.40.10 &LH-Tests.&Menu.&ask.vnore vnoreask
48
+
49
+  call s:CheckInMode('i', 'i')
50
+
51
+endfunction
52
+
53
+function! s:CheckInMode(mode, name)
54
+  let g:menu = lh#askvim#menu('LH-Tests.Menu.ask.'.a:name, a:mode)
55
+  let g:name = a:name
56
+  " VUAssert 55 Equals g:menu.name     g:name     "Name mismatch"
57
+  " VUAssert 56 Equals g:menu.priority '42.40.10' "Priority mismatch"
58
+  " VUAssert 57 Fail "parce qu'il le faut bien"
59
+  echomsg "name= ".g:menu.name
60
+  echomsg "prio= ".g:menu.priority
61
+endfunction
62
+
63
+" Functions }}}1
64
+"------------------------------------------------------------------------
65
+let &cpo=s:cpo_save
66
+"=============================================================================
67
+" vim600: set fdm=marker:

+ 69
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-command.vim View File

@@ -0,0 +1,69 @@
1
+" $Id: test-command.vim 156 2010-05-07 00:54:36Z luc.hermitte $
2
+" Tests for lh-vim-lib . lh#command
3
+
4
+" FindFilter(filter):                            Helper {{{3
5
+function! s:FindFilter(filter)
6
+  let filter = a:filter . '.vim'
7
+  let result =globpath(&rtp, "compiler/BTW-".filter) . "\n" .
8
+	\ globpath(&rtp, "compiler/BTW_".filter). "\n" .
9
+	\ globpath(&rtp, "compiler/BTW/".filter)
10
+  let result = substitute(result, '\n\n', '\n', 'g')
11
+  let result = substitute(result, '^\n', '', 'g')
12
+  return result
13
+endfunction
14
+
15
+function! s:ComplFilter(filter)
16
+  let files = s:FindFilter('*')
17
+  let files = substitute(files,
18
+	\ '\(^\|\n\).\{-}compiler[\\/]BTW[-_\\/]\(.\{-}\)\.vim\>\ze\%(\n\|$\)',
19
+	\ '\1\2', 'g')
20
+  return files
21
+endfunction
22
+
23
+function! s:Add()
24
+endfunction
25
+
26
+let s:v1 = 'v1'
27
+let s:v2 = 2
28
+
29
+function! s:Foo(i)
30
+  return a:i*a:i
31
+endfunction
32
+
33
+function! s:echo(params)
34
+  echo s:{join(a:params, '')}
35
+endfunction
36
+
37
+function! Echo(params)
38
+  " echo "Echo(".string(a:params).')'
39
+  let expr = 's:'.join(a:params, '')
40
+  " echo expr
41
+  exe 'echo '.expr
42
+endfunction
43
+
44
+let TBTWcommand = {
45
+      \ "name"      : "TBT",
46
+      \ "arg_type"  : "sub_commands",
47
+      \ "arguments" :
48
+      \     [
49
+      \       { "name"      : "echo",
50
+      \		"arg_type"  : "function",
51
+      \         "arguments" : "v1,v2",
52
+      \         "action": function("\<sid>echo") },
53
+      \       { "name"      : "Echo",
54
+      \		"arg_type"  : "function",
55
+      \         "arguments" : "v1,v2",
56
+      \         "action": function("Echo") },
57
+      \       { "name"  : "help" },
58
+      \       { "name"  : "add",
59
+      \         "arguments": function("s:ComplFilter"),
60
+      \         "action" : function("s:Add") }
61
+      \     ]
62
+      \ }
63
+
64
+call lh#command#new(TBTWcommand)
65
+
66
+nnoremap µ :call lh#command#new(TBTWcommand)<cr>
67
+
68
+"=============================================================================
69
+" vim600: set fdm=marker:

+ 56
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-menu-map.vim View File

@@ -0,0 +1,56 @@
1
+"=============================================================================
2
+" $Id: test-menu-map.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:		tests/lh/test-menu-map.vim                               {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:	3.0.0
9
+" Created:	05th Dec 2006
10
+" Last Update:	$Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:	Tests for lh-vim-lib . lh#menu#
13
+" 
14
+"------------------------------------------------------------------------
15
+" Installation:	«install details»
16
+" History:	«history»
17
+" TODO:		«missing features»
18
+" }}}1
19
+"=============================================================================
20
+
21
+
22
+" let g:want_buffermenu_or_global_disable = 1
23
+" let b:want_buffermenu_or_global_disable = 1
24
+" echo lh#option#get("want_buffermenu_or_global_disable", 1, "bg")
25
+
26
+" Call a command (':Command')
27
+call lh#menu#make("nic", '42.50.340',
28
+      \ '&LH-Tests.&Menu-Make.Build Ta&gs', "<C-L>g",
29
+      \ '<buffer>',
30
+      \ ":echo 'TeXtags'<CR>")
31
+
32
+" With '{' expanding to '{}××', or '{}' regarding the mode
33
+call lh#menu#IVN_make('42.50.360.200',
34
+      \ '&LH-Tests.&Menu-Make.&Insert.\toto{}', ']toto',
35
+      \ '\\toto{',
36
+      \ '{%i\\toto<ESC>%l',
37
+      \ "viw]toto")
38
+
39
+" Noremap for the visual maps
40
+call lh#menu#IVN_make('42.50.360.200',
41
+      \ '&LH-Tests.&Menu-Make.&Insert.\titi{}', ']titi',
42
+      \ '\\titi{',
43
+      \ '<ESC>`>a}<ESC>`<i\\titi{<ESC>%l',
44
+      \ "viw]titi",
45
+      \ 0, 1, 0)
46
+
47
+" Noremap for the insert and visual maps
48
+call lh#menu#IVN_make('42.50.360.200',
49
+      \ '&LH-Tests.&Menu-Make.&Insert.<tata></tata>', ']tata',
50
+      \ '<tata></tata><esc>?<<CR>i', 
51
+      \ '<ESC>`>a</tata><ESC>`<i<tata><ESC>/<\\/tata>/e1<CR>',
52
+      \ "viw]tata", 
53
+      \ 1, 1, 0)
54
+
55
+"=============================================================================
56
+" vim600: set fdm=marker:

+ 86
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/test-toggle-menu.vim View File

@@ -0,0 +1,86 @@
1
+"=============================================================================
2
+" $Id: test-toggle-menu.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:         tests/lh/test-toggle-menu.vim                            {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"               <URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      17th Apr 2007
10
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:  
13
+"       Tests for lh-vim-lib . lh#menu#def_toggle_item()
14
+"
15
+"------------------------------------------------------------------------
16
+" Installation: «install details»
17
+" History:      «history»
18
+" TODO:         «missing features»
19
+" }}}1
20
+"=============================================================================
21
+
22
+runtime autoload/lh/menu.vim
23
+
24
+let Data = {
25
+      \ "variable": "bar",
26
+      \ "idx_crt_value": 1,
27
+      \ "values": [ 'a', 'b', 'c', 'd' ],
28
+      \ "menu": { "priority": '42.50.10', "name": '&LH-Tests.&TogMenu.&bar'}
29
+      \}
30
+
31
+call lh#menu#def_toggle_item(Data)
32
+
33
+let Data2 = {
34
+      \ "variable": "foo",
35
+      \ "idx_crt_value": 3,
36
+      \ "texts": [ 'un', 'deux', 'trois', 'quatre' ],
37
+      \ "values": [ 1, 2, 3, 4 ],
38
+      \ "menu": { "priority": '42.50.11', "name": '&LH-Tests.&TogMenu.&foo'}
39
+      \}
40
+
41
+call lh#menu#def_toggle_item(Data2)
42
+
43
+" No default
44
+let Data3 = {
45
+      \ "variable": "nodef",
46
+      \ "texts": [ 'one', 'two', 'three', 'four' ],
47
+      \ "values": [ 1, 2, 3, 4 ],
48
+      \ "menu": { "priority": '42.50.12', "name": '&LH-Tests.&TogMenu.&nodef'}
49
+      \}
50
+call lh#menu#def_toggle_item(Data3)
51
+
52
+" No default
53
+let g:def = 2
54
+let Data4 = {
55
+      \ "variable": "def",
56
+      \ "values": [ 1, 2, 3, 4 ],
57
+      \ "menu": { "priority": '42.50.13', "name": '&LH-Tests.&TogMenu.&def'}
58
+      \}
59
+call lh#menu#def_toggle_item(Data4)
60
+
61
+" What follows does not work because we can't build an exportable FuncRef on top
62
+" of a script local function
63
+" finish
64
+
65
+function! s:getSNR()
66
+  if !exists("s:SNR")
67
+    let s:SNR=matchstr(expand("<sfile>"), "<SNR>\\d\\+_\\zegetSNR$")
68
+  endif
69
+  return s:SNR 
70
+endfunction
71
+
72
+function! s:Yes()
73
+  echomsg "Yes"
74
+endfunction
75
+
76
+function! s:No()
77
+  echomsg "No"
78
+endfunction
79
+let Data4 = {
80
+      \ "variable": "yesno",
81
+      \ "values": [ 1, 2 ],
82
+      \ "text": [ "No", "Yes" ],
83
+      \ "actions": [ function(s:getSNR()."No"), function(s:getSNR()."Yes") ],
84
+      \ "menu": { "priority": '42.50.20', "name": '&LH-Tests.&TogMenu.&yesno'}
85
+      \}
86
+call lh#menu#def_toggle_item(Data4)

+ 122
- 0
dotfiles/vim/bundle/lh-vim-lib/tests/lh/topological-sort.vim View File

@@ -0,0 +1,122 @@
1
+"=============================================================================
2
+" $Id: topological-sort.vim 520 2012-03-19 18:09:15Z luc.hermitte $
3
+" File:         tests/lh/topological-sort.vim                            {{{1
4
+" Author:       Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"               <URL:http://code.google.com/p/lh-vim/>
6
+" License:      GPLv3 with exceptions
7
+"               <URL:http://code.google.com/p/lh-vim/wiki/License>
8
+" Version:      3.0.0
9
+" Created:      17th Apr 2008
10
+" Last Update:  $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
11
+"------------------------------------------------------------------------
12
+" Description:  «description»
13
+"
14
+"------------------------------------------------------------------------
15
+" Installation: «install details»
16
+" History:      «history»
17
+" TODO:         «missing features»
18
+" }}}1
19
+"=============================================================================
20
+
21
+let s:cpo_save=&cpo
22
+set cpo&vim
23
+"------------------------------------------------------------------------
24
+UTSuite [lh-vim-lib] topological sort
25
+
26
+" Fully defineds DAGs {{{1
27
+
28
+" A Direct Acyclic Graph {{{2
29
+let s:dag1 = {}
30
+let s:dag1[7] = [11, 8]
31
+let s:dag1[5] = [11]
32
+let s:dag1[3] = [8, 10]
33
+let s:dag1[11] = [2, 9, 10]
34
+let s:dag1[8] = [9]
35
+
36
+" A Direct Cyclic Graph {{{2
37
+let s:dcg1 = deepcopy(s:dag1)
38
+let s:dcg1[9] = [11]
39
+
40
+" Check routine: are the elements correctly sorted? {{{2
41
+function! s:DoTestOrder(elements)
42
+  Assert! len(a:elements) == 8
43
+  Assert index(a:elements, 7) < index(a:elements, 11)
44
+  Assert index(a:elements, 7) < index(a:elements, 8)
45
+  Assert index(a:elements, 5) < index(a:elements, 11)
46
+  Assert index(a:elements, 3) < index(a:elements, 8)
47
+  Assert index(a:elements, 3) < index(a:elements, 10)
48
+  Assert index(a:elements, 11) < index(a:elements, 2)
49
+  Assert index(a:elements, 11) < index(a:elements, 9)
50
+  Assert index(a:elements, 11) < index(a:elements, 10)
51
+  Assert index(a:elements, 8) < index(a:elements, 9)
52
+endfunction
53
+
54
+" Test DAG1 {{{2
55
+function! s:TestDAG_depth()
56
+  let res = lh#graph#tsort#depth(s:dag1, [3, 5,7])
57
+  call s:DoTestOrder(res)
58
+  echo "D(s:dag1)=".string(res)
59
+endfunction
60
+
61
+function! s:TestDAG_breadth()
62
+  let res = lh#graph#tsort#breadth(s:dag1, [3, 5,7])
63
+  call s:DoTestOrder(res)
64
+  echo "B(s:dag1)=".string(res)
65
+endfunction
66
+
67
+" Test DCG1 {{{2
68
+function! s:TestDCG_depth()
69
+  let expr = 'lh#graph#tsort#depth('.string(s:dcg1).', [3, 5,7])'
70
+  Assert should#throw(expr, 'Tsort: cyclic graph detected')
71
+endfunction
72
+
73
+function! s:TestDCG_breadth()
74
+  let expr = 'lh#graph#tsort#breadth('.string(s:dcg1).', [3, 5,7])'
75
+  Assert should#throw(expr, 'Tsort: cyclic graph detected')
76
+endfunction
77
+
78
+" Lazzy Evaluated DAGs {{{1
79
+
80
+" Emulated lazzyness {{{2
81
+" The time-consumings evaluation function
82
+let s:called = 0
83
+function! Fetch(node)
84
+  let s:called += 1
85
+  return has_key(s:dag1, a:node) ? (s:dag1[a:node]) : []
86
+endfunction
87
+
88
+" Test Fetch on a DAG {{{2
89
+function! s:TestDAG_fetch()
90
+  let s:called = 0
91
+  let res = lh#graph#tsort#depth(function('Fetch'), [3,5,7])
92
+  call s:DoTestOrder(res)
93
+  echo "D(fetch)=".string(res)
94
+  echo "Fetch has been evaluated ".s:called." times / ".len(res)
95
+  Assert s:called == len(res)
96
+endfunction
97
+
98
+
99
+" Setup/Teardown functions {{{1
100
+" display the test name before each assertion
101
+function! s:Setup()
102
+  if exists('g:UT_print_test')
103
+    let s:old_print_test = g:UT_print_test
104
+  endif
105
+  let g:UT_print_test = 1
106
+endfunction
107
+
108
+function! s:Teardown()
109
+  if exists('s:old_print_test')
110
+    let g:UT_print_test = s:old_print_test 
111
+    unlet s:old_print_test
112
+  else
113
+    unlet g:UT_print_test
114
+  endif
115
+endfunction
116
+
117
+
118
+" }}}1
119
+let &cpo=s:cpo_save
120
+"=============================================================================
121
+" vim600: set fdm=marker:
122
+

+ 187
- 0
dotfiles/vim/plugin/local_vimrc.vim View File

@@ -0,0 +1,187 @@
1
+"=============================================================================
2
+" $Id$
3
+" File:		plugin/local_vimrc.vim                                     {{{1
4
+" Author:	Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
5
+"		<URL:http://code.google.com/p/lh-vim/>
6
+" Version:	1.10
7
+" Created:	09th Apr 2003
8
+" Last Update:	10th Apr 2012
9
+" License:      GPLv3
10
+"------------------------------------------------------------------------
11
+" Description:	Solution to Yakov Lerner's question on Vim ML {{{2
12
+"	Search for a _vimrc_local.vim file in the parents directories and
13
+"	source it if found.
14
+"
15
+"	Initial Question:
16
+"	"Is it possible, after sourcing ~/.exrc, to traverse from $HOME down
17
+"	 to cwd, and source .exrc from every directory if present ?
18
+"	 (And if cwd is not under $HOME, just source ~/.exrc).
19
+"	 What do I put into .vimrc to do this ?
20
+" 
21
+"	"Example: current dir is ~/a/b/c. Files are sourced in this order:
22
+"	 ~/.exrc, then ~/a/.exrc, ~/a/b/.exrc, ~/a/b/c/.exrc.
23
+"	 No messages if some of .exrc does not exist."
24
+" }}}2
25
+"------------------------------------------------------------------------
26
+" Installation:	{{{2
27
+" 	0- Set g:local_vimrc in your .vimrc if you wish to use filenames other
28
+" 	   than '_vimrc_local.vim'
29
+" 	a- Drop this plugin into a {rtp}/plugin/ directory, and install
30
+" 	   lh-vim-lib.
31
+" 	b- Define _vimrc_local.vim files into your directories
32
+"
33
+" 	   Ideally, each foo/bar/_vimrc_local.vim should be defined the same
34
+" 	   way as a ftplugin, i.e.: {{{3
35
+"		" Global stuff that needs to be updated/override
36
+"		let g:bar = 'bar'  " YES! This is a global variable!
37
+"		
38
+"		" Local stuff that needs to be defined once for each buffer
39
+"		if exists('b:foo_bar_local_vimrc') | finish | endif
40
+"		let b:foo_bar_local_vimrc = 1
41
+"		setlocal xxx
42
+"		nnoremap <buffer> foo :call <sid>s:Foo()<cr>
43
+"		let b:foo = 'foo'
44
+"		
45
+"		" Global stuff that needs to be defined once only => functions
46
+"		if exists('g:foo_bar_local_vimrc') | finish | endif
47
+"		let g:foo_bar_local_vimrc = 1
48
+"		function s:Foo()
49
+"		  ...
50
+"		endfunction
51
+"	c- In order to load the local variable before a skeleton is read, ask
52
+"	   the maintainer of template-file expander pluin to explicitly execute
53
+"	   :SourceLocalVimrc before doing the actual expansion.
54
+"
55
+" History:	{{{2
56
+"	v1.10   s:k_version in local_vimrc files is automatically incremented
57
+"	        on saving
58
+"	v1.9    New command :SourceLocalVimrc in order to explicitly load the
59
+"	        local-vimrc file before creating new files from a template (We
60
+"	        can't just rely on BufNewFile as there is no guaranty
61
+"	        local_vimrc's BufNewFile will be called before the one from the
62
+"	        Template Expander Plugin => it's up to the TEP to call the
63
+"	        function)
64
+"	v1.8    No more infinite recursion on file in non existent paths.
65
+"	        + patch from cristiklein to support paths with spaces
66
+"	v1.7    Don't search a local vimrc with remote paths (ftp://, http, ... )
67
+"	v1.6    Sometimes root path is Z:\\, which is quite odd
68
+"	v1.5    The auto-command is moved to the au-group LocalVimrc
69
+"	v1.4	Stop the recursion when we get to // or \\ (UNC paths)
70
+"	v1.3    More comments.
71
+"	        Trace of the directories searched when 'verbose' >= 2
72
+"	v1.2	Stops at $HOME or at root (/)
73
+" 	v1.1	Uses _vimrc_local.vim
74
+" 	v1.0	Initial solution
75
+" TODO:		{{{2
76
+" 	(*) Add option to stop looking at $HOME or elsewhere
77
+" 	    ([bg]:lv_stop_at : string, default $HOME) 
78
+" See also: alternative scripts: #441, #3393, #1860, ...
79
+" }}}1
80
+"=============================================================================
81
+
82
+"=============================================================================
83
+" Avoid global reinclusion {{{1
84
+let s:k_version = 109
85
+if exists("g:loaded_local_vimrc") 
86
+      \ && (g:loaded_local_vimrc >= s:k_version)
87
+      \ && !exists('g:force_reload_local_vimrc')
88
+  finish 
89
+endif
90
+let g:loaded_local_vimrc_vim = s:k_version
91
+let s:cpo_save=&cpo
92
+set cpo&vim
93
+" Avoid global reinclusion }}}1
94
+"------------------------------------------------------------------------
95
+" Commands {{{1
96
+command! -nargs=0 SourceLocalVimrc call s:Main(expand('%:p'))
97
+
98
+" Functions {{{1
99
+" Name of the files used                                              {{{2
100
+function! s:LocalVimrcName()
101
+  return exists('g:local_vimrc') ? g:local_vimrc : '_vimrc_local.vim'
102
+endfunction
103
+
104
+let s:local_vimrc = s:LocalVimrcName()
105
+
106
+" Value of $HOME -- actually a regex.                                 {{{2
107
+let s:home = substitute($HOME, '/\|\\', '[/\\\\]', 'g')
108
+
109
+" Regex used to determine when we must stop looking for local-vimrc's {{{2
110
+" Sometimes paths appears as Z:\\ ....
111
+let s:re_last_path = '^/\=$\|^[A-Za-z]:[/\\]\+$\|^//$\|^\\\\$'. 
112
+      \ ((s:home != '') ? ('\|^'.s:home.'$') : '')
113
+
114
+" The main function                                                   {{{2
115
+function! s:SourceLocal(path)
116
+  let up_path = fnamemodify(a:path,':h')
117
+  if up_path == '.' " likelly a non existant path
118
+    if ! isdirectory(a:path)
119
+      call lh#common#warning_msg("[local_vimrc] The current file '".expand('%:p:')."' seems to be in a non-existant directory: '".a:path."'")
120
+    endif
121
+    let up_path = getcwd()
122
+  endif
123
+  " call confirm('crt='.a:path."\nup=".up_path."\n$HOME=".s:home, '&Ok', 1)
124
+  " echomsg ('crt='.a:path."\nup=".up_path."\n$HOME=".s:home)
125
+  if (a:path !~ s:re_last_path)
126
+    if (up_path !~ s:re_last_path)
127
+      " Recursive call: first check the parent directory
128
+      call s:SourceLocal(up_path)
129
+    elseif filereadable(up_path.'/'.s:local_vimrc)
130
+      " Terminal condition: try to source the upper(/uppest?) local-vimrc
131
+      if &verbose >= 2
132
+	echo 'Check '.up_path.' for '.s:local_vimrc.' ... found!'
133
+      endif
134
+      exe 'source '.escape(up_path.'/'.s:local_vimrc, ' \$,')
135
+    elseif &verbose >= 2
136
+      echo 'Check '.up_path.' for '.s:local_vimrc.' ... none!'
137
+    endif
138
+  endif
139
+
140
+  " In all case, try to source the local-vimrc present in the directory
141
+  " currently considered
142
+  if filereadable(a:path.'/'.s:local_vimrc)
143
+    if &verbose >= 2
144
+      echo 'Check '.a:path.' for '.s:local_vimrc.' ... found!'
145
+    endif
146
+    exe 'source '.escape(a:path.'/'.s:local_vimrc, ' \$,')
147
+  elseif &verbose >= 2
148
+    echo 'Check '.a:path.' for '.s:local_vimrc.' ... none!'
149
+  endif
150
+endfunction
151
+
152
+function! s:CheckForbiddenPath(path)
153
+  let ok = a:path !~ '^\(s\=ftp:\|s\=http:\|scp:\|^$\)'
154
+  return ok
155
+endfunction
156
+
157
+function! s:Main(path)
158
+  " echomsg 'Sourcing: '.a:path
159
+  if !s:CheckForbiddenPath(a:path) 
160
+    return
161
+  else
162
+    call s:SourceLocal(a:path)
163
+  endif
164
+endfunction
165
+
166
+" Update s:k_version in local_vimrc files                             {{{2
167
+function! s:IncrementVersionOnSave()
168
+  let l = search('let s:k_version', 'n')
169
+  if l > 0
170
+    let nl = substitute(getline(l), '\(let\s\+s:k_version\s*=\s*\)\(\d\+\)\s*$', '\=submatch(1).(1+submatch(2))', '')
171
+    call setline(l, nl)
172
+  endif
173
+endfunction
174
+
175
+" Auto-command                                                        {{{2
176
+" => automate the loading of local-vimrc's every time we change buffers 
177
+aug LocalVimrc
178
+  au!
179
+  au BufEnter * :call s:Main(expand('<afile>:p:h'))
180
+  exe 'au BufWritePre '.s:local_vimrc . ' call s:IncrementVersionOnSave()'
181
+aug END
182
+
183
+" Functions }}}1
184
+"------------------------------------------------------------------------
185
+let &cpo=s:cpo_save
186
+"=============================================================================
187
+" vim600: set fdm=marker:

+ 27
- 0
dotfiles/vim/syntax/ini.vim View File

@@ -0,0 +1,27 @@
1
+" Vim syntax file
2
+" Language:	Vim 7.2 script
3
+" Filenames:    *.ini, .hgrc, */.hg/hgrc
4
+" Maintainer:	Peter Hosey
5
+" Last Change:	Nov 11, 2008
6
+" Version:	7.2-02
7
+
8
+" Quit when a syntax file was already loaded
9
+if exists("b:current_syntax")
10
+  finish
11
+endif
12
+
13
+syn match   iniSection skipwhite contains=iniRule "^\[.\+\]$"
14
+
15
+syn match   iniRule "^[^=:]\{-1,}="
16
+syn match   iniRule "^[^:=]\{-1,}:"
17
+
18
+syn match   iniComment skipwhite "^[#;].*"
19
+
20
+" Highlighting Settings
21
+" ====================
22
+
23
+hi def link iniSection Keyword
24
+hi def link iniRule Identifier
25
+hi def link iniComment Comment
26
+
27
+let b:current_syntax = "ini"

+ 535
- 0
dotfiles/vim/syntax/python.vim View File

@@ -0,0 +1,535 @@
1
+" Vim syntax file
2
+" Language:     Python
3
+" Maintainer:   Dmitry Vasiliev <dima at hlabs dot org>
4
+" URL:          https://github.com/hdima/vim-scripts/blob/master/syntax/python/python.vim
5
+" Last Change:  2013-03-10
6
+" Filenames:    *.py
7
+" Version:      3.3.0
8
+"
9
+" Based on python.vim (from Vim 6.1 distribution)
10
+" by Neil Schemenauer <nas at python dot ca>
11
+"
12
+" Bugs and feature requests can be reported through email
13
+" <dima at hlabs dot org>, GitHub at:
14
+"
15
+"   https://github.com/hdima/vim-scripts/issues
16
+"
17
+" , or Twitter:
18
+"
19
+"   https://twitter.com/hdima
20
+"
21
+" Contributors
22
+" ============
23
+"
24
+"   Jeroen Ruigrok van der Werven
25
+"   Pedro Algarvio
26
+"   John Eikenberry
27
+"   Caleb Adamantine
28
+"   Andrea Riciputi
29
+"   Anton Butanaev
30
+"   Marc Weber
31
+"
32
+" Options
33
+" =======
34
+"
35
+"    :let OPTION_NAME = 1                   Enable option
36
+"    :let OPTION_NAME = 0                   Disable option
37
+"
38
+"
39
+" Option to select Python version
40
+" -------------------------------
41
+"
42
+"    python_version_2                       Enable highlighting for Python 2
43
+"                                           (Python 3 highlighting is enabled
44
+"                                           by default). Can also be set as
45
+"                                           a buffer (b:python_version_2)
46
+"                                           variable.
47
+"
48
+"    You can also use the following local to buffer commands to switch
49
+"    between two highlighting modes:
50
+"
51
+"    :Python2Syntax                         Switch to Python 2 highlighting
52
+"                                           mode
53
+"    :Python3Syntax                         Switch to Python 3 highlighting
54
+"                                           mode
55
+"
56
+" Option names used by the script
57
+" -------------------------------
58
+"
59
+"    python_highlight_builtins              Highlight builtin functions and
60
+"                                           objects
61
+"      python_highlight_builtin_objs        Highlight builtin objects only
62
+"      python_highlight_builtin_funcs       Highlight builtin functions only
63
+"    python_highlight_exceptions            Highlight standard exceptions
64
+"    python_highlight_string_formatting     Highlight % string formatting
65
+"    python_highlight_string_format         Highlight str.format syntax
66
+"    python_highlight_string_templates      Highlight string.Template syntax
67
+"    python_highlight_indent_errors         Highlight indentation errors
68
+"    python_highlight_space_errors          Highlight trailing spaces
69
+"    python_highlight_doctests              Highlight doc-tests
70
+"    python_print_as_function               Highlight 'print' statement as
71
+"                                           function for Python 2
72
+"
73
+"    python_highlight_all                   Enable all the options above
74
+"                                           NOTE: This option don't override
75
+"                                           any previously set options
76
+"
77
+"    python_slow_sync                       Can be set to 0 for slow machines
78
+"
79
+
80
+" For version 5.x: Clear all syntax items
81
+" For versions greater than 6.x: Quit when a syntax file was already loaded
82
+if version < 600
83
+  syntax clear
84
+elseif exists("b:current_syntax")
85
+  finish
86
+endif
87
+
88
+"
89
+" Commands
90
+"
91
+command! -buffer Python2Syntax let b:python_version_2 = 1 | if exists("g:syntax_on") | syn off | endif | syn enable
92
+command! -buffer Python3Syntax let b:python_version_2 = 0 | if exists("g:syntax_on") | syn off | endif | syn enable
93
+
94
+" Enable option if it's not defined
95
+function! s:EnableByDefault(name)
96
+  if !exists(a:name)
97
+    let {a:name} = 1
98
+  endif
99
+endfunction
100
+
101
+" Check if option is enabled
102
+function! s:Enabled(name)
103
+  return exists(a:name) && {a:name} != 0
104
+endfunction
105
+
106
+" Is it Python 2 syntax?
107
+function! s:Python2Syntax()
108
+  return s:Enabled("b:python_version_2") || s:Enabled("g:python_version_2")
109
+endfunction
110
+
111
+"
112
+" Default options
113
+"
114
+
115
+call s:EnableByDefault("g:python_slow_sync")
116
+
117
+if s:Enabled("g:python_highlight_all")
118
+  call s:EnableByDefault("g:python_highlight_builtins")
119
+  if s:Enabled("g:python_highlight_builtins")
120
+    call s:EnableByDefault("g:python_highlight_builtin_objs")
121
+    call s:EnableByDefault("g:python_highlight_builtin_funcs")
122
+  endif
123
+  call s:EnableByDefault("g:python_highlight_exceptions")
124
+  call s:EnableByDefault("g:python_highlight_string_formatting")
125
+  call s:EnableByDefault("g:python_highlight_string_format")
126
+  call s:EnableByDefault("g:python_highlight_string_templates")
127
+  call s:EnableByDefault("g:python_highlight_indent_errors")
128
+  call s:EnableByDefault("g:python_highlight_space_errors")
129
+  call s:EnableByDefault("g:python_highlight_doctests")
130
+  call s:EnableByDefault("g:python_print_as_function")
131
+endif
132
+
133
+"
134
+" Keywords
135
+"
136
+
137
+syn keyword pythonStatement     break continue del
138
+syn keyword pythonStatement     exec return
139
+syn keyword pythonStatement     pass raise
140
+syn keyword pythonStatement     global assert
141
+syn keyword pythonStatement     lambda yield
142
+syn keyword pythonStatement     with
143
+syn keyword pythonStatement     def class nextgroup=pythonFunction skipwhite
144
+syn keyword pythonRepeat        for while
145
+syn keyword pythonConditional   if elif else
146
+syn keyword pythonPreCondit     import from
147
+syn keyword pythonException     try except finally
148
+syn keyword pythonOperator      and in is not or
149
+
150
+" added by aloism
151
+syn keyword pythonConvention    self
152
+
153
+if s:Python2Syntax()
154
+  if !s:Enabled("g:python_print_as_function")
155
+    syn keyword pythonStatement  print
156
+  endif
157
+  syn keyword pythonPreCondit   as
158
+  syn match   pythonFunction    "[a-zA-Z_][a-zA-Z0-9_]*" display contained
159
+else
160
+  syn keyword pythonStatement   as nonlocal False None True
161
+  syn match   pythonFunction    "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
162
+endif
163
+
164
+"
165
+" Decorators (new in Python 2.4)
166
+"
167
+
168
+syn match   pythonDecorator	"@" display nextgroup=pythonDottedName skipwhite
169
+syn match   pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
170
+syn match   pythonDot        "\." display containedin=pythonDottedName
171
+
172
+"
173
+" Comments
174
+"
175
+
176
+syn match   pythonComment	"#.*$" display contains=pythonTodo,@Spell
177
+syn match   pythonRun		"\%^#!.*$"
178
+syn match   pythonCoding	"\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
179
+syn keyword pythonTodo		TODO FIXME XXX contained
180
+
181
+"
182
+" Errors
183
+"
184
+
185
+syn match pythonError		"\<\d\+\D\+\>" display
186
+syn match pythonError		"[$?]" display
187
+syn match pythonError		"[&|]\{2,}" display
188
+syn match pythonError		"[=]\{3,}" display
189
+
190
+" Mixing spaces and tabs also may be used for pretty formatting multiline
191
+" statements
192
+if s:Enabled("g:python_highlight_indent_errors")
193
+  syn match pythonIndentError	"^\s*\%( \t\|\t \)\s*\S"me=e-1 display
194
+endif
195
+
196
+" Trailing space errors
197
+if s:Enabled("g:python_highlight_space_errors")
198
+  syn match pythonSpaceError	"\s\+$" display
199
+endif
200
+
201
+"
202
+" Strings
203
+"
204
+
205
+if s:Python2Syntax()
206
+  " Python 2 strings
207
+  syn region pythonString   start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
208
+  syn region pythonString   start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
209
+  syn region pythonString   start=+[bB]\="""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
210
+  syn region pythonString   start=+[bB]\='''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
211
+else
212
+  " Python 3 byte strings
213
+  syn region pythonBytes		start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell
214
+  syn region pythonBytes		start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell
215
+  syn region pythonBytes		start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell
216
+  syn region pythonBytes		start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell
217
+
218
+  syn match pythonBytesError    ".\+" display contained
219
+  syn match pythonBytesContent  "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError
220
+endif
221
+
222
+syn match pythonBytesEscape       +\\[abfnrtv'"\\]+ display contained
223
+syn match pythonBytesEscape       "\\\o\o\=\o\=" display contained
224
+syn match pythonBytesEscapeError  "\\\o\{,2}[89]" display contained
225
+syn match pythonBytesEscape       "\\x\x\{2}" display contained
226
+syn match pythonBytesEscapeError  "\\x\x\=\X" display contained
227
+syn match pythonBytesEscape       "\\$"
228
+
229
+syn match pythonUniEscape         "\\u\x\{4}" display contained
230
+syn match pythonUniEscapeError    "\\u\x\{,3}\X" display contained
231
+syn match pythonUniEscape         "\\U\x\{8}" display contained
232
+syn match pythonUniEscapeError    "\\U\x\{,7}\X" display contained
233
+syn match pythonUniEscape         "\\N{[A-Z ]\+}" display contained
234
+syn match pythonUniEscapeError    "\\N{[^A-Z ]\+}" display contained
235
+
236
+if s:Python2Syntax()
237
+  " Python 2 Unicode strings
238
+  syn region pythonUniString  start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
239
+  syn region pythonUniString  start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
240
+  syn region pythonUniString  start=+[uU]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
241
+  syn region pythonUniString  start=+[uU]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
242
+else
243
+  " Python 3 strings
244
+  syn region pythonString   start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
245
+  syn region pythonString   start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
246
+  syn region pythonString   start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
247
+  syn region pythonString   start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
248
+endif
249
+
250
+if s:Python2Syntax()
251
+  " Python 2 Unicode raw strings
252
+  syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
253
+  syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
254
+  syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
255
+  syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
256
+
257
+  syn match  pythonUniRawEscape       "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
258
+  syn match  pythonUniRawEscapeError  "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
259
+endif
260
+
261
+" Python 2/3 raw strings
262
+if s:Python2Syntax()
263
+  syn region pythonRawString  start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
264
+  syn region pythonRawString  start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
265
+  syn region pythonRawString  start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
266
+  syn region pythonRawString  start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
267
+else
268
+  syn region pythonRawString  start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
269
+  syn region pythonRawString  start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
270
+  syn region pythonRawString  start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
271
+  syn region pythonRawString  start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
272
+
273
+  syn region pythonRawBytes  start=+[bB][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
274
+  syn region pythonRawBytes  start=+[bB][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
275
+  syn region pythonRawBytes  start=+[bB][rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
276
+  syn region pythonRawBytes  start=+[bB][rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
277
+endif
278
+
279
+syn match pythonRawEscape +\\['"]+ display transparent contained
280
+
281
+if s:Enabled("g:python_highlight_string_formatting")
282
+  " % operator string formatting
283
+  if s:Python2Syntax()
284
+    syn match pythonStrFormatting	"%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
285
+    syn match pythonStrFormatting	"%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
286
+  else
287
+    syn match pythonStrFormatting	"%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString
288
+    syn match pythonStrFormatting	"%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString
289
+  endif
290
+endif
291
+
292
+if s:Enabled("g:python_highlight_string_format")
293
+  " str.format syntax
294
+  if s:Python2Syntax()
295
+    syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
296
+    syn match pythonStrFormat	"{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
297
+  else
298
+    syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString
299
+    syn match pythonStrFormat	"{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString
300
+  endif
301
+endif
302
+
303
+if s:Enabled("g:python_highlight_string_templates")
304
+  " string.Template format
305
+  if s:Python2Syntax()
306
+    syn match pythonStrTemplate	"\$\$" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
307
+    syn match pythonStrTemplate	"\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
308
+    syn match pythonStrTemplate	"\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
309
+  else
310
+    syn match pythonStrTemplate	"\$\$" contained containedin=pythonString,pythonRawString
311
+    syn match pythonStrTemplate	"\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonRawString
312
+    syn match pythonStrTemplate	"\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonRawString
313
+  endif
314
+endif
315
+
316
+if s:Enabled("g:python_highlight_doctests")
317
+  " DocTests
318
+  syn region pythonDocTest	start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
319
+  syn region pythonDocTest2	start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
320
+endif
321
+
322
+"
323
+" Numbers (ints, longs, floats, complex)
324
+"
325
+
326
+if s:Python2Syntax()
327
+  syn match   pythonHexError	"\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>" display
328
+  syn match   pythonOctError	"\<0[oO]\=\o*\D\+\d*[lL]\=\>" display
329
+  syn match   pythonBinError	"\<0[bB][01]*\D\+\d*[lL]\=\>" display
330
+
331
+  syn match   pythonHexNumber	"\<0[xX]\x\+[lL]\=\>" display
332
+  syn match   pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
333
+  syn match   pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
334
+
335
+  syn match   pythonNumberError	"\<\d\+\D[lL]\=\>" display
336
+  syn match   pythonNumber	"\<\d[lL]\=\>" display
337
+  syn match   pythonNumber	"\<[0-9]\d\+[lL]\=\>" display
338
+  syn match   pythonNumber	"\<\d\+[lLjJ]\>" display
339
+
340
+  syn match   pythonOctError	"\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
341
+  syn match   pythonBinError	"\<0[bB][01]*[2-9]\d*[lL]\=\>" display
342
+else
343
+  syn match   pythonHexError	"\<0[xX]\x*[g-zG-Z]\x*\>" display
344
+  syn match   pythonOctError	"\<0[oO]\=\o*\D\+\d*\>" display
345
+  syn match   pythonBinError	"\<0[bB][01]*\D\+\d*\>" display
346
+
347
+  syn match   pythonHexNumber	"\<0[xX]\x\+\>" display
348
+  syn match   pythonOctNumber "\<0[oO]\o\+\>" display
349
+  syn match   pythonBinNumber "\<0[bB][01]\+\>" display
350
+
351
+  syn match   pythonNumberError	"\<\d\+\D\>" display
352
+  syn match   pythonNumberError	"\<0\d\+\>" display
353
+  syn match   pythonNumber	"\<\d\>" display
354
+  syn match   pythonNumber	"\<[1-9]\d\+\>" display
355
+  syn match   pythonNumber	"\<\d\+[jJ]\>" display
356
+
357
+  syn match   pythonOctError	"\<0[oO]\=\o*[8-9]\d*\>" display
358
+  syn match   pythonBinError	"\<0[bB][01]*[2-9]\d*\>" display
359
+endif
360
+
361
+syn match   pythonFloat		"\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display
362
+syn match   pythonFloat		"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
363
+syn match   pythonFloat		"\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display
364
+
365
+"
366
+" Builtin objects and types
367
+"
368
+
369
+if s:Enabled("g:python_highlight_builtin_objs")
370
+  if s:Python2Syntax()
371
+    syn keyword pythonBuiltinObj	True False None
372
+  endif
373
+  syn keyword pythonBuiltinObj	Ellipsis NotImplemented
374
+  syn keyword pythonBuiltinObj	__debug__ __doc__ __file__ __name__ __package__
375
+endif
376
+
377
+"
378
+" Builtin functions
379
+"
380
+
381
+if s:Enabled("g:python_highlight_builtin_funcs")
382
+  if s:Python2Syntax()
383
+    syn keyword pythonBuiltinFunc	apply basestring buffer callable coerce
384
+    syn keyword pythonBuiltinFunc	execfile file help intern long raw_input
385
+    syn keyword pythonBuiltinFunc	reduce reload unichr unicode xrange
386
+    if s:Enabled("g:python_print_as_function")
387
+      syn keyword pythonBuiltinFunc	print
388
+    endif
389
+  else
390
+    syn keyword pythonBuiltinFunc	ascii exec memoryview print
391
+  endif
392
+  syn keyword pythonBuiltinFunc	__import__ abs all any
393
+  syn keyword pythonBuiltinFunc	bin bool bytearray bytes
394
+  syn keyword pythonBuiltinFunc	chr classmethod cmp compile complex
395
+  syn keyword pythonBuiltinFunc	delattr dict dir divmod enumerate eval
396
+  syn keyword pythonBuiltinFunc	filter float format frozenset getattr
397
+  syn keyword pythonBuiltinFunc	globals hasattr hash hex id
398
+  syn keyword pythonBuiltinFunc	input int isinstance
399
+  syn keyword pythonBuiltinFunc	issubclass iter len list locals map max
400
+  syn keyword pythonBuiltinFunc	min next object oct open ord
401
+  syn keyword pythonBuiltinFunc	pow property range
402
+  syn keyword pythonBuiltinFunc	repr reversed round set setattr
403
+  syn keyword pythonBuiltinFunc	slice sorted staticmethod str sum super tuple
404
+  syn keyword pythonBuiltinFunc	type vars zip
405
+endif
406
+
407
+"
408
+" Builtin exceptions and warnings
409
+"
410
+
411
+if s:Enabled("g:python_highlight_exceptions")
412
+  if s:Python2Syntax()
413
+    syn keyword pythonExClass	StandardError
414
+  else
415
+    syn keyword pythonExClass	BlockingIOError ChildProcessError
416
+    syn keyword pythonExClass	ConnectionError BrokenPipeError
417
+    syn keyword pythonExClass	ConnectionAbortedError ConnectionRefusedError
418
+    syn keyword pythonExClass	ConnectionResetError FileExistsError
419
+    syn keyword pythonExClass	FileNotFoundError InterruptedError
420
+    syn keyword pythonExClass	IsADirectoryError NotADirectoryError
421
+    syn keyword pythonExClass	PermissionError ProcessLookupError TimeoutError
422
+
423
+    syn keyword pythonExClass	ResourceWarning
424
+  endif
425
+  syn keyword pythonExClass	BaseException
426
+  syn keyword pythonExClass	Exception ArithmeticError
427
+  syn keyword pythonExClass	LookupError EnvironmentError
428
+
429
+  syn keyword pythonExClass	AssertionError AttributeError BufferError EOFError
430
+  syn keyword pythonExClass	FloatingPointError GeneratorExit IOError
431
+  syn keyword pythonExClass	ImportError IndexError KeyError
432
+  syn keyword pythonExClass	KeyboardInterrupt MemoryError NameError
433
+  syn keyword pythonExClass	NotImplementedError OSError OverflowError
434
+  syn keyword pythonExClass	ReferenceError RuntimeError StopIteration
435
+  syn keyword pythonExClass	SyntaxError IndentationError TabError
436
+  syn keyword pythonExClass	SystemError SystemExit TypeError
437
+  syn keyword pythonExClass	UnboundLocalError UnicodeError
438
+  syn keyword pythonExClass	UnicodeEncodeError UnicodeDecodeError
439
+  syn keyword pythonExClass	UnicodeTranslateError ValueError VMSError
440
+  syn keyword pythonExClass	WindowsError ZeroDivisionError
441
+
442
+  syn keyword pythonExClass	Warning UserWarning BytesWarning DeprecationWarning
443
+  syn keyword pythonExClass	PendingDepricationWarning SyntaxWarning
444
+  syn keyword pythonExClass	RuntimeWarning FutureWarning
445
+  syn keyword pythonExClass	ImportWarning UnicodeWarning
446
+endif
447
+
448
+if s:Enabled("g:python_slow_sync")
449
+  syn sync minlines=2000
450
+else
451
+  " This is fast but code inside triple quoted strings screws it up. It
452
+  " is impossible to fix because the only way to know if you are inside a
453
+  " triple quoted string is to start from the beginning of the file.
454
+  syn sync match pythonSync grouphere NONE "):$"
455
+  syn sync maxlines=200
456
+endif
457
+
458
+if version >= 508 || !exists("did_python_syn_inits")
459
+  if version <= 508
460
+    let did_python_syn_inits = 1
461
+    command -nargs=+ HiLink hi link <args>
462
+  else
463
+    command -nargs=+ HiLink hi def link <args>
464
+  endif
465
+
466
+  HiLink pythonStatement        Statement
467
+  HiLink pythonPreCondit        Statement
468
+  HiLink pythonFunction         Function
469
+  HiLink pythonConditional      Conditional
470
+  HiLink pythonRepeat           Repeat
471
+  HiLink pythonException        Exception
472
+  HiLink pythonOperator         Operator
473
+
474
+  HiLink pythonDecorator        Define
475
+  HiLink pythonDottedName       Function
476
+  HiLink pythonDot              Normal
477
+
478
+  HiLink pythonComment          Comment
479
+  HiLink pythonCoding           Special
480
+  HiLink pythonRun              Special
481
+  HiLink pythonTodo             Todo
482
+
483
+  HiLink pythonError            Error
484
+  HiLink pythonIndentError      Error
485
+  HiLink pythonSpaceError       Error
486
+
487
+  HiLink pythonString           String
488
+  HiLink pythonRawString        String
489
+
490
+  HiLink pythonUniEscape        Special
491
+  HiLink pythonUniEscapeError   Error
492
+
493
+  if s:Python2Syntax()
494
+    HiLink pythonUniString          String
495
+    HiLink pythonUniRawString       String
496
+    HiLink pythonUniRawEscape       Special
497
+    HiLink pythonUniRawEscapeError  Error
498
+  else
499
+    HiLink pythonBytes              String
500
+    HiLink pythonRawBytes           String
501
+    HiLink pythonBytesContent       String
502
+    HiLink pythonBytesError         Error
503
+    HiLink pythonBytesEscape        Special
504
+    HiLink pythonBytesEscapeError   Error
505
+  endif
506
+
507
+  HiLink pythonStrFormatting    Special
508
+  HiLink pythonStrFormat        Special
509
+  HiLink pythonStrTemplate      Special
510
+
511
+  HiLink pythonDocTest          Special
512
+  HiLink pythonDocTest2         Special
513
+
514
+  " added by aloism
515
+  HiLink pythonConvention       Define	
516
+
517
+  HiLink pythonNumber           Number
518
+  HiLink pythonHexNumber        Number
519
+  HiLink pythonOctNumber        Number
520
+  HiLink pythonBinNumber        Number
521
+  HiLink pythonFloat            Float
522
+  HiLink pythonNumberError      Error
523
+  HiLink pythonOctError         Error
524
+  HiLink pythonHexError         Error
525
+  HiLink pythonBinError         Error
526
+
527
+  HiLink pythonBuiltinObj       Structure
528
+  HiLink pythonBuiltinFunc      Function
529
+
530
+  HiLink pythonExClass          Structure
531
+
532
+  delcommand HiLink
533
+endif
534
+
535
+let b:current_syntax = "python"

+ 93
- 0
dotfiles/vim/vimrc View File

@@ -0,0 +1,93 @@
1
+execute pathogen#infect()
2
+
3
+"#### vrom vimrc_example.vim ####"
4
+
5
+" allow backspacing over everything in insert mode
6
+set backspace=indent,eol,start
7
+set history=500		" keep 50 lines of command line history
8
+set ruler		" show the cursor position all the time
9
+set showcmd		" display incomplete commands
10
+set incsearch		" do incremental searching
11
+
12
+" In many terminal emulators the mouse works just fine, thus enable it.
13
+if has('mouse')
14
+  set mouse=a
15
+endif
16
+
17
+" Switch syntax highlighting on, when the terminal has colors
18
+" Also switch on highlighting the last used search pattern.
19
+if &t_Co > 2 || has("gui_running")
20
+  syntax on
21
+  set hlsearch
22
+endif
23
+
24
+" Only do this part when compiled with support for autocommands.
25
+if has("autocmd")
26
+
27
+  " Enable file type detection.
28
+  " Use the default filetype settings, so that mail gets 'tw' set to 72,
29
+  " 'cindent' is on in C files, etc.
30
+  " Also load indent files, to automatically do language-dependent indenting.
31
+  filetype plugin indent on
32
+
33
+  " Put these in an autocmd group, so that we can delete them easily.
34
+  augroup vimrcEx
35
+  au!
36
+
37
+  " For all text files set 'textwidth' to 78 characters.
38
+  autocmd FileType text setlocal textwidth=78
39
+
40
+  " When editing a file, always jump to the last known cursor position.
41
+  " Don't do it when the position is invalid or when inside an event handler
42
+  " (happens when dropping a file on gvim).
43
+  " Also don't do it when the mark is in the first line, that is the default
44
+  " position when opening a file.
45
+  autocmd BufReadPost *
46
+    \ if line("'\"") > 1 && line("'\"") <= line("$") |
47
+    \   exe "normal! g`\"" |
48
+    \ endif
49
+
50
+  augroup END
51
+
52
+else
53
+
54
+  set autoindent		" always set autoindenting on
55
+
56
+endif " has("autocmd")
57
+
58
+" Convenient command to see the difference between the current buffer and the
59
+" file it was loaded from, thus the changes you made.
60
+" Only define it when not defined already.
61
+if !exists(":DiffOrig")
62
+  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
63
+		  \ | wincmd p | diffthis
64
+endif
65
+
66
+"########################
67
+"######## from me #######
68
+
69
+set listchars=tab:>-,precedes:<
70
+set list
71
+
72
+" my favorite indent style
73
+set tabstop=4
74
+set shiftwidth=4
75
+set expandtab
76
+
77
+let g:local_vimrc=".vimrc_local.vim"
78
+
79
+" for gvim
80
+colorscheme torte
81
+set gfn=Droid\ Sans\ Mono\ 9
82
+
83
+set fileencodings=ucs-bom,utf-8,cp1250,latin1
84
+
85
+let python_highlight_all = 1
86
+
87
+set number
88
+highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
89
+
90
+set autoindent
91
+
92
+set pastetoggle=<F2>
93
+nmap <F3> :set invnumber<CR>

+ 49
- 0
mklinks View File

@@ -0,0 +1,49 @@
1
+#!/bin/sh
2
+
3
+# ============================================
4
+# mklinks
5
+# --------------------------------------------
6
+# This script will go through each sub-folder
7
+# of DOTROOT and create symbolic link to it
8
+# under your HOME named with "." prefix.
9
+#
10
+# This is useful for sharing your dotfiles
11
+# (e.g. using service like Dropbox or keeping
12
+# them in a shared VCS repository like git)
13
+#
14
+#    DOTROOT - path where your shared dot-files
15
+#              are.
16
+#    PREFIX  - where you want your links to
17
+#              dot-files to be created ($HOME
18
+#              by default)
19
+#
20
+# --------------------------------------------
21
+# By Alois Mahdal; no warranty
22
+# ============================================
23
+
24
+
25
+if [ -z "$1" ];
26
+    then echo "usage: $0: DOTROOT [PREFIX]";
27
+    exit 1;
28
+fi;
29
+
30
+dotroot=$1
31
+prefix=$HOME
32
+
33
+if [ -n "$2" ];
34
+    then prefix=$2;
35
+fi;
36
+
37
+
38
+ls $dotroot | while read item;
39
+do
40
+    source=$dotroot/$item;
41
+    target=$prefix/.$item;
42
+    if [ -e $target ];
43
+    then
44
+        echo "target exists: $target" 1>&2;
45
+    else
46
+        ln -s $source $target;
47
+    fi;
48
+done;
49
+

+ 0
- 0
test_dotfiles/aaafile View File


+ 0
- 0
test_dotfiles/bbbfile View File