2 " @Author: Thomas Link (mailto:samul@web.de?subject=vim-vikiAnyWord)
3 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
4 " @Created: 04-Apr-2005.
5 " @Last Change: 16-Feb-2006.
8 if &cp || exists("loaded_vikianyword")
11 let loaded_vikianyword = 1
14 fun! VikiMinorModeAnyWord (state) "{{{3
15 let b:vikiFamily = 'AnyWord'
16 call VikiMinorMode(a:state)
18 command! VikiMinorModeAnyWord call VikiMinorModeAnyWord(1)
19 command! VikiMinorModeMaybeAnyWord call VikiMinorModeAnyWord(-1)
21 fun! VikiSetupBufferAnyWord(state, ...) "{{{3
22 echom "DBG VikiSetupBufferAnyWord"
23 let dontSetup = a:0 > 0 ? a:1 : ''
24 call VikiSetupBuffer(a:state, dontSetup)
25 if b:vikiNameTypes =~? "s" && !(dontSetup =~? "s")
26 if b:vikiNameTypes =~# "S" && !(dontSetup =~# "S")
27 let simpleWikiName = b:vikiSimpleNameQuoteBeg
28 \ .'['. b:vikiSimpleNameQuoteChars .']'
29 \ .'\{-}'. b:vikiSimpleNameQuoteEnd
31 let simpleWikiName = ""
33 if b:vikiNameTypes =~# "s" && !(dontSetup =~# "s")
34 let simple = '\<['. g:vikiUpperCharacters .']['. g:vikiLowerCharacters
35 \ .']\+\(['. g:vikiUpperCharacters.']['.g:vikiLowerCharacters
37 if simpleWikiName != ""
38 let simpleWikiName = simpleWikiName .'\|'. simple
40 let simpleWikiName = simple
43 let anyword = '\<['. b:vikiSimpleNameQuoteChars .' ]\+\>'
44 if simpleWikiName != ""
45 let simpleWikiName = simpleWikiName .'\|'. anyword
47 let simpleWikiName = anyword
49 let b:vikiSimpleNameRx = '\C\(\(\<['. g:vikiUpperCharacters .']\+::\)\?'
50 \ .'\('. simpleWikiName .'\)\)'
51 \ .'\(#\('. b:vikiAnchorNameRx .'\)\>\)\?'
52 let b:vikiSimpleNameSimpleRx = '\C\(\<['.g:vikiUpperCharacters.']\+::\)\?'
53 \ .'\('. simpleWikiName .'\)'
54 \ .'\(#'. b:vikiAnchorNameRx .'\>\)\?'
55 let b:vikiSimpleNameNameIdx = 1
56 let b:vikiSimpleNameDestIdx = 0
57 let b:vikiSimpleNameAnchorIdx = 6
58 let b:vikiSimpleNameCompound = 'let erx="'. escape(b:vikiSimpleNameRx, '\"')
59 \ .'" | let nameIdx='. b:vikiSimpleNameNameIdx
60 \ .' | let destIdx='. b:vikiSimpleNameDestIdx
61 \ .' | let anchorIdx='. b:vikiSimpleNameAnchorIdx
63 let b:vikiInexistentHighlight = "vikiAnyWordInexistentLink"
64 let b:vikiMarkInexistent = 2
67 fun! VikiDefineMarkupAnyWord(state) "{{{3
68 if b:vikiNameTypes =~? "s" && b:vikiSimpleNameRx != ""
69 exe "syn match vikiRevLink /" . b:vikiSimpleNameRx . "/"
71 if b:vikiNameTypes =~# "e" && b:vikiExtendedNameRx != ""
72 exe "syn match vikiRevExtendedLink '" . b:vikiExtendedNameRx . "'"
74 if b:vikiNameTypes =~# "u" && b:vikiUrlRx != ""
75 exe "syn match vikiURL /" . b:vikiUrlRx . "/"
79 fun! VikiDefineHighlightingAnyWord(state, ...) "{{{3
80 let dontSetup = a:0 > 0 ? a:1 : ''
81 call VikiDefineHighlighting(a:state)
83 command! -nargs=+ VikiHiLink hi link <args>
85 command! -nargs=+ VikiHiLink hi def link <args>
87 exec 'VikiHiLink '. b:vikiInexistentHighlight .' Normal'
91 fun! VikiFindAnyWord(flag, ...) "{{{3
92 let rx = VikiRxFromCollection(b:vikiNamesOk)
93 let i = a:0 >= 1 ? a:1 : 0
94 call VikiFind(a:flag, i, rx)