[ADD] conf for archlinux, <init>
[arrow.git] / archlinux_conf / home / .vim / plugin / viki.vim
bloba276af10a2c645479371c35fc9c3a8a2d0381bcb
1 " Viki.vim -- Some kind of personal wiki for Vim
2 " @Author:      Thomas Link (micathom AT gmail com?subject=vim)
3 " @License:     GPL (see http://www.gnu.org/licenses/gpl.txt)
4 " @Created:     08-Dec-2003.
5 " @Last Change: 2008-06-22.
6 " @Revision: 3.7.2563
8 " GetLatestVimScripts: 861 1 viki.vim
10 " Short Description:
11 " This plugin adds wiki-like hypertext capabilities to any document.  Just 
12 " type :VikiMinorMode and all wiki names will be highlighted. If you press 
13 " <c-cr> (or <LocalLeader>vf) when the cursor is over a wiki name, you 
14 " jump to (or create) the referred page. When invoked via :set ft=viki, 
15 " additional highlighting is provided.
17 " Requirements:
18 " - tlib.vim (vimscript #1863)
19
20 " Optional Enhancements:
21 " - imaps.vim (vimscript #244 or #475 for |:VimQuote|)
22 " - kpsewhich (not a vim plugin :-) for vikiLaTeX
24 " TODO:
25 " - File names containing # (the # is interpreted as URL component)
26 " - Per Interviki simple name patterns
27 " - Allow Wiki links like ::Word or even ::word (not in minor mode due 
28 "   possible conflict with various programming languages?)
29 " - :VikiRename command: rename links/files (requires a cross-plattform grep 
30 "   or similar; or one could a global register)
31 " - don't know how to deal with viki names that span several lines (e.g.  in 
32 "   LaTeX mode)
34 if &cp || exists("loaded_viki") "{{{2
35     finish
36 endif
37 if !exists('g:loaded_tlib') || g:loaded_tlib < 15
38     runtime plugin/02tlib.vim
39     if !exists('g:loaded_tlib') || g:loaded_tlib < 15
40         echoerr 'tlib >= 0.15 is required'
41         finish
42     endif
43 endif
44 let loaded_viki = 308
46 " This is what we consider nil, in the absence of nil in vimscript
47 let g:vikiDefNil  = ''
49 " In a previous version this was used as list separator and as nil too
50 let g:vikiDefSep  = "\n"
52 " let s:vikiSelfEsc = '\'
54 " In extended viki links this is considered as a reference to the current 
55 " document. This is likely to go away.
56 let g:vikiSelfRef = '.'
58 " let s:vikiEnabledID = loaded_viki .'_'. strftime('%c')
61 " Configuration {{{1
62 " If zero, viki is disabled, though the code is loaded.
63 if !exists("g:vikiEnabled") "{{{2
64     let g:vikiEnabled = 1
65 endif
67 " Support for the taglist plugin.
68 if !exists("tlist_viki_settings") "{{{2
69     let tlist_viki_settings="deplate;s:structure"
70 endif
72 " A simple viki name is made from a series of upper and lower characters 
73 " (i.e. CamelCase-names). These two variables define what is considered as 
74 " upper and lower-case characters. We don't rely on the builtin 
75 " functionality for this.
76 if !exists("g:vikiUpperCharacters") "{{{2
77     let g:vikiUpperCharacters = "A-Z"
78 endif
79 if !exists("g:vikiLowerCharacters") "{{{2
80     let g:vikiLowerCharacters = "a-z"
81 endif
83 " The prefix for the menu of intervikis. Set to '' in order to remove the 
84 " menu.
85 if !exists("g:vikiMenuPrefix") "{{{2
86     let g:vikiMenuPrefix = "Plugin.Viki."
87 endif
89 " Make submenus for N letters of the interviki names.
90 if !exists('g:vikiMenuLevel')
91     let g:vikiMenuLevel = 1   "{{{2
92 endif
94 " URLs matching these protocols are handled by VikiOpenSpecialProtocol()
95 if !exists("g:vikiSpecialProtocols") "{{{2
96     let g:vikiSpecialProtocols = 'https\?\|ftps\?\|nntp\|mailto\|mailbox\|file'
97 endif
99 " Exceptions from g:vikiSpecialProtocols
100 if !exists("g:vikiSpecialProtocolsExceptions") "{{{2
101     let g:vikiSpecialProtocolsExceptions = ""
102 endif
104 " Files matching these suffixes are handled by viki#OpenSpecialFile()
105 if !exists("g:vikiSpecialFiles") "{{{2
106     let g:vikiSpecialFiles = [
107                 \ 'aac',
108                 \ 'aif',
109                 \ 'aiff',
110                 \ 'au',
111                 \ 'avi',
112                 \ 'bmp',
113                 \ 'dia',
114                 \ 'doc',
115                 \ 'dvi',
116                 \ 'eps',
117                 \ 'eps',
118                 \ 'gif',
119                 \ 'htm',
120                 \ 'html',
121                 \ 'jpeg',
122                 \ 'jpg',
123                 \ 'm3u',
124                 \ 'mp1',
125                 \ 'mp2',
126                 \ 'mp3',
127                 \ 'mp4',
128                 \ 'mpeg',
129                 \ 'mpg',
130                 \ 'odg',
131                 \ 'ods',
132                 \ 'odt',
133                 \ 'ogg',
134                 \ 'pdf',
135                 \ 'png',
136                 \ 'ppt',
137                 \ 'ps',
138                 \ 'rtf',
139                 \ 'voc',
140                 \ 'wav',
141                 \ 'wma',
142                 \ 'wmf',
143                 \ 'wmv',
144                 \ 'xhtml',
145                 \ 'xls',
146                 \ ]
147 endif
149 " Exceptions from g:vikiSpecialFiles
150 if !exists("g:vikiSpecialFilesExceptions") "{{{2
151     let g:vikiSpecialFilesExceptions = ""
152 endif
154 if !exists('g:viki_highlight_hyperlink_light') "{{{2
155     " let g:viki_highlight_hyperlink_light = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=DarkBlue guifg=DarkBlue'
156     let g:viki_highlight_hyperlink_light = 'term=underline cterm=underline gui=underline ctermfg=DarkBlue guifg=DarkBlue'
157 endif
158 if !exists('g:viki_highlight_hyperlink_dark') "{{{2
159     " let g:viki_highlight_hyperlink_dark = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=DarkBlue guifg=LightBlue'
160     let g:viki_highlight_hyperlink_dark = 'term=underline cterm=underline gui=underline ctermfg=LightBlue guifg=#bfbfff'
161 endif
163 if !exists('g:viki_highlight_inexistent_light') "{{{2
164     " let g:viki_highlight_inexistent_light = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=DarkRed guifg=DarkRed'
165     let g:viki_highlight_inexistent_light = 'term=underline cterm=underline gui=underline ctermfg=DarkRed guifg=DarkRed'
166 endif
167 if !exists('g:viki_highlight_inexistent_dark') "{{{2
168     " let g:viki_highlight_inexistent_dark = 'term=bold,underline cterm=bold,underline gui=bold,underline ctermfg=Red guifg=Red'
169     let g:viki_highlight_inexistent_dark = 'term=underline cterm=underline gui=underline ctermfg=Red guifg=Red'
170 endif
172 " If set to true, any files loaded by viki will become viki enabled (in 
173 " minor mode); this was the default behaviour in earlier versions
174 if !exists('g:vikiPromote') "{{{2
175     let g:vikiPromote = 0
176 endif
178 " If non-nil, use the parent document's suffix.
179 if !exists("g:vikiUseParentSuffix") | let g:vikiUseParentSuffix = 0      | endif "{{{2
181 " Default file suffix.
182 if !exists("g:vikiNameSuffix")      | let g:vikiNameSuffix = ""          | endif "{{{2
184 " Prefix for anchors
185 if !exists("g:vikiAnchorMarker")    | let g:vikiAnchorMarker = "#"       | endif "{{{2
187 " If non-nil, search anchors anywhere in the text too (without special 
188 " markup)
189 if !exists("g:vikiFreeMarker")      | let g:vikiFreeMarker = 0           | endif "{{{2
191 if !exists('g:vikiPostFindAnchor') "{{{2
192     let g:vikiPostFindAnchor = 'norm! zz'
193 endif
195 " List of enabled viki name types
196 " c ... Camel case
197 " s ... Simple names
198 " S ... Quoted simple names
199 " e ... Extended names
200 " u ... URLs
201 " i ... Intervikis
202 " x ... Commands
203 " w ... "hyperwords"
204 " f ... Filenames as "hyperwords"
205 if !exists("g:vikiNameTypes")       | let g:vikiNameTypes = "csSeuixwf"  | endif "{{{2
207 " Which directory explorer to use to edit directories
208 if !exists("g:vikiExplorer")        | let g:vikiExplorer = "Sexplore"    | endif "{{{2
209 " if !exists("g:vikiExplorer")        | let g:vikiExplorer = "split"    | endif "{{{2
210 " if !exists("g:vikiExplorer")        | let g:vikiExplorer = "edit"          | endif "{{{2
212 " If hide or update: use the respective command when leaving a buffer
213 if !exists("g:vikiHide")            | let g:vikiHide = ''                | endif "{{{2
215 " Don't use g:vikiHide for commands matching this rx
216 if !exists("g:vikiNoWrapper")       | let g:vikiNoWrapper = '\cexplore'  | endif "{{{2
218 " Cache information about a document's inexistent names
219 if !exists("g:vikiCacheInexistent") | let g:vikiCacheInexistent = 0      | endif "{{{2
221 " Mark up inexistent names.
222 if !exists("g:vikiMarkInexistent")  | let g:vikiMarkInexistent = 1       | endif "{{{2
224 " If non-nil, map keys that trigger the evaluation of inexistent names
225 if !exists("g:vikiMapInexistent")   | let g:vikiMapInexistent = 1        | endif "{{{2
227 " Map these keys for g:vikiMapInexistent to LineQuick
228 if !exists("g:vikiMapKeys")         | let g:vikiMapKeys = "]).,;:!?\"' " | endif "{{{2
230 " Map these keys for g:vikiMapInexistent to ParagraphVisible
231 if !exists("g:vikiMapQParaKeys")    | let g:vikiMapQParaKeys = "\n"      | endif "{{{2
233 " Install hooks for these conditions (requires hookcursormoved to be 
234 " installed)
235 " "linechange" could cause some slowdown.
236 if !exists("g:vikiHCM") "{{{2
237     let g:vikiHCM = ['syntaxleave_oneline']
238 endif
240 " Check the viki name before inserting this character
241 if !exists("g:vikiMapBeforeKeys")   | let g:vikiMapBeforeKeys = ']'      | endif "{{{2
243 " Some functions a gathered in families/classes. See vikiLatex.vim for 
244 " an example.
245 if !exists("g:vikiFamily")          | let g:vikiFamily = ""              | endif "{{{2
247 " The directory separator
248 if !exists("g:vikiDirSeparator")    | let g:vikiDirSeparator = "/"       | endif "{{{2
250 " The version of Deplate markup
251 if !exists("g:vikiTextstylesVer")   | let g:vikiTextstylesVer = 2        | endif "{{{2
253 " if !exists("g:vikiBasicSyntax")     | let g:vikiBasicSyntax = 0          | endif "{{{2
254 " If non-nil, display headings of different levels in different colors
255 if !exists("g:vikiFancyHeadings")   | let g:vikiFancyHeadings = 0        | endif "{{{2
257 " Choose folding method version
258 if !exists("g:vikiFoldMethodVersion") | let g:vikiFoldMethodVersion = 4  | endif "{{{2
260 " What is considered for folding.
261 " This variable is only used if g:vikiFoldMethodVersion is 1.
262 if !exists("g:vikiFolds")           | let g:vikiFolds = 'hf'             | endif "{{{2
264 " Context lines for folds
265 if !exists("g:vikiFoldsContext") "{{{2
266     let g:vikiFoldsContext = [2, 2, 2, 2]
267 endif
269 " Consider fold levels bigger that this as text body, levels smaller 
270 " than this as headings
271 " This variable is only used if g:vikiFoldMethodVersion is 1.
272 if !exists("g:vikiFoldBodyLevel")   | let g:vikiFoldBodyLevel = 6        | endif "{{{2
274 " The default viki page (as absolute filename)
275 if !exists("g:vikiHomePage")        | let g:vikiHomePage = ''            | endif "{{{2
277 " The default filename for an interviki's index name
278 if !exists("g:vikiIndex")           | let g:vikiIndex = 'index'          | endif "{{{2
280 " How often the feedback is changed when marking inexisting links
281 if !exists("g:vikiFeedbackMin")     | let g:vikiFeedbackMin = &lines     | endif "{{{2
283 " The map leader for most viki key maps.
284 if !exists("g:vikiMapLeader")       | let g:vikiMapLeader = '<LocalLeader>v' | endif "{{{2
286 " If non-nil, anchors like #mX are turned into vim marks
287 if !exists("g:vikiAutoMarks")       | let g:vikiAutoMarks = 1            | endif "{{{2
289 " if !exists("g:vikiOpenInWindow")    | let g:vikiOpenInWindow = ''        | endif "{{{2
290 if !exists("g:vikiHighlightMath")   | let g:vikiHighlightMath = ''       | endif "{{{2
292 " If non-nil, cache back-links information
293 if !exists("g:vikiSaveHistory")     | let g:vikiSaveHistory = 0          | endif "{{{2
295 " The variable that keeps back-links information
296 if !exists("g:VIKIBACKREFS")        | let g:VIKIBACKREFS = {}            | endif "{{{2
298 " A list of files that contain special viki names
299 if v:version >= 700 && !exists("g:vikiHyperWordsFiles") "{{{2
300     let g:vikiHyperWordsFiles = [
301                 \ get(split(&rtp, ','), 0).'/vikiWords.txt',
302                 \ './.vikiWords',
303                 \ ]
304 endif
306 " Definition of intervikis. (This variable won't be evaluated until 
307 " autoload/viki.vim is loaded).
308 if !exists('g:viki_intervikis')
309     let g:viki_intervikis = {}   "{{{2
310 endif
312 " Define which keys to map
313 if !exists("g:vikiMapFunctionality") "{{{2
314     " b     ... go back
315     " c     ... follow link (c-cr)
316     " e     ... edit
317     " F     ... find
318     " f     ... follow link (<LocalLeader>v)
319     " i     ... check for inexistant destinations
320     " I     ... map keys in g:vikiMapKeys and g:vikiMapQParaKeys
321     " m[fb] ... map mouse (depends on f or b)
322     " p     ... edit parent (or backlink)
323     " q     ... quote
324     " tF    ... tab as find
325     " Files ... #Files related
326     " let g:vikiMapFunctionality      = 'mf mb tF c q e i I Files'
327     let g:vikiMapFunctionality      = 'ALL'
328 endif
329 " Define which keys to map in minor mode (invoked via :VikiMinorMode)
330 if !exists("g:vikiMapFunctionalityMinor") "{{{2
331     " let g:vikiMapFunctionalityMinor = 'f b p mf mb tF c q e i'
332     let g:vikiMapFunctionalityMinor = 'f b p mf mb tF c q e'
333 endif
336 " Special file handlers {{{1
337 if !exists('g:vikiOpenFileWith_ws') && exists(':WsOpen') "{{{2
338     function! VikiOpenAsWorkspace(file)
339         exec 'WsOpen '. escape(a:file, ' &!%')
340         exec 'lcd '. escape(fnamemodify(a:file, ':p:h'), ' &!%')
341     endf
342     let g:vikiOpenFileWith_ws = "call VikiOpenAsWorkspace('%{FILE}')"
343     call add(g:vikiSpecialFiles, 'ws')
344 endif
345 if type(g:vikiSpecialFiles) != 3
346     echoerr 'Viki: g:vikiSpecialFiles must be a list'
347 endif
348 " TAssert IsList(g:vikiSpecialFiles)
350 if !exists("g:vikiOpenFileWith_ANY") "{{{2
351     if exists('g:netrw_browsex_viewer')
352         let g:vikiOpenFileWith_ANY = "exec 'silent !'. g:netrw_browsex_viewer .' '. escape('%{FILE}', ' &!%')"
353     elseif has("win32") || has("win16") || has("win64")
354         let g:vikiOpenFileWith_ANY = "exec 'silent !cmd /c start '. escape('%{FILE}', ' &!%')"
355     elseif $GNOME_DESKTOP_SESSION_ID != ""
356         let g:vikiOpenFileWith_ANY = "exec 'silent !gnome-open '. escape('%{FILE}', ' &!%')"
357     elseif $KDEDIR != ""
358         let g:vikiOpenFileWith_ANY = "exec 'silent !kfmclient exec '. escape('%{FILE}', ' &!%')"
359     endif
360 endif
362 if !exists('*VikiOpenSpecialFile') "{{{2
363     function! VikiOpenSpecialFile(file) "{{{3
364         " let proto = tolower(matchstr(a:file, '\c\.\zs[a-z]\+$'))
365         let proto = tolower(fnamemodify(a:file, ':e'))
366         if exists('g:vikiOpenFileWith_'. proto)
367             let prot = g:vikiOpenFileWith_{proto}
368         elseif exists('g:vikiOpenFileWith_ANY')
369             let prot = g:vikiOpenFileWith_ANY
370         else
371             let prot = ''
372         endif
373         if prot != ''
374             let openFile = viki#SubstituteArgs(prot, 'FILE', a:file)
375             " TLogVAR openFile
376             call viki#ExecExternal(openFile)
377         else
378             throw 'Viki: Please define g:vikiOpenFileWith_'. proto .' or g:vikiOpenFileWith_ANY!'
379         endif
380     endf
381 endif
384 " Special protocol handlers {{{1
385 if !exists('g:vikiOpenUrlWith_mailbox') "{{{2
386     let g:vikiOpenUrlWith_mailbox="call VikiOpenMailbox('%{URL}')"
387     function! VikiOpenMailbox(url) "{{{3
388         exec viki#DecomposeUrl(strpart(a:url, 10))
389         let idx = matchstr(args, 'number=\zs\d\+$')
390         if filereadable(filename)
391             call viki#OpenLink(filename, '', 0, 'go '.idx)
392         else
393             throw 'Viki: Can't find mailbox url: '.filename
394         endif
395     endf
396 endif
398 " Possible values: special*, query, normal
399 if !exists("g:vikiUrlFileAs") | let g:vikiUrlFileAs = 'special' | endif "{{{2
401 if !exists("g:vikiOpenUrlWith_file") "{{{2
402     let g:vikiOpenUrlWith_file="call VikiOpenFileUrl('%{URL}')"
403     function! VikiOpenFileUrl(url) "{{{3
404         if viki#IsSpecialFile(a:url)
405             if g:vikiUrlFileAs == 'special'
406                 let as_special = 1
407             elseif g:vikiUrlFileAs == 'query'
408                 echo a:url
409                 let as_special = input('Treat URL as special file? (Y/n) ')
410                 let as_special = (as_special[0] !=? 'n')
411             else
412                 let as_special = 0
413             endif
414             if as_special
415                 call VikiOpenSpecialFile(a:url)
416                 return
417             endif
418         endif
419         exec viki#DecomposeUrl(strpart(a:url, 7))
420         if filereadable(filename)
421             call viki#OpenLink(filename, anchor)
422         else
423             throw 'Viki: Can't find file url: '.filename
424         endif
425     endf
426 endif
428 if !exists("g:vikiOpenUrlWith_ANY") "{{{2
429     " let g:vikiOpenUrlWith_ANY = "exec 'silent !". g:netrw_browsex_viewer ." '. escape('%{URL}', ' &!%')"
430     if has("win32")
431         let g:vikiOpenUrlWith_ANY = "exec 'silent !rundll32 url.dll,FileProtocolHandler '. escape('%{URL}', ' !&%')"
432     elseif $GNOME_DESKTOP_SESSION_ID != ""
433         let g:vikiOpenUrlWith_ANY = "exec 'silent !gnome-open '. escape('%{URL}', ' !&%')"
434     elseif $KDEDIR != ""
435         let g:vikiOpenUrlWith_ANY = "exec 'silent !kfmclient exec '. escape('%{URL}', ' !&%')"
436     endif
437 endif
439 if !exists("*VikiOpenSpecialProtocol") "{{{2
440     function! VikiOpenSpecialProtocol(url) "{{{3
441         let proto = tolower(matchstr(a:url, '\c^[a-z]\{-}\ze:'))
442         let prot  = 'g:vikiOpenUrlWith_'. proto
443         let protp = exists(prot)
444         if !protp
445             let prot  = 'g:vikiOpenUrlWith_ANY'
446             let protp = exists(prot)
447         endif
448         if protp
449             exec 'let openURL = '. prot
450             let openURL = viki#SubstituteArgs(openURL, 'URL', a:url)
451             " TLogVAR openURL
452             call viki#ExecExternal(openURL)
453         else
454             throw 'Viki: Please define g:vikiOpenUrlWith_'. proto .' or g:vikiOpenUrlWith_ANY!'
455         endif
456     endf
457 endif
460 " This is mostly a legacy function. Using set ft=viki should work too.
461 " Set filetype=viki
462 function! VikiMode(...) "{{{3
463     TVarArg 'family'
464     " if exists('b:vikiEnabled')
465     "     if b:vikiEnabled
466     "         return 0
467     "     endif
468     "     " if b:vikiEnabled && a:state < 0
469     "     "     return 0
470     "     " endif
471     "     " echom "VIKI: Viki mode already set."
472     " endif
473     unlet! b:did_ftplugin
474     if !empty(family)
475         let b:vikiFamily = family
476     endif
477     set filetype=viki
478 endf
481 if g:vikiMenuPrefix != '' "{{{2
482     exec 'amenu '. g:vikiMenuPrefix .'Home :VikiHome<cr>'
483     exec 'amenu '. g:vikiMenuPrefix .'-SepViki1- :'
484 endif
487 command! -nargs=+ VikiDefine call viki#Define(<f-args>)
488 command! -count VikiFindNext call viki#DispatchOnFamily('Find', '', '',  <count>)
489 command! -count VikiFindPrev call viki#DispatchOnFamily('Find', '', 'b', <count>)
491 " command! -nargs=* -range=% VikiMarkInexistent
492 "             \ call VikiSaveCursorPosition()
493 "             \ | call <SID>VikiMarkInexistent(<line1>, <line2>, <f-args>)
494 "             \ | call VikiRestoreCursorPosition()
495 "             \ | call <SID>ResetSavedCursorPosition()
496 command! -nargs=* -range=% VikiMarkInexistent call viki#MarkInexistentInRange(<line1>, <line2>)
498 command! -nargs=? -bar VikiMinorMode call viki#DispatchOnFamily('MinorMode', empty(<q-args>) && exists('b:vikiFamily') ? b:vikiFamily : <q-args>, 1)
499 command! -nargs=? -bar VikiMinorModeMaybe echom "Deprecated command: VikiMinorModeMaybe" | VikiMinorMode <q-args>
500 command! VikiMinorModeViki call viki_viki#MinorMode(1)
501 command! VikiMinorModeLaTeX call viki_latex#MinorMode(1)
502 command! VikiMinorModeAnyWord call viki_anyword#MinorMode(1)
504 " this requires imaps to be installed
505 command! -range VikiQuote :call VEnclose("[-", "-]", "[-", "-]")
507 command! -nargs=? -bar VikiMode call VikiMode(<q-args>)
508 command! -nargs=? -bar VikiModeMaybe echom "Deprecated command: VikiModeMaybe: Please use 'set ft=viki' instead" | call VikiMode(<q-args>)
510 command! -narg=? VikiGoBack call viki#GoBack(<f-args>)
512 command! VikiJump call viki#MaybeFollowLink(0,1)
514 command! VikiIndex :call viki#Index()
516 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEdit :call viki#Edit(<q-args>, "<bang>")
517 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInVim :call viki#Edit(<q-args>, "<bang>", 0, 1)
518 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditTab :call viki#Edit(<q-args>, "<bang>", 'tab')
519 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin1 :call viki#Edit(<q-args>, "<bang>", 1)
520 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin2 :call viki#Edit(<q-args>, "<bang>", 2)
521 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin3 :call viki#Edit(<q-args>, "<bang>", 3)
522 command! -nargs=1 -bang -complete=customlist,viki#EditComplete VikiEditInWin4 :call viki#Edit(<q-args>, "<bang>", 4)
524 command! -nargs=1 -complete=customlist,viki#BrowseComplete VikiBrowse :call viki#Browse(<q-args>)
526 command! VikiHome :call viki#Edit('*', '!')
527 command! VIKI :call viki#Edit('*', '!')
529 command! VikiFilesUpdate call viki#FilesUpdate()
530 command! VikiFilesUpdateAll call viki#FilesUpdateAll()
532 command! -nargs=* -bang -complete=command VikiFileExec call viki#FilesExec(<q-args>, '<bang>', 1)
533 command! -nargs=* -bang -complete=command VikiFilesExec call viki#FilesExec(<q-args>, '<bang>')
534 command! -nargs=* -bang VikiFilesCmd call viki#FilesCmd(<q-args>, '<bang>')
535 command! -nargs=* -bang VikiFilesCall call viki#FilesCall(<q-args>, '<bang>')
538 augroup viki
539     au!
540     autocmd BufEnter * call viki#MinorModeReset()
541     autocmd BufEnter * call viki#CheckInexistent()
542     autocmd BufLeave * if &filetype == 'viki' | let b:vikiCheckInexistent = line(".") | endif
543     autocmd BufWritePost,BufUnload * if &filetype == 'viki' | call viki#SaveCache() | endif
544     autocmd VimLeavePre * let g:vikiEnabled = 0
545     if g:vikiSaveHistory
546         autocmd VimEnter * if exists('VIKIBACKREFS_STRING') | exec 'let g:VIKIBACKREFS = '. VIKIBACKREFS_STRING | unlet VIKIBACKREFS_STRING | endif
547         autocmd VimLeavePre * let VIKIBACKREFS_STRING = string(g:VIKIBACKREFS)
548     endif
549     " As viki uses its own styles, we have to reset &filetype.
550     autocmd ColorScheme * if &filetype == 'viki' | set filetype=viki | endif
551 augroup END
554 finish "{{{1
555 ______________________________________________________________________________
557 * Change Log
559 - Extended names: For compatibility reasons with other wikis, the anchor is 
560 now in the reference part.
561 - For compatibility reasons with other wikis, prepending an anchor with 
562 b:commentStart is optional.
563 - g:vikiUseParentSuffix
564 - Renamed variables & functions (basically s/Wiki/Viki/g)
565 - added a ftplugin stub, moved the description to a help file
566 - "[--]" is reference to current file
567 - Folding support (at section level)
568 - Intervikis
569 - More highlighting
570 - g:vikiFamily, b:vikiFamily
571 - VikiGoBack() (persistent history data)
572 - rudimentary LaTeX support ("soft" viki names)
575 - g:vikiExplorer (for viewing directories)
576 - preliminary support for "soft" anchors (b:vikiAnchorRx)
577 - improved VikiOpenSpecialProtocol(url); g:vikiOpenUrlWith_{PROTOCOL}, 
578 g:vikiOpenUrlWith_ANY
579 - improved VikiOpenSpecialFile(file); g:vikiOpenFileWith_{SUFFIX}, 
580 g:vikiOpenFileWith_ANY
581 - anchors may contain upper characters (but must begin with a lower char)
582 - some support for Mozilla ThunderBird mailbox-URLs (this requires spaces to 
583 be encoded as %20)
584 - changed g:vikiDefSep to '‡‡‡'
587 - syntax file: fix nested regexp problem
588 - deplate: conversion to html/latex; download from 
589 http://sourceforge.net/projects/deplate/
590 - made syntax a little bit more restrictive (*WORD* now matches /\*\w+\*/ 
591 instead of /\*\S+\*/)
592 - interviki definitions can now be buffer local variables, too
593 - fixed <SID>DecodeFileUrl(dest)
594 - some kind of compiler plugin (uses deplate)
595 - removed g/b:vikiMarkupEndsWithNewline variable
596 - saved all files in unix format (thanks to Grant Bowman for the hint)
597 - removed international characters from g:vikiLowerCharacters and 
598 g:vikiUpperCharacters because of difficulties with different encodings (thanks 
599 to Grant Bowman for pointing out this problem); non-english-speaking users have 
600 to set these variables in their vimrc file
603 - basic ctags support (see |viki-tags|)
604 - mini-ftplugin for bibtex files (use record labels as anchors)
605 - added mapping <LocalLeader><c-cr>: follow link in other window (if any)
606 - disabled the highlighting of italic char styles (i.e., /text/)
607 - the ftplugin doesn't set deplate as the compiler; renamed the compiler plugin to deplate
608 - syntax: sync minlines=50
609 - fix: VikiFoldLevel()
611 1.3.1
612 - fixed bug when VikiBack was called without a definitiv back-reference
613 - fixed problems with latin-1 characters
616 - fixed problem with table highlighting that could cause vim to hang
617 - it is now possible to selectivly disable simple or quoted viki names
618 - indent plugin
621 - distinguish between links to existing and non-existing files
622 - added key bindings <LL>vs (split) and <LL>vv (split vertically)
623 - added key bindings <LL>v1 through to <LL>v4: open the viki link under cursor 
624 in the windows 1 to 4
625 - handle variables g:vikiSplit, b:vikiSplit
626 - don't indent regions
627 - regions can be indented
628 - When a file doesn't exist, ESC or "n" aborts creation
630 1.5.1
631 - depends on multvals >= 3.8.0
632 - new viki family "AnyWord" (see |viki-any-word|), which turns any word into a 
633 potential viki link
634 - <LocalLeader>vq, VikiQuote: mark selected text as a quoted viki name 
635 (requires imaps.vim, vimscript #244 or vimscript #475)
636 - check for null links when pressing <space>, <cr>, ], and some other keys 
637 (defined in g:vikiMapKeys)
638 - a global suffix for viki files can be defined by g:vikiNameSuffix
639 - fix syntax problem when checking for links to inexistent files
641 1.5.2
642 - changed default markup of textstyles: __emphasize__, ''code''; the 
643 previous markup can be re-enabled by setting g:vikiTextstylesVer to 1)
644 - fixed problem with VikiQuote
645 - on follow link check for yet unsaved buffers too
648 - b:vikiInverseFold: Inverse folding of subsections
649 - support for some regions/commands/macros: #INC/#INCLUDE, #IMG, #Img 
650 (requires an id to be defined), {img}
651 - g:vikiFreeMarker: Search for the plain anchor text if no explicitly marked 
652 anchor could be found.
653 - new command: VikiEdit NAME ... allows editing of arbitrary viki names (also 
654 understands extended and interviki formats)
655 - setting the b:vikiNoSimpleNames to true prevents viki from recognizing 
656 simple viki names
657 - made some script local functions global so that it should be easier to 
658 integrate viki with other plugins
659 - fixed moving cursor on <SID>VikiMarkInexistent()
660 - fixed typo in b:VikiEnabled, which should be b:vikiEnabled (thanks to Ned 
661 Konz)
663 1.6.1
664 - removed forgotten debug message
665 - fixed indentation bug
667 1.6.2
668 - b:vikiDisableType
669 - Put AnyWord-related stuff into a file of its own.
670 - indentation for notices (!!!, ??? etc.)
672 1.6.3
673 - When creating a new file by following a link, the desired window number was 
674 ignored
675 - (VikiOpenSpecialFile) Escape blanks in the filename
676 - Set &include and &define (ftplugin)
677 - Set g:vikiFolds to '' to avoid using Headings for folds (which may cause a 
678 major slowdown on slower machines)
679 - renamed <SID>DecodeFileUrl(dest) to VikiDecomposeUrl()
680 - fixed problem with table highlighting
681 - file type URLs (file://) are now treated like special files
682 - indent: if g:vikiIndentDesc is '::', align a definition's description to the 
683 first non-blank position after the '::' separator
686 - g:vikiHomePage: If you call VikiEdit! (with "bang"), the homepage is opened 
687 first so that its customizations are in effect. Also, if you call :VikiHome or 
688 :VikiEdit *, the homepage is opened.
689 - basic highlighting & indentation of emacs-planner style task lists (sort of)
690 - command line completion for :VikiEdit
691 - new command/function VikiDefine for defining intervikis
692 - added <LocalLeader>ve map for :VikiEdit
693 - fixed problem in VikiEdit (when the cursor was on a valid viki link, the 
694 text argument was ignored)
695 - fixed opening special files/urls in a designated window
696 - fixed highlighting of comments
697 - vikiLowerCharacters and vikiUpperCharacters can be buffer local
698 - fixed problem when an url contained an ampersand
699 - fixed error message when the &hidden option wasn't set (see g:vikiHide)
702 - Fold lists too (see also g:vikiFolds)
703 - Allow interviki names in extended viki names (e.g., 
704 [[WIKI::WikiName][Display Name]])
705 - Renamed <SID>GetSimpleRx4SimpleWikiName() to 
706 VikiGetSimpleRx4SimpleWikiName() (required in some occasions; increased the 
707 version number so that we can check against it)
708 - Fix: Problem with urls/fnames containing '!' and other special characters 
709 (which now have to be escaped by the handler; so if you defined a custom 
710 handler, e.g. g:vikiOpenFileWith_ANY, please adapt its definition)
711 - Fix: VikiEdit! opens the homepage only when b:vikiEnabled is defined in the 
712 current buffer (we assume that for the homepage the global configuration is in 
713 effect)
714 - Fix: Problem when g:vikiMarkInexistent was false/0
715 - Fix: Removed \c from the regular expression for extended names, which caused 
716 FindNext to malfunction and caused a serious slowdown when matching of 
717 bad/unknown links
718 - Fix: Re-set viki minor mode after entering a buffer
719 - The state argument in Viki(Minor)Mode is now mostly ignored
720 - Fix: A simple name's anchor was ignored
723 - Register mp3, ogg and some other multimedia related suffixes as 
724 special files
725 - Add a menu of Intervikis if g:vikiMenuPrefix is != ''
726 - g:vikiMapKeys can contain "\n" and " " (supplement g:vikiMapKeys with 
727 the variables g:vikiMapQParaKeys and g:vikiMapBeforeKeys)
728 - FIX: <SID>IsSupportedType
729 - FIX: Only the first inexistent link in a line was highlighted
730 - FIX: Set &buflisted when editing an existing buffer
731 - FIX: VikiDefine: Non-viki index names weren't quoted
732 - FIX: In "minor mode", vikiFamily wasn't correctly set in some 
733 situations; other problems related to b:vikiFamily
734 - FIX: AnyWord works again
735 - Removed: VikiMinorModeMaybe
736 - VikiDefine now takes an optional fourth argument (an index file; 
737 default=Index) and automatically creates a vim command with the name of 
738 the interviki that opens this index file
740 1.10
741 - Pseudo anchors (not supported by deplate):
742 -- Jump to a line number, e.g. [[file#l=10]] or [[file#line=10]]
743 -- Find an regexp, e.g. [[file#rx=\\d]]
744 -- Execute some vim code, e.g. [[file#vim=call Whatever()]]
745 -- You can define your own handlers: VikiAnchor_{type}(arg)
746 - g:vikiFolds: new 'b' flag: the body has a higher level than all 
747 headings (gives you some kind of outliner experience; the default value 
748 for g:vikiFolds was changed to 'h')
749 - FIX: VikiFindAnchor didn't work properly in some situations
750 - FIX: Escape blanks when following a link (this could cause problems in 
751 some situations, not always)
752 - FIX: Don't try to mark inexistent links when pressing enter if the current 
753 line is empty.
754 - FIX: Restore vertical cursor position in window after looking for 
755 inexistent links.
756 - FIX: Backslashes got lost in some situations.
758 1.11
759 - Enable [[INTERVIKI::]]
760 - VikiEdit also creates commands for intervikis that have no index
761 - Respect "!" and "*" modifiers in extended viki links
762 - New g:vikiMapFunctionalityMinor variable
763 - New g:vikiMapLeader variable
764 - CHANGE: Don't map VikiMarkInexistent in minor mode (see 
765 g:vikiMapFunctionalityMinor)
766 - CHANGE: new attributes for g:vikiMapFunctionality: c, m[fb], i, I
767 - SYNTAX: cterm support for todo lists, emphasize
768 - FIX: Erroneous cursor movement
769 - FIX: VikiEdit didn't check if a file was already opened, which caused 
770 a file to be opened in two buffers under certain conditions
771 - FIX: Error in <SID>MapMarkInexistent()
772 - FIX: VikiEdit: Non-viki names were not quoted
773 - FIX: Use fnamemodify() to expand tildes in filenames
774 - FIX: Inexistent quoted viki names with an interviki prefix weren't 
775 properly highlighted
776 - FIX: Minor problem with suffixes & extended viki names
777 - FIX: Use keepjumps
778 - FIX: Catch E325
779 - FIX: Don't catch errors in <SID>EditWrapper() if the command matches 
780 g:vikiNoWrapper (due to possible compatibility problems eg with :Explore 
781 in vim 6.4)
782 - OBSOLETE: Negative arguments to VikiMode or VikiMinorMode are obsolete 
783 (or they became the default to be precise)
784 - OBSOLETE: g:vikiMapMouse
785 - REMOVED: mapping to <LocalLeader><c-cr>
786 - DEPRECATED: VikiModeMaybe
788 1.12
789 - Define some keywords in syntax file (useful for omnicompletion)
790 - Define :VIKI command as an alias for :VikiHome
791 - FIX: Problem with names containing spaces
792 - FIX: Extended names with suffix & interviki
793 - FIX: Indentation of priority lists.
794 - FIX: VikiDefine created wrong (old-fashioned) VikiEdit commands under 
795 certain conditions.
796 - FIX: Directories in extended viki names + interviki names were marked 
797 as inexistent
798 - FIX: Syntax highlighting of regions or commands the headline of which 
799 spanned several lines
800 - Added ppt to g:vikiSpecialFiles.
802 1.13
803 - Intervikis can now be defined as function ('*Function("%s")', this 
804 breaks conversion via deplate) or format string ('%/foo/%s/bar', not yet 
805 supported by deplate)
806 - Task lists take optional tags, eg #A [tag] foo; they may also be 
807 tagged with the letters G-Z, which are highlighted as general task (not 
808 supported by deplate)
809 - Automatically set marks for labels prefixed with "m" (eg #ma -> 'a, 
810 #mB -> 'B)
811 - Two new g:vikiNameTypes: w = (Hyper)Words, f = File names in cwd as 
812 hyperwords (experimental, not implemented in deplate)
813 - In extended viki names: add the suffix only if the destination hasn't 
814 got one
815 - A buffer local b:vikiOpenInWindow allows links to be redirected to a 
816 certain window (ie, if b:vikiOpenInWindow = 2, pressing <c-cr> behaves 
817 like <LocalLeader>v2); this is useful if you use some kind of 
818 directory/catalog metafile; possible values: absolute number, +/- 
819 relative number, "last"
820 - Switched back to old regexp for simple names in order to avoid 
821 highlighting of names like LaTeX
822 - VikiEdit opens the homepage only if b:vikiFamily is set
823 - Map <LocalLeader>vF to <LocalLeader>vn<LocalLeader>vf
824 - Improved syntax for (nested) macros
825 - Set &suffixesadd so that you can use vim's own gf in some situations
826 - SYNTAX: Allow empty lines as region delimiters (deplate 0.8.1)
827 - FIX: simple viki names with anchors where not recognised
828 - FIX: don't mark simple (inter)viki names as inexistent that expand to 
829 links matching g:vikiSpecialProtocols
830 - FIX: file names containing %
831 - FIX: added a patch (VikiMarkInexistentInElement) by Kevin Kleinfelter 
832 for compatibility with an unpatched vim70 (untested)
833 - FIX: disabling simple names (s) also properly disables the name types: 
834 Scwf
837 - Got rid of multvals & genutils dependencies (use vim7 lists instead)
838 - New dependency: tlib.vim (vimscript #1863)
839 - INCOMPATIBLE CHANGE: The format of g:vikiMapFunctionality has changed.
840 - INCOMPATIBLE CHANGE: g:vikiSpecialFiles is now a list!
841 - Viki now has a special #Files region that can be automatically 
842 updated. This way we can start thinking about using viki for as 
843 project/file management tool. This is for vim only and not supported yet 
844 in deplate. New related maps & commands: :VikiFilesUpdate (<LL>vu), 
845 :VikiFilesUpdateAll (<LL>vU), :VikiFilesCmd, :VikiFilesCall, 
846 :VikiFilesExec (<LL>vx), and VikiFileExec.
847 - VikiGoParent() (mapped to <LL>v<bs> or <LL>v<up>): If b:vikiParent is 
848 defined, open this viki name, otherwise follow the backlink.
849 - New :VikiEditTab command.
850 - Map <LL>vt to open in tab.
851 - Map <LL>v<left> to open go back.
852 - Keys listed in g:vikiMapQParaKeys are now mapped to 
853 s:VikiMarkInexistentInParagraphVisible() which checks only the visible 
854 area and thus avoids scrolling.
855 - Highlight lines containing blanks (which vim doesn't treat as 
856 paragraph separators)
857 - When following a link, check if it is an special viki name before 
858 assuming it's a simple one.
859 - Map [[, ]], [], ][
860 - If an interviki has an index file, a viki name like [[INTERVIKI::]] 
861 will now open the index file. In order to browse the directory, use 
862 [[INTERVIKI::.]]. If no index file is defined, the directory will be 
863 opened either way.
864 - Set the default value of g:vikiFeedbackMin to &lines.
865 - Added ws as special files to be opened with :WsOpen if existent.
866 - Replaced most occurences of <SID> with s:
867 - Use tlib#input#List() for selecting back references.
868 - g:vikiOpenFileWith_ANY now uses g:netrw_browsex_viewer by default.
869 - CHANGE: g:vikiSaveHistory: We now rely on viminfo's "!" option to save 
870 back-references.
871 - FIX: VikiEdit now works properly with protocols that are to be opened 
872 with an external viewer
873 - FIX: VikiEdit completion, which is more usable now
876 - Cache inexistent patterns (experimental)
877 - s:EditWrapper: Don't escape ' '.
878 - FIX: VikiMode(): Error message about b:did_ftplugin not being defined
879 - FIX: Check if g:netrw_browsex_viewer is defined (thanks to Erik Olsson 
880 for pointing this and some other problems out)
881 - ftplugin/viki.vim: FIX: Problem with heading in the last line.  
882 Disabled vikiFolds type 's' (until I find out what this was about)
883 - Always check the current line for inexistent links when re-entering a 
884 viki buffer
887 - Re-Enabled the previously (2.1) made and then disabled change 
888 concerning re-entering a viki buffer
889 - Don't try to use cached values for buffers that have no file attached 
890 yet (thanks to Erik Olsson)
891 - Require tlib >= 0.8
894 - Require tlib >= 0.9
895 - FIX: Use absolute file names when editing a local file (avoid problem 
896 when opening a file in a different window with a different CWD).
897 - New folding routine. Use the old folding method by setting 
898 g:vikiFoldMethodVersion to 1.
901 - The shortcuts automatically defined by VikiDefine may now take an 
902 optional argument (the file on an interviki) (:WIKI thus is the same as 
903 :VikiEdit WIKI:: and supports the same command-line completion)
904 - Read ".vikiWords" in parent directories (top-down); 
905 g:vikiHyperWordsFiles: Changed order (read global words first)
906 - In .vikiWords: destination can be an interviki name (if not, it is 
907 assumed to be a relative filename); if destination is -, the word will 
908 be removed from the jump table; blanks in "hyperwords" will be replaced 
909 with \s\+ in the regular expression.
910 - New :VikiBrowse command.
911 - FIX: wrong value for &comments
912 - FIX: need to reset filetype on color-scheme change (because of viki's 
913 own styles)
914 - FIX: Caching of inexistent viki names.
915 - In minor mode, don't map keys that trigger a check for inexistent 
916 links.
917 - Don't highlight textstyles (emphasized, typewriter) in comments.
918 - Removed configuration by: VikiInexistentColor(), 
919 g:vikiInexistentColor, VikiHyperLinkColor(), g:vikiHyperLinkColor; use 
920 g:viki_highlight_hyperlink_light, g:viki_highlight_hyperlink_dark, 
921 g:viki_highlight_inexistent_light, g:viki_highlight_inexistent_dark 
922 instead. By default, links are no longer made bold.
923 - The new default fold expression (g:vikiFoldMethodVersion=4) support 
924 only hH folds (normal and inverse headings based; see g:vikiFolds). 
925 Previous fold methods can be used by setting g:vikiFoldMethodVersion.
928 - VikiFolds() rev4: The text body is set to max heading level + 1 in 
929 order to avoid lookups and thus speed-up the code.
930 - g:vikiPromote: Don't set viki minor modes for any files opened via 
931 viki, unless this variable is set
932 - Added support for 'l' vikiFolds to the default fold expression.
933 - Added support for the {ref} macro (the referenced label has to be in 
934 the same file though)
935 - INCOMPATIBLE CHANGE: Moved most function to autoload/viki.vim; moved 
936 support for deplate/viki markup to vikiDeplate.vim.
937 - The argument of the VikiMode() has changed. (But this function 
938 shouldn't be used anyway.)
939 - With g:vikiFoldMethodVersion=4 (the default), the text body is at the 
940 level of the heading. This uses "=" for the body, which can be a problem 
941 on slow machines. With g:vikiFoldMethodVersion=5, the body is below the 
942 lowest heading, which can cause other problem.
943 - :VikiEditInVim ... edit special files in vim
944 - Set the default value for g:vikiCacheInexistent in order not to 
945 surprise users with the abundance of cached data.
946 - Require tlib 0.15
947 - Use tlib#progressbar
948 - Improved (poor-man's) tex/math syntax highlighting
949 - Removed norm! commands form s:MarkInexistent().
950 - FIX: Wrong value for b:vikiSimpleNameAnchorIdx when simple viki names 
951 weren't disabled.
952 - Optionally use hookcursormoved for improved detection of hyperlinks to 
953 inexistent sources. If this plugin causes difficulties, please tell me 
954 and temporarily remove it.
955 - Use matchlist() instead of substitute(), which could speed things up a 
956 little.
959 - Slightly improved performance of s:MarkInexistent() and 
960 viki#HookCheckPreviousPosition().
963 - viki_viki.vim: Wrong value for b:vikiCmdDestIdx and 
964 b:vikiCmdAnchorIdx.
965 - Moved :VikiMinorModeViki, :VikiMinorModeLaTeX, and 
966 :VikiMinorModeAnyWord to plugin/viki.vim
969 - Use hookcursormoved >= 0.3
970 - Backslash-save command-line completion
971 - Mark unknown intervikis as inexistent
974 - Promote anchors to VikiOpenSpecialProtocol().
975 - viki_viki: Enabled #INCLUDE
976 - Put the poor-man's math highlighting into syntax/texmath.vim so that 
977 it can be included from other syntax files.
978 - Cascade menu of intervikis
979 - FIX: don't register viki names as known/unknown more than once
982 - Don't try to append an empty anchor to an url (Thanks RM Schmid).
983 - New variable g:viki_intervikis to define intervikis in ~/.vimrc.
984 - Minor updates to the help file.
987 - Forgot to define a default value for g:viki_intervikis.
990 - In a file that doesn't contain headings, return 0 instead of '=' as 
991 default value if g:vikiFoldMethodVersion == 4.
992 - FIX: "=" in if expressions in certain versions of VikiFoldLevel()
995 - FIX: viki#MarkInexistentInElement() for pre 7.0.009 vim (thanks to M 
996 Brandmeyer)
997 - FIX: Make sure tlib is loaded even if it is installed in a different 
998 rtp-directory (thanks to M Brandmeyer)
999 - Added dia to g:vikiSpecialFiles
1000 - FIX: Scrambled window when opening an url from vim (thanks A Moell)
1003 " vim: ff=unix