mirror of
https://github.com/gryf/.vim.git
synced 2025-12-17 19:40:29 +01:00
Commented changes in plugins, updated vimwiki, repaired zoom plugin, added
buffergator, updated pythonhelper, removed leftovers
This commit is contained in:
5
.vimrc
5
.vimrc
@@ -168,6 +168,11 @@ autocmd ColorScheme * call <SID>CustomHighlightings()
|
|||||||
"}}}
|
"}}}
|
||||||
" DirDiff{{{
|
" DirDiff{{{
|
||||||
let g:DirDiffExcludes = "CVS,*.class,*.exe,.*.swp,*.pyc,*.pyo"
|
let g:DirDiffExcludes = "CVS,*.class,*.exe,.*.swp,*.pyc,*.pyo"
|
||||||
|
" Make use of cursor keys
|
||||||
|
nmap <M-Up> [c
|
||||||
|
nmap <M-Down> ]c
|
||||||
|
nmap <C-Up> \dk
|
||||||
|
nmap <C-Down> \d
|
||||||
" }}}
|
" }}}
|
||||||
"}}}
|
"}}}
|
||||||
"KEYS: User definied keyboard shortcuts {{{
|
"KEYS: User definied keyboard shortcuts {{{
|
||||||
|
|||||||
@@ -1,43 +1,41 @@
|
|||||||
ScriptID SourceID Filename
|
ScriptID SourceID Filename
|
||||||
--------------------------
|
--------------------------
|
||||||
### plugins
|
### plugins
|
||||||
|
3619 15858 buffergator
|
||||||
102 13435 DirDiff.vim
|
102 13435 DirDiff.vim
|
||||||
#2754 13139 :AutoInstall: delimitMate.vim
|
1984 13961 :AutoInstall: FuzzyFinder
|
||||||
1984 13961 fuzzyfinder.vim
|
|
||||||
311 7645 grep.vim
|
311 7645 grep.vim
|
||||||
3304 15744 gundo.vim
|
3304 15744 gundo.vim
|
||||||
2727 11120 jsbeautify.vim
|
2727 11120 jsbeautify.vim
|
||||||
|
3252 13948 :AutoInstall: L9
|
||||||
|
2289 8922 loremipsum
|
||||||
2666 15663 Mark
|
2666 15663 Mark
|
||||||
2262 8944 occur.vim
|
2262 8944 occur.vim
|
||||||
910 14691 pydoc.vim
|
2136 8206 repeat.vim
|
||||||
#2421 9423 pysmell.vim
|
|
||||||
152 3342 showmarks.vim
|
152 3342 showmarks.vim
|
||||||
2540 11006 snipMate.vim
|
2540 11006 snipMate.vim
|
||||||
1697 12566 :AutoInstall: surround.vim
|
1697 12566 :AutoInstall: surround.vim
|
||||||
#273 7701 taglist.vim # exchanged with taglisttoo
|
|
||||||
#and taglisttoo was exchanged by tagbar
|
|
||||||
3465 15751 Tagbar
|
3465 15751 Tagbar
|
||||||
90 15797 vcscommand.vim
|
90 15797 vcscommand.vim
|
||||||
2226 13756 vimwiki.vim
|
2226 15854 vimwiki.vim
|
||||||
2289 0 loremipsum.vim
|
|
||||||
1334 6377 vst.vim
|
1334 6377 vst.vim
|
||||||
1984 13961 :AutoInstall: FuzzyFinder
|
2321 9055 zoom.vim
|
||||||
3252 13948 :AutoInstall: L9
|
|
||||||
### colors
|
### colors
|
||||||
2855 12456 github.vim
|
2855 12456 github.vim
|
||||||
1143 11833 inkpot.vim
|
1143 11833 inkpot.vim
|
||||||
2555 15432 jellybeans.vim
|
2555 15432 jellybeans.vim
|
||||||
2536 15197 lucius.vim
|
2536 15197 lucius.vim
|
||||||
3299 14475 sorcerer.vim
|
3299 14475 sorcerer.vim
|
||||||
|
1165 3741 tolerable.vim
|
||||||
3309 15759 vydark
|
3309 15759 vydark
|
||||||
2589 15760 vylight
|
2589 15760 vylight
|
||||||
1165 3741 tolerable.vim
|
|
||||||
415 15531 zenburn
|
415 15531 zenburn
|
||||||
# compiler
|
|
||||||
891 10365 pylint.vim
|
|
||||||
# ftplugin
|
# ftplugin
|
||||||
|
910 14691 pydoc.vim
|
||||||
2441 14403 pyflakes.vim
|
2441 14403 pyflakes.vim
|
||||||
30 9196 python_fn.vim
|
30 9196 python_fn.vim
|
||||||
|
435 12010 pythonhelper.vim
|
||||||
|
2527 10034 jpythonfold.vim
|
||||||
### indent
|
### indent
|
||||||
1936 7708 javascript.vim
|
1936 7708 javascript.vim
|
||||||
# there is also python.vim, which is close to PEP8, but author of
|
# there is also python.vim, which is close to PEP8, but author of
|
||||||
@@ -48,4 +46,3 @@ ScriptID SourceID Filename
|
|||||||
2651 10658 fitnesse.vim
|
2651 10658 fitnesse.vim
|
||||||
### doc
|
### doc
|
||||||
3277 14056 py2stdlib
|
3277 14056 py2stdlib
|
||||||
|
|
||||||
|
|||||||
@@ -1,748 +0,0 @@
|
|||||||
" ============================================================================
|
|
||||||
" File: autoload/delimitMate.vim
|
|
||||||
" Version: 2.3.1
|
|
||||||
" Modified: 2010-06-06
|
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
|
||||||
" Manual: Read ":help delimitMate".
|
|
||||||
|
|
||||||
" Utilities {{{
|
|
||||||
function! delimitMate#Init() "{{{
|
|
||||||
" Initialize variables:
|
|
||||||
|
|
||||||
" delimitMate_autoclose {{{
|
|
||||||
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
|
||||||
let b:delimitMate_autoclose = 1
|
|
||||||
elseif !exists("b:delimitMate_autoclose") && exists("g:delimitMate_autoclose")
|
|
||||||
let b:delimitMate_autoclose = g:delimitMate_autoclose
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_matchpairs {{{
|
|
||||||
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs")
|
|
||||||
let s:matchpairs_temp = &matchpairs
|
|
||||||
elseif exists("b:delimitMate_matchpairs")
|
|
||||||
let s:matchpairs_temp = b:delimitMate_matchpairs
|
|
||||||
else
|
|
||||||
let s:matchpairs_temp = g:delimitMate_matchpairs
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_quotes {{{
|
|
||||||
if exists("b:delimitMate_quotes")
|
|
||||||
let s:quotes = split(b:delimitMate_quotes)
|
|
||||||
elseif exists("g:delimitMate_quotes")
|
|
||||||
let s:quotes = split(g:delimitMate_quotes)
|
|
||||||
else
|
|
||||||
let s:quotes = split("\" ' `")
|
|
||||||
endif
|
|
||||||
let b:delimitMate_quotes_list = s:quotes " }}}
|
|
||||||
|
|
||||||
" delimitMate_excluded_regions {{{
|
|
||||||
if exists("b:delimitMate_excluded_regions")
|
|
||||||
let s:excluded_regions = b:delimitMate_excluded_regions
|
|
||||||
elseif exists("g:delimitMate_excluded_regions")
|
|
||||||
let s:excluded_regions = g:delimitMate_excluded_regions
|
|
||||||
else
|
|
||||||
let s:excluded_regions = "Comment"
|
|
||||||
endif
|
|
||||||
let b:delimitMate_excluded_regions_list = split(s:excluded_regions, ',\s*')
|
|
||||||
let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list) " }}}
|
|
||||||
|
|
||||||
" delimitMate_visual_leader {{{
|
|
||||||
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
|
|
||||||
let b:delimitMate_visual_leader = exists('b:maplocalleader') ? b:maplocalleader :
|
|
||||||
\ exists('g:mapleader') ? g:mapleader : "\\"
|
|
||||||
elseif !exists("b:delimitMate_visual_leader") && exists("g:delimitMate_visual_leader")
|
|
||||||
let b:delimitMate_visual_leader = g:delimitMate_visual_leader
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_expand_space {{{
|
|
||||||
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
|
||||||
let b:delimitMate_expand_space = 0
|
|
||||||
elseif !exists("b:delimitMate_expand_space") && exists("g:delimitMate_expand_space")
|
|
||||||
let b:delimitMate_expand_space = g:delimitMate_expand_space
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_expand_cr {{{
|
|
||||||
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr")
|
|
||||||
let b:delimitMate_expand_cr = 0
|
|
||||||
elseif !exists("b:delimitMate_expand_cr") && exists("g:delimitMate_expand_cr")
|
|
||||||
let b:delimitMate_expand_cr = g:delimitMate_expand_cr
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_smart_quotes {{{
|
|
||||||
if !exists("b:delimitMate_smart_quotes") && !exists("g:delimitMate_smart_quotes")
|
|
||||||
let b:delimitMate_smart_quotes = 1
|
|
||||||
elseif !exists("b:delimitMate_smart_quotes") && exists("g:delimitMate_smart_quotes")
|
|
||||||
let b:delimitMate_smart_quotes = split(g:delimitMate_smart_quotes)
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_apostrophes {{{
|
|
||||||
if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes")
|
|
||||||
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
|
|
||||||
let s:apostrophes = []
|
|
||||||
elseif !exists("b:delimitMate_apostrophes") && exists("g:delimitMate_apostrophes")
|
|
||||||
let s:apostrophes = split(g:delimitMate_apostrophes)
|
|
||||||
else
|
|
||||||
let s:apostrophes = split(b:delimitMate_apostrophes)
|
|
||||||
endif
|
|
||||||
let b:delimitMate_apostrophes_list = s:apostrophes " }}}
|
|
||||||
|
|
||||||
" delimitMate_tab2exit {{{
|
|
||||||
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit")
|
|
||||||
let b:delimitMate_tab2exit = 1
|
|
||||||
elseif !exists("b:delimitMate_tab2exit") && exists("g:delimitMate_tab2exit")
|
|
||||||
let b:delimitMate_tab2exit = g:delimitMate_tab2exit
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
let b:delimitMate_matchpairs_list = split(s:matchpairs_temp, ',')
|
|
||||||
let b:delimitMate_left_delims = split(s:matchpairs_temp, ':.,\=')
|
|
||||||
let b:delimitMate_right_delims = split(s:matchpairs_temp, ',\=.:')
|
|
||||||
|
|
||||||
let b:delimitMate_buffer = []
|
|
||||||
|
|
||||||
call delimitMate#UnMap()
|
|
||||||
if b:delimitMate_autoclose
|
|
||||||
call delimitMate#AutoClose()
|
|
||||||
else
|
|
||||||
call delimitMate#NoAutoClose()
|
|
||||||
endif
|
|
||||||
call delimitMate#VisualMaps()
|
|
||||||
call delimitMate#ExtraMappings()
|
|
||||||
|
|
||||||
let b:loaded_delimitMate = 1
|
|
||||||
let b:delimitMate_enabled = 1
|
|
||||||
endfunction "}}} Init()
|
|
||||||
|
|
||||||
function! delimitMate#ShouldJump() "{{{
|
|
||||||
" Returns 1 if the next character is a closing delimiter.
|
|
||||||
let col = col('.')
|
|
||||||
let lcol = col('$')
|
|
||||||
let char = getline('.')[col - 1]
|
|
||||||
|
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
|
||||||
if char == cdel
|
|
||||||
" Closing delimiter on the right.
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
let nchar = getline('.')[col]
|
|
||||||
if b:delimitMate_expand_space && char == " "
|
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
|
||||||
if nchar == cdel
|
|
||||||
" Closing delimiter with space expansion.
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
let uchar = getline(line('.') + 1)[0]
|
|
||||||
if b:delimitMate_expand_cr && char == ""
|
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
|
||||||
if uchar == cdel
|
|
||||||
" Closing delimiter with CR expansion.
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
return 0
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#IsBlockVisual() " {{{
|
|
||||||
if mode() == "\<C-V>"
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
|
||||||
let b:save_reg = getreg('"')
|
|
||||||
let b:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
|
||||||
" This for proper wrap of empty lines.
|
|
||||||
let @" = "\n"
|
|
||||||
endif
|
|
||||||
return 0
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#Visual(del) " {{{
|
|
||||||
let mode = mode()
|
|
||||||
if mode == "\<C-V>"
|
|
||||||
redraw
|
|
||||||
echom "delimitMate: delimitMate is disabled on blockwise visual mode."
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
|
||||||
let b:save_reg = getreg('"')
|
|
||||||
let b:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
|
||||||
" This for proper wrap of empty lines.
|
|
||||||
let @" = "\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
if mode ==# "V"
|
|
||||||
let dchar = "\<BS>"
|
|
||||||
else
|
|
||||||
let dchar = ""
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_left_delims, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = a:del
|
|
||||||
let rd = b:delimitMate_right_delims[index]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_right_delims, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = b:delimitMate_left_delims[index]
|
|
||||||
let rd = a:del
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_quotes_list, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = a:del
|
|
||||||
let rd = ld
|
|
||||||
endif
|
|
||||||
|
|
||||||
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#IsEmptyPair(str) "{{{
|
|
||||||
for pair in b:delimitMate_matchpairs_list
|
|
||||||
if a:str == join( split( pair, ':' ),'' )
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
for quote in b:delimitMate_quotes_list
|
|
||||||
if a:str == quote . quote
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return 0
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#IsCRExpansion() " {{{
|
|
||||||
let nchar = getline(line('.')-1)[-1:]
|
|
||||||
let schar = getline(line('.')+1)[:0]
|
|
||||||
let isEmpty = getline('.') == ""
|
|
||||||
if index(b:delimitMate_left_delims, nchar) > -1 &&
|
|
||||||
\ index(b:delimitMate_left_delims, nchar) == index(b:delimitMate_right_delims, schar) &&
|
|
||||||
\ isEmpty
|
|
||||||
return 1
|
|
||||||
elseif index(b:delimitMate_quotes_list, nchar) > -1 &&
|
|
||||||
\ index(b:delimitMate_quotes_list, nchar) == index(b:delimitMate_quotes_list, schar) &&
|
|
||||||
\ isEmpty
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
endfunction " }}} delimitMate#IsCRExpansion()
|
|
||||||
|
|
||||||
function! delimitMate#IsSpaceExpansion() " {{{
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if col > 0
|
|
||||||
let pchar = line[col - 1]
|
|
||||||
let nchar = line[col + 2]
|
|
||||||
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
|
|
||||||
|
|
||||||
if index(b:delimitMate_left_delims, pchar) > -1 &&
|
|
||||||
\ index(b:delimitMate_left_delims, pchar) == index(b:delimitMate_right_delims, nchar) &&
|
|
||||||
\ isSpaces
|
|
||||||
return 1
|
|
||||||
elseif index(b:delimitMate_quotes_list, pchar) > -1 &&
|
|
||||||
\ index(b:delimitMate_quotes_list, pchar) == index(b:delimitMate_quotes_list, nchar) &&
|
|
||||||
\ isSpaces
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return 0
|
|
||||||
endfunction " }}} IsSpaceExpansion()
|
|
||||||
|
|
||||||
function! delimitMate#WithinEmptyPair() "{{{
|
|
||||||
let cur = strpart( getline('.'), col('.')-2, 2 )
|
|
||||||
return delimitMate#IsEmptyPair( cur )
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#WriteBefore(str) "{{{
|
|
||||||
let len = len(a:str)
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if col < 0
|
|
||||||
call setline('.',line[(col+len+1):])
|
|
||||||
else
|
|
||||||
call setline('.',line[:(col)].line[(col+len+1):])
|
|
||||||
endif
|
|
||||||
return a:str
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#WriteAfter(str) "{{{
|
|
||||||
let len = len(a:str)
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if (col) < 0
|
|
||||||
call setline('.',a:str.line)
|
|
||||||
else
|
|
||||||
call setline('.',line[:(col)].a:str.line[(col+len):])
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#RestoreRegister() " {{{
|
|
||||||
" Restore unnamed register values store in delimitMate#IsBlockVisual().
|
|
||||||
call setreg('"', b:save_reg, b:save_reg_mode)
|
|
||||||
echo ""
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#GetSyntaxRegion(line, col) "{{{
|
|
||||||
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#GetCurrentSyntaxRegion() "{{{
|
|
||||||
let col = col('.')
|
|
||||||
if col == col('$')
|
|
||||||
let col = col - 1
|
|
||||||
endif
|
|
||||||
return delimitMate#GetSyntaxRegion(line('.'), col)
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
|
||||||
let col = col('.')
|
|
||||||
let origin_line = getline('.')
|
|
||||||
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
|
||||||
call setline('.', changed_line)
|
|
||||||
let region = delimitMate#GetSyntaxRegion(line('.'), col)
|
|
||||||
call setline('.', origin_line)
|
|
||||||
return region
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#IsForbidden(char) "{{{
|
|
||||||
if b:delimitMate_excluded_regions_enabled == 0
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
"let result = index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
|
||||||
if index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
|
||||||
"echom "Forbidden 1!"
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
|
||||||
"let result = index(b:delimitMate_excluded_regions_list, region) >= 0
|
|
||||||
"return result || region == 'Comment'
|
|
||||||
"echom "Forbidden 2!"
|
|
||||||
return index(b:delimitMate_excluded_regions_list, region) >= 0
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#FlushBuffer() " {{{
|
|
||||||
let b:delimitMate_buffer = []
|
|
||||||
return ''
|
|
||||||
endfunction " }}}
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Doers {{{
|
|
||||||
function! delimitMate#JumpIn(char) " {{{
|
|
||||||
if delimitMate#IsForbidden(a:char)
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if (col) < 0
|
|
||||||
call setline('.',a:char.line)
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
else
|
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
|
||||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#JumpOut(char) "{{{
|
|
||||||
if delimitMate#IsForbidden(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if line[col+1] == a:char
|
|
||||||
return a:char . delimitMate#Del()
|
|
||||||
else
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#JumpAny(key) " {{{
|
|
||||||
if delimitMate#IsForbidden('')
|
|
||||||
return a:key
|
|
||||||
endif
|
|
||||||
if !delimitMate#ShouldJump()
|
|
||||||
return a:key
|
|
||||||
endif
|
|
||||||
" Let's get the character on the right.
|
|
||||||
let char = getline('.')[col('.')-1]
|
|
||||||
if char == " "
|
|
||||||
" Space expansion.
|
|
||||||
"let char = char . getline('.')[col('.')] . delimitMate#Del()
|
|
||||||
return char . getline('.')[col('.')] . delimitMate#Del() . delimitMate#Del()
|
|
||||||
"call delimitMate#RmBuffer(1)
|
|
||||||
elseif char == ""
|
|
||||||
" CR expansion.
|
|
||||||
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
|
||||||
let b:delimitMate_buffer = []
|
|
||||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
|
||||||
else
|
|
||||||
"call delimitMate#RmBuffer(1)
|
|
||||||
return char . delimitMate#Del()
|
|
||||||
endif
|
|
||||||
endfunction " delimitMate#JumpAny() }}}
|
|
||||||
|
|
||||||
function! delimitMate#SkipDelim(char) "{{{
|
|
||||||
if delimitMate#IsForbidden(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
let col = col('.') - 1
|
|
||||||
let line = getline('.')
|
|
||||||
if col > 0
|
|
||||||
let cur = line[col]
|
|
||||||
let pre = line[col-1]
|
|
||||||
else
|
|
||||||
let cur = line[col]
|
|
||||||
let pre = ""
|
|
||||||
endif
|
|
||||||
if pre == "\\"
|
|
||||||
" Escaped character
|
|
||||||
return a:char
|
|
||||||
elseif cur == a:char
|
|
||||||
" Exit pair
|
|
||||||
"return delimitMate#WriteBefore(a:char)
|
|
||||||
return a:char . delimitMate#Del()
|
|
||||||
elseif delimitMate#IsEmptyPair( pre . a:char )
|
|
||||||
" Add closing delimiter and jump back to the middle.
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
return delimitMate#WriteAfter(a:char)
|
|
||||||
else
|
|
||||||
" Nothing special here, return the same character.
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#QuoteDelim(char) "{{{
|
|
||||||
if delimitMate#IsForbidden(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.') - 2
|
|
||||||
if line[col] == "\\"
|
|
||||||
" Seems like a escaped character, insert one quotation mark.
|
|
||||||
return a:char
|
|
||||||
elseif line[col + 1] == a:char
|
|
||||||
" Get out of the string.
|
|
||||||
"return delimitMate#WriteBefore(a:char)
|
|
||||||
return a:char . delimitMate#Del()
|
|
||||||
elseif (line[col] =~ '[a-zA-Z0-9]' && a:char == "'") ||
|
|
||||||
\(line[col] =~ '[a-zA-Z0-9]' && b:delimitMate_smart_quotes)
|
|
||||||
" Seems like an apostrophe or a closing, insert a single quote.
|
|
||||||
return a:char
|
|
||||||
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:delimitMate_smart_quotes
|
|
||||||
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
return delimitMate#WriteAfter(a:char)
|
|
||||||
else
|
|
||||||
" Insert a pair and jump to the middle.
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
call delimitMate#WriteAfter(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#MapMsg(msg) "{{{
|
|
||||||
redraw
|
|
||||||
echomsg a:msg
|
|
||||||
return ""
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#ExpandReturn() "{{{
|
|
||||||
if delimitMate#IsForbidden("")
|
|
||||||
return "\<CR>"
|
|
||||||
endif
|
|
||||||
if delimitMate#WithinEmptyPair()
|
|
||||||
" Expand:
|
|
||||||
call delimitMate#FlushBuffer()
|
|
||||||
"return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
|
||||||
return "\<CR>\<UP>\<Esc>o"
|
|
||||||
else
|
|
||||||
return "\<CR>"
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#ExpandSpace() "{{{
|
|
||||||
if delimitMate#IsForbidden("\<Space>")
|
|
||||||
return "\<Space>"
|
|
||||||
endif
|
|
||||||
if delimitMate#WithinEmptyPair()
|
|
||||||
" Expand:
|
|
||||||
call insert(b:delimitMate_buffer, 's')
|
|
||||||
return delimitMate#WriteAfter(' ') . "\<Space>"
|
|
||||||
else
|
|
||||||
return "\<Space>"
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#BS() " {{{
|
|
||||||
if delimitMate#IsForbidden("")
|
|
||||||
return "\<BS>"
|
|
||||||
endif
|
|
||||||
if delimitMate#WithinEmptyPair()
|
|
||||||
"call delimitMate#RmBuffer(1)
|
|
||||||
return "\<BS>" . delimitMate#Del()
|
|
||||||
" return "\<Right>\<BS>\<BS>"
|
|
||||||
elseif delimitMate#IsSpaceExpansion()
|
|
||||||
"call delimitMate#RmBuffer(1)
|
|
||||||
return "\<BS>" . delimitMate#Del()
|
|
||||||
elseif delimitMate#IsCRExpansion()
|
|
||||||
return "\<BS>\<Del>"
|
|
||||||
else
|
|
||||||
return "\<BS>"
|
|
||||||
endif
|
|
||||||
endfunction " }}} delimitMate#BS()
|
|
||||||
|
|
||||||
function! delimitMate#Del() " {{{
|
|
||||||
if len(b:delimitMate_buffer) > 0
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.') - 2
|
|
||||||
call delimitMate#RmBuffer(1)
|
|
||||||
call setline('.', line[:col] . line[col+2:])
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
return "\<Del>"
|
|
||||||
endif
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#Finish() " {{{
|
|
||||||
let len = len(b:delimitMate_buffer)
|
|
||||||
if len > 0
|
|
||||||
let buffer = join(b:delimitMate_buffer, '')
|
|
||||||
" Reset buffer:
|
|
||||||
let b:delimitMate_buffer = []
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.') -2
|
|
||||||
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
|
||||||
if col < 0
|
|
||||||
call setline('.', line[col+len+1:])
|
|
||||||
else
|
|
||||||
call setline('.', line[:col] . line[col+len+1:])
|
|
||||||
endif
|
|
||||||
let i = 1
|
|
||||||
let lefts = "\<Left>"
|
|
||||||
while i < len
|
|
||||||
let lefts = lefts . "\<Left>"
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
return substitute(buffer, "s", "\<Space>", 'g') . lefts
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#RmBuffer(num) " {{{
|
|
||||||
if len(b:delimitMate_buffer) > 0
|
|
||||||
call remove(b:delimitMate_buffer, 0, (a:num-1))
|
|
||||||
endif
|
|
||||||
return ""
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Mappers: {{{
|
|
||||||
function! delimitMate#NoAutoClose() "{{{
|
|
||||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
|
||||||
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"\|') . '")<CR>'
|
|
||||||
endfor
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#AutoClose() "{{{
|
|
||||||
" Add matching pair and jump to the midle:
|
|
||||||
" inoremap <buffer> ( ()<Left>
|
|
||||||
let i = 0
|
|
||||||
while i < len(b:delimitMate_matchpairs_list)
|
|
||||||
let ld = b:delimitMate_left_delims[i]
|
|
||||||
let rd = b:delimitMate_right_delims[i]
|
|
||||||
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#JumpIn("' . rd . '")<CR>'
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
" Exit from inside the matching pair:
|
|
||||||
for delim in b:delimitMate_right_delims
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
|
||||||
" inoremap <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
|
||||||
for delim in b:delimitMate_quotes_list
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Try to fix the use of apostrophes (de-activated by default):
|
|
||||||
" inoremap <buffer> n't n't
|
|
||||||
for map in b:delimitMate_apostrophes_list
|
|
||||||
exec "inoremap <buffer> " . map . " " . map
|
|
||||||
endfor
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#VisualMaps() " {{{
|
|
||||||
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
|
||||||
let vleader = b:delimitMate_visual_leader
|
|
||||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
|
||||||
for del in b:delimitMate_right_delims + b:delimitMate_left_delims + b:delimitMate_quotes_list
|
|
||||||
exec "vnoremap <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
|
|
||||||
endfor
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#ExtraMappings() "{{{
|
|
||||||
" If pair is empty, delete both delimiters:
|
|
||||||
inoremap <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
|
||||||
|
|
||||||
" If pair is empty, delete closing delimiter:
|
|
||||||
inoremap <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() && !delimitMate#IsForbidden("") ? "\<Del>" : "\<S-BS>"
|
|
||||||
|
|
||||||
" Expand return if inside an empty pair:
|
|
||||||
if b:delimitMate_expand_cr != 0
|
|
||||||
inoremap <buffer> <CR> <C-R>=delimitMate#ExpandReturn()<CR>
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Expand space if inside an empty pair:
|
|
||||||
if b:delimitMate_expand_space != 0
|
|
||||||
inoremap <buffer> <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Jump out ot any empty pair:
|
|
||||||
if b:delimitMate_tab2exit
|
|
||||||
inoremap <buffer> <S-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fix the re-do feature:
|
|
||||||
inoremap <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
|
|
||||||
|
|
||||||
" Flush the char buffer on mouse click:
|
|
||||||
inoremap <buffer> <LeftMouse> <C-R>=delimitMate#Finish()<CR><LeftMouse>
|
|
||||||
inoremap <buffer> <RightMouse> <C-R>=delimitMate#Finish()<CR><RightMouse>
|
|
||||||
|
|
||||||
" Flush the char buffer on key movements:
|
|
||||||
inoremap <buffer> <Left> <C-R>=delimitMate#Finish()<CR><Left>
|
|
||||||
inoremap <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
|
|
||||||
inoremap <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
|
|
||||||
inoremap <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
|
|
||||||
|
|
||||||
inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR>
|
|
||||||
|
|
||||||
"the following simply creates an ambiguous mapping so vim fully
|
|
||||||
"processes the escape sequence for terminal keys, see 'ttimeout' for a
|
|
||||||
"rough explanation, this just forces it to work
|
|
||||||
if &term[:4] != "builtin_gui"
|
|
||||||
inoremap <silent> <C-[>OC <RIGHT>
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#UnMap() " {{{
|
|
||||||
let imaps =
|
|
||||||
\ b:delimitMate_right_delims +
|
|
||||||
\ b:delimitMate_left_delims +
|
|
||||||
\ b:delimitMate_quotes_list +
|
|
||||||
\ b:delimitMate_apostrophes_list +
|
|
||||||
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
|
||||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>']
|
|
||||||
|
|
||||||
let vmaps =
|
|
||||||
\ b:delimitMate_right_delims +
|
|
||||||
\ b:delimitMate_left_delims +
|
|
||||||
\ b:delimitMate_quotes_list
|
|
||||||
|
|
||||||
for map in imaps
|
|
||||||
if maparg(map, "i") =~? 'delimitMate'
|
|
||||||
exec 'silent! iunmap <buffer> ' . map
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
if !exists("b:delimitMate_visual_leader")
|
|
||||||
let vleader = ""
|
|
||||||
else
|
|
||||||
let vleader = b:delimitMate_visual_leader
|
|
||||||
endif
|
|
||||||
for map in vmaps
|
|
||||||
if maparg(vleader . map, "v") =~? "delimitMate"
|
|
||||||
exec 'silent! vunmap <buffer> ' . vleader . map
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
let b:delimitMate_enabled = 0
|
|
||||||
endfunction " }}} delimitMate#UnMap()
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Tools: {{{
|
|
||||||
function! delimitMate#TestMappings() "{{{
|
|
||||||
exec "normal i*b:delimitMate_autoclose = " . b:delimitMate_autoclose . "\<CR>"
|
|
||||||
exec "normal i*b:delimitMate_expand_space = " . b:delimitMate_expand_space . "\<CR>"
|
|
||||||
exec "normal i*b:delimitMate_expand_cr = " . b:delimitMate_expand_cr . "\<CR>\<CR>"
|
|
||||||
|
|
||||||
if b:delimitMate_autoclose
|
|
||||||
for i in range(len(b:delimitMate_left_delims))
|
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i]. "|"
|
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . "\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . " |"
|
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . " \<BS>|"
|
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . "\<CR>|"
|
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
|
||||||
endfor
|
|
||||||
for i in range(len(b:delimitMate_quotes_list))
|
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
|
|
||||||
exec "normal A\<CR>Delete: "
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
|
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . " \<BS>|"
|
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . "\<CR>|"
|
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
for i in range(len(b:delimitMate_left_delims))
|
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|"
|
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |"
|
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " \<BS>|"
|
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>|"
|
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
|
||||||
endfor
|
|
||||||
for i in range(len(b:delimitMate_quotes_list))
|
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " |"
|
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " \<BS>|"
|
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>|"
|
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
exec "normal \<Esc>i"
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" vim:foldmethod=marker:foldcolumn=4
|
|
||||||
@@ -1,591 +0,0 @@
|
|||||||
" ---------------------------------------------------------------------
|
|
||||||
" getscript.vim
|
|
||||||
" Author: Charles E. Campbell, Jr.
|
|
||||||
" Date: Jan 08, 2008
|
|
||||||
" Version: 29
|
|
||||||
" Installing: :help glvs-install
|
|
||||||
" Usage: :help glvs
|
|
||||||
"
|
|
||||||
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
|
|
||||||
"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Initialization: {{{1
|
|
||||||
" if you're sourcing this file, surely you can't be
|
|
||||||
" expecting vim to be in its vi-compatible mode!
|
|
||||||
if &cp
|
|
||||||
echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:keepcpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
"DechoTabOn
|
|
||||||
|
|
||||||
if exists("g:loaded_getscript")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_getscript= "v29"
|
|
||||||
|
|
||||||
" ---------------------------
|
|
||||||
" Global Variables: {{{1
|
|
||||||
" ---------------------------
|
|
||||||
" Cygwin Detection ------- {{{2
|
|
||||||
if !exists("g:getscript_cygwin")
|
|
||||||
if has("win32") || has("win95") || has("win64") || has("win16")
|
|
||||||
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
|
|
||||||
let g:getscript_cygwin= 1
|
|
||||||
else
|
|
||||||
let g:getscript_cygwin= 0
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let g:getscript_cygwin= 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
" shell quoting character {{{2
|
|
||||||
if exists("g:netrw_shq") && !exists("g:getscript_shq")
|
|
||||||
let g:getscript_shq= g:netrw_shq
|
|
||||||
elseif !exists("g:getscript_shq")
|
|
||||||
if exists("&shq") && &shq != ""
|
|
||||||
let g:getscript_shq= &shq
|
|
||||||
elseif exists("&sxq") && &sxq != ""
|
|
||||||
let g:getscript_shq= &sxq
|
|
||||||
elseif has("win32") || has("win95") || has("win64") || has("win16")
|
|
||||||
if g:getscript_cygwin
|
|
||||||
let g:getscript_shq= "'"
|
|
||||||
else
|
|
||||||
let g:getscript_shq= '"'
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let g:getscript_shq= "'"
|
|
||||||
endif
|
|
||||||
" call Decho("g:getscript_shq<".g:getscript_shq.">")
|
|
||||||
endif
|
|
||||||
|
|
||||||
" wget vs curl {{{2
|
|
||||||
if !exists("g:GetLatestVimScripts_wget")
|
|
||||||
if executable("wget")
|
|
||||||
let g:GetLatestVimScripts_wget= "wget"
|
|
||||||
elseif executable("curl")
|
|
||||||
let g:GetLatestVimScripts_wget= "curl"
|
|
||||||
else
|
|
||||||
let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"'
|
|
||||||
let g:GetLatestVimScripts_options = ""
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" options that wget and curl require:
|
|
||||||
if !exists("g:GetLatestVimScripts_options")
|
|
||||||
if g:GetLatestVimScripts_wget == "wget"
|
|
||||||
let g:GetLatestVimScripts_options= "-q -O"
|
|
||||||
elseif g:GetLatestVimScripts_wget == "curl"
|
|
||||||
let g:GetLatestVimScripts_options= "-s -O"
|
|
||||||
else
|
|
||||||
let g:GetLatestVimScripts_options= ""
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" by default, allow autoinstall lines to work
|
|
||||||
if !exists("g:GetLatestVimScripts_allowautoinstall")
|
|
||||||
let g:GetLatestVimScripts_allowautoinstall= 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
"" For debugging:
|
|
||||||
"let g:GetLatestVimScripts_wget = "echo"
|
|
||||||
"let g:GetLatestVimScripts_options = "options"
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Check If AutoInstall Capable: {{{1
|
|
||||||
let s:autoinstall= ""
|
|
||||||
if g:GetLatestVimScripts_allowautoinstall
|
|
||||||
|
|
||||||
if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash"
|
|
||||||
" windows (but not cygwin/bash)
|
|
||||||
let s:dotvim= "vimfiles"
|
|
||||||
if !exists("g:GetLatestVimScripts_mv")
|
|
||||||
let g:GetLatestVimScripts_mv= "ren"
|
|
||||||
endif
|
|
||||||
|
|
||||||
else
|
|
||||||
" unix
|
|
||||||
let s:dotvim= ".vim"
|
|
||||||
if !exists("g:GetLatestVimScripts_mv")
|
|
||||||
let g:GetLatestVimScripts_mv= "mv"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim)
|
|
||||||
let s:autoinstall= $HOME."/".s:dotvim
|
|
||||||
endif
|
|
||||||
" call Decho("s:autoinstall<".s:autoinstall.">")
|
|
||||||
"else "Decho
|
|
||||||
" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled")
|
|
||||||
endif
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Public Interface: {{{1
|
|
||||||
com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
|
|
||||||
com! -nargs=0 GetScript call getscript#GetLatestVimScripts()
|
|
||||||
silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" GetOneScript: (Get Latest Vim Script) this function operates {{{1
|
|
||||||
" on the current line, interpreting two numbers and text as
|
|
||||||
" ScriptID, SourceID, and Filename.
|
|
||||||
" It downloads any scripts that have newer versions from vim.sf.net.
|
|
||||||
fun! s:GetOneScript(...)
|
|
||||||
" call Dfunc("GetOneScript()")
|
|
||||||
|
|
||||||
" set options to allow progress to be shown on screen
|
|
||||||
let rega= @a
|
|
||||||
let t_ti= &t_ti
|
|
||||||
let t_te= &t_te
|
|
||||||
let rs = &rs
|
|
||||||
set t_ti= t_te= nors
|
|
||||||
|
|
||||||
" put current line on top-of-screen and interpret it into
|
|
||||||
" a script identifer : used to obtain webpage
|
|
||||||
" source identifier : used to identify current version
|
|
||||||
" and an associated comment: used to report on what's being considered
|
|
||||||
if a:0 >= 3
|
|
||||||
let scriptid = a:1
|
|
||||||
let srcid = a:2
|
|
||||||
let fname = a:3
|
|
||||||
let cmmnt = ""
|
|
||||||
" call Decho("scriptid<".scriptid.">")
|
|
||||||
" call Decho("srcid <".srcid.">")
|
|
||||||
" call Decho("fname <".fname.">")
|
|
||||||
else
|
|
||||||
let curline = getline(".")
|
|
||||||
if curline =~ '^\s*#'
|
|
||||||
let @a= rega
|
|
||||||
" call Dret("GetOneScript : skipping a pure comment line")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$'
|
|
||||||
try
|
|
||||||
let scriptid = substitute(curline,parsepat,'\1','e')
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E486/
|
|
||||||
let scriptid= 0
|
|
||||||
endtry
|
|
||||||
try
|
|
||||||
let srcid = substitute(curline,parsepat,'\2','e')
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E486/
|
|
||||||
let srcid= 0
|
|
||||||
endtry
|
|
||||||
try
|
|
||||||
let fname= substitute(curline,parsepat,'\3','e')
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E486/
|
|
||||||
let fname= ""
|
|
||||||
endtry
|
|
||||||
try
|
|
||||||
let cmmnt= substitute(curline,parsepat,'\4','e')
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E486/
|
|
||||||
let cmmnt= ""
|
|
||||||
endtry
|
|
||||||
" call Decho("curline <".curline.">")
|
|
||||||
" call Decho("parsepat<".parsepat.">")
|
|
||||||
" call Decho("scriptid<".scriptid.">")
|
|
||||||
" call Decho("srcid <".srcid.">")
|
|
||||||
" call Decho("fname <".fname.">")
|
|
||||||
endif
|
|
||||||
|
|
||||||
if scriptid == 0 || srcid == 0
|
|
||||||
" When looking for :AutoInstall: lines, skip scripts that have 0 0 scriptname
|
|
||||||
let @a= rega
|
|
||||||
" call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let doautoinstall= 0
|
|
||||||
if fname =~ ":AutoInstall:"
|
|
||||||
" call Decho("case AutoInstall: fname<".fname.">")
|
|
||||||
let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','')
|
|
||||||
" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall)
|
|
||||||
if s:autoinstall != ""
|
|
||||||
let doautoinstall = g:GetLatestVimScripts_allowautoinstall
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let aicmmnt= fname
|
|
||||||
endif
|
|
||||||
" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall)
|
|
||||||
|
|
||||||
exe "norm z\<CR>"
|
|
||||||
redraw!
|
|
||||||
" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid)
|
|
||||||
echomsg 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid
|
|
||||||
|
|
||||||
" grab a copy of the plugin's vim.sf.net webpage
|
|
||||||
let scriptaddr = 'http://vim.sf.net/script.php?script_id='.scriptid
|
|
||||||
let tmpfile = tempname()
|
|
||||||
let v:errmsg = ""
|
|
||||||
|
|
||||||
" make up to three tries at downloading the description
|
|
||||||
let itry= 1
|
|
||||||
while itry <= 3
|
|
||||||
" call Decho("try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr)
|
|
||||||
if has("win32") || has("win16") || has("win95")
|
|
||||||
" call Decho("new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq.' '.g:getscript_shq.scriptaddr.g:getscript_shq."|q!")
|
|
||||||
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq.' '.g:getscript_shq.scriptaddr.g:getscript_shq|q!
|
|
||||||
else
|
|
||||||
" call Decho("exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq." ".g:getscript_shq.scriptaddr.g:getscript_shq)
|
|
||||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq." ".g:getscript_shq.scriptaddr.g:getscript_shq
|
|
||||||
endif
|
|
||||||
if itry == 1
|
|
||||||
exe "silent vsplit ".tmpfile
|
|
||||||
else
|
|
||||||
silent! e %
|
|
||||||
endif
|
|
||||||
|
|
||||||
" find the latest source-id in the plugin's webpage
|
|
||||||
silent! 1
|
|
||||||
let findpkg= search('Click on the package to download','W')
|
|
||||||
if findpkg > 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let itry= itry + 1
|
|
||||||
endwhile
|
|
||||||
" call Decho(" --- end downloading tries while loop --- itry=".itry)
|
|
||||||
|
|
||||||
" testing: did finding "Click on the package..." fail?
|
|
||||||
if findpkg == 0 || itry >= 4
|
|
||||||
silent q!
|
|
||||||
call delete(tmpfile)
|
|
||||||
" restore options
|
|
||||||
let &t_ti = t_ti
|
|
||||||
let &t_te = t_te
|
|
||||||
let &rs = rs
|
|
||||||
let s:downerrors = s:downerrors + 1
|
|
||||||
" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
|
|
||||||
echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
|
|
||||||
" call Dret("GetOneScript : srch for /Click on the package/ failed")
|
|
||||||
let @a= rega
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" call Decho('found "Click on the package to download"')
|
|
||||||
|
|
||||||
let findsrcid= search('src_id=','W')
|
|
||||||
if findsrcid == 0
|
|
||||||
silent q!
|
|
||||||
call delete(tmpfile)
|
|
||||||
" restore options
|
|
||||||
let &t_ti = t_ti
|
|
||||||
let &t_te = t_te
|
|
||||||
let &rs = rs
|
|
||||||
let s:downerrors = s:downerrors + 1
|
|
||||||
" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
|
|
||||||
echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
|
|
||||||
let @a= rega
|
|
||||||
" call Dret("GetOneScript : srch for /src_id/ failed")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" call Decho('found "src_id=" in description page')
|
|
||||||
|
|
||||||
let srcidpat = '^\s*<td class.*src_id=\(\d\+\)">\([^<]\+\)<.*$'
|
|
||||||
let latestsrcid= substitute(getline("."),srcidpat,'\1','')
|
|
||||||
let sname = substitute(getline("."),srcidpat,'\2','') " script name actually downloaded
|
|
||||||
" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> sname<".sname.">")
|
|
||||||
silent q!
|
|
||||||
call delete(tmpfile)
|
|
||||||
|
|
||||||
" convert the strings-of-numbers into numbers
|
|
||||||
let srcid = srcid + 0
|
|
||||||
let latestsrcid = latestsrcid + 0
|
|
||||||
" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." sname<".sname.">")
|
|
||||||
|
|
||||||
" has the plugin's most-recent srcid increased, which indicates
|
|
||||||
" that it has been updated
|
|
||||||
if latestsrcid > srcid
|
|
||||||
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."]: need to update <".sname.">")
|
|
||||||
|
|
||||||
let s:downloads= s:downloads + 1
|
|
||||||
if sname == bufname("%")
|
|
||||||
" GetLatestVimScript has to be careful about downloading itself
|
|
||||||
let sname= "NEW_".sname
|
|
||||||
endif
|
|
||||||
|
|
||||||
" the plugin has been updated since we last obtained it, so download a new copy
|
|
||||||
" call Decho("...downloading new <".sname.">")
|
|
||||||
echomsg "...downloading new <".sname.">"
|
|
||||||
if has("win32") || has("win16") || has("win95")
|
|
||||||
" call Decho("new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq."|q")
|
|
||||||
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq|q
|
|
||||||
else
|
|
||||||
" call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq)
|
|
||||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq
|
|
||||||
endif
|
|
||||||
|
|
||||||
" AutoInstall: only if doautoinstall has been requested by the plugin itself
|
|
||||||
if doautoinstall
|
|
||||||
" call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
|
|
||||||
if filereadable(sname)
|
|
||||||
" call Decho("silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.s:autoinstall.g:getscript_shq)
|
|
||||||
exe "silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.s:autoinstall.g:getscript_shq
|
|
||||||
let curdir = escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #")
|
|
||||||
let installdir= curdir."/Installed"
|
|
||||||
if !isdirectory(installdir)
|
|
||||||
call mkdir(installdir)
|
|
||||||
endif
|
|
||||||
" call Decho("exe cd ".s:autoinstall)
|
|
||||||
exe "cd ".escape(s:autoinstall,' ')
|
|
||||||
|
|
||||||
" decompress
|
|
||||||
if sname =~ '\.bz2$'
|
|
||||||
" call Decho("decompress: attempt to bunzip2 ".sname)
|
|
||||||
exe "silent !bunzip2 ".g:getscript_shq.sname.g:getscript_shq
|
|
||||||
let sname= substitute(sname,'\.bz2$','','')
|
|
||||||
" call Decho("decompress: new sname<".sname."> after bunzip2")
|
|
||||||
elseif sname =~ '\.gz$'
|
|
||||||
" call Decho("decompress: attempt to gunzip ".sname)
|
|
||||||
exe "silent !gunzip ".g:getscript_shq.sname.g:getscript_shq
|
|
||||||
let sname= substitute(sname,'\.gz$','','')
|
|
||||||
" call Decho("decompress: new sname<".sname."> after gunzip")
|
|
||||||
endif
|
|
||||||
|
|
||||||
" distribute archive(.zip, .tar, .vba) contents
|
|
||||||
if sname =~ '\.zip$'
|
|
||||||
" call Decho("dearchive: attempt to unzip ".sname)
|
|
||||||
exe "silent !unzip -o ".g:getscript_shq.sname.g:getscript_shq
|
|
||||||
elseif sname =~ '\.tar$'
|
|
||||||
" call Decho("dearchive: attempt to untar ".sname)
|
|
||||||
exe "silent !tar -xvf ".g:getscript_shq.sname.g:getscript_shq
|
|
||||||
elseif sname =~ '\.vba$'
|
|
||||||
" call Decho("dearchive: attempt to handle a vimball: ".sname)
|
|
||||||
silent 1split
|
|
||||||
exe "silent e ".escape(sname,' ')
|
|
||||||
silent so %
|
|
||||||
silent q
|
|
||||||
endif
|
|
||||||
|
|
||||||
if sname =~ '.vim$'
|
|
||||||
" call Decho("dearchive: attempt to simply move ".sname." to plugin")
|
|
||||||
exe "silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." plugin"
|
|
||||||
else
|
|
||||||
" call Decho("dearchive: move <".sname."> to installdir<".installdir.">")
|
|
||||||
exe "silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." ".installdir
|
|
||||||
endif
|
|
||||||
|
|
||||||
" helptags step
|
|
||||||
let docdir= substitute(&rtp,',.*','','e')."/doc"
|
|
||||||
" call Decho("helptags: docdir<".docdir.">")
|
|
||||||
exe "helptags ".docdir
|
|
||||||
exe "cd ".curdir
|
|
||||||
endif
|
|
||||||
if fname !~ ':AutoInstall:'
|
|
||||||
let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt
|
|
||||||
else
|
|
||||||
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
|
|
||||||
endif
|
|
||||||
|
|
||||||
" update the data in the <GetLatestVimScripts.dat> file
|
|
||||||
call setline(line("."),modline)
|
|
||||||
" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
|
|
||||||
" else " Decho
|
|
||||||
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
|
|
||||||
endif
|
|
||||||
|
|
||||||
" restore options
|
|
||||||
let &t_ti = t_ti
|
|
||||||
let &t_te = t_te
|
|
||||||
let &rs = rs
|
|
||||||
let @a = rega
|
|
||||||
|
|
||||||
" call Dret("GetOneScript")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" GetLatestVimScripts: this function gets the latest versions of {{{1
|
|
||||||
" scripts based on the list in
|
|
||||||
" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
|
|
||||||
fun! getscript#GetLatestVimScripts()
|
|
||||||
" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">")
|
|
||||||
|
|
||||||
" insure that wget is executable
|
|
||||||
if executable(g:GetLatestVimScripts_wget) != 1
|
|
||||||
echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system"
|
|
||||||
" call Dret("GetLatestVimScripts : wget not executable/availble")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Find the .../GetLatest subdirectory under the runtimepath
|
|
||||||
for datadir in split(&rtp,',') + ['']
|
|
||||||
if isdirectory(datadir."/GetLatest")
|
|
||||||
" call Decho("found directory<".datadir.">")
|
|
||||||
let datadir= datadir . "/GetLatest"
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
if filereadable(datadir."GetLatestVimScripts.dat")
|
|
||||||
" call Decho("found ".datadir."/GetLatestVimScripts.dat")
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Sanity checks: readability and writability
|
|
||||||
if datadir == ""
|
|
||||||
echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
|
|
||||||
" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if filewritable(datadir) != 2
|
|
||||||
echoerr "(getLatestVimScripts) Your ".datadir." isn't writable"
|
|
||||||
" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let datafile= datadir."/GetLatestVimScripts.dat"
|
|
||||||
if !filereadable(datafile)
|
|
||||||
echoerr "Your data file<".datafile."> isn't readable"
|
|
||||||
" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
if !filewritable(datafile)
|
|
||||||
echoerr "Your data file<".datafile."> isn't writable"
|
|
||||||
" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" call Decho("datadir <".datadir.">")
|
|
||||||
" call Decho("datafile <".datafile.">")
|
|
||||||
|
|
||||||
" don't let any events interfere (like winmanager's, taglist's, etc)
|
|
||||||
let eikeep= &ei
|
|
||||||
set ei=all
|
|
||||||
|
|
||||||
" record current directory, change to datadir, open split window with
|
|
||||||
" datafile
|
|
||||||
let origdir= getcwd()
|
|
||||||
exe "cd ".escape(substitute(datadir,'\','/','ge'),"|[]*'\" #")
|
|
||||||
split
|
|
||||||
exe "e ".escape(substitute(datafile,'\','/','ge'),"|[]*'\" #")
|
|
||||||
res 1000
|
|
||||||
let s:downloads = 0
|
|
||||||
let s:downerrors= 0
|
|
||||||
|
|
||||||
" Check on dependencies mentioned in plugins
|
|
||||||
" call Decho(" ")
|
|
||||||
" call Decho("searching plugins for GetLatestVimScripts dependencies")
|
|
||||||
let lastline = line("$")
|
|
||||||
" call Decho("lastline#".lastline)
|
|
||||||
let plugins = split(globpath(&rtp,"plugin/*.vim"),'\n')
|
|
||||||
let foundscript = 0
|
|
||||||
let firstdir= ""
|
|
||||||
|
|
||||||
for plugin in plugins
|
|
||||||
|
|
||||||
" don't process plugins in system directories
|
|
||||||
if firstdir == ""
|
|
||||||
let firstdir= substitute(plugin,'[/\\][^/\\]\+$','','')
|
|
||||||
" call Decho("setting firstdir<".firstdir.">")
|
|
||||||
else
|
|
||||||
let curdir= substitute(plugin,'[/\\][^/\\]\+$','','')
|
|
||||||
" call Decho("curdir<".curdir.">")
|
|
||||||
if curdir != firstdir
|
|
||||||
" call Decho("skipping subsequent plugins: curdir<".curdir."> != firstdir<".firstdir.">")
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" read plugin in
|
|
||||||
$
|
|
||||||
" call Decho(" ")
|
|
||||||
" call Decho(".dependency checking<".plugin."> line$=".line("$"))
|
|
||||||
exe "silent r ".escape(plugin,"[]#*$%'\" ?`!&();<>\\")
|
|
||||||
|
|
||||||
while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
|
|
||||||
let newscript= substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
|
|
||||||
let llp1 = lastline+1
|
|
||||||
" call Decho("..newscript<".newscript.">")
|
|
||||||
|
|
||||||
" don't process ""GetLatestVimScripts lines -- those that have been doubly-commented out
|
|
||||||
if newscript !~ '^"'
|
|
||||||
" found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile
|
|
||||||
let curline = line(".")
|
|
||||||
let noai_script = substitute(newscript,'\s*:AutoInstall:\s*','','e')
|
|
||||||
exe llp1
|
|
||||||
let srchline = search('\<'.noai_script.'\>','bW')
|
|
||||||
" call Decho("..noai_script<".noai_script."> srch=".srchline."curline#".line(".")." lastline#".lastline)
|
|
||||||
|
|
||||||
if srchline == 0
|
|
||||||
" found a new script to permanently include in the datafile
|
|
||||||
let keep_rega = @a
|
|
||||||
let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','')
|
|
||||||
exe lastline."put a"
|
|
||||||
echomsg "Appending <".@a."> to ".datafile." for ".newscript
|
|
||||||
" call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat")
|
|
||||||
let @a = keep_rega
|
|
||||||
let lastline = llp1
|
|
||||||
let curline = curline + 1
|
|
||||||
let foundscript = foundscript + 1
|
|
||||||
" else " Decho
|
|
||||||
" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
|
|
||||||
endif
|
|
||||||
|
|
||||||
let curline = curline + 1
|
|
||||||
exe curline
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let llp1= lastline + 1
|
|
||||||
" call Decho(".deleting lines: ".llp1.",$d")
|
|
||||||
exe "silent! ".llp1.",$d"
|
|
||||||
endfor
|
|
||||||
" call Decho("--- end dependency checking loop --- foundscript=".foundscript)
|
|
||||||
" call Decho(" ")
|
|
||||||
|
|
||||||
if foundscript == 0
|
|
||||||
setlocal nomod
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
|
|
||||||
" call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
|
|
||||||
setlocal lz
|
|
||||||
1
|
|
||||||
" /^-----/,$g/^\s*\d/call Decho(getline("."))
|
|
||||||
1
|
|
||||||
/^-----/,$g/^\s*\d/call s:GetOneScript()
|
|
||||||
" call Decho("--- end out-of-date checking --- ")
|
|
||||||
|
|
||||||
" Final report (an echomsg)
|
|
||||||
try
|
|
||||||
silent! ?^-------?
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E114/
|
|
||||||
" call Dret("GetLatestVimScripts : nothing done!")
|
|
||||||
return
|
|
||||||
endtry
|
|
||||||
exe "norm! kz\<CR>"
|
|
||||||
redraw!
|
|
||||||
let s:msg = ""
|
|
||||||
if s:downloads == 1
|
|
||||||
let s:msg = "Downloaded one updated script to <".datadir.">"
|
|
||||||
elseif s:downloads == 2
|
|
||||||
let s:msg= "Downloaded two updated scripts to <".datadir.">"
|
|
||||||
elseif s:downloads > 1
|
|
||||||
let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">"
|
|
||||||
else
|
|
||||||
let s:msg= "Everything was already current"
|
|
||||||
endif
|
|
||||||
if s:downerrors > 0
|
|
||||||
let s:msg= s:msg." (".s:downerrors." downloading errors)"
|
|
||||||
endif
|
|
||||||
echomsg s:msg
|
|
||||||
" save the file
|
|
||||||
if &mod
|
|
||||||
silent! w!
|
|
||||||
endif
|
|
||||||
q
|
|
||||||
|
|
||||||
" restore events and current directory
|
|
||||||
exe "cd ".escape(substitute(origdir,'\','/','ge'),"|[]*'\" #")
|
|
||||||
let &ei= eikeep
|
|
||||||
setlocal nolz
|
|
||||||
" call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Restore Options: {{{1
|
|
||||||
let &cpo= s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Modelines: {{{1
|
|
||||||
" vim: ts=8 sts=2 fdm=marker nowrap
|
|
||||||
@@ -18,14 +18,18 @@ let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]'
|
|||||||
|
|
||||||
" MISC helper functions {{{
|
" MISC helper functions {{{
|
||||||
|
|
||||||
function! vimwiki#chomp_slash(str) "{{{
|
function! vimwiki#base#chomp_slash(str) "{{{
|
||||||
return substitute(a:str, '[/\\]\+$', '', '')
|
return substitute(a:str, '[/\\]\+$', '', '')
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#mkdir(path) "{{{
|
function! vimwiki#base#path_norm(path) "{{{
|
||||||
|
return substitute(a:path, '\', '/', 'g')
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! vimwiki#base#mkdir(path) "{{{
|
||||||
let path = expand(a:path)
|
let path = expand(a:path)
|
||||||
if !isdirectory(path) && exists("*mkdir")
|
if !isdirectory(path) && exists("*mkdir")
|
||||||
let path = vimwiki#chomp_slash(path)
|
let path = vimwiki#base#chomp_slash(path)
|
||||||
if s:is_windows() && !empty(g:vimwiki_w32_dir_enc)
|
if s:is_windows() && !empty(g:vimwiki_w32_dir_enc)
|
||||||
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
||||||
endif
|
endif
|
||||||
@@ -34,17 +38,30 @@ function! vimwiki#mkdir(path) "{{{
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! vimwiki#safe_link(string) "{{{
|
function! vimwiki#base#safe_link(link) "{{{
|
||||||
return substitute(a:string, s:badsymbols, g:vimwiki_stripsym, 'g')
|
" handling Windows absolute paths
|
||||||
|
if a:link =~ '^[[:alpha:]]:[/\\].*'
|
||||||
|
let link_start = a:link[0 : 2]
|
||||||
|
let link = a:link[3 : ]
|
||||||
|
else
|
||||||
|
let link_start = ''
|
||||||
|
let link = a:link
|
||||||
|
endif
|
||||||
|
let link = substitute(link, s:badsymbols, g:vimwiki_stripsym, 'g')
|
||||||
|
return link_start.link
|
||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! vimwiki#unsafe_link(string) "{{{
|
function! vimwiki#base#unsafe_link(string) "{{{
|
||||||
|
if len(g:vimwiki_stripsym) > 0
|
||||||
return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g')
|
return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g')
|
||||||
|
else
|
||||||
|
return a:string
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! vimwiki#subdir(path, filename)"{{{
|
function! vimwiki#base#subdir(path, filename)"{{{
|
||||||
let path = expand(a:path)
|
let path = expand(a:path)
|
||||||
let filename = expand(a:filename)
|
let filename = expand(a:filename)
|
||||||
let idx = 0
|
let idx = 0
|
||||||
@@ -60,13 +77,17 @@ function! vimwiki#subdir(path, filename)"{{{
|
|||||||
return res
|
return res
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! vimwiki#current_subdir()"{{{
|
function! vimwiki#base#current_subdir()"{{{
|
||||||
return vimwiki#subdir(VimwikiGet('path'), expand('%:p'))
|
return vimwiki#base#subdir(VimwikiGet('path'), expand('%:p'))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! vimwiki#open_link(cmd, link, ...) "{{{
|
function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||||
if vimwiki#is_non_wiki_link(a:link)
|
if vimwiki#base#is_non_wiki_link(a:link)
|
||||||
call s:edit_file(a:cmd, a:link)
|
if s:is_path_absolute(a:link)
|
||||||
|
call vimwiki#base#edit_file(a:cmd, a:link)
|
||||||
|
else
|
||||||
|
call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link)
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
if a:0
|
if a:0
|
||||||
let vimwiki_prev_link = [a:1, []]
|
let vimwiki_prev_link = [a:1, []]
|
||||||
@@ -74,17 +95,17 @@ function! vimwiki#open_link(cmd, link, ...) "{{{
|
|||||||
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if vimwiki#is_link_to_dir(a:link)
|
if vimwiki#base#is_link_to_dir(a:link)
|
||||||
if g:vimwiki_dir_link == ''
|
if g:vimwiki_dir_link == ''
|
||||||
call s:edit_file(a:cmd, VimwikiGet('path').a:link)
|
call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link)
|
||||||
else
|
else
|
||||||
call s:edit_file(a:cmd,
|
call vimwiki#base#edit_file(a:cmd,
|
||||||
\ VimwikiGet('path').a:link.
|
\ VimwikiGet('path').a:link.
|
||||||
\ g:vimwiki_dir_link.
|
\ g:vimwiki_dir_link.
|
||||||
\ VimwikiGet('ext'))
|
\ VimwikiGet('ext'))
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext'))
|
call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('vimwiki_prev_link')
|
if exists('vimwiki_prev_link')
|
||||||
@@ -94,7 +115,7 @@ function! vimwiki#open_link(cmd, link, ...) "{{{
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! vimwiki#select(wnum)"{{{
|
function! vimwiki#base#select(wnum)"{{{
|
||||||
if a:wnum < 1 || a:wnum > len(g:vimwiki_list)
|
if a:wnum < 1 || a:wnum > len(g:vimwiki_list)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -105,7 +126,7 @@ function! vimwiki#select(wnum)"{{{
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! vimwiki#generate_links()"{{{
|
function! vimwiki#base#generate_links()"{{{
|
||||||
let links = s:get_links('*'.VimwikiGet('ext'))
|
let links = s:get_links('*'.VimwikiGet('ext'))
|
||||||
|
|
||||||
" We don't want link to itself.
|
" We don't want link to itself.
|
||||||
@@ -127,8 +148,8 @@ function! vimwiki#generate_links()"{{{
|
|||||||
endfor
|
endfor
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! vimwiki#goto(key) "{{{
|
function! vimwiki#base#goto(key) "{{{
|
||||||
call s:edit_file(':e',
|
call vimwiki#base#edit_file(':e',
|
||||||
\ VimwikiGet('path').
|
\ VimwikiGet('path').
|
||||||
\ a:key.
|
\ a:key.
|
||||||
\ VimwikiGet('ext'))
|
\ VimwikiGet('ext'))
|
||||||
@@ -138,9 +159,13 @@ function! s:is_windows() "{{{
|
|||||||
return has("win32") || has("win64") || has("win95") || has("win16")
|
return has("win32") || has("win64") || has("win95") || has("win16")
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:is_path_absolute(path) "{{{
|
||||||
|
return a:path =~ '^/.*' || a:path =~ '^[[:alpha:]]:[/\\].*'
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:get_links(pat) "{{{
|
function! s:get_links(pat) "{{{
|
||||||
" search all wiki files in 'path' and its subdirs.
|
" search all wiki files in 'path' and its subdirs.
|
||||||
let subdir = vimwiki#current_subdir()
|
let subdir = vimwiki#base#current_subdir()
|
||||||
|
|
||||||
" if current wiki is temporary -- was added by an arbitrary wiki file then do
|
" if current wiki is temporary -- was added by an arbitrary wiki file then do
|
||||||
" not search wiki files in subdirectories. Or it would hang the system if
|
" not search wiki files in subdirectories. Or it would hang the system if
|
||||||
@@ -173,11 +198,11 @@ function! s:cursor(lnum, cnum) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:filename(link) "{{{
|
function! s:filename(link) "{{{
|
||||||
let result = vimwiki#safe_link(a:link)
|
let result = vimwiki#base#safe_link(a:link)
|
||||||
if a:link =~ '|'
|
if a:link =~ '|'
|
||||||
let result = vimwiki#safe_link(split(a:link, '|')[0])
|
let result = vimwiki#base#safe_link(split(a:link, '|')[0])
|
||||||
elseif a:link =~ ']['
|
elseif a:link =~ ']['
|
||||||
let result = vimwiki#safe_link(split(a:link, '][')[0])
|
let result = vimwiki#base#safe_link(split(a:link, '][')[0])
|
||||||
endif
|
endif
|
||||||
return result
|
return result
|
||||||
endfunction
|
endfunction
|
||||||
@@ -191,10 +216,15 @@ function! s:is_wiki_word(str) "{{{
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! s:edit_file(command, filename) "{{{
|
function! vimwiki#base#edit_file(command, filename) "{{{
|
||||||
let fname = escape(a:filename, '% ')
|
let fname = escape(a:filename, '% ')
|
||||||
call vimwiki#mkdir(fnamemodify(a:filename, ":p:h"))
|
call vimwiki#base#mkdir(fnamemodify(a:filename, ":p:h"))
|
||||||
|
try
|
||||||
execute a:command.' '.fname
|
execute a:command.' '.fname
|
||||||
|
catch /E37/ " catch 'No write since last change' error
|
||||||
|
execute ':split '.fname
|
||||||
|
catch /E325/ " catch 'ATTENTION' error (:h E325)
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
@@ -242,13 +272,13 @@ function! s:strip_word(word) "{{{
|
|||||||
let w = split(w, "][")[0]
|
let w = split(w, "][")[0]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let result = vimwiki#safe_link(w)
|
let result = vimwiki#base#safe_link(w)
|
||||||
endif
|
endif
|
||||||
return result
|
return result
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! vimwiki#is_non_wiki_link(lnk) "{{{
|
function! vimwiki#base#is_non_wiki_link(lnk) "{{{
|
||||||
let exts = '.\+\.\%('.
|
let exts = '.\+\.\%('.
|
||||||
\ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
|
\ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
|
||||||
\ '\)$'
|
\ '\)$'
|
||||||
@@ -258,7 +288,7 @@ function! vimwiki#is_non_wiki_link(lnk) "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#is_link_to_dir(link) "{{{
|
function! vimwiki#base#is_link_to_dir(link) "{{{
|
||||||
" Check if link is to a directory.
|
" Check if link is to a directory.
|
||||||
" It should be ended with \ or /.
|
" It should be ended with \ or /.
|
||||||
if a:link =~ '.\+[/\\]$'
|
if a:link =~ '.\+[/\\]$'
|
||||||
@@ -314,10 +344,10 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if !s:is_wiki_word(old_fname)
|
if !s:is_wiki_word(old_fname)
|
||||||
let old_fname_r = '\[\[\zs'.vimwiki#unsafe_link(old_fname).
|
let old_fname_r = '\[\[\zs'.vimwiki#base#unsafe_link(old_fname).
|
||||||
\ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]'
|
\ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]'
|
||||||
else
|
else
|
||||||
let old_fname_r = '\<'.old_fname.'\>'
|
let old_fname_r = '!\@<!\<'.old_fname.'\>'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
|
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
|
||||||
@@ -383,7 +413,7 @@ function! s:get_wiki_buffers() "{{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:open_wiki_buffer(item) "{{{
|
function! s:open_wiki_buffer(item) "{{{
|
||||||
call s:edit_file('e', a:item[0])
|
call vimwiki#base#edit_file(':e', a:item[0])
|
||||||
if !empty(a:item[1])
|
if !empty(a:item[1])
|
||||||
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
|
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
|
||||||
endif
|
endif
|
||||||
@@ -392,7 +422,7 @@ endfunction " }}}
|
|||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" SYNTAX highlight {{{
|
" SYNTAX highlight {{{
|
||||||
function! vimwiki#highlight_links() "{{{
|
function! vimwiki#base#highlight_links() "{{{
|
||||||
try
|
try
|
||||||
syntax clear VimwikiNoExistsLink
|
syntax clear VimwikiNoExistsLink
|
||||||
syntax clear VimwikiNoExistsLinkT
|
syntax clear VimwikiNoExistsLinkT
|
||||||
@@ -442,21 +472,21 @@ function! s:highlight_existed_links() "{{{
|
|||||||
|
|
||||||
for link in links
|
for link in links
|
||||||
if g:vimwiki_camel_case &&
|
if g:vimwiki_camel_case &&
|
||||||
\ link =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link)
|
\ link =~ g:vimwiki_rxWikiWord && !vimwiki#base#is_non_wiki_link(link)
|
||||||
execute 'syntax match VimwikiLink /!\@<!\<'.link.'\>/ display'
|
execute 'syntax match VimwikiLink /!\@<!\<'.link.'\>/ display'
|
||||||
endif
|
endif
|
||||||
execute 'syntax match VimwikiLink /\[\['.
|
execute 'syntax match VimwikiLink /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||||
\ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar'
|
\ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar'
|
||||||
execute 'syntax match VimwikiLink /\[\['.
|
execute 'syntax match VimwikiLink /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||||
\ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar'
|
\ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar'
|
||||||
|
|
||||||
execute 'syntax match VimwikiLinkT /\[\['.
|
execute 'syntax match VimwikiLinkT /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||||
\ '\%(|\+.\{-}\)\{-}\]\]/ display contained'
|
\ '\%(|\+.\{-}\)\{-}\]\]/ display contained'
|
||||||
execute 'syntax match VimwikiLinkT /\[\['.
|
execute 'syntax match VimwikiLinkT /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||||
\ '\]\[.\{-1,}\]\]/ display contained'
|
\ '\]\[.\{-1,}\]\]/ display contained'
|
||||||
endfor
|
endfor
|
||||||
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
||||||
@@ -485,76 +515,22 @@ function! s:highlight_existed_links() "{{{
|
|||||||
call map(dirs, 'substitute(v:val, os_p, os_p2, "g")')
|
call map(dirs, 'substitute(v:val, os_p, os_p2, "g")')
|
||||||
for dir in dirs
|
for dir in dirs
|
||||||
execute 'syntax match VimwikiLink /\[\['.
|
execute 'syntax match VimwikiLink /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||||
\ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
\ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
||||||
execute 'syntax match VimwikiLink /\[\['.
|
execute 'syntax match VimwikiLink /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||||
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
||||||
|
|
||||||
execute 'syntax match VimwikiLinkT /\[\['.
|
execute 'syntax match VimwikiLinkT /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||||
\ '[/\\]*\%(|\+.*\)*\]\]/ display contained'
|
\ '[/\\]*\%(|\+.*\)*\]\]/ display contained'
|
||||||
execute 'syntax match VimwikiLinkT /\[\['.
|
execute 'syntax match VimwikiLinkT /\[\['.
|
||||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||||
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contained'
|
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contained'
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#setup_colors() "{{{
|
function! vimwiki#base#hl_exists(hl) "{{{
|
||||||
|
|
||||||
function! s:set_visible_ignore_color() "{{{
|
|
||||||
if !exists("g:colors_name") || g:colors_name == 'default'
|
|
||||||
if &background == 'light'
|
|
||||||
hi VimwikiIgnore guifg=#d0d0d0
|
|
||||||
else
|
|
||||||
hi VimwikiIgnore guifg=#505050
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
hi link VimwikiIgnore Normal
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
let hlfg_ignore = vimwiki#get_hl_param('Ignore', 'guifg')
|
|
||||||
let hlbg_normal = vimwiki#get_hl_param('Normal', 'guibg')
|
|
||||||
if hlfg_ignore == 'bg' || hlfg_ignore == hlbg_normal
|
|
||||||
call s:set_visible_ignore_color()
|
|
||||||
else
|
|
||||||
hi link VimwikiIgnore Ignore
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:vimwiki_hl_headers == 0
|
|
||||||
hi def link VimwikiHeader Title
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if &background == 'light'
|
|
||||||
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed
|
|
||||||
hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen
|
|
||||||
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue
|
|
||||||
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black
|
|
||||||
hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black
|
|
||||||
hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black
|
|
||||||
else
|
|
||||||
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red
|
|
||||||
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green
|
|
||||||
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue
|
|
||||||
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White
|
|
||||||
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White
|
|
||||||
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function vimwiki#get_hl_param(hgroup, hparam) "{{{
|
|
||||||
redir => hlstatus
|
|
||||||
try
|
|
||||||
exe "silent hi ".a:hgroup
|
|
||||||
catch /E411/
|
|
||||||
endtry
|
|
||||||
redir END
|
|
||||||
return matchstr(hlstatus, a:hparam.'\s*=\s*\zs\S\+')
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! vimwiki#hl_exists(hl) "{{{
|
|
||||||
if !hlexists(a:hl)
|
if !hlexists(a:hl)
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
@@ -565,7 +541,7 @@ function! vimwiki#hl_exists(hl) "{{{
|
|||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! vimwiki#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
||||||
" From http://vim.wikia.com/wiki/VimTip857
|
" From http://vim.wikia.com/wiki/VimTip857
|
||||||
let ft=toupper(a:filetype)
|
let ft=toupper(a:filetype)
|
||||||
let group='textGroup'.ft
|
let group='textGroup'.ft
|
||||||
@@ -615,21 +591,23 @@ endfunction "}}}
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" WIKI functions {{{
|
" WIKI functions {{{
|
||||||
function! vimwiki#find_next_link() "{{{
|
function! vimwiki#base#find_next_link() "{{{
|
||||||
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '')
|
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '')
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! vimwiki#find_prev_link() "{{{
|
function! vimwiki#base#find_prev_link() "{{{
|
||||||
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b')
|
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b')
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function! vimwiki#follow_link(split) "{{{
|
function! vimwiki#base#follow_link(split) "{{{
|
||||||
if a:split == "split"
|
if a:split == "split"
|
||||||
let cmd = ":split "
|
let cmd = ":split "
|
||||||
elseif a:split == "vsplit"
|
elseif a:split == "vsplit"
|
||||||
let cmd = ":vsplit "
|
let cmd = ":vsplit "
|
||||||
|
elseif a:split == "tabnew"
|
||||||
|
let cmd = ":tabnew "
|
||||||
else
|
else
|
||||||
let cmd = ":e "
|
let cmd = ":e "
|
||||||
endif
|
endif
|
||||||
@@ -645,12 +623,12 @@ function! vimwiki#follow_link(split) "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let subdir = vimwiki#current_subdir()
|
let subdir = vimwiki#base#current_subdir()
|
||||||
call vimwiki#open_link(cmd, subdir.link)
|
call vimwiki#base#open_link(cmd, subdir.link)
|
||||||
|
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! vimwiki#go_back_link() "{{{
|
function! vimwiki#base#go_back_link() "{{{
|
||||||
if exists("b:vimwiki_prev_link")
|
if exists("b:vimwiki_prev_link")
|
||||||
" go back to saved WikiWord
|
" go back to saved WikiWord
|
||||||
let prev_word = b:vimwiki_prev_link
|
let prev_word = b:vimwiki_prev_link
|
||||||
@@ -659,23 +637,13 @@ function! vimwiki#go_back_link() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! vimwiki#goto_index(index) "{{{
|
function! vimwiki#base#goto_index(index) "{{{
|
||||||
call vimwiki#select(a:index)
|
call vimwiki#base#select(a:index)
|
||||||
call vimwiki#mkdir(VimwikiGet('path'))
|
call vimwiki#base#edit_file('e',
|
||||||
|
|
||||||
try
|
|
||||||
execute ':e '.fnameescape(
|
|
||||||
\ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext'))
|
\ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext'))
|
||||||
catch /E37/ " catch 'No write since last change' error
|
|
||||||
execute ':split '.
|
|
||||||
\ VimwikiGet('path').
|
|
||||||
\ VimwikiGet('index').
|
|
||||||
\ VimwikiGet('ext')
|
|
||||||
catch /E325/ " catch 'ATTENTION' error (:h E325)
|
|
||||||
endtry
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#delete_link() "{{{
|
function! vimwiki#base#delete_link() "{{{
|
||||||
"" file system funcs
|
"" file system funcs
|
||||||
"" Delete WikiWord you are in from filesystem
|
"" Delete WikiWord you are in from filesystem
|
||||||
let val = input('Delete ['.expand('%').'] (y/n)? ', "")
|
let val = input('Delete ['.expand('%').'] (y/n)? ', "")
|
||||||
@@ -697,9 +665,9 @@ function! vimwiki#delete_link() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#rename_link() "{{{
|
function! vimwiki#base#rename_link() "{{{
|
||||||
"" Rename WikiWord, update all links to renamed WikiWord
|
"" Rename WikiWord, update all links to renamed WikiWord
|
||||||
let subdir = vimwiki#current_subdir()
|
let subdir = vimwiki#base#current_subdir()
|
||||||
let old_fname = subdir.expand('%:t')
|
let old_fname = subdir.expand('%:t')
|
||||||
|
|
||||||
" there is no file (new one maybe)
|
" there is no file (new one maybe)
|
||||||
@@ -727,7 +695,7 @@ function! vimwiki#rename_link() "{{{
|
|||||||
echomsg 'vimwiki: Cannot rename to an empty filename!'
|
echomsg 'vimwiki: Cannot rename to an empty filename!'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if vimwiki#is_non_wiki_link(new_link)
|
if vimwiki#base#is_non_wiki_link(new_link)
|
||||||
echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!'
|
echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -797,13 +765,13 @@ function! vimwiki#rename_link() "{{{
|
|||||||
let &more = setting_more
|
let &more = setting_more
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! vimwiki#ui_select()"{{{
|
function! vimwiki#base#ui_select()"{{{
|
||||||
call s:print_wiki_list()
|
call s:print_wiki_list()
|
||||||
let idx = input("Select Wiki (specify number): ")
|
let idx = input("Select Wiki (specify number): ")
|
||||||
if idx == ""
|
if idx == ""
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call vimwiki#goto_index(idx)
|
call vimwiki#base#goto_index(idx)
|
||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
@@ -811,7 +779,7 @@ endfunction
|
|||||||
|
|
||||||
" TEXT OBJECTS functions {{{
|
" TEXT OBJECTS functions {{{
|
||||||
|
|
||||||
function! vimwiki#TO_header(inner, visual) "{{{
|
function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||||
if !search('^\(=\+\).\+\1\s*$', 'bcW')
|
if !search('^\(=\+\).\+\1\s*$', 'bcW')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -821,7 +789,7 @@ function! vimwiki#TO_header(inner, visual) "{{{
|
|||||||
let block_start = line(".")
|
let block_start = line(".")
|
||||||
let advance = 0
|
let advance = 0
|
||||||
|
|
||||||
let level = vimwiki#count_first_sym(getline('.'))
|
let level = vimwiki#base#count_first_sym(getline('.'))
|
||||||
|
|
||||||
let is_header_selected = sel_start == block_start
|
let is_header_selected = sel_start == block_start
|
||||||
\ && sel_start != sel_end
|
\ && sel_start != sel_end
|
||||||
@@ -854,7 +822,7 @@ function! vimwiki#TO_header(inner, visual) "{{{
|
|||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! vimwiki#TO_table_cell(inner, visual) "{{{
|
function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
||||||
if col('.') == col('$')-1
|
if col('.') == col('$')-1
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -918,7 +886,7 @@ function! vimwiki#TO_table_cell(inner, visual) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#TO_table_col(inner, visual) "{{{
|
function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||||
let t_rows = vimwiki_tbl#get_rows(line('.'))
|
let t_rows = vimwiki_tbl#get_rows(line('.'))
|
||||||
if empty(t_rows)
|
if empty(t_rows)
|
||||||
return
|
return
|
||||||
@@ -1032,12 +1000,12 @@ function! vimwiki#TO_table_col(inner, visual) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#count_first_sym(line) "{{{
|
function! vimwiki#base#count_first_sym(line) "{{{
|
||||||
let first_sym = matchstr(a:line, '\S')
|
let first_sym = matchstr(a:line, '\S')
|
||||||
return len(matchstr(a:line, first_sym.'\+'))
|
return len(matchstr(a:line, first_sym.'\+'))
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#AddHeaderLevel() "{{{
|
function! vimwiki#base#AddHeaderLevel() "{{{
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
|
|
||||||
@@ -1046,7 +1014,7 @@ function! vimwiki#AddHeaderLevel() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if line =~ '^\s*\(=\+\).\+\1\s*$'
|
if line =~ '^\s*\(=\+\).\+\1\s*$'
|
||||||
let level = vimwiki#count_first_sym(line)
|
let level = vimwiki#base#count_first_sym(line)
|
||||||
if level < 6
|
if level < 6
|
||||||
let line = substitute(line, '\(=\+\).\+\1', '=&=', '')
|
let line = substitute(line, '\(=\+\).\+\1', '=&=', '')
|
||||||
call setline(lnum, line)
|
call setline(lnum, line)
|
||||||
@@ -1059,7 +1027,7 @@ function! vimwiki#AddHeaderLevel() "{{{
|
|||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! vimwiki#RemoveHeaderLevel() "{{{
|
function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
|
|
||||||
@@ -1068,7 +1036,7 @@ function! vimwiki#RemoveHeaderLevel() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if line =~ '^\s*\(=\+\).\+\1\s*$'
|
if line =~ '^\s*\(=\+\).\+\1\s*$'
|
||||||
let level = vimwiki#count_first_sym(line)
|
let level = vimwiki#base#count_first_sym(line)
|
||||||
let old = repeat('=', level)
|
let old = repeat('=', level)
|
||||||
let new = repeat('=', level - 1)
|
let new = repeat('=', level - 1)
|
||||||
|
|
||||||
11
autoload/vimwiki/default.tpl
Normal file
11
autoload/vimwiki/default.tpl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
|
||||||
|
<title>%title%</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
%content%
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -197,19 +197,24 @@ function! s:make_date_link(...) "{{{
|
|||||||
return VimwikiGet('diary_rel_path').link
|
return VimwikiGet('diary_rel_path').link
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_diary#make_note(index, ...) "{{{
|
function! vimwiki#diary#make_note(index, ...) "{{{
|
||||||
call vimwiki#select(a:index)
|
call vimwiki#base#select(a:index)
|
||||||
call vimwiki#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path'))
|
call vimwiki#base#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path'))
|
||||||
if a:0
|
if a:0
|
||||||
let link = s:make_date_link(a:1)
|
let link = s:make_date_link(a:1)
|
||||||
else
|
else
|
||||||
let link = s:make_date_link()
|
let link = s:make_date_link()
|
||||||
endif
|
endif
|
||||||
call vimwiki#open_link(':e ', link, s:diary_index())
|
call vimwiki#base#open_link(':e ', link, s:diary_index())
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! vimwiki#diary#goto_index(index) "{{{
|
||||||
|
call vimwiki#base#select(a:index)
|
||||||
|
call vimwiki#base#edit_file(':e', s:diary_index())
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
" Calendar.vim callback function.
|
" Calendar.vim callback function.
|
||||||
function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{
|
function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||||
let day = s:prefix_zero(a:day)
|
let day = s:prefix_zero(a:day)
|
||||||
let month = s:prefix_zero(a:month)
|
let month = s:prefix_zero(a:month)
|
||||||
|
|
||||||
@@ -228,11 +233,11 @@ function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Create diary note for a selected date in default wiki.
|
" Create diary note for a selected date in default wiki.
|
||||||
call vimwiki_diary#make_note(1, link)
|
call vimwiki#diary#make_note(1, link)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
" Calendar.vim sign function.
|
" Calendar.vim sign function.
|
||||||
function vimwiki_diary#calendar_sign(day, month, year) "{{{
|
function vimwiki#diary#calendar_sign(day, month, year) "{{{
|
||||||
let day = s:prefix_zero(a:day)
|
let day = s:prefix_zero(a:day)
|
||||||
let month = s:prefix_zero(a:month)
|
let month = s:prefix_zero(a:month)
|
||||||
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
|
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
|
||||||
@@ -240,7 +245,7 @@ function vimwiki_diary#calendar_sign(day, month, year) "{{{
|
|||||||
return filereadable(expand(sfile))
|
return filereadable(expand(sfile))
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_diary#goto_next_day() "{{{
|
function! vimwiki#diary#goto_next_day() "{{{
|
||||||
let link = ''
|
let link = ''
|
||||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||||
|
|
||||||
@@ -256,11 +261,11 @@ function! vimwiki_diary#goto_next_day() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if len(link)
|
if len(link)
|
||||||
call vimwiki#open_link(':e ', link)
|
call vimwiki#base#open_link(':e ', link)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_diary#goto_prev_day() "{{{
|
function! vimwiki#diary#goto_prev_day() "{{{
|
||||||
let link = ''
|
let link = ''
|
||||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||||
|
|
||||||
@@ -276,6 +281,6 @@ function! vimwiki_diary#goto_prev_day() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if len(link)
|
if len(link)
|
||||||
call vimwiki#open_link(':e ', link)
|
call vimwiki#base#open_link(':e ', link)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@@ -13,12 +13,6 @@ endif
|
|||||||
let g:loaded_vimwiki_html_auto = 1
|
let g:loaded_vimwiki_html_auto = 1
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" SCRIPT VARS "{{{
|
|
||||||
" Warn if html header or html footer do not exist only once.
|
|
||||||
let s:warn_html_header = 0
|
|
||||||
let s:warn_html_footer = 0
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" UTILITY "{{{
|
" UTILITY "{{{
|
||||||
function! s:root_path(subdir) "{{{
|
function! s:root_path(subdir) "{{{
|
||||||
return repeat('../', len(split(a:subdir, '[/\\]')))
|
return repeat('../', len(split(a:subdir, '[/\\]')))
|
||||||
@@ -35,7 +29,7 @@ function! s:remove_blank_lines(lines) " {{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_web_link(lnk) "{{{
|
function! s:is_web_link(lnk) "{{{
|
||||||
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\)'
|
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\|mailto:\)'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@@ -55,104 +49,69 @@ function! s:has_abs_path(fname) "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:find_autoload_file(name) " {{{
|
||||||
|
for path in split(&runtimepath, ',')
|
||||||
|
let fname = path.'/autoload/vimwiki/'.a:name
|
||||||
|
if glob(fname) != ''
|
||||||
|
return fname
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return ''
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:create_default_CSS(path) " {{{
|
function! s:create_default_CSS(path) " {{{
|
||||||
let path = expand(a:path)
|
let path = expand(a:path)
|
||||||
let css_full_name = path.VimwikiGet('css_name')
|
let css_full_name = path.VimwikiGet('css_name')
|
||||||
if glob(css_full_name) == ""
|
if glob(css_full_name) == ""
|
||||||
call vimwiki#mkdir(fnamemodify(css_full_name, ':p:h'))
|
call vimwiki#base#mkdir(fnamemodify(css_full_name, ':p:h'))
|
||||||
let lines = []
|
let default_css = s:find_autoload_file('style.css')
|
||||||
|
if default_css != ''
|
||||||
call add(lines, 'body {font-family: Tahoma, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}')
|
let lines = readfile(default_css)
|
||||||
call add(lines, 'h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, serif; margin-top: 1.5em; margin-bottom: 0.5em;}')
|
|
||||||
call add(lines, 'h1 {font-size: 2.0em; color: #a77070;}')
|
|
||||||
call add(lines, 'h2 {font-size: 1.6em; color: #779977;}')
|
|
||||||
call add(lines, 'h3 {font-size: 1.3em; color: #555577;}')
|
|
||||||
call add(lines, 'h4 {font-size: 1.2em; color: #222244;}')
|
|
||||||
call add(lines, 'h5 {font-size: 1.1em; color: #222244;}')
|
|
||||||
call add(lines, 'h6 {font-size: 1.0em; color: #222244;}')
|
|
||||||
call add(lines, 'p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}')
|
|
||||||
call add(lines, 'ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}')
|
|
||||||
call add(lines, 'li {margin: 0.3em auto;}')
|
|
||||||
call add(lines, 'ul {margin-left: 2em; padding-left: 0.5em;}')
|
|
||||||
call add(lines, 'dt {font-weight: bold;}')
|
|
||||||
call add(lines, 'img {border: none;}')
|
|
||||||
call add(lines, 'pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}')
|
|
||||||
call add(lines, 'blockquote {padding: 0.4em; background-color: #f6f5eb;}')
|
|
||||||
call add(lines, 'th, td {border: 1px solid #ccc; padding: 0.3em;}')
|
|
||||||
call add(lines, 'th {background-color: #f0f0f0;}')
|
|
||||||
call add(lines, 'hr {border: none; border-top: 1px solid #ccc; width: 100%;}')
|
|
||||||
call add(lines, 'del {text-decoration: line-through; color: #777777;}')
|
|
||||||
call add(lines, '.toc li {list-style-type: none;}')
|
|
||||||
call add(lines, '.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}')
|
|
||||||
call add(lines, '.justleft {text-align: left;}')
|
|
||||||
call add(lines, '.justright {text-align: right;}')
|
|
||||||
call add(lines, '.justcenter {text-align: center;}')
|
|
||||||
call add(lines, '.center {margin-left: auto; margin-right: auto;}')
|
|
||||||
|
|
||||||
call writefile(lines, css_full_name)
|
call writefile(lines, css_full_name)
|
||||||
echomsg "Default style.css is created."
|
echomsg "Default style.css has been created."
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:get_html_header(title, subdir, charset) "{{{
|
function! s:template_full_name(name) "{{{
|
||||||
|
if a:name == ''
|
||||||
|
let name = VimwikiGet('template_default')
|
||||||
|
else
|
||||||
|
let name = a:name
|
||||||
|
endif
|
||||||
|
|
||||||
|
let fname = expand(VimwikiGet('template_path').
|
||||||
|
\name.
|
||||||
|
\VimwikiGet('template_ext'))
|
||||||
|
|
||||||
|
if filereadable(fname)
|
||||||
|
return fname
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:get_html_template(wikifile, template) "{{{
|
||||||
|
" TODO: refactor it!!!
|
||||||
let lines=[]
|
let lines=[]
|
||||||
|
|
||||||
if VimwikiGet('html_header') != "" && !s:warn_html_header
|
let template_name = s:template_full_name(a:template)
|
||||||
|
if template_name != ''
|
||||||
try
|
try
|
||||||
let lines = readfile(expand(VimwikiGet('html_header')))
|
let lines = readfile(template_name)
|
||||||
call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")')
|
|
||||||
call map(lines, 'substitute(v:val, "%root_path%", "'.
|
|
||||||
\ s:root_path(a:subdir) .'", "g")')
|
|
||||||
return lines
|
return lines
|
||||||
catch /E484/
|
catch /E484/
|
||||||
let s:warn_html_header = 1
|
echomsg 'vimwiki: html template '.template_name.
|
||||||
echomsg 'vimwiki: Header template '.VimwikiGet('html_header').
|
|
||||||
\ ' does not exist!'
|
\ ' does not exist!'
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let css_name = expand(VimwikiGet('css_name'))
|
" if no VimwikiGet('html_template') set up or error while reading template
|
||||||
let css_name = substitute(css_name, '\', '/', 'g')
|
" file -- use default one.
|
||||||
if !s:has_abs_path(css_name)
|
let default_tpl = s:find_autoload_file('default.tpl')
|
||||||
" Relative css file for deep links: [[dir1/dir2/dir3/filename]]
|
if default_tpl != ''
|
||||||
let css_name = s:root_path(a:subdir).css_name
|
let lines = readfile(default_tpl)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" if no VimwikiGet('html_header') set up or error while reading template
|
|
||||||
" file -- use default header.
|
|
||||||
call add(lines, '<html>')
|
|
||||||
call add(lines, '<head>')
|
|
||||||
call add(lines, '<link rel="Stylesheet" type="text/css" href="'.
|
|
||||||
\ css_name.'" />')
|
|
||||||
call add(lines, '<title>'.a:title.'</title>')
|
|
||||||
call add(lines, '<meta http-equiv="Content-Type" content="text/html;'.
|
|
||||||
\ ' charset='.a:charset.'" />')
|
|
||||||
call add(lines, '</head>')
|
|
||||||
call add(lines, '<body>')
|
|
||||||
|
|
||||||
return lines
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! s:get_html_footer() "{{{
|
|
||||||
let lines=[]
|
|
||||||
|
|
||||||
if VimwikiGet('html_footer') != "" && !s:warn_html_footer
|
|
||||||
try
|
|
||||||
let lines = readfile(expand(VimwikiGet('html_footer')))
|
|
||||||
return lines
|
|
||||||
catch /E484/
|
|
||||||
let s:warn_html_footer = 1
|
|
||||||
echomsg 'vimwiki: Footer template '.VimwikiGet('html_footer').
|
|
||||||
\ ' does not exist!'
|
|
||||||
endtry
|
|
||||||
endif
|
|
||||||
|
|
||||||
" if no VimwikiGet('html_footer') set up or error while reading template
|
|
||||||
" file -- use default footer.
|
|
||||||
call add(lines, "")
|
|
||||||
call add(lines, '</body>')
|
|
||||||
call add(lines, '</html>')
|
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
@@ -174,6 +133,19 @@ endfunction "}}}
|
|||||||
function! s:delete_html_files(path) "{{{
|
function! s:delete_html_files(path) "{{{
|
||||||
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
|
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
|
||||||
for fname in htmlfiles
|
for fname in htmlfiles
|
||||||
|
" ignore user html files, e.g. search.html,404.html
|
||||||
|
if stridx(g:vimwiki_user_htmls, fnamemodify(fname, ":t")) >= 0
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
" delete if there is no corresponding wiki file
|
||||||
|
let subdir = vimwiki#base#subdir(VimwikiGet('path_html'), fname)
|
||||||
|
let wikifile = VimwikiGet("path").subdir.
|
||||||
|
\fnamemodify(fname, ":t:r").VimwikiGet("ext")
|
||||||
|
if filereadable(wikifile)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
try
|
try
|
||||||
call delete(fname)
|
call delete(fname)
|
||||||
catch
|
catch
|
||||||
@@ -182,45 +154,6 @@ function! s:delete_html_files(path) "{{{
|
|||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:remove_comments(lines) "{{{
|
|
||||||
let res = []
|
|
||||||
let multiline_comment = 0
|
|
||||||
|
|
||||||
let idx = 0
|
|
||||||
while idx < len(a:lines)
|
|
||||||
let line = a:lines[idx]
|
|
||||||
let idx += 1
|
|
||||||
|
|
||||||
if multiline_comment
|
|
||||||
let col = matchend(line, '-->',)
|
|
||||||
if col != -1
|
|
||||||
let multiline_comment = 0
|
|
||||||
let line = strpart(line, col)
|
|
||||||
else
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !multiline_comment && line =~ '<!--.*-->'
|
|
||||||
let line = substitute(line, '<!--.*-->', '', 'g')
|
|
||||||
if line =~ '^\s*$'
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !multiline_comment
|
|
||||||
let col = match(line, '<!--',)
|
|
||||||
if col != -1
|
|
||||||
let multiline_comment = 1
|
|
||||||
let line = strpart(line, 1, col - 1)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(res, line)
|
|
||||||
endwhile
|
|
||||||
return res
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! s:mid(value, cnt) "{{{
|
function! s:mid(value, cnt) "{{{
|
||||||
return strpart(a:value, a:cnt, len(a:value) - 2 * a:cnt)
|
return strpart(a:value, a:cnt, len(a:value) - 2 * a:cnt)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@@ -283,7 +216,7 @@ function! s:get_html_toc(toc_list) "{{{
|
|||||||
|
|
||||||
let toc_text = s:process_tags_remove_links(text)
|
let toc_text = s:process_tags_remove_links(text)
|
||||||
let toc_text = s:process_tags_typefaces(toc_text)
|
let toc_text = s:process_tags_typefaces(toc_text)
|
||||||
call add(toc, '<li><a href="#'.id.'">'.toc_text.'</a></li>')
|
call add(toc, '<li><a href="#'.id.'">'.toc_text.'</a>')
|
||||||
let plevel = level
|
let plevel = level
|
||||||
endfor
|
endfor
|
||||||
call s:close_list(toc, level, 0)
|
call s:close_list(toc, level, 0)
|
||||||
@@ -293,6 +226,7 @@ endfunction "}}}
|
|||||||
|
|
||||||
" insert toc into dest.
|
" insert toc into dest.
|
||||||
function! s:process_toc(dest, placeholders, toc) "{{{
|
function! s:process_toc(dest, placeholders, toc) "{{{
|
||||||
|
let toc_idx = 0
|
||||||
if !empty(a:placeholders)
|
if !empty(a:placeholders)
|
||||||
for [placeholder, row, idx] in a:placeholders
|
for [placeholder, row, idx] in a:placeholders
|
||||||
let [type, param] = placeholder
|
let [type, param] = placeholder
|
||||||
@@ -301,8 +235,9 @@ function! s:process_toc(dest, placeholders, toc) "{{{
|
|||||||
if !empty(param)
|
if !empty(param)
|
||||||
call insert(toc, '<h1>'.param.'</h1>')
|
call insert(toc, '<h1>'.param.'</h1>')
|
||||||
endif
|
endif
|
||||||
let shift = idx * len(toc)
|
let shift = toc_idx * len(toc)
|
||||||
call extend(a:dest, toc, row + shift)
|
call extend(a:dest, toc, row + shift)
|
||||||
|
let toc_idx += 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
@@ -321,6 +256,46 @@ function! s:process_title(placeholders, default_title) "{{{
|
|||||||
return a:default_title
|
return a:default_title
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:is_html_uptodate(wikifile) "{{{
|
||||||
|
let tpl_time = -1
|
||||||
|
|
||||||
|
let tpl_file = s:template_full_name('')
|
||||||
|
if tpl_file != ''
|
||||||
|
let tpl_time = getftime(tpl_file)
|
||||||
|
endif
|
||||||
|
|
||||||
|
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||||
|
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||||
|
let htmlfile = expand(VimwikiGet('path_html').subdir.
|
||||||
|
\fnamemodify(wikifile, ":t:r").".html")
|
||||||
|
|
||||||
|
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:html_insert_contents(html_lines, content) "{{{
|
||||||
|
let lines = []
|
||||||
|
for line in a:html_lines
|
||||||
|
if line =~ '%content%'
|
||||||
|
let parts = split(line, '%content%', 1)
|
||||||
|
if empty(parts)
|
||||||
|
call extend(lines, a:content)
|
||||||
|
else
|
||||||
|
for idx in range(len(parts))
|
||||||
|
call add(lines, parts[idx])
|
||||||
|
if idx < len(parts) - 1
|
||||||
|
call extend(lines, a:content)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
call add(lines, line)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return lines
|
||||||
|
endfunction "}}}
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" INLINE TAGS "{{{
|
" INLINE TAGS "{{{
|
||||||
@@ -376,19 +351,19 @@ function! s:tag_internal_link(value) "{{{
|
|||||||
if s:is_img_link(a:caption)
|
if s:is_img_link(a:caption)
|
||||||
let link = '<a href="'.a:src.'"><img src="'.a:caption.'"'.style_str.' />'.
|
let link = '<a href="'.a:src.'"><img src="'.a:caption.'"'.style_str.' />'.
|
||||||
\ '</a>'
|
\ '</a>'
|
||||||
elseif vimwiki#is_non_wiki_link(a:src)
|
elseif vimwiki#base#is_non_wiki_link(a:src)
|
||||||
let link = '<a href="'.a:src.'">'.a:caption.'</a>'
|
let link = '<a href="'.a:src.'">'.a:caption.'</a>'
|
||||||
elseif s:is_img_link(a:src)
|
elseif s:is_img_link(a:src)
|
||||||
let link = '<img src="'.a:src.'" alt="'.a:caption.'"'. style_str.' />'
|
let link = '<img src="'.a:src.'" alt="'.a:caption.'"'. style_str.' />'
|
||||||
elseif vimwiki#is_link_to_dir(a:src)
|
elseif vimwiki#base#is_link_to_dir(a:src)
|
||||||
if g:vimwiki_dir_link == ''
|
if g:vimwiki_dir_link == ''
|
||||||
let link = '<a href="'.vimwiki#safe_link(a:src).'">'.a:caption.'</a>'
|
let link = '<a href="'.vimwiki#base#safe_link(a:src).'">'.a:caption.'</a>'
|
||||||
else
|
else
|
||||||
let link = '<a href="'.vimwiki#safe_link(a:src).
|
let link = '<a href="'.vimwiki#base#safe_link(a:src).
|
||||||
\ g:vimwiki_dir_link.'.html">'.a:caption.'</a>'
|
\ g:vimwiki_dir_link.'.html">'.a:caption.'</a>'
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let link = '<a href="'.vimwiki#safe_link(a:src).
|
let link = '<a href="'.vimwiki#base#safe_link(a:src).
|
||||||
\ '.html">'.a:caption.'</a>'
|
\ '.html">'.a:caption.'</a>'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -574,8 +549,6 @@ function! s:process_tags_typefaces(line) "{{{
|
|||||||
let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super')
|
let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super')
|
||||||
let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
|
let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
|
||||||
let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
|
let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
|
||||||
let line = s:make_tag(line, g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd,
|
|
||||||
\ 's:tag_pre')
|
|
||||||
return line
|
return line
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
@@ -624,13 +597,100 @@ function! s:close_tag_table(table, ldest) "{{{
|
|||||||
" The first element of table list is a string which tells us if table should be centered.
|
" The first element of table list is a string which tells us if table should be centered.
|
||||||
" The rest elements are rows which are lists of columns:
|
" The rest elements are rows which are lists of columns:
|
||||||
" ['center',
|
" ['center',
|
||||||
" ['col1', 'col2', 'col3'],
|
" [ CELL1, CELL2, CELL3 ],
|
||||||
" ['col1', 'col2', 'col3'],
|
" [ CELL1, CELL2, CELL3 ],
|
||||||
" ['col1', 'col2', 'col3']
|
" [ CELL1, CELL2, CELL3 ],
|
||||||
" ]
|
" ]
|
||||||
|
" And CELLx is: { 'body': 'col_x', 'rowspan': r, 'colspan': c }
|
||||||
|
|
||||||
|
function! s:sum_rowspan(table) "{{{
|
||||||
|
let table = a:table
|
||||||
|
|
||||||
|
" Get max cells
|
||||||
|
let max_cells = 0
|
||||||
|
for row in table[1:]
|
||||||
|
let n_cells = len(row)
|
||||||
|
if n_cells > max_cells
|
||||||
|
let max_cells = n_cells
|
||||||
|
end
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" Sum rowspan
|
||||||
|
for cell_idx in range(max_cells)
|
||||||
|
let rows = 1
|
||||||
|
|
||||||
|
for row_idx in range(len(table)-1, 1, -1)
|
||||||
|
if cell_idx >= len(table[row_idx])
|
||||||
|
let rows = 1
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
if table[row_idx][cell_idx].rowspan == 0
|
||||||
|
let rows += 1
|
||||||
|
else " table[row_idx][cell_idx].rowspan == 1
|
||||||
|
let table[row_idx][cell_idx].rowspan = rows
|
||||||
|
let rows = 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:sum_colspan(table) "{{{
|
||||||
|
for row in a:table[1:]
|
||||||
|
let cols = 1
|
||||||
|
|
||||||
|
for cell_idx in range(len(row)-1, 0, -1)
|
||||||
|
if row[cell_idx].colspan == 0
|
||||||
|
let cols += 1
|
||||||
|
else "row[cell_idx].colspan == 1
|
||||||
|
let row[cell_idx].colspan = cols
|
||||||
|
let cols = 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:close_tag_row(row, header, ldest) "{{{
|
||||||
|
call add(a:ldest, '<tr>')
|
||||||
|
|
||||||
|
" Set tag element of columns
|
||||||
|
if a:header
|
||||||
|
let tag_name = 'th'
|
||||||
|
else
|
||||||
|
let tag_name = 'td'
|
||||||
|
end
|
||||||
|
|
||||||
|
" Close tag of columns
|
||||||
|
for cell in a:row
|
||||||
|
if cell.rowspan == 0 || cell.colspan == 0
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
if cell.rowspan > 1
|
||||||
|
let rowspan_attr = ' rowspan="' . cell.rowspan . '"'
|
||||||
|
else "cell.rowspan == 1
|
||||||
|
let rowspan_attr = ''
|
||||||
|
endif
|
||||||
|
if cell.colspan > 1
|
||||||
|
let colspan_attr = ' colspan="' . cell.colspan . '"'
|
||||||
|
else "cell.colspan == 1
|
||||||
|
let colspan_attr = ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(a:ldest, '<' . tag_name . rowspan_attr . colspan_attr .'>')
|
||||||
|
call add(a:ldest, s:process_inline_tags(cell.body))
|
||||||
|
call add(a:ldest, '</'. tag_name . '>')
|
||||||
|
endfor
|
||||||
|
|
||||||
|
call add(a:ldest, '</tr>')
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
let table = a:table
|
let table = a:table
|
||||||
let ldest = a:ldest
|
let ldest = a:ldest
|
||||||
if len(table)
|
if len(table)
|
||||||
|
call s:sum_rowspan(table)
|
||||||
|
call s:sum_colspan(table)
|
||||||
|
|
||||||
if table[0] == 'center'
|
if table[0] == 'center'
|
||||||
call add(ldest, "<table class='center'>")
|
call add(ldest, "<table class='center'>")
|
||||||
else
|
else
|
||||||
@@ -651,21 +711,15 @@ function! s:close_tag_table(table, ldest) "{{{
|
|||||||
if head > 0
|
if head > 0
|
||||||
for row in table[1 : head-1]
|
for row in table[1 : head-1]
|
||||||
if !empty(filter(row, '!empty(v:val)'))
|
if !empty(filter(row, '!empty(v:val)'))
|
||||||
call add(ldest, '<tr>')
|
call s:close_tag_row(row, 1, ldest)
|
||||||
call extend(ldest, map(row, '"<th>".s:process_inline_tags(v:val)."</th>"'))
|
|
||||||
call add(ldest, '</tr>')
|
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
for row in table[head+1 :]
|
for row in table[head+1 :]
|
||||||
call add(ldest, '<tr>')
|
call s:close_tag_row(row, 0, ldest)
|
||||||
call extend(ldest, map(row, '"<td>".s:process_inline_tags(v:val)."</td>"'))
|
|
||||||
call add(ldest, '</tr>')
|
|
||||||
endfor
|
endfor
|
||||||
else
|
else
|
||||||
for row in table[1 :]
|
for row in table[1 :]
|
||||||
call add(ldest, '<tr>')
|
call s:close_tag_row(row, 0, ldest)
|
||||||
call extend(ldest, map(row, '"<td>".s:process_inline_tags(v:val)."</td>"'))
|
|
||||||
call add(ldest, '</tr>')
|
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
call add(ldest, "</table>")
|
call add(ldest, "</table>")
|
||||||
@@ -741,11 +795,15 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
|
|
||||||
let chk = matchlist(a:line, a:rx_list)
|
let chk = matchlist(a:line, a:rx_list)
|
||||||
if len(chk) > 0
|
if len(chk) > 0
|
||||||
if chk[1] == g:vimwiki_listsyms[4]
|
if len(chk[1])>0
|
||||||
let st_tag .= '<del><input type="checkbox" checked />'
|
"wildcard characters are difficult to match correctly
|
||||||
let en_tag = '</del>'.a:en_tag
|
if chk[1] =~ '[.*\\^$~]'
|
||||||
else
|
let chk[1] ='\'.chk[1]
|
||||||
let st_tag .= '<input type="checkbox" />'
|
endif
|
||||||
|
let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
|
||||||
|
if completion >= 0 && completion <=4
|
||||||
|
let st_tag = '<li class="done'.completion.'">'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return [st_tag, en_tag]
|
return [st_tag, en_tag]
|
||||||
@@ -790,7 +848,7 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
|
|
||||||
let checkbox = '\s*\[\(.\?\)\]\s*'
|
let checkbox = '\s*\[\(.\?\)\]\s*'
|
||||||
let [st_tag, en_tag] = s:add_checkbox(line,
|
let [st_tag, en_tag] = s:add_checkbox(line,
|
||||||
\ lstRegExp.checkbox, '<li>', '</li>')
|
\ lstRegExp.checkbox, '<li>', '')
|
||||||
|
|
||||||
if !in_list
|
if !in_list
|
||||||
call add(a:lists, [lstTagClose, indent])
|
call add(a:lists, [lstTagClose, indent])
|
||||||
@@ -948,10 +1006,27 @@ endfunction "}}}
|
|||||||
|
|
||||||
function! s:process_tag_table(line, table) "{{{
|
function! s:process_tag_table(line, table) "{{{
|
||||||
function! s:table_empty_cell(value) "{{{
|
function! s:table_empty_cell(value) "{{{
|
||||||
if a:value =~ '^\s*$'
|
let cell = {}
|
||||||
return ' '
|
|
||||||
|
if a:value =~ '^\s*\\/\s*$'
|
||||||
|
let cell.body = ''
|
||||||
|
let cell.rowspan = 0
|
||||||
|
let cell.colspan = 1
|
||||||
|
elseif a:value =~ '^\s*>\s*$'
|
||||||
|
let cell.body = ''
|
||||||
|
let cell.rowspan = 1
|
||||||
|
let cell.colspan = 0
|
||||||
|
elseif a:value =~ '^\s*$'
|
||||||
|
let cell.body = ' '
|
||||||
|
let cell.rowspan = 1
|
||||||
|
let cell.colspan = 1
|
||||||
|
else
|
||||||
|
let cell.body = a:value
|
||||||
|
let cell.rowspan = 1
|
||||||
|
let cell.colspan = 1
|
||||||
endif
|
endif
|
||||||
return a:value
|
|
||||||
|
return cell
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:table_add_row(table, line) "{{{
|
function! s:table_add_row(table, line) "{{{
|
||||||
@@ -1010,6 +1085,12 @@ function! s:parse_line(line, state) " {{{
|
|||||||
|
|
||||||
let processed = 0
|
let processed = 0
|
||||||
|
|
||||||
|
if !processed
|
||||||
|
if line =~ g:vimwiki_rxComment
|
||||||
|
let processed = 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
" nohtml -- placeholder
|
" nohtml -- placeholder
|
||||||
if !processed
|
if !processed
|
||||||
if line =~ '^\s*%nohtml'
|
if line =~ '^\s*%nohtml'
|
||||||
@@ -1027,6 +1108,16 @@ function! s:parse_line(line, state) " {{{
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" html template -- placeholder "{{{
|
||||||
|
if !processed
|
||||||
|
if line =~ '^\s*%template'
|
||||||
|
let processed = 1
|
||||||
|
let param = matchstr(line, '^\s*%template\s\zs.*')
|
||||||
|
let state.placeholder = ['template', param]
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
"}}}
|
||||||
|
|
||||||
" toc -- placeholder "{{{
|
" toc -- placeholder "{{{
|
||||||
if !processed
|
if !processed
|
||||||
if line =~ '^\s*%toc'
|
if line =~ '^\s*%toc'
|
||||||
@@ -1093,6 +1184,7 @@ function! s:parse_line(line, state) " {{{
|
|||||||
let state.table = s:close_tag_table(state.table, res_lines)
|
let state.table = s:close_tag_table(state.table, res_lines)
|
||||||
let state.pre = s:close_tag_pre(state.pre, res_lines)
|
let state.pre = s:close_tag_pre(state.pre, res_lines)
|
||||||
let state.quote = s:close_tag_quote(state.quote, res_lines)
|
let state.quote = s:close_tag_quote(state.quote, res_lines)
|
||||||
|
let state.para = s:close_tag_para(state.para, res_lines)
|
||||||
|
|
||||||
let line = s:process_inline_tags(line)
|
let line = s:process_inline_tags(line)
|
||||||
|
|
||||||
@@ -1189,25 +1281,32 @@ function! s:parse_line(line, state) " {{{
|
|||||||
|
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
function! vimwiki#html#Wiki2HTML(path, wikifile) "{{{
|
||||||
|
|
||||||
|
let starttime = reltime() " start the clock
|
||||||
|
echo 'Generating HTML ... '
|
||||||
if !s:syntax_supported()
|
if !s:syntax_supported()
|
||||||
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||||
let subdir = vimwiki#subdir(VimwikiGet('path'), wikifile)
|
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||||
|
|
||||||
let lsource = s:remove_comments(readfile(wikifile))
|
|
||||||
let ldest = []
|
|
||||||
|
|
||||||
let path = expand(a:path).subdir
|
let path = expand(a:path).subdir
|
||||||
call vimwiki#mkdir(path)
|
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
|
||||||
|
|
||||||
|
let lsource = readfile(wikifile)
|
||||||
|
let ldest = []
|
||||||
|
|
||||||
|
call vimwiki#base#mkdir(path)
|
||||||
|
|
||||||
" nohtml placeholder -- to skip html generation.
|
" nohtml placeholder -- to skip html generation.
|
||||||
let nohtml = 0
|
let nohtml = 0
|
||||||
|
|
||||||
|
" template placeholder
|
||||||
|
let template_name = ''
|
||||||
|
|
||||||
" for table of contents placeholders.
|
" for table of contents placeholders.
|
||||||
let placeholders = []
|
let placeholders = []
|
||||||
|
|
||||||
@@ -1238,17 +1337,23 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
|||||||
if state.placeholder[0] == 'nohtml'
|
if state.placeholder[0] == 'nohtml'
|
||||||
let nohtml = 1
|
let nohtml = 1
|
||||||
break
|
break
|
||||||
|
elseif state.placeholder[0] == 'template'
|
||||||
|
let template_name = state.placeholder[1]
|
||||||
else
|
else
|
||||||
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
|
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
|
||||||
let state.placeholder = []
|
|
||||||
endif
|
endif
|
||||||
|
let state.placeholder = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call extend(ldest, lines)
|
call extend(ldest, lines)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|
||||||
if !nohtml
|
if nohtml
|
||||||
|
echon "\r"."%nohtml placeholder found"
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
let toc = s:get_html_toc(state.toc)
|
let toc = s:get_html_toc(state.toc)
|
||||||
call s:process_toc(ldest, placeholders, toc)
|
call s:process_toc(ldest, placeholders, toc)
|
||||||
call s:remove_blank_lines(ldest)
|
call s:remove_blank_lines(ldest)
|
||||||
@@ -1265,16 +1370,37 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
|||||||
call extend(ldest, lines)
|
call extend(ldest, lines)
|
||||||
|
|
||||||
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
|
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
|
||||||
call extend(ldest, s:get_html_header(title, subdir, &fileencoding), 0)
|
|
||||||
call extend(ldest, s:get_html_footer())
|
let html_lines = s:get_html_template(a:wikifile, template_name)
|
||||||
|
|
||||||
|
" processing template variables (refactor to a function)
|
||||||
|
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
|
||||||
|
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
|
||||||
|
\ s:root_path(subdir) .'", "g")')
|
||||||
|
|
||||||
|
let css_name = expand(VimwikiGet('css_name'))
|
||||||
|
let css_name = substitute(css_name, '\', '/', 'g')
|
||||||
|
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
|
||||||
|
|
||||||
|
let enc = &fileencoding
|
||||||
|
if enc == ''
|
||||||
|
let enc = &encoding
|
||||||
|
endif
|
||||||
|
call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
|
||||||
|
|
||||||
|
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
|
||||||
|
|
||||||
"" make html file.
|
"" make html file.
|
||||||
let wwFileNameOnly = fnamemodify(wikifile, ":t:r")
|
call writefile(html_lines, path.htmlfile)
|
||||||
call writefile(ldest, path.wwFileNameOnly.'.html')
|
|
||||||
endif
|
" measure the elapsed time and cut away miliseconds and smaller
|
||||||
|
let elapsedtimestr = matchstr(reltimestr(reltime(starttime)),'\d\+\(\.\d\d\)\=')
|
||||||
|
echon "\r".htmlfile.' written (time: '.elapsedtimestr.'s)'
|
||||||
|
return path.htmlfile
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_html#WikiAll2HTML(path) "{{{
|
|
||||||
|
function! vimwiki#html#WikiAll2HTML(path) "{{{
|
||||||
if !s:syntax_supported()
|
if !s:syntax_supported()
|
||||||
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
||||||
return
|
return
|
||||||
@@ -1289,9 +1415,9 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
|
|||||||
let &eventignore = save_eventignore
|
let &eventignore = save_eventignore
|
||||||
|
|
||||||
let path = expand(a:path)
|
let path = expand(a:path)
|
||||||
call vimwiki#mkdir(path)
|
call vimwiki#base#mkdir(path)
|
||||||
|
|
||||||
echomsg 'Deleting old html files...'
|
echomsg 'Deleting non-wiki html files...'
|
||||||
call s:delete_html_files(path)
|
call s:delete_html_files(path)
|
||||||
|
|
||||||
echomsg 'Converting wiki to html files...'
|
echomsg 'Converting wiki to html files...'
|
||||||
@@ -1300,8 +1426,12 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
|
|||||||
|
|
||||||
let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
|
let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
|
||||||
for wikifile in wikifiles
|
for wikifile in wikifiles
|
||||||
|
if !s:is_html_uptodate(wikifile)
|
||||||
echomsg 'Processing '.wikifile
|
echomsg 'Processing '.wikifile
|
||||||
call vimwiki_html#Wiki2HTML(path, wikifile)
|
call vimwiki#html#Wiki2HTML(path, wikifile)
|
||||||
|
else
|
||||||
|
echomsg 'Skipping '.wikifile
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
call s:create_default_CSS(path)
|
call s:create_default_CSS(path)
|
||||||
echomsg 'Done!'
|
echomsg 'Done!'
|
||||||
@@ -46,7 +46,7 @@ endfunction "}}}
|
|||||||
" Get level of the list item.
|
" Get level of the list item.
|
||||||
function! s:get_level(lnum) "{{{
|
function! s:get_level(lnum) "{{{
|
||||||
if VimwikiGet('syntax') == 'media'
|
if VimwikiGet('syntax') == 'media'
|
||||||
let level = vimwiki#count_first_sym(getline(a:lnum))
|
let level = vimwiki#base#count_first_sym(getline(a:lnum))
|
||||||
else
|
else
|
||||||
let level = indent(a:lnum)
|
let level = indent(a:lnum)
|
||||||
endif
|
endif
|
||||||
@@ -287,7 +287,7 @@ endfunction "}}}
|
|||||||
" Script functions }}}
|
" Script functions }}}
|
||||||
|
|
||||||
" Toggle list item between [ ] and [X]
|
" Toggle list item between [ ] and [X]
|
||||||
function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
|
function! vimwiki#lst#ToggleListItem(line1, line2) "{{{
|
||||||
let line1 = a:line1
|
let line1 = a:line1
|
||||||
let line2 = a:line2
|
let line2 = a:line2
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
|
|||||||
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_lst#kbd_cr() "{{{
|
function! vimwiki#lst#kbd_cr() "{{{
|
||||||
" This function is heavily relies on proper 'set comments' option.
|
" This function is heavily relies on proper 'set comments' option.
|
||||||
let cr = "\<CR>"
|
let cr = "\<CR>"
|
||||||
if getline('.') =~ s:rx_cb_list_item()
|
if getline('.') =~ s:rx_cb_list_item()
|
||||||
@@ -325,9 +325,12 @@ function! vimwiki_lst#kbd_cr() "{{{
|
|||||||
return cr
|
return cr
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_lst#kbd_oO(cmd) "{{{
|
function! vimwiki#lst#kbd_oO(cmd) "{{{
|
||||||
" cmd should be 'o' or 'O'
|
" cmd should be 'o' or 'O'
|
||||||
|
|
||||||
|
let l:count = v:count1
|
||||||
|
while l:count > 0
|
||||||
|
|
||||||
let beg_lnum = foldclosed('.')
|
let beg_lnum = foldclosed('.')
|
||||||
let end_lnum = foldclosedend('.')
|
let end_lnum = foldclosedend('.')
|
||||||
if end_lnum != -1 && a:cmd ==# 'o'
|
if end_lnum != -1 && a:cmd ==# 'o'
|
||||||
@@ -348,6 +351,7 @@ function! vimwiki_lst#kbd_oO(cmd) "{{{
|
|||||||
elseif &autoindent || &smartindent
|
elseif &autoindent || &smartindent
|
||||||
let res = matchstr(line, '^\s*')
|
let res = matchstr(line, '^\s*')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:cmd ==# 'o'
|
if a:cmd ==# 'o'
|
||||||
call append(lnum, res)
|
call append(lnum, res)
|
||||||
call cursor(lnum + 1, col('$'))
|
call cursor(lnum + 1, col('$'))
|
||||||
@@ -355,5 +359,11 @@ function! vimwiki_lst#kbd_oO(cmd) "{{{
|
|||||||
call append(lnum - 1, res)
|
call append(lnum - 1, res)
|
||||||
call cursor(lnum, col('$'))
|
call cursor(lnum, col('$'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:count -= 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
startinsert!
|
||||||
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
39
autoload/vimwiki/style.css
Normal file
39
autoload/vimwiki/style.css
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}
|
||||||
|
h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;}
|
||||||
|
h1 {font-size: 2.6em; color: #000000;}
|
||||||
|
h2 {font-size: 2.2em; color: #404040;}
|
||||||
|
h3 {font-size: 1.8em; color: #707070;}
|
||||||
|
h4 {font-size: 1.4em; color: #909090;}
|
||||||
|
h5 {font-size: 1.3em; color: #989898;}
|
||||||
|
h6 {font-size: 1.2em; color: #9c9c9c;}
|
||||||
|
p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}
|
||||||
|
ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}
|
||||||
|
li {margin: 0.3em auto;}
|
||||||
|
ul {margin-left: 2em; padding-left: 0.5em;}
|
||||||
|
dt {font-weight: bold;}
|
||||||
|
img {border: none;}
|
||||||
|
pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}
|
||||||
|
blockquote {padding: 0.4em; background-color: #f6f5eb;}
|
||||||
|
th, td {border: 1px solid #ccc; padding: 0.3em;}
|
||||||
|
th {background-color: #f0f0f0;}
|
||||||
|
hr {border: none; border-top: 1px solid #ccc; width: 100%;}
|
||||||
|
del {text-decoration: line-through; color: #777777;}
|
||||||
|
.toc li {list-style-type: none;}
|
||||||
|
.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}
|
||||||
|
.justleft {text-align: left;}
|
||||||
|
.justright {text-align: right;}
|
||||||
|
.justcenter {text-align: center;}
|
||||||
|
.center {margin-left: auto; margin-right: auto;}
|
||||||
|
/* classes for items of todo lists */
|
||||||
|
.done0:before {content: "\2592\2592\2592\2592"; color: SkyBlue;}
|
||||||
|
.done1:before {content: "\2588\2592\2592\2592"; color: SkyBlue;}
|
||||||
|
.done2:before {content: "\2588\2588\2592\2592"; color: SkyBlue;}
|
||||||
|
.done3:before {content: "\2588\2588\2588\2592"; color: SkyBlue;}
|
||||||
|
.done4:before {content: "\2588\2588\2588\2588"; color: SkyBlue;}
|
||||||
|
/* comment the next four or five lines out *
|
||||||
|
* if you do not want color-coded todo lists */
|
||||||
|
.done0 {color: #c00000;}
|
||||||
|
.done1 {color: #c08000;}
|
||||||
|
.done2 {color: #80a000;}
|
||||||
|
.done3 {color: #00c000;}
|
||||||
|
.done4 {color: #7f7f7f; text-decoration: line-through;}
|
||||||
@@ -299,7 +299,7 @@ endfunction "}}}
|
|||||||
" Keyboard functions "{{{
|
" Keyboard functions "{{{
|
||||||
function! s:kbd_create_new_row(cols, goto_first) "{{{
|
function! s:kbd_create_new_row(cols, goto_first) "{{{
|
||||||
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
|
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
|
||||||
let cmd .= "\<ESC>:call vimwiki_tbl#format(line('.'))\<CR>"
|
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
|
||||||
if a:goto_first
|
if a:goto_first
|
||||||
let cmd .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
|
let cmd .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
|
||||||
else
|
else
|
||||||
@@ -341,7 +341,7 @@ endfunction "}}}
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Global functions {{{
|
" Global functions {{{
|
||||||
function! vimwiki_tbl#kbd_cr() "{{{
|
function! vimwiki#tbl#kbd_cr() "{{{
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
if !s:is_table(getline(lnum))
|
if !s:is_table(getline(lnum))
|
||||||
return "\<CR>"
|
return "\<CR>"
|
||||||
@@ -355,7 +355,7 @@ function! vimwiki_tbl#kbd_cr() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#kbd_tab() "{{{
|
function! vimwiki#tbl#kbd_tab() "{{{
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
if !s:is_table(getline(lnum))
|
if !s:is_table(getline(lnum))
|
||||||
return "\<Tab>"
|
return "\<Tab>"
|
||||||
@@ -369,7 +369,7 @@ function! vimwiki_tbl#kbd_tab() "{{{
|
|||||||
return s:kbd_goto_next_col(last)
|
return s:kbd_goto_next_col(last)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#kbd_shift_tab() "{{{
|
function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
if !s:is_table(getline(lnum))
|
if !s:is_table(getline(lnum))
|
||||||
return "\<S-Tab>"
|
return "\<S-Tab>"
|
||||||
@@ -382,7 +382,7 @@ function! vimwiki_tbl#kbd_shift_tab() "{{{
|
|||||||
return s:kbd_goto_prev_col(first)
|
return s:kbd_goto_prev_col(first)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#format(lnum, ...) "{{{
|
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
if !s:is_table(line)
|
if !s:is_table(line)
|
||||||
return
|
return
|
||||||
@@ -406,7 +406,7 @@ function! vimwiki_tbl#format(lnum, ...) "{{{
|
|||||||
let &tw = s:textwidth
|
let &tw = s:textwidth
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#create(...) "{{{
|
function! vimwiki#tbl#create(...) "{{{
|
||||||
if a:0 > 1
|
if a:0 > 1
|
||||||
let cols = a:1
|
let cols = a:1
|
||||||
let rows = a:2
|
let rows = a:2
|
||||||
@@ -441,15 +441,15 @@ function! vimwiki_tbl#create(...) "{{{
|
|||||||
call append(line('.'), lines)
|
call append(line('.'), lines)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#align_or_cmd(cmd) "{{{
|
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||||
if s:is_table(getline('.'))
|
if s:is_table(getline('.'))
|
||||||
call vimwiki_tbl#format(line('.'))
|
call vimwiki#tbl#format(line('.'))
|
||||||
else
|
else
|
||||||
exe 'normal! '.a:cmd
|
exe 'normal! '.a:cmd
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#reset_tw(lnum) "{{{
|
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
if !s:is_table(line)
|
if !s:is_table(line)
|
||||||
return
|
return
|
||||||
@@ -461,7 +461,7 @@ endfunction "}}}
|
|||||||
|
|
||||||
" TODO: move_column_left and move_column_right are good candidates to be
|
" TODO: move_column_left and move_column_right are good candidates to be
|
||||||
" refactored.
|
" refactored.
|
||||||
function! vimwiki_tbl#move_column_left() "{{{
|
function! vimwiki#tbl#move_column_left() "{{{
|
||||||
if !s:is_table(getline('.'))
|
if !s:is_table(getline('.'))
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -472,7 +472,7 @@ function! vimwiki_tbl#move_column_left() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if cur_col > 0
|
if cur_col > 0
|
||||||
call vimwiki_tbl#format(line('.'), cur_col-1, cur_col)
|
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
|
||||||
call cursor(line('.'), 1)
|
call cursor(line('.'), 1)
|
||||||
if !s:is_separator(getline('.'))
|
if !s:is_separator(getline('.'))
|
||||||
call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW')
|
call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW')
|
||||||
@@ -482,7 +482,7 @@ function! vimwiki_tbl#move_column_left() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#move_column_right() "{{{
|
function! vimwiki#tbl#move_column_right() "{{{
|
||||||
if !s:is_table(getline('.'))
|
if !s:is_table(getline('.'))
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -493,7 +493,7 @@ function! vimwiki_tbl#move_column_right() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if cur_col < s:col_count(line('.'))-1
|
if cur_col < s:col_count(line('.'))-1
|
||||||
call vimwiki_tbl#format(line('.'), cur_col, cur_col+1)
|
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
|
||||||
call cursor(line('.'), 1)
|
call cursor(line('.'), 1)
|
||||||
if !s:is_separator(getline('.'))
|
if !s:is_separator(getline('.'))
|
||||||
call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW')
|
call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW')
|
||||||
@@ -503,7 +503,7 @@ function! vimwiki_tbl#move_column_right() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki_tbl#get_rows(lnum) "{{{
|
function! vimwiki#tbl#get_rows(lnum) "{{{
|
||||||
return s:get_rows(a:lnum)
|
return s:get_rows(a:lnum)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ hi Normal guifg=#000000 guibg=#F8F8FF
|
|||||||
hi Cursor guibg=#444454 guifg=#F8F8FF
|
hi Cursor guibg=#444454 guifg=#F8F8FF
|
||||||
hi CursorLine guibg=#D8D8DD
|
hi CursorLine guibg=#D8D8DD
|
||||||
hi CursorColumn guibg=#E8E8EE
|
hi CursorColumn guibg=#E8E8EE
|
||||||
|
" gryf: added colorcolumn highlight
|
||||||
hi ColorColumn guibg=#E8E8EE
|
hi ColorColumn guibg=#E8E8EE
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ if has("gui_running")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
hi CursorLine guibg=#2e2e37
|
hi CursorLine guibg=#2e2e37
|
||||||
|
" gryf: added colorcolumn highlight
|
||||||
hi ColorColumn guibg=#2e2e37
|
hi ColorColumn guibg=#2e2e37
|
||||||
|
|
||||||
hi IncSearch gui=BOLD guifg=#303030 guibg=#cd8b60
|
hi IncSearch gui=BOLD guifg=#303030 guibg=#cd8b60
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ set background=dark
|
|||||||
if version >= 700
|
if version >= 700
|
||||||
call s:X("CursorLine","","1c1c1c","","","Black")
|
call s:X("CursorLine","","1c1c1c","","","Black")
|
||||||
call s:X("CursorColumn","","1c1c1c","","","Black")
|
call s:X("CursorColumn","","1c1c1c","","","Black")
|
||||||
|
" gryf: added colorcolumn highlight
|
||||||
call s:X("ColorColumn","","1c1c1c","","","")
|
call s:X("ColorColumn","","1c1c1c","","","")
|
||||||
call s:X("MatchParen","ffffff","80a090","bold","","DarkCyan")
|
call s:X("MatchParen","ffffff","80a090","bold","","DarkCyan")
|
||||||
|
|
||||||
|
|||||||
200
doc/buffergator.txt
Normal file
200
doc/buffergator.txt
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
*buffergator.txt* Buffer indexing and navigation plugin.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
*buffergator* *buffergator-contents*
|
||||||
|
CONTENTS~
|
||||||
|
|
||||||
|
1. Introduction ....................... |buffergator-introduction|
|
||||||
|
2. Commands ........................... |buffergator-commands|
|
||||||
|
3. Key Mappings (Global) .............. |buffergator-global-keys|
|
||||||
|
4. Key Mappings (Catalog Viewer) ...... |buffergator-keys|
|
||||||
|
5. Options and Settings ............... |buffergator-options|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
*buffergator-introduction*
|
||||||
|
INTRODUCTION~
|
||||||
|
|
||||||
|
Buffergator is a plugin for listing, navigating between, and selecting buffers
|
||||||
|
to edit. Upon invocation, a "catalog" of listed buffers are displayed in a
|
||||||
|
separate new window split (vertical or horizontal, based on user options;
|
||||||
|
default = vertical). From this "buffer catalog", a buffer can be selected and
|
||||||
|
opened in an existing window, a new window split (vertical or horizontal), or
|
||||||
|
a new tab page.
|
||||||
|
|
||||||
|
Selected buffers can be "previewed", i.e. opened in a window or tab page, but
|
||||||
|
with focus remaining in the buffer catalog. Even better, you can "walk" up and
|
||||||
|
down the list of buffers shown in the catalog by using <C-N> (or <SPACE>) /
|
||||||
|
<C-P> (or <C-SPACE>). These keys select the next/previous buffer in succession,
|
||||||
|
respectively, opening it for preview without leaving the buffer catalog
|
||||||
|
viewer.
|
||||||
|
|
||||||
|
By default, Buffergator provides global key maps that invoke its main
|
||||||
|
commands: "<Leader>b" to open, "<Leader>B" to close. If you prefer to map
|
||||||
|
other keys, or do not want any keys mapped at all, set
|
||||||
|
"g:buffergator_suppress_keymaps" to 1 in your $VIMRUNTIME.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
*buffergator-commands*
|
||||||
|
COMMANDS~
|
||||||
|
|
||||||
|
These following commands are provided globally by Buffergator:
|
||||||
|
|
||||||
|
:BuffergatorOpen
|
||||||
|
Open the buffer catalog, or go to it if it is already open.
|
||||||
|
|
||||||
|
:BuffergatorClose
|
||||||
|
Close the buffer catalog if it is already open.
|
||||||
|
|
||||||
|
:BuffergatorToggle
|
||||||
|
Open the buffer catalog if it is closed, or close it if
|
||||||
|
it is already open.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
*buffergator-global-keys*
|
||||||
|
KEY MAPPINGS (GLOBAL)~
|
||||||
|
|
||||||
|
Unless "g:buffergator_suppress_keymaps" is set to 1, then the following
|
||||||
|
key mappings are defined:
|
||||||
|
|
||||||
|
<Leader>b Invokes ":BuffergatorOpen": open the buffer catalog, or go
|
||||||
|
to it if it is already open.
|
||||||
|
|
||||||
|
<Leader>B Invokes ":BuffergatorClose": close the buffer catalog.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
*buffergator-keys*
|
||||||
|
KEY MAPPINGS (CATALOG VIEWER)~
|
||||||
|
|
||||||
|
Invoking Buffergator results in the listed buffers being displayed in a
|
||||||
|
special Buffergator window, which is referred to as a "buffer catalog viewer".
|
||||||
|
The following key mappings are available when in the viewer.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Catalog Management~
|
||||||
|
|
||||||
|
s Cycle through sort regimes.
|
||||||
|
i Cycle through display regimes (alternate).
|
||||||
|
u Update (rebuild/refresh) index.
|
||||||
|
d Delete the selected buffer.
|
||||||
|
D Unconditionally delete the selected buffer.
|
||||||
|
x Wipe the selected buffer.
|
||||||
|
X Unconditionally wipe the selected buffer.
|
||||||
|
q Quit the index/catalog window.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Open Selected Buffer~
|
||||||
|
|
||||||
|
<CR> Switch focus to the previous window and go to the current
|
||||||
|
entry. If "g:buffergator_autodismiss_on_select" is True,
|
||||||
|
then the catalog viewer is closed; otherwise it is kept
|
||||||
|
open.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Preview Selected Buffer Without Leaving the Catalog Viewer~
|
||||||
|
|
||||||
|
The following keys all open the currently-selected buffer, but retain focus on
|
||||||
|
the catalog viewer.
|
||||||
|
|
||||||
|
po, . Preview the currently-selected buffer in the previous
|
||||||
|
window, keeping focus on the catalog.
|
||||||
|
ps Preview the currently-selected buffer is a new split,
|
||||||
|
keeping focus on the catalog.
|
||||||
|
pv Preview the currently-selected buffer is a new vertical
|
||||||
|
split, keeping focus on the catalog.
|
||||||
|
pt Preview the currently-selected buffer is a new tab
|
||||||
|
page, keeping focus on the catalog.
|
||||||
|
<SPACE>, <C-N> Go to the next buffer entry and preview it in the previous
|
||||||
|
window.
|
||||||
|
<C-SPACE>, <C-P> Go to the previous buffer entry and preview it in the
|
||||||
|
previous window.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Open Selected Buffer Without Closing the Catalog Viewer~
|
||||||
|
|
||||||
|
The following keys all open the currently-selected buffer and switch focus to
|
||||||
|
it, but keep the catalog viewer open.
|
||||||
|
|
||||||
|
o Keeping the catalog viewer open, switch focus to the
|
||||||
|
previous window and go to the currently-selected buffer
|
||||||
|
(as <CR> if "g:buffergator_autodismiss_on_select" is 0).
|
||||||
|
ws Keeping the catalog viewer open, split the previous window,
|
||||||
|
switch focus, and go to the currently-selected buffer.
|
||||||
|
wv Keeping the catalog viewer open, split the previous window
|
||||||
|
vertically, switch focus, and go to the currently-selected
|
||||||
|
buffer.
|
||||||
|
t Keeping the catalog viewer open, open the current selected
|
||||||
|
in a new tab page.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Open Selected Buffer and Close the Catalog Viewer~
|
||||||
|
|
||||||
|
The following keys all open the currently-selected buffer and switch focus to
|
||||||
|
it, closing the catalog viewer at the same time.
|
||||||
|
|
||||||
|
O Close catalog viewer and go to the currently-selected
|
||||||
|
buffer (as <CR> if "g:buffergator_autodismiss_on_select"
|
||||||
|
is 1).
|
||||||
|
wS Close the catalog viewer, split the previous window
|
||||||
|
and go to the currently-selected buffer.
|
||||||
|
wV Close the catalog viewer, split the previous window
|
||||||
|
vertically and go to the currently-selected buffer.
|
||||||
|
T Close the catalog viewer and open the currently-selected
|
||||||
|
buffer in a new tab page.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Window Control~
|
||||||
|
|
||||||
|
A Zoom/unzoom window, expanding to full height (if
|
||||||
|
horizontally split) or full width (if vertically split)
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
*buffergator-options*
|
||||||
|
OPTIONS AND SETTINGS~
|
||||||
|
|
||||||
|
The following options can be used to customize the behavior of this plugin:
|
||||||
|
|
||||||
|
g:buffergator_viewport_split_policy~
|
||||||
|
Default: "L"
|
||||||
|
Determines how a new Buffergator window will be opened. Can be one of the
|
||||||
|
following values:
|
||||||
|
"L" : vertical left (full screen height)
|
||||||
|
"R" : vertical right (full screen height)
|
||||||
|
"T" : horizontal top (full screen width)
|
||||||
|
"B" : horizontal bottom (full screen width)
|
||||||
|
|
||||||
|
g:buffergator_autodismiss_on_select~
|
||||||
|
Default: 1
|
||||||
|
If true, then selection an entry with <CR> will close the catalog. Otherwise,
|
||||||
|
catalog stays open. Default is 1.
|
||||||
|
|
||||||
|
g:buffergator_autoexpand_on_split~
|
||||||
|
Default: 1
|
||||||
|
If true and running in GUI mode, then the application screen will be expanded
|
||||||
|
to accommodate the Buffergator window.
|
||||||
|
|
||||||
|
g:buffergator_split_size~
|
||||||
|
Default: 40
|
||||||
|
If greater than 0, this will be the width of the Buffergator window in any
|
||||||
|
vertical splitting mode, or its height in any horizontal splitting mode.
|
||||||
|
|
||||||
|
g:buffergator_sort_regime~
|
||||||
|
Default: "bufnum"
|
||||||
|
Sets the default sort regime for buffer listing:
|
||||||
|
"bufnum" : sort by buffer number [default]
|
||||||
|
"basename": sort by buffer file basename
|
||||||
|
"filepath": sort by full buffer filepath
|
||||||
|
|
||||||
|
g:buffergator_display_regime~
|
||||||
|
Default: "basename"
|
||||||
|
Sets the default sort regime for buffer listing:
|
||||||
|
"basename": display buffer basename first,
|
||||||
|
followed by directory [default]
|
||||||
|
"filepath": display full buffer filepath
|
||||||
|
"bufname": display buffer name
|
||||||
|
|
||||||
|
g:buffergator_suppress_keymaps~
|
||||||
|
Default: 0
|
||||||
|
If true, then Buffergator will not automatically map "<Leader>b" to
|
||||||
|
open the Buffergator catalog and "<Leader>B" to close it.
|
||||||
|
|
||||||
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
@@ -1,649 +0,0 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.3.1 *delimitMate.txt*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
|
||||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
|
||||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
|
||||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
|
||||||
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
|
||||||
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
|
||||||
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
|
||||||
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
|
||||||
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
|
||||||
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
|
||||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
0.- CONTENTS *delimitMate-contents*
|
|
||||||
|
|
||||||
1. Introduction____________________________|delimitMateIntro|
|
|
||||||
2. Functionality___________________________|delimitMateFunctionality|
|
|
||||||
2.1 Automatic closing & exiting________|delimitMateAutoClose|
|
|
||||||
2.2 Expansion of space and CR__________|delimitMateExpansion|
|
|
||||||
2.3 Backspace__________________________|delimitMateBackspace|
|
|
||||||
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
|
||||||
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
|
||||||
2.6 FileType based configuration_______|delimitMateFileType|
|
|
||||||
2.7 Syntax awareness___________________|delimitMateSyntax|
|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
|
||||||
4. Commands________________________________|delimitMateCommands|
|
|
||||||
5. Functions_______________________________|delimitMateFunctions|
|
|
||||||
6. TODO list_______________________________|delimitMateTodo|
|
|
||||||
7. Maintainer______________________________|delimitMateMaintainer|
|
|
||||||
8. Credits_________________________________|delimitMateCredits|
|
|
||||||
9. History_________________________________|delimitMateHistory|
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
1.- INTRODUCTION *delimitMateIntro*
|
|
||||||
|
|
||||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
|
||||||
etc.; besides some other related features that should make your time in insert
|
|
||||||
mode a little bit easier.
|
|
||||||
|
|
||||||
Most of the features can be modified or disabled permanently, using global
|
|
||||||
variables, or on a FileType basis, using autocommands. With a couple of
|
|
||||||
exceptions and limitations, this features don't brake undo, redo or history.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
2. FUNCTIONALITY *delimitMateFunctionality*
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
|
||||||
|
|
||||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
|
||||||
inserts the closing delimiter and places the cursor between the pair. With
|
|
||||||
automatic closing disabled, no closing delimiters is inserted by delimitMate,
|
|
||||||
but when a pair of delimiters is typed, the cursor is placed in the middle.
|
|
||||||
|
|
||||||
When the cursor is inside an empty pair or located next to the left of a
|
|
||||||
closing delimiter, the cursor is placed outside the pair to the right of the
|
|
||||||
closing delimiter.
|
|
||||||
|
|
||||||
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'|are set, this
|
|
||||||
script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
|
|
||||||
for quotes respectively.
|
|
||||||
|
|
||||||
The following table shows the behaviour, this applies to quotes too (the final
|
|
||||||
position of the cursor is represented by a "|"):
|
|
||||||
|
|
||||||
With auto-close: >
|
|
||||||
Type | You get
|
|
||||||
====================
|
|
||||||
( | (|)
|
|
||||||
–––––––––|––––––––––
|
|
||||||
() | ()|
|
|
||||||
–––––––––|––––––––––
|
|
||||||
(<S-Tab> | ()|
|
|
||||||
<
|
|
||||||
Without auto-close: >
|
|
||||||
|
|
||||||
Type | You get
|
|
||||||
=====================
|
|
||||||
() | (|)
|
|
||||||
–––––––––-|––––––––––
|
|
||||||
()) | ()|
|
|
||||||
–––––––––-|––––––––––
|
|
||||||
()<S-Tab> | ()|
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
|
||||||
|
|
||||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
|
||||||
expanded, see |'delimitMate_expand_space'| and
|
|
||||||
|'delimitMate_expand_cr'|:
|
|
||||||
|
|
||||||
Expand <Space> to: >
|
|
||||||
|
|
||||||
<Space><Space><Left> | You get
|
|
||||||
====================================
|
|
||||||
(|) | ( | )
|
|
||||||
<
|
|
||||||
Expand <CR> to: >
|
|
||||||
|
|
||||||
<CR><CR><Up> | You get
|
|
||||||
============================
|
|
||||||
(|) | (
|
|
||||||
| |
|
|
||||||
| )
|
|
||||||
<
|
|
||||||
|
|
||||||
NOTE that the expansion of <CR> will brake the redo command.
|
|
||||||
|
|
||||||
Since <Space> and <CR> are used everywhere, I have made the functions involved
|
|
||||||
in expansions global, so they can be used to make custom mappings. Read
|
|
||||||
|delimitMateFunctions| for more details.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.3 BACKSPACE *delimitMateBackspace*
|
|
||||||
|
|
||||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
|
||||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
|
||||||
deleting <CR> expansions will brake the redo command.
|
|
||||||
|
|
||||||
If you type shift + backspace instead, only the closing delimiter will be
|
|
||||||
deleted.
|
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
|
||||||
|
|
||||||
What | Before | After
|
|
||||||
==============================================
|
|
||||||
<BS> | call expand(|) | call expand|
|
|
||||||
---------|-------------------|-----------------
|
|
||||||
<BS> | call expand( | ) | call expand(|)
|
|
||||||
---------|-------------------|-----------------
|
|
||||||
<BS> | call expand( | call expand(|)
|
|
||||||
| | |
|
|
||||||
| ) |
|
|
||||||
---------|-------------------|-----------------
|
|
||||||
<S-BS> | call expand(|) | call expand(|
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
|
|
||||||
|
|
||||||
When visual mode is active this script allows for the selection to be enclosed
|
|
||||||
with delimiters. But, since brackets have special meaning in visual mode, a
|
|
||||||
leader (the value of 'mapleader' by default) should precede the delimiter.
|
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
|
||||||
blockwise visual mode, any suggestions to fix this will be very welcome.
|
|
||||||
|
|
||||||
e.g. (selection represented between square brackets): >
|
|
||||||
|
|
||||||
Selected text | After \"
|
|
||||||
=============================================
|
|
||||||
An [absurd] example! | An "absurd" example!
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
|
||||||
|
|
||||||
Only one quote will be inserted following a quote, a "\" or an alphanumeric
|
|
||||||
character. This should cover closing quotes, escaped quotes and apostrophes.
|
|
||||||
Except for apostrophes, this feature can be disabled setting the option
|
|
||||||
|'delimitMate_smart_quotes'| to 0.
|
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
|
||||||
|
|
||||||
What | Before | After
|
|
||||||
=======================================
|
|
||||||
" | "String| | "String"|
|
|
||||||
" | let i = "| | let i = "|"
|
|
||||||
' | I| | I'|
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
|
||||||
|
|
||||||
delimitMate options can be set globally for all buffers using global
|
|
||||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
|
||||||
options for specific file types (see |'filetype'|) using buffer variables in
|
|
||||||
the following way: >
|
|
||||||
|
|
||||||
au FileType mail,text let b:delimitMate_autoclose = 0
|
|
||||||
^ ^ ^ ^ ^
|
|
||||||
| | | | |
|
|
||||||
| | | | - Option value.
|
|
||||||
| | | - Option name.
|
|
||||||
| | - Buffer variable.
|
|
||||||
| - File types for which the option will be set.
|
|
||||||
- Don't forget to put this event.
|
|
||||||
<
|
|
||||||
NOTE that you should use buffer variables (|b:var|) only to set options with
|
|
||||||
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.7 SYNTAX AWARENESS *delimitMateSyntax*
|
|
||||||
|
|
||||||
The features of this plug-in might not be always helpful, comments and strings
|
|
||||||
usualy don't need auto-completion. delimitMate monitors which region is being
|
|
||||||
edited and if it detects that the cursor is in a comment it'll turn itself off
|
|
||||||
until the cursor leaves the comment. The excluded regions can be set using the
|
|
||||||
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
|
||||||
regions or syntax group names.
|
|
||||||
|
|
||||||
NOTE that this feature relies on a proper syntax file for the current file
|
|
||||||
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
|
||||||
know about it.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
3. CUSTOMIZATION *delimitMateOptions*
|
|
||||||
|
|
||||||
You can create your own mappings for some features using the global functions.
|
|
||||||
Read |DelimitMateFunctions| for more info.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
3.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
|
||||||
|
|
||||||
The behaviour of this script can be customized setting the following options
|
|
||||||
in your vimrc file. You can use local options to set the configuration for
|
|
||||||
specific file types, see |delimitMateOptionDetails| for examples.
|
|
||||||
|
|
||||||
|'loaded_delimitMate'| Turns off the script.
|
|
||||||
|
|
||||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
|
||||||
insert the closing delimiter.
|
|
||||||
|
|
||||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
|
||||||
matching pairs.
|
|
||||||
|
|
||||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
|
||||||
used.
|
|
||||||
|
|
||||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
|
||||||
|
|
||||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
|
||||||
|
|
||||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
|
||||||
|
|
||||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
|
||||||
|
|
||||||
|'delimitMate_excluded_regions'|Turns off the script for the given regions or
|
|
||||||
syntax group names.
|
|
||||||
|
|
||||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
|
||||||
balancing of single quotes when used as
|
|
||||||
apostrophes. NOTE: Not needed any more, kept
|
|
||||||
for compatibility with older versions.
|
|
||||||
|
|
||||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
3.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
|
||||||
|
|
||||||
Add the shown lines to your vimrc file in order to set the below options.
|
|
||||||
Buffer variables take precedence over global ones and can be used along with
|
|
||||||
autocmd to modify delimitMate's behavior for specific file types, read more in
|
|
||||||
|delimitMateFileType|.
|
|
||||||
|
|
||||||
Note: Use buffer variables only to set options for specific file types using
|
|
||||||
:autocmd, use global variables to set options for every buffer. Read more in
|
|
||||||
|g:var| and |b:var|.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'loaded_delimitMate'*
|
|
||||||
*'b:loaded_delimitMate'*
|
|
||||||
This option prevents delimitMate from loading.
|
|
||||||
e.g.: >
|
|
||||||
let loaded_delimitMate = 1
|
|
||||||
au FileType mail let b:loaded_delimitMate = 1
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_autoclose'*
|
|
||||||
*'b:delimitMate_autoclose'*
|
|
||||||
Values: 0 or 1. ~
|
|
||||||
Default: 1 ~
|
|
||||||
|
|
||||||
If this option is set to 0, delimitMate will not add a closing delimiter
|
|
||||||
automagically. See |delimitMateAutoClose| for details.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_autoclose = 0
|
|
||||||
au FileType mail let b:delimitMate_autoclose = 0
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_matchpairs'*
|
|
||||||
*'b:delimitMate_matchpairs'*
|
|
||||||
Values: A string with |matchpairs| syntax. ~
|
|
||||||
Default: &matchpairs ~
|
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered
|
|
||||||
matching pairs. Read |delimitMateAutoClose| for details.
|
|
||||||
e.g: >
|
|
||||||
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
|
||||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_quotes'*
|
|
||||||
*'b:delimitMate_quotes'*
|
|
||||||
Values: A string of characters separated by spaces. ~
|
|
||||||
Default: "\" ' `" ~
|
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered as
|
|
||||||
quotes. Read |delimitMateAutoClose| for details.
|
|
||||||
e.g.: >
|
|
||||||
let b:delimitMate_quotes = "\" ' ` *"
|
|
||||||
au FileType html let b:delimitMate_quotes = "\" '"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_visual_leader'*
|
|
||||||
*'b:delimitMate_visual_leader'*
|
|
||||||
Values: Any character. ~
|
|
||||||
Default: q ~
|
|
||||||
|
|
||||||
The value of this option will be used to wrap the selection in visual mode
|
|
||||||
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
|
|
||||||
e.g: >
|
|
||||||
let delimitMate_visual_leader = "f"
|
|
||||||
au FileType html let b:delimitMate_visual_leader = "f"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_expand_cr'*
|
|
||||||
*'b:delimitMate_expand_cr'*
|
|
||||||
Values: 1 or 0 ~
|
|
||||||
Default: 0 ~
|
|
||||||
|
|
||||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
|
||||||
for details.
|
|
||||||
e.g.: >
|
|
||||||
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
|
|
||||||
au FileType mail let b:delimitMate_expand_cr = "\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_expand_space'*
|
|
||||||
*'b:delimitMate_expand_space'*
|
|
||||||
Values: A key mapping. ~
|
|
||||||
Default: "\<Space>" ~
|
|
||||||
|
|
||||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
|
||||||
for details.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_expand_space = "\<Space>\<Space>\<Left>"
|
|
||||||
au FileType tcl let b:delimitMate_expand_space = "\<Space>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_excluded_ft'*
|
|
||||||
Values: A string of file type names separated by single commas. ~
|
|
||||||
Default: Empty. ~
|
|
||||||
|
|
||||||
This options turns delimitMate off for the listed file types, use this option
|
|
||||||
only if you don't want any of the features it provides on those file types.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_excluded_ft = "mail,txt"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_excluded_regions'*
|
|
||||||
Values: A string of syntax group names names separated by single commas. ~
|
|
||||||
Default: Comment ~
|
|
||||||
|
|
||||||
This options turns delimitMate off for the listed regions, read |group-name|
|
|
||||||
for more info about what is a region.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_excluded_regions = "Comments,String"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_apostrophes'*
|
|
||||||
Values: Strings separated by ":". ~
|
|
||||||
Default: No longer used. ~
|
|
||||||
|
|
||||||
NOTE: This feature is turned off by default, it's been kept for compatibility
|
|
||||||
with older version, read |delimitMateSmartQuotes| for details.
|
|
||||||
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
|
||||||
balancing of single quotes when used as apostrophes. The values of this option
|
|
||||||
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
|
||||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
|
||||||
disable this feature.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_apostrophes = ""
|
|
||||||
au FileType tcl let delimitMate_apostrophes = ""
|
|
||||||
<
|
|
||||||
==============================================================================
|
|
||||||
4. COMMANDS *delimitMateCommands*
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
:DelimitMateReload *:DelimitMateReload*
|
|
||||||
|
|
||||||
Re-sets all the mappings used for this script, use it if any option has been
|
|
||||||
changed or if the filetype option hasn't been set yet.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
:DelimitMateSwitch *:DelimitMateSwitch*
|
|
||||||
|
|
||||||
Switches the plug-in on and off.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
:DelimitMateTest *:DelimitMateTest*
|
|
||||||
|
|
||||||
This command tests every mapping set-up for this script, useful for testing
|
|
||||||
custom configurations.
|
|
||||||
|
|
||||||
The following output corresponds to the default values, it will be different
|
|
||||||
depending on your configuration. "Open & close:" represents the final result
|
|
||||||
when the closing delimiter has been inserted, either manually or
|
|
||||||
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
|
|
||||||
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
|
|
||||||
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
|
|
||||||
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
|
|
||||||
"Visual-R" and "Visual" shows visual wrapping, see
|
|
||||||
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
|
|
||||||
|delimitMateExpansion|. The cursor's position at the end of every test is
|
|
||||||
represented by an "|": >
|
|
||||||
|
|
||||||
* AUTOCLOSE:
|
|
||||||
Open & close: (|)
|
|
||||||
Delete: |
|
|
||||||
Exit: ()|
|
|
||||||
Space: ( |)
|
|
||||||
Visual-L: (v)
|
|
||||||
Visual-R: (v)
|
|
||||||
Car return: (
|
|
||||||
|)
|
|
||||||
|
|
||||||
Open & close: {|}
|
|
||||||
Delete: |
|
|
||||||
Exit: {}|
|
|
||||||
Space: { |}
|
|
||||||
Visual-L: {v}
|
|
||||||
Visual-R: {v}
|
|
||||||
Car return: {
|
|
||||||
|}
|
|
||||||
|
|
||||||
Open & close: [|]
|
|
||||||
Delete: |
|
|
||||||
Exit: []|
|
|
||||||
Space: [ |]
|
|
||||||
Visual-L: [v]
|
|
||||||
Visual-R: [v]
|
|
||||||
Car return: [
|
|
||||||
|]
|
|
||||||
|
|
||||||
Open & close: "|"
|
|
||||||
Delete: |
|
|
||||||
Exit: ""|
|
|
||||||
Space: " |"
|
|
||||||
Visual: "v"
|
|
||||||
Car return: "
|
|
||||||
|"
|
|
||||||
|
|
||||||
Open & close: '|'
|
|
||||||
Delete: |
|
|
||||||
Exit: ''|
|
|
||||||
Space: ' |'
|
|
||||||
Visual: 'v'
|
|
||||||
Car return: '
|
|
||||||
|'
|
|
||||||
|
|
||||||
Open & close: `|`
|
|
||||||
Delete: |
|
|
||||||
Exit: ``|
|
|
||||||
Space: ` |`
|
|
||||||
Visual: `v`
|
|
||||||
Car return: `
|
|
||||||
|`
|
|
||||||
<
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
|
||||||
|
|
||||||
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
|
||||||
might not work as expected or at all.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
|
||||||
|
|
||||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
|
||||||
|
|
||||||
Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
|
||||||
<CR> otherwise.
|
|
||||||
|
|
||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
|
||||||
<CR> inside an empty pair: >
|
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
|
||||||
|
|
||||||
Returns the expansion for <Space> if enabled and inside an empty pair, returns
|
|
||||||
<Space> otherwise.
|
|
||||||
e.g.: >
|
|
||||||
|
|
||||||
inoremap <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
|
||||||
|
|
||||||
Returns 1 if there is a closing delimiter or a quote to the right of the
|
|
||||||
cursor, 0 otherwise.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
|
||||||
|
|
||||||
This function returns a mapping that will make the cursor jump to the right
|
|
||||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
|
||||||
>
|
|
||||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
6. TODO LIST *delimitMateTodo*
|
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
|
||||||
|
|
||||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
|
||||||
mailto:israelchauca@gmail.com
|
|
||||||
|
|
||||||
Feel free to send me any suggestions and/or comments about this plugin, I'll
|
|
||||||
be very pleased to read them.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
8. CREDITS *delimitMateCredits*
|
|
||||||
|
|
||||||
Some of the code that make this script is modified or just shamelessly copied
|
|
||||||
from the following sources:
|
|
||||||
|
|
||||||
- Ian McCracken
|
|
||||||
Post titled: Vim, Part II: Matching Pairs:
|
|
||||||
http://concisionandconcinnity.blogspot.com/
|
|
||||||
|
|
||||||
- Aristotle Pagaltzis
|
|
||||||
From the comments on the previous blog post and from:
|
|
||||||
http://gist.github.com/144619
|
|
||||||
|
|
||||||
- Vim Scripts:
|
|
||||||
http://www.vim.org/scripts
|
|
||||||
|
|
||||||
This script was inspired by the auto-completion of delimiters of TextMate.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
9. HISTORY *delimitMateHistory*
|
|
||||||
|
|
||||||
Version Date Release notes ~
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.3.1 2010-06-06 * Current release:
|
|
||||||
- Fix: an extra <Space> is inserted after <Space>
|
|
||||||
expansion.
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
|
||||||
or other regions, customizable.
|
|
||||||
- Changed format of most mappings.
|
|
||||||
- Fix: <CR> expansion doesn't brake automatic
|
|
||||||
indentation adjustments anymore.
|
|
||||||
- Fix: Arrow keys would insert A, B, C or D instead
|
|
||||||
of moving the cursor when using Vim on a terminal.
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
|
||||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
|
||||||
- Fix: A small problem when inserting a delimiter at
|
|
||||||
the beginning of the line.
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
|
||||||
autoload script to avoid loading unnecessary ones.
|
|
||||||
- Fixed a problem with the redo command.
|
|
||||||
- Many small fixes.
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.0 2010-04-01 * New features:
|
|
||||||
- All features are redo/undo-wise safe.
|
|
||||||
- A single quote typed after an alphanumeric
|
|
||||||
character is considered an apostrophe and one
|
|
||||||
single quote is inserted.
|
|
||||||
- A quote typed after another quote inserts a single
|
|
||||||
quote and the cursor jumps to the middle.
|
|
||||||
- <S-Tab> jumps out of any empty pair.
|
|
||||||
- <CR> and <Space> expansions are fixed, but the
|
|
||||||
functions used for it are global and can be used in
|
|
||||||
custom mappings. The previous system is still
|
|
||||||
active if you have any of the expansion options
|
|
||||||
set.
|
|
||||||
- <S-Backspace> deletes the closing delimiter.
|
|
||||||
|
|
||||||
* Fixed bug:
|
|
||||||
- s:vars were being used to store buffer options.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single
|
|
||||||
quotes when used as apostrophes. You can read
|
|
||||||
|delimitMate_apostrophes| for details.
|
|
||||||
Fixed an error when |b:delimitMate_expand_space|
|
|
||||||
wasn't set but |delimitMate_expand_space| wasn't.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.5 2009-10-05 * Fix: delimitMate should work correctly for files
|
|
||||||
passed as arguments to Vim. Thanks to Ben Beuchler
|
|
||||||
for helping to nail this bug.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even
|
|
||||||
if they don't have set the file type option or were
|
|
||||||
opened directly from the terminal.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.3 2009-09-24 * Now local options can be used along with autocmd
|
|
||||||
for specific file type configurations.
|
|
||||||
Fixes:
|
|
||||||
- Unnamed register content is not lost on visual
|
|
||||||
mode.
|
|
||||||
- Use noremap where appropiate.
|
|
||||||
- Wrapping a single empty line works as expected.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.2 2009-09-07 * Fixes:
|
|
||||||
- When inside nested empty pairs, deleting the
|
|
||||||
innermost left delimiter would delete all right
|
|
||||||
contiguous delimiters.
|
|
||||||
- When inside an empty pair, inserting a left
|
|
||||||
delimiter wouldn't insert the right one, instead
|
|
||||||
the cursor would jump to the right.
|
|
||||||
- New buffer inside the current window wouldn't
|
|
||||||
have the mappings set.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't
|
|
||||||
set and added support for GetLatestScripts
|
|
||||||
auto-detection.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.0 2009-08-23 * Initial upload.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
|
|
||||||
|
|
||||||
`\|||/´ MMM \|/ www __^__ ~
|
|
||||||
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
|
||||||
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
|
||||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
|
||||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
|
||||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
|
||||||
23
doc/tags
23
doc/tags
@@ -106,8 +106,10 @@
|
|||||||
:VCSVimDiff vcscommand.txt /*:VCSVimDiff*
|
:VCSVimDiff vcscommand.txt /*:VCSVimDiff*
|
||||||
:VWS vimwiki.txt /*:VWS*
|
:VWS vimwiki.txt /*:VWS*
|
||||||
:Vimwiki2HTML vimwiki.txt /*:Vimwiki2HTML*
|
:Vimwiki2HTML vimwiki.txt /*:Vimwiki2HTML*
|
||||||
|
:Vimwiki2HTMLBrowse vimwiki.txt /*:Vimwiki2HTMLBrowse*
|
||||||
:VimwikiAll2HTML vimwiki.txt /*:VimwikiAll2HTML*
|
:VimwikiAll2HTML vimwiki.txt /*:VimwikiAll2HTML*
|
||||||
:VimwikiDeleteLink vimwiki.txt /*:VimwikiDeleteLink*
|
:VimwikiDeleteLink vimwiki.txt /*:VimwikiDeleteLink*
|
||||||
|
:VimwikiDiaryIndex vimwiki.txt /*:VimwikiDiaryIndex*
|
||||||
:VimwikiDiaryNextDay vimwiki.txt /*:VimwikiDiaryNextDay*
|
:VimwikiDiaryNextDay vimwiki.txt /*:VimwikiDiaryNextDay*
|
||||||
:VimwikiDiaryPrevDay vimwiki.txt /*:VimwikiDiaryPrevDay*
|
:VimwikiDiaryPrevDay vimwiki.txt /*:VimwikiDiaryPrevDay*
|
||||||
:VimwikiFollowLink vimwiki.txt /*:VimwikiFollowLink*
|
:VimwikiFollowLink vimwiki.txt /*:VimwikiFollowLink*
|
||||||
@@ -126,6 +128,7 @@
|
|||||||
:VimwikiTable vimwiki.txt /*:VimwikiTable*
|
:VimwikiTable vimwiki.txt /*:VimwikiTable*
|
||||||
:VimwikiTableMoveColumnLeft vimwiki.txt /*:VimwikiTableMoveColumnLeft*
|
:VimwikiTableMoveColumnLeft vimwiki.txt /*:VimwikiTableMoveColumnLeft*
|
||||||
:VimwikiTableMoveColumnRight vimwiki.txt /*:VimwikiTableMoveColumnRight*
|
:VimwikiTableMoveColumnRight vimwiki.txt /*:VimwikiTableMoveColumnRight*
|
||||||
|
:VimwikiTabnewLink vimwiki.txt /*:VimwikiTabnewLink*
|
||||||
:VimwikiToggleListItem vimwiki.txt /*:VimwikiToggleListItem*
|
:VimwikiToggleListItem vimwiki.txt /*:VimwikiToggleListItem*
|
||||||
:VimwikiUISelect vimwiki.txt /*:VimwikiUISelect*
|
:VimwikiUISelect vimwiki.txt /*:VimwikiUISelect*
|
||||||
:VimwikiVSplitLink vimwiki.txt /*:VimwikiVSplitLink*
|
:VimwikiVSplitLink vimwiki.txt /*:VimwikiVSplitLink*
|
||||||
@@ -184,6 +187,14 @@ b:VCSCommandOriginalBuffer vcscommand.txt /*b:VCSCommandOriginalBuffer*
|
|||||||
b:VCSCommandSourceFile vcscommand.txt /*b:VCSCommandSourceFile*
|
b:VCSCommandSourceFile vcscommand.txt /*b:VCSCommandSourceFile*
|
||||||
b:VCSCommandVCSType vcscommand.txt /*b:VCSCommandVCSType*
|
b:VCSCommandVCSType vcscommand.txt /*b:VCSCommandVCSType*
|
||||||
b:loremipsum_file loremipsum.txt /*b:loremipsum_file*
|
b:loremipsum_file loremipsum.txt /*b:loremipsum_file*
|
||||||
|
buffergator buffergator.txt /*buffergator*
|
||||||
|
buffergator-commands buffergator.txt /*buffergator-commands*
|
||||||
|
buffergator-contents buffergator.txt /*buffergator-contents*
|
||||||
|
buffergator-global-keys buffergator.txt /*buffergator-global-keys*
|
||||||
|
buffergator-introduction buffergator.txt /*buffergator-introduction*
|
||||||
|
buffergator-keys buffergator.txt /*buffergator-keys*
|
||||||
|
buffergator-options buffergator.txt /*buffergator-options*
|
||||||
|
buffergator.txt buffergator.txt /*buffergator.txt*
|
||||||
cs surround.txt /*cs*
|
cs surround.txt /*cs*
|
||||||
cvscommand-changes vcscommand.txt /*cvscommand-changes*
|
cvscommand-changes vcscommand.txt /*cvscommand-changes*
|
||||||
delimitMate delimitMate.txt /*delimitMate*
|
delimitMate delimitMate.txt /*delimitMate*
|
||||||
@@ -411,6 +422,7 @@ g:vimwiki_table_auto_fmt vimwiki.txt /*g:vimwiki_table_auto_fmt*
|
|||||||
g:vimwiki_upper vimwiki.txt /*g:vimwiki_upper*
|
g:vimwiki_upper vimwiki.txt /*g:vimwiki_upper*
|
||||||
g:vimwiki_use_calendar vimwiki.txt /*g:vimwiki_use_calendar*
|
g:vimwiki_use_calendar vimwiki.txt /*g:vimwiki_use_calendar*
|
||||||
g:vimwiki_use_mouse vimwiki.txt /*g:vimwiki_use_mouse*
|
g:vimwiki_use_mouse vimwiki.txt /*g:vimwiki_use_mouse*
|
||||||
|
g:vimwiki_user_htmls vimwiki.txt /*g:vimwiki_user_htmls*
|
||||||
g:vimwiki_valid_html_tags vimwiki.txt /*g:vimwiki_valid_html_tags*
|
g:vimwiki_valid_html_tags vimwiki.txt /*g:vimwiki_valid_html_tags*
|
||||||
g:vimwiki_w32_dir_enc vimwiki.txt /*g:vimwiki_w32_dir_enc*
|
g:vimwiki_w32_dir_enc vimwiki.txt /*g:vimwiki_w32_dir_enc*
|
||||||
gundo.txt gundo.txt /*gundo.txt*
|
gundo.txt gundo.txt /*gundo.txt*
|
||||||
@@ -958,14 +970,15 @@ vimwiki-option-diary_index vimwiki.txt /*vimwiki-option-diary_index*
|
|||||||
vimwiki-option-diary_link_count vimwiki.txt /*vimwiki-option-diary_link_count*
|
vimwiki-option-diary_link_count vimwiki.txt /*vimwiki-option-diary_link_count*
|
||||||
vimwiki-option-diary_rel_path vimwiki.txt /*vimwiki-option-diary_rel_path*
|
vimwiki-option-diary_rel_path vimwiki.txt /*vimwiki-option-diary_rel_path*
|
||||||
vimwiki-option-ext vimwiki.txt /*vimwiki-option-ext*
|
vimwiki-option-ext vimwiki.txt /*vimwiki-option-ext*
|
||||||
vimwiki-option-html_footer vimwiki.txt /*vimwiki-option-html_footer*
|
|
||||||
vimwiki-option-html_header vimwiki.txt /*vimwiki-option-html_header*
|
|
||||||
vimwiki-option-index vimwiki.txt /*vimwiki-option-index*
|
vimwiki-option-index vimwiki.txt /*vimwiki-option-index*
|
||||||
vimwiki-option-maxhi vimwiki.txt /*vimwiki-option-maxhi*
|
vimwiki-option-maxhi vimwiki.txt /*vimwiki-option-maxhi*
|
||||||
vimwiki-option-nested_syntaxes vimwiki.txt /*vimwiki-option-nested_syntaxes*
|
vimwiki-option-nested_syntaxes vimwiki.txt /*vimwiki-option-nested_syntaxes*
|
||||||
vimwiki-option-path vimwiki.txt /*vimwiki-option-path*
|
vimwiki-option-path vimwiki.txt /*vimwiki-option-path*
|
||||||
vimwiki-option-path_html vimwiki.txt /*vimwiki-option-path_html*
|
vimwiki-option-path_html vimwiki.txt /*vimwiki-option-path_html*
|
||||||
vimwiki-option-syntax vimwiki.txt /*vimwiki-option-syntax*
|
vimwiki-option-syntax vimwiki.txt /*vimwiki-option-syntax*
|
||||||
|
vimwiki-option-template_default vimwiki.txt /*vimwiki-option-template_default*
|
||||||
|
vimwiki-option-template_ext vimwiki.txt /*vimwiki-option-template_ext*
|
||||||
|
vimwiki-option-template_path vimwiki.txt /*vimwiki-option-template_path*
|
||||||
vimwiki-options vimwiki.txt /*vimwiki-options*
|
vimwiki-options vimwiki.txt /*vimwiki-options*
|
||||||
vimwiki-placeholders vimwiki.txt /*vimwiki-placeholders*
|
vimwiki-placeholders vimwiki.txt /*vimwiki-placeholders*
|
||||||
vimwiki-prerequisites vimwiki.txt /*vimwiki-prerequisites*
|
vimwiki-prerequisites vimwiki.txt /*vimwiki-prerequisites*
|
||||||
@@ -973,6 +986,7 @@ vimwiki-syntax vimwiki.txt /*vimwiki-syntax*
|
|||||||
vimwiki-syntax-blockquotes vimwiki.txt /*vimwiki-syntax-blockquotes*
|
vimwiki-syntax-blockquotes vimwiki.txt /*vimwiki-syntax-blockquotes*
|
||||||
vimwiki-syntax-comments vimwiki.txt /*vimwiki-syntax-comments*
|
vimwiki-syntax-comments vimwiki.txt /*vimwiki-syntax-comments*
|
||||||
vimwiki-syntax-headers vimwiki.txt /*vimwiki-syntax-headers*
|
vimwiki-syntax-headers vimwiki.txt /*vimwiki-syntax-headers*
|
||||||
|
vimwiki-syntax-hr vimwiki.txt /*vimwiki-syntax-hr*
|
||||||
vimwiki-syntax-links vimwiki.txt /*vimwiki-syntax-links*
|
vimwiki-syntax-links vimwiki.txt /*vimwiki-syntax-links*
|
||||||
vimwiki-syntax-lists vimwiki.txt /*vimwiki-syntax-lists*
|
vimwiki-syntax-lists vimwiki.txt /*vimwiki-syntax-lists*
|
||||||
vimwiki-syntax-paragraphs vimwiki.txt /*vimwiki-syntax-paragraphs*
|
vimwiki-syntax-paragraphs vimwiki.txt /*vimwiki-syntax-paragraphs*
|
||||||
@@ -982,6 +996,7 @@ vimwiki-syntax-typefaces vimwiki.txt /*vimwiki-syntax-typefaces*
|
|||||||
vimwiki-table-mappings vimwiki.txt /*vimwiki-table-mappings*
|
vimwiki-table-mappings vimwiki.txt /*vimwiki-table-mappings*
|
||||||
vimwiki-table-of-contents vimwiki.txt /*vimwiki-table-of-contents*
|
vimwiki-table-of-contents vimwiki.txt /*vimwiki-table-of-contents*
|
||||||
vimwiki-tables vimwiki.txt /*vimwiki-tables*
|
vimwiki-tables vimwiki.txt /*vimwiki-tables*
|
||||||
|
vimwiki-template vimwiki.txt /*vimwiki-template*
|
||||||
vimwiki-temporary-wiki vimwiki.txt /*vimwiki-temporary-wiki*
|
vimwiki-temporary-wiki vimwiki.txt /*vimwiki-temporary-wiki*
|
||||||
vimwiki-text-objects vimwiki.txt /*vimwiki-text-objects*
|
vimwiki-text-objects vimwiki.txt /*vimwiki-text-objects*
|
||||||
vimwiki-title vimwiki.txt /*vimwiki-title*
|
vimwiki-title vimwiki.txt /*vimwiki-title*
|
||||||
@@ -994,10 +1009,14 @@ vimwiki_<A-Right> vimwiki.txt /*vimwiki_<A-Right>*
|
|||||||
vimwiki_<Backspace> vimwiki.txt /*vimwiki_<Backspace>*
|
vimwiki_<Backspace> vimwiki.txt /*vimwiki_<Backspace>*
|
||||||
vimwiki_<C-CR> vimwiki.txt /*vimwiki_<C-CR>*
|
vimwiki_<C-CR> vimwiki.txt /*vimwiki_<C-CR>*
|
||||||
vimwiki_<C-Down> vimwiki.txt /*vimwiki_<C-Down>*
|
vimwiki_<C-Down> vimwiki.txt /*vimwiki_<C-Down>*
|
||||||
|
vimwiki_<C-S-CR> vimwiki.txt /*vimwiki_<C-S-CR>*
|
||||||
vimwiki_<C-Space> vimwiki.txt /*vimwiki_<C-Space>*
|
vimwiki_<C-Space> vimwiki.txt /*vimwiki_<C-Space>*
|
||||||
vimwiki_<C-Up> vimwiki.txt /*vimwiki_<C-Up>*
|
vimwiki_<C-Up> vimwiki.txt /*vimwiki_<C-Up>*
|
||||||
vimwiki_<CR> vimwiki.txt /*vimwiki_<CR>*
|
vimwiki_<CR> vimwiki.txt /*vimwiki_<CR>*
|
||||||
|
vimwiki_<D-CR> vimwiki.txt /*vimwiki_<D-CR>*
|
||||||
vimwiki_<Leader>wd vimwiki.txt /*vimwiki_<Leader>wd*
|
vimwiki_<Leader>wd vimwiki.txt /*vimwiki_<Leader>wd*
|
||||||
|
vimwiki_<Leader>wh vimwiki.txt /*vimwiki_<Leader>wh*
|
||||||
|
vimwiki_<Leader>whh vimwiki.txt /*vimwiki_<Leader>whh*
|
||||||
vimwiki_<Leader>wr vimwiki.txt /*vimwiki_<Leader>wr*
|
vimwiki_<Leader>wr vimwiki.txt /*vimwiki_<Leader>wr*
|
||||||
vimwiki_<S-CR> vimwiki.txt /*vimwiki_<S-CR>*
|
vimwiki_<S-CR> vimwiki.txt /*vimwiki_<S-CR>*
|
||||||
vimwiki_<S-Tab> vimwiki.txt /*vimwiki_<S-Tab>*
|
vimwiki_<S-Tab> vimwiki.txt /*vimwiki_<S-Tab>*
|
||||||
|
|||||||
690
doc/vimwiki.txt
690
doc/vimwiki.txt
File diff suppressed because it is too large
Load Diff
783
doc2/vst-s5.html
783
doc2/vst-s5.html
@@ -1,783 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
<title>Vim reStructured Text</title>
|
|
||||||
<meta name="Generator" content="Vim reStructured Text 140 - Vim 7.2" />
|
|
||||||
<meta name="Author" content="George V. Reilly <george@reilly.org>" />
|
|
||||||
<meta name="Title" content="Vim reStructured Text - A Quick Introduction" />
|
|
||||||
<meta name="Date" content="2006/05/12" />
|
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
/*<![CDATA[*/
|
|
||||||
body { color: #000; background-color: #fff; margin: 0px 10%; min-width: 720px; font-family: Verdana, sans-serif;
|
|
||||||
counter-reset: chapter section subsection subsubsection paragraph lchapter lsection lsubsection lsubsubsection lparagraph}
|
|
||||||
div.footnote { border-left: 1px solid #000; margin-left: 0em; clear: both }
|
|
||||||
div.ftext { position: relative; margin-left: 50px }
|
|
||||||
div.fnumber { float: left; width: 40px; padding: 0em; margin-left: 0.5em; margin-top: 0em }
|
|
||||||
div.fnumber a { margin: 0px; padding: 0px }
|
|
||||||
div.ctext { position: relative; margin-left: 100px }
|
|
||||||
div.cnumber { float: left; width: 90px; padding: 0em; margin-left: 0.5em; margin-top: 0em }
|
|
||||||
div.cnumber a { margin: 0px; padding: 0px }
|
|
||||||
div.tip { border: 2px solid #0d0; margin: 0.5em 2em 1em 2em; padding: 0em 1em }
|
|
||||||
div.warning, div.caution, div.danger, div.error { border: 2px solid #f00; margin: 0.5em 2em 1em 2em; padding: 0em 1em }
|
|
||||||
div.note, div.hint, div.important { border: 2px solid #000; margin: 0.5em 2em 1em 2em; padding: 0em 1em }
|
|
||||||
div.figure { display: block; padding: 1em; width: 400px; clear: both}
|
|
||||||
div.topic { margin: 2em }
|
|
||||||
div.vstsidebar, div.sidebar { border: 2px solid #aaa; color: #000; background-color: #ffffee; float: right; width: 40%; margin-left: 1em; margin-right: -1em; padding: 1em }
|
|
||||||
span.strike { text-decoration: line-through }
|
|
||||||
span.big { font-size: large }
|
|
||||||
span.small { font-size: small }
|
|
||||||
span.title { font-style: italic }
|
|
||||||
span.notetitle { font-size: large; font-weight: 900; font-family: Verdana, sans-serif }
|
|
||||||
p.toc { font-size: large; font-weight: 900 }
|
|
||||||
p.notesubtitle { font-weight: 900; font-family: Verdana, sans-serif }
|
|
||||||
p.attribution { font-style: italic; margin-left: 8em; text-indent: -1.4em }
|
|
||||||
.vstright { float: right; margin: 1em }
|
|
||||||
.vstleft { float: left; margin: 1em }
|
|
||||||
.vstcenter { margin: 1em auto }
|
|
||||||
blockquote.pull { font-size: large }
|
|
||||||
p.rubric { font-size: large; margin-left: 2em }
|
|
||||||
dd.normal { margin-bottom: 0.5em }
|
|
||||||
dt.option { float: left; margin: 0em 0em 5px 2em; padding: 0px; font-family: monospace }
|
|
||||||
dd.option { padding: 0px; margin: 0em 0em 5px 10em; text-indent: 0.5em }
|
|
||||||
dd.option > p { margin: 0px }
|
|
||||||
dd.normal > p { margin: 0px }
|
|
||||||
table { border-collapse: collapse; margin: 0.5em 0em }
|
|
||||||
thead, tfoot { text-align: center; font-weight: bold }
|
|
||||||
td { border: 1px solid #000; padding: 0.25em; _top: 0%; vertical-align: top }
|
|
||||||
td blockquote p{ margin: 0px; padding: 0px}
|
|
||||||
td blockquote { margin: 0px; padding: 0px}
|
|
||||||
table.vstbless td { border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top }
|
|
||||||
td > p { margin: 0px }
|
|
||||||
table.field { border: 0px solid #000; margin-left: 2em; padding: 0.25em; _top: 0%; vertical-align: top }
|
|
||||||
td.fkey { font-weight: 900 }
|
|
||||||
td.fval { border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top }
|
|
||||||
td.fkey { font-weight: 900; border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top }
|
|
||||||
td.fdkey { text-align: center; font-weight: 900 }
|
|
||||||
td.fdval { text-align: center; font-style: italic }
|
|
||||||
td.fakey { text-align: center; font-weight: 900 }
|
|
||||||
td.faval { border: 0px solid #000; padding: 0.25em; _top: 0%; vertical-align: top }
|
|
||||||
hr { width: 80%; margin: 1.5em auto }
|
|
||||||
h1 { text-align: center; clear: both }
|
|
||||||
h2, h3, h4, h5, h6 { text-align: left; margin-top: 1em; clear: both }
|
|
||||||
h2 { counter-reset: section subsection subsubsection paragraph }
|
|
||||||
h3 { counter-reset: subsection subsubsection paragraph }
|
|
||||||
h4 { counter-reset: subsubsection paragraph }
|
|
||||||
h5 { counter-reset: paragraph }
|
|
||||||
h1 a { color: #000; background-color: transparent }
|
|
||||||
h2 a { color: #000; background-color: transparent }
|
|
||||||
h3 a { color: #000; background-color: transparent }
|
|
||||||
h4 a { color: #000; background-color: transparent }
|
|
||||||
h5 a { color: #000; background-color: transparent }
|
|
||||||
h6 a { color: #000; background-color: transparent }
|
|
||||||
p.subh1 { text-align: center; font-size: 120%; font-variant: small-caps }
|
|
||||||
p.subh2, p.subh3, p.subh4, p.subh5, p.subh6 { text-align: left; font-size: 120%; font-variant: small-caps }
|
|
||||||
h2:before { content: counter(chapter)" "; counter-increment: chapter }
|
|
||||||
h3:before { content: counter(chapter)"."counter(section)" "; counter-increment: section }
|
|
||||||
h4:before { content: counter(chapter)"."counter(section)"."counter(subsection)" "; counter-increment: subsection }
|
|
||||||
h5:before { content: counter(chapter)"."counter(section)"."counter(subsection)"."counter(subsubsection)" "; counter-increment: subsubsection }
|
|
||||||
h6:before { content: counter(chapter)"."counter(section)"."counter(subsection)"."counter(subsubsection)"."counter(paragraph)" "; counter-increment: paragraph}
|
|
||||||
li.h1 { margin-left: 0em }
|
|
||||||
li.h2 { margin-left: 1em; counter-reset: lsection lsubsection lsubsubsection lparagraph }
|
|
||||||
li.h3 { margin-left: 2em; counter-reset: lsubsection lsubsubsection lparagraph }
|
|
||||||
li.h4 { margin-left: 3em; counter-reset: lsubsubsection lparagraph }
|
|
||||||
li.h5 { margin-left: 4em; counter-reset: lparagraph }
|
|
||||||
li.h2:before { content: counter(lchapter)" "; counter-increment: lchapter }
|
|
||||||
li.h3:before { content: counter(lchapter)"."counter(lsection)" "; counter-increment: lsection }
|
|
||||||
li.h4:before { content: counter(lchapter)"."counter(lsection)"."counter(lsubsection)" "; counter-increment: lsubsection }
|
|
||||||
li.h5:before { content: counter(lchapter)"."counter(lsection)"."counter(lsubsection)"."counter(lsubsubsection)" "; counter-increment: lsubsubsection }
|
|
||||||
li.h6:before { content: counter(lchapter)"."counter(lsection)"."counter(lsubsection)"."counter(lsubsubsection)"."counter(lparagraph)" "; counter-increment: lparagraph}
|
|
||||||
li.h6 { margin-left: 5em }
|
|
||||||
ol, ul { margin-bottom: 0.5em; margin-top: 0.5em }
|
|
||||||
ol.loweralpha { list-style-type: lower-alpha }
|
|
||||||
ol.upperalpha { list-style-type: upper-alpha }
|
|
||||||
ol.lowerroman { list-style-type: lower-roman }
|
|
||||||
ol.upperroman { list-style-type: upper-roman }
|
|
||||||
ol.decimal { list-style-type: decimal }
|
|
||||||
ul.square { list-style-type: square }
|
|
||||||
ul.circle { list-style-type: circle }
|
|
||||||
ul.disc { list-style-type: disc }
|
|
||||||
li > p { margin: 0em }
|
|
||||||
img { border: 1px solid #000; padding: 0em; display: block; margin: 1em auto }
|
|
||||||
img.inline { border: 1px solid #000; padding: 0em; margin: 0em; display: inline }
|
|
||||||
pre { color: #000; background-color: #eee; margin-left: 2em; clear: both; overflow: auto }
|
|
||||||
div.unknown { font-family: monospace; color: #000; background-color: #fff; margin: 1em; padding: 1em; clear: both; border: 3px solid red}
|
|
||||||
pre.quoted { color: #000; background-color: #eee; margin-left: 0em; clear: both; overflow: auto }
|
|
||||||
pre.rawlatex { color: #000; background-color: #ddd; border: 1px solid #000; padding: 0.1em; clear: both; overflow: auto }
|
|
||||||
pre.address { font-family: Verdana, sans-serif; display: inline; margin: 0px; color: #000; background-color: #fff; overflow: auto }
|
|
||||||
span.target { text-decoration: underline }
|
|
||||||
div.vstfooter hr { width: 100%; margin: 0px }
|
|
||||||
div.vstfooter p { margin: 0px }
|
|
||||||
/*]]>*/
|
|
||||||
</style>
|
|
||||||
<!-- configuration parameters -->
|
|
||||||
<meta name="defaultView" content="slideshow" />
|
|
||||||
<meta name="controlVis" content="hidden" />
|
|
||||||
<meta name="version" content="S5 1.1" />
|
|
||||||
<!-- style sheet links -->
|
|
||||||
<link rel="stylesheet" href="s5ui/slides.css" type="text/css" media="projection" id="slideProj" />
|
|
||||||
<link rel="stylesheet" href="s5ui/outline.css" type="text/css" media="screen" id="outlineStyle" />
|
|
||||||
<link rel="stylesheet" href="s5ui/print.css" type="text/css" media="print" id="slidePrint" />
|
|
||||||
<link rel="stylesheet" href="s5ui/opera.css" type="text/css" media="projection" id="operaFix" />
|
|
||||||
<!-- S5 JS -->
|
|
||||||
<script src="s5ui/slides.js" type="text/javascript"></script>
|
|
||||||
<!-- VST-S5 -->
|
|
||||||
<style type="text/css">
|
|
||||||
/*<![CDATA[*/
|
|
||||||
h1:before, h2:before, h3:before, h4:before, h5:before, h6:before { content: "" }
|
|
||||||
/*]]>*/
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="layout">
|
|
||||||
<div id="controls"><!-- DO NOT EDIT --></div>
|
|
||||||
<div id="currentSlide"><!-- DO NOT EDIT --></div>
|
|
||||||
<div id="header"></div>
|
|
||||||
<div id="footer">
|
|
||||||
<h1>Vim reStructured Text</h1>
|
|
||||||
<h2>George V. Reilly <george@reilly.org> • 2006/05/12</h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="presentation">
|
|
||||||
|
|
||||||
<!-- .. This is a comment
|
|
||||||
-->
|
|
||||||
<!-- .. Use ":Vst s5" to generate the HTML for this document
|
|
||||||
-->
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lvim-restructured-text">Vim reStructured Text</h1>
|
|
||||||
<table class="field" summary="Field list"><tr><td class="fkey">Title:</td><td class="fval"> Vim reStructured Text - A Quick Introduction</td></tr>
|
|
||||||
|
|
||||||
<tr><td class="fkey">Author:</td><td class="fval"> George V. Reilly <george@reilly.org></td></tr>
|
|
||||||
|
|
||||||
<tr><td class="fkey">Date:</td><td class="fval"> 2006/05/12</td></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lwhat-is-vst63">What is VST?</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<a href="http://skawina.eu.org/mikolaj/vst.html" title="VST">VST</a> is an easy way to produce:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul class="circle">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
HTML
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
S5 Slides, like this document
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
LaTeX and PDF
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
from <a href="http://docutils.sf.net" title="reStructured text">reStructured text</a>: plain text
|
|
||||||
with minimal markup.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The powerful <a href="http://www.vim.org" title="Vim">Vim</a> editor is used to prepare the
|
|
||||||
material.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Please read the <span id="lsource" title="source" class="target">source</span> of these slides to see how the effects used herein are
|
|
||||||
achieved.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lsimple-markup">Simple markup</h1>
|
|
||||||
<ul class="square">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Bulleted Lists
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Numeric lists (nested)
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<ol class="decimal">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<strong>Bold</strong> text
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<em>Italics</em> text
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<code>typewriter</code> text
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li></ol>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Subscripts, H<sub>2</sub>O.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Replacement -- Vim reStructured Text -- of text.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lblockquotes">Blockquotes</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
You can embed blockquotes inside your text:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
Simple markup
|
|
||||||
==============
|
|
||||||
|
|
||||||
+ Bulleted Lists
|
|
||||||
+ Numeric lists (nested)
|
|
||||||
|
|
||||||
#. **Bold** text
|
|
||||||
2. *Italics* text
|
|
||||||
#. ``typewriter`` text
|
|
||||||
|
|
||||||
+ Replacement -- |VST| -- of text.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
is most of the text of the previous slide.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="llinks">Links</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
VST supports a variety of hyperlink notations.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul class="circle">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Starting points: <a href="#lwhat-is-vst63" title="What is VST?">What is VST?</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<a href="http://skawina.eu.org/mikolaj/vst.html#lexternal-links" title="External links">External links</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Internal links, such as <a href="#lsource" title="source">source</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Standalone links, <a href="http://www.vim.org">http://www.vim.org</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<a href="http://skawina.eu.org/mikolaj/vst.html#lembedded-uris" title="Embedded URIs">Embedded URIs</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The full effect of these links cannot be seen in the S5 slides.
|
|
||||||
Regenerate with <code>:Vst</code> instead.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="limages">Images</h1>
|
|
||||||
<p>
|
|
||||||
<a href="http://www.vim.org/">
|
|
||||||
<img src="http://www.vim.org/images/vim_header.gif" alt="http://www.vim.org/images/vim_header.gif" title="Vim" />
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
<div class="tip">
|
|
||||||
<p><span class="notetitle">Tip</span></p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
You can apply a variety of attributes to images.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
If you need really fine control, you may need to use <code>.. raw:: html</code>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</blockquote>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lsimple-tables">Simple Tables</h1>
|
|
||||||
<table class="vstborder" summary=""><col width="12%" /><col width="12%" /><col width="12%" /><col width="12%" /><col width="12%" /><col width="12%" /><col width="12%" />
|
|
||||||
<thead>
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
su
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
mo
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
tu
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
we
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
th
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
fr
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
sa
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td></tr>
|
|
||||||
|
|
||||||
</thead>
|
|
||||||
<tr><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
1
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td></tr>
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
2
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
3
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
4
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
5
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
6
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
7
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
8
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td></tr>
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
9
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
10
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
11
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
12
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
13
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
14
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
15
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td></tr>
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
16
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
17
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
18
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
19
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
20
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
21
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
22
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td></tr>
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
23
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
24
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
25
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
26
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
27
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
28
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
29
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td></tr>
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
30
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
31
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td><td>
|
|
||||||
</td></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lrich-tables">Rich Tables</h1>
|
|
||||||
<table class="vstborder" summary=""><col width="34%" /><col width="26%" /><col width="29%" />
|
|
||||||
<tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Cells are
|
|
||||||
separated
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
by bar with
|
|
||||||
spaces around
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<Space>|<Space>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr><tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<em>You</em> may use
|
|
||||||
<strong>inline</strong>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
markup,
|
|
||||||
<a href="#llinks" title="links">links</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
included.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr><tr><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
You can use various
|
|
||||||
types of structure
|
|
||||||
elements:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
Welcome to world
|
|
||||||
of preformatted
|
|
||||||
text.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
<ul class="disc">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
like lists
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="square">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
various
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
embedded
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
one into
|
|
||||||
other
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
VST will
|
|
||||||
interpret them.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Even paragraphs.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ol class="decimal">
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
And
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
not
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</li></ol>
|
|
||||||
</td>
|
|
||||||
</tr><tr><td colspan="2" style="text-align: center;">
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Text may span across several
|
|
||||||
columns. Cell can be also empty ->
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
</td>
|
|
||||||
</tr></table>
|
|
||||||
</div>
|
|
||||||
<div class="slide">
|
|
||||||
<h1 id="lconclusion">Conclusion</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
VST is an easy way to produce marked-up documents with easy-to-read source, in
|
|
||||||
Vim.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
This slideshow displays only a few features of VST. Be sure to read the
|
|
||||||
<a href="http://skawina.eu.org/mikolaj/vst.html" title="manual">manual</a>.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- .. vim:set tw=78 ai fo+=n fo-=l:
|
|
||||||
-->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
"Fast jump between differnces
|
|
||||||
nmap <M-Up> [c
|
|
||||||
nmap <M-Down> ]c
|
|
||||||
@@ -13,8 +13,6 @@ setlocal softtabstop=4
|
|||||||
setlocal tabstop=4
|
setlocal tabstop=4
|
||||||
setlocal textwidth=78
|
setlocal textwidth=78
|
||||||
setlocal colorcolumn=+1
|
setlocal colorcolumn=+1
|
||||||
" overwrite status line
|
|
||||||
setlocal statusline=%<%F\ %{TagInStatusLine()}\ %h%m%r%=%(%l,%c%V%)\ %3p%%
|
|
||||||
|
|
||||||
set wildignore+=*.pyc
|
set wildignore+=*.pyc
|
||||||
|
|
||||||
|
|||||||
@@ -1,311 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
ast
|
|
||||||
~~~
|
|
||||||
|
|
||||||
The `ast` module helps Python applications to process trees of the Python
|
|
||||||
abstract syntax grammar. The abstract syntax itself might change with
|
|
||||||
each Python release; this module helps to find out programmatically what
|
|
||||||
the current grammar looks like and allows modifications of it.
|
|
||||||
|
|
||||||
An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as
|
|
||||||
a flag to the `compile()` builtin function or by using the `parse()`
|
|
||||||
function from this module. The result will be a tree of objects whose
|
|
||||||
classes all inherit from `ast.AST`.
|
|
||||||
|
|
||||||
A modified abstract syntax tree can be compiled into a Python code object
|
|
||||||
using the built-in `compile()` function.
|
|
||||||
|
|
||||||
Additionally various helper functions are provided that make working with
|
|
||||||
the trees simpler. The main intention of the helper functions and this
|
|
||||||
module in general is to provide an easy to use interface for libraries
|
|
||||||
that work tightly with the python syntax (template engines for example).
|
|
||||||
|
|
||||||
|
|
||||||
:copyright: Copyright 2008 by Armin Ronacher.
|
|
||||||
:license: Python License.
|
|
||||||
"""
|
|
||||||
from _ast import *
|
|
||||||
from _ast import __version__
|
|
||||||
|
|
||||||
|
|
||||||
def parse(expr, filename='<unknown>', mode='exec'):
|
|
||||||
"""
|
|
||||||
Parse an expression into an AST node.
|
|
||||||
Equivalent to compile(expr, filename, mode, PyCF_ONLY_AST).
|
|
||||||
"""
|
|
||||||
return compile(expr, filename, mode, PyCF_ONLY_AST)
|
|
||||||
|
|
||||||
|
|
||||||
def literal_eval(node_or_string):
|
|
||||||
"""
|
|
||||||
Safely evaluate an expression node or a string containing a Python
|
|
||||||
expression. The string or node provided may only consist of the following
|
|
||||||
Python literal structures: strings, numbers, tuples, lists, dicts, booleans,
|
|
||||||
and None.
|
|
||||||
"""
|
|
||||||
_safe_names = {'None': None, 'True': True, 'False': False}
|
|
||||||
if isinstance(node_or_string, basestring):
|
|
||||||
node_or_string = parse(node_or_string, mode='eval')
|
|
||||||
if isinstance(node_or_string, Expression):
|
|
||||||
node_or_string = node_or_string.body
|
|
||||||
def _convert(node):
|
|
||||||
if isinstance(node, Str):
|
|
||||||
return node.s
|
|
||||||
elif isinstance(node, Num):
|
|
||||||
return node.n
|
|
||||||
elif isinstance(node, Tuple):
|
|
||||||
return tuple(map(_convert, node.elts))
|
|
||||||
elif isinstance(node, List):
|
|
||||||
return list(map(_convert, node.elts))
|
|
||||||
elif isinstance(node, Dict):
|
|
||||||
return dict((_convert(k), _convert(v)) for k, v
|
|
||||||
in zip(node.keys, node.values))
|
|
||||||
elif isinstance(node, Name):
|
|
||||||
if node.id in _safe_names:
|
|
||||||
return _safe_names[node.id]
|
|
||||||
raise ValueError('malformed string')
|
|
||||||
return _convert(node_or_string)
|
|
||||||
|
|
||||||
|
|
||||||
def dump(node, annotate_fields=True, include_attributes=False):
|
|
||||||
"""
|
|
||||||
Return a formatted dump of the tree in *node*. This is mainly useful for
|
|
||||||
debugging purposes. The returned string will show the names and the values
|
|
||||||
for fields. This makes the code impossible to evaluate, so if evaluation is
|
|
||||||
wanted *annotate_fields* must be set to False. Attributes such as line
|
|
||||||
numbers and column offsets are not dumped by default. If this is wanted,
|
|
||||||
*include_attributes* can be set to True.
|
|
||||||
"""
|
|
||||||
def _format(node):
|
|
||||||
if isinstance(node, AST):
|
|
||||||
fields = [(a, _format(b)) for a, b in iter_fields(node)]
|
|
||||||
rv = '%s(%s' % (node.__class__.__name__, ', '.join(
|
|
||||||
('%s=%s' % field for field in fields)
|
|
||||||
if annotate_fields else
|
|
||||||
(b for a, b in fields)
|
|
||||||
))
|
|
||||||
if include_attributes and node._attributes:
|
|
||||||
rv += fields and ', ' or ' '
|
|
||||||
rv += ', '.join('%s=%s' % (a, _format(getattr(node, a)))
|
|
||||||
for a in node._attributes)
|
|
||||||
return rv + ')'
|
|
||||||
elif isinstance(node, list):
|
|
||||||
return '[%s]' % ', '.join(_format(x) for x in node)
|
|
||||||
return repr(node)
|
|
||||||
if not isinstance(node, AST):
|
|
||||||
raise TypeError('expected AST, got %r' % node.__class__.__name__)
|
|
||||||
return _format(node)
|
|
||||||
|
|
||||||
|
|
||||||
def copy_location(new_node, old_node):
|
|
||||||
"""
|
|
||||||
Copy source location (`lineno` and `col_offset` attributes) from
|
|
||||||
*old_node* to *new_node* if possible, and return *new_node*.
|
|
||||||
"""
|
|
||||||
for attr in 'lineno', 'col_offset':
|
|
||||||
if attr in old_node._attributes and attr in new_node._attributes \
|
|
||||||
and hasattr(old_node, attr):
|
|
||||||
setattr(new_node, attr, getattr(old_node, attr))
|
|
||||||
return new_node
|
|
||||||
|
|
||||||
|
|
||||||
def fix_missing_locations(node):
|
|
||||||
"""
|
|
||||||
When you compile a node tree with compile(), the compiler expects lineno and
|
|
||||||
col_offset attributes for every node that supports them. This is rather
|
|
||||||
tedious to fill in for generated nodes, so this helper adds these attributes
|
|
||||||
recursively where not already set, by setting them to the values of the
|
|
||||||
parent node. It works recursively starting at *node*.
|
|
||||||
"""
|
|
||||||
def _fix(node, lineno, col_offset):
|
|
||||||
if 'lineno' in node._attributes:
|
|
||||||
if not hasattr(node, 'lineno'):
|
|
||||||
node.lineno = lineno
|
|
||||||
else:
|
|
||||||
lineno = node.lineno
|
|
||||||
if 'col_offset' in node._attributes:
|
|
||||||
if not hasattr(node, 'col_offset'):
|
|
||||||
node.col_offset = col_offset
|
|
||||||
else:
|
|
||||||
col_offset = node.col_offset
|
|
||||||
for child in iter_child_nodes(node):
|
|
||||||
_fix(child, lineno, col_offset)
|
|
||||||
_fix(node, 1, 0)
|
|
||||||
return node
|
|
||||||
|
|
||||||
def add_col_end(node):
|
|
||||||
def _fix(node, next):
|
|
||||||
children = list(iter_child_nodes(node))
|
|
||||||
for i, child in enumerate(children):
|
|
||||||
next_offset = children[i+1].col_offset if i < len(children) else next.col_offset
|
|
||||||
child.col_end = next_offset
|
|
||||||
|
|
||||||
|
|
||||||
def increment_lineno(node, n=1):
|
|
||||||
"""
|
|
||||||
Increment the line number of each node in the tree starting at *node* by *n*.
|
|
||||||
This is useful to "move code" to a different location in a file.
|
|
||||||
"""
|
|
||||||
if 'lineno' in node._attributes:
|
|
||||||
node.lineno = getattr(node, 'lineno', 0) + n
|
|
||||||
for child in walk(node):
|
|
||||||
if 'lineno' in child._attributes:
|
|
||||||
child.lineno = getattr(child, 'lineno', 0) + n
|
|
||||||
return node
|
|
||||||
|
|
||||||
|
|
||||||
def iter_fields(node):
|
|
||||||
"""
|
|
||||||
Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
|
|
||||||
that is present on *node*.
|
|
||||||
"""
|
|
||||||
if node._fields is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
for field in node._fields:
|
|
||||||
try:
|
|
||||||
yield field, getattr(node, field)
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def iter_child_nodes(node):
|
|
||||||
"""
|
|
||||||
Yield all direct child nodes of *node*, that is, all fields that are nodes
|
|
||||||
and all items of fields that are lists of nodes.
|
|
||||||
"""
|
|
||||||
for name, field in iter_fields(node):
|
|
||||||
if isinstance(field, AST):
|
|
||||||
yield field
|
|
||||||
elif isinstance(field, list):
|
|
||||||
for item in field:
|
|
||||||
if isinstance(item, AST):
|
|
||||||
yield item
|
|
||||||
|
|
||||||
|
|
||||||
def get_docstring(node, clean=True):
|
|
||||||
"""
|
|
||||||
Return the docstring for the given node or None if no docstring can
|
|
||||||
be found. If the node provided does not have docstrings a TypeError
|
|
||||||
will be raised.
|
|
||||||
"""
|
|
||||||
if not isinstance(node, (FunctionDef, ClassDef, Module)):
|
|
||||||
raise TypeError("%r can't have docstrings" % node.__class__.__name__)
|
|
||||||
if node.body and isinstance(node.body[0], Expr) and \
|
|
||||||
isinstance(node.body[0].value, Str):
|
|
||||||
if clean:
|
|
||||||
import inspect
|
|
||||||
return inspect.cleandoc(node.body[0].value.s)
|
|
||||||
return node.body[0].value.s
|
|
||||||
|
|
||||||
|
|
||||||
def walk(node):
|
|
||||||
"""
|
|
||||||
Recursively yield all child nodes of *node*, in no specified order. This is
|
|
||||||
useful if you only want to modify nodes in place and don't care about the
|
|
||||||
context.
|
|
||||||
"""
|
|
||||||
from collections import deque
|
|
||||||
todo = deque([node])
|
|
||||||
while todo:
|
|
||||||
node = todo.popleft()
|
|
||||||
todo.extend(iter_child_nodes(node))
|
|
||||||
yield node
|
|
||||||
|
|
||||||
|
|
||||||
class NodeVisitor(object):
|
|
||||||
"""
|
|
||||||
A node visitor base class that walks the abstract syntax tree and calls a
|
|
||||||
visitor function for every node found. This function may return a value
|
|
||||||
which is forwarded by the `visit` method.
|
|
||||||
|
|
||||||
This class is meant to be subclassed, with the subclass adding visitor
|
|
||||||
methods.
|
|
||||||
|
|
||||||
Per default the visitor functions for the nodes are ``'visit_'`` +
|
|
||||||
class name of the node. So a `TryFinally` node visit function would
|
|
||||||
be `visit_TryFinally`. This behavior can be changed by overriding
|
|
||||||
the `visit` method. If no visitor function exists for a node
|
|
||||||
(return value `None`) the `generic_visit` visitor is used instead.
|
|
||||||
|
|
||||||
Don't use the `NodeVisitor` if you want to apply changes to nodes during
|
|
||||||
traversing. For this a special visitor exists (`NodeTransformer`) that
|
|
||||||
allows modifications.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def visit(self, node):
|
|
||||||
"""Visit a node."""
|
|
||||||
method = 'visit_' + node.__class__.__name__
|
|
||||||
visitor = getattr(self, method, self.generic_visit)
|
|
||||||
return visitor(node)
|
|
||||||
|
|
||||||
def generic_visit(self, node):
|
|
||||||
"""Called if no explicit visitor function exists for a node."""
|
|
||||||
for field, value in iter_fields(node):
|
|
||||||
if isinstance(value, list):
|
|
||||||
for item in value:
|
|
||||||
if isinstance(item, AST):
|
|
||||||
self.visit(item)
|
|
||||||
elif isinstance(value, AST):
|
|
||||||
self.visit(value)
|
|
||||||
|
|
||||||
|
|
||||||
class NodeTransformer(NodeVisitor):
|
|
||||||
"""
|
|
||||||
A :class:`NodeVisitor` subclass that walks the abstract syntax tree and
|
|
||||||
allows modification of nodes.
|
|
||||||
|
|
||||||
The `NodeTransformer` will walk the AST and use the return value of the
|
|
||||||
visitor methods to replace or remove the old node. If the return value of
|
|
||||||
the visitor method is ``None``, the node will be removed from its location,
|
|
||||||
otherwise it is replaced with the return value. The return value may be the
|
|
||||||
original node in which case no replacement takes place.
|
|
||||||
|
|
||||||
Here is an example transformer that rewrites all occurrences of name lookups
|
|
||||||
(``foo``) to ``data['foo']``::
|
|
||||||
|
|
||||||
class RewriteName(NodeTransformer):
|
|
||||||
|
|
||||||
def visit_Name(self, node):
|
|
||||||
return copy_location(Subscript(
|
|
||||||
value=Name(id='data', ctx=Load()),
|
|
||||||
slice=Index(value=Str(s=node.id)),
|
|
||||||
ctx=node.ctx
|
|
||||||
), node)
|
|
||||||
|
|
||||||
Keep in mind that if the node you're operating on has child nodes you must
|
|
||||||
either transform the child nodes yourself or call the :meth:`generic_visit`
|
|
||||||
method for the node first.
|
|
||||||
|
|
||||||
For nodes that were part of a collection of statements (that applies to all
|
|
||||||
statement nodes), the visitor may also return a list of nodes rather than
|
|
||||||
just a single node.
|
|
||||||
|
|
||||||
Usually you use the transformer like this::
|
|
||||||
|
|
||||||
node = YourTransformer().visit(node)
|
|
||||||
"""
|
|
||||||
|
|
||||||
def generic_visit(self, node):
|
|
||||||
for field, old_value in iter_fields(node):
|
|
||||||
old_value = getattr(node, field, None)
|
|
||||||
if isinstance(old_value, list):
|
|
||||||
new_values = []
|
|
||||||
for value in old_value:
|
|
||||||
if isinstance(value, AST):
|
|
||||||
value = self.visit(value)
|
|
||||||
if value is None:
|
|
||||||
continue
|
|
||||||
elif not isinstance(value, AST):
|
|
||||||
new_values.extend(value)
|
|
||||||
continue
|
|
||||||
new_values.append(value)
|
|
||||||
old_value[:] = new_values
|
|
||||||
elif isinstance(old_value, AST):
|
|
||||||
new_node = self.visit(old_value)
|
|
||||||
if new_node is None:
|
|
||||||
delattr(node, field)
|
|
||||||
else:
|
|
||||||
setattr(node, field, new_node)
|
|
||||||
return node
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
" File: pythonhelper.vim
|
" File: pythonhelper.vim
|
||||||
" Author: Michal Vitecek <fuf-at-mageo-dot-cz>
|
" Author: Michal Vitecek <fuf-at-mageo-dot-cz>
|
||||||
" Version: 0.81
|
" Version: 0.83
|
||||||
" Last Modified: Oct 24, 2002
|
" Last Modified: Jan 4, 2010
|
||||||
"
|
|
||||||
" Modified by Marius Gedminas <mgedmin@b4net.lt>
|
|
||||||
"
|
"
|
||||||
" Overview
|
" Overview
|
||||||
" --------
|
" --------
|
||||||
@@ -20,12 +18,6 @@
|
|||||||
" support by issuing command :ver and looking for +python in the list of
|
" support by issuing command :ver and looking for +python in the list of
|
||||||
" features.
|
" features.
|
||||||
"
|
"
|
||||||
" Note: The script displays current tag on the status line only in NORMAL
|
|
||||||
" mode. This is because CursorHold event is fired up only in this mode.
|
|
||||||
" However if you badly need to know what tag you are in even in INSERT or
|
|
||||||
" VISUAL mode, contact me on the above specified email address and I'll send
|
|
||||||
" you a patch that enables firing up CursorHold event in those modes as well.
|
|
||||||
"
|
|
||||||
" Installation
|
" Installation
|
||||||
" ------------
|
" ------------
|
||||||
" 1. Make sure your Vim has python feature on (+python). If not, you will need
|
" 1. Make sure your Vim has python feature on (+python). If not, you will need
|
||||||
@@ -33,18 +25,14 @@
|
|||||||
" 2. Copy script pythonhelper.vim to the $HOME/.vim/plugin directory
|
" 2. Copy script pythonhelper.vim to the $HOME/.vim/plugin directory
|
||||||
" 3. Run Vim and open any python file.
|
" 3. Run Vim and open any python file.
|
||||||
"
|
"
|
||||||
" Marius Gedminas <marius@gedmin.as>:
|
|
||||||
" 4. change 'statusline' to include
|
|
||||||
" %{TagInStatusLine()}
|
|
||||||
"
|
|
||||||
if has("python")
|
|
||||||
python << EOS
|
python << EOS
|
||||||
|
|
||||||
# import of required modules {{{
|
# import of required modules {{{
|
||||||
import vim
|
|
||||||
import time
|
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
import vim
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +44,7 @@ BUFFERTICKS = {}
|
|||||||
|
|
||||||
|
|
||||||
# class PythonTag() {{{
|
# class PythonTag() {{{
|
||||||
class PythonTag:
|
class PythonTag(object):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""A simple storage class representing a python tag.
|
"""A simple storage class representing a python tag.
|
||||||
"""
|
"""
|
||||||
@@ -65,17 +53,17 @@ class PythonTag:
|
|||||||
|
|
||||||
# STATIC VARIABLES {{{
|
# STATIC VARIABLES {{{
|
||||||
|
|
||||||
# tag type IDs {{{
|
# possible tag types {{{
|
||||||
TAGTYPE_CLASS = 0
|
TT_CLASS = 0
|
||||||
TAGTYPE_METHOD = 1
|
TT_METHOD = 1
|
||||||
TAGTYPE_FUNCTION = 2
|
TT_FUNCTION = 2
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# tag type names {{{
|
# tag type names {{{
|
||||||
typeName = {
|
TAG_TYPE_NAME = {
|
||||||
TAGTYPE_CLASS : "class",
|
TT_CLASS : "class",
|
||||||
TAGTYPE_METHOD : "method",
|
TT_METHOD : "method",
|
||||||
TAGTYPE_FUNCTION : "function",
|
TT_FUNCTION : "function",
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -84,9 +72,9 @@ class PythonTag:
|
|||||||
|
|
||||||
# METHODS {{{
|
# METHODS {{{
|
||||||
|
|
||||||
def __init__(self, type, name, fullName, lineNumber, indentLevel, parentTag):
|
def __init__(self, type, name, fullName, lineNumber, indentLevel):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Initializes instances of class PythonTag().
|
"""Initializes instances of PythonTag().
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
@@ -103,12 +91,13 @@ class PythonTag:
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# remember the settings {{{
|
||||||
self.type = type
|
self.type = type
|
||||||
self.name = name
|
self.name = name
|
||||||
self.fullName = fullName
|
self.fullName = fullName
|
||||||
self.lineNumber = lineNumber
|
self.lineNumber = lineNumber
|
||||||
self.indentLevel = indentLevel
|
self.indentLevel = indentLevel
|
||||||
self.parentTag = parentTag
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,10 +108,11 @@ class PythonTag:
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
return "%s (%s) [%s, %u, %u]" % (self.name, PythonTag.typeName[self.type],
|
return "%s (%s) [%s, %u, %u]" % (self.name, PythonTag.TAG_TYPE_NAME[self.type],
|
||||||
self.fullName, self.lineNumber, self.indentLevel,)
|
self.fullName, self.lineNumber, self.indentLevel,)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
__repr__ = __str__
|
__repr__ = __str__
|
||||||
|
|
||||||
|
|
||||||
@@ -131,10 +121,9 @@ class PythonTag:
|
|||||||
|
|
||||||
|
|
||||||
# class SimplePythonTagsParser() {{{
|
# class SimplePythonTagsParser() {{{
|
||||||
class SimplePythonTagsParser:
|
class SimplePythonTagsParser(object):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Provides a simple python tag parser. Returns list of PythonTag()
|
"""Provides a simple python tag parser.
|
||||||
instances.
|
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -143,13 +132,12 @@ class SimplePythonTagsParser:
|
|||||||
|
|
||||||
# how many chars a single tab represents (visually)
|
# how many chars a single tab represents (visually)
|
||||||
TABSIZE = 8
|
TABSIZE = 8
|
||||||
|
# regexp used to extract indentation and strip comments
|
||||||
# regexp used to get indentation and strip comments
|
COMMENTS_INDENT_RE = re.compile('([ \t]*)([^\n#]*).*')
|
||||||
commentsIndentStripRE = re.compile('([ \t]*)([^\n#]*).*')
|
# regexp used to extract a class name
|
||||||
# regexp used to get class name
|
CLASS_RE = re.compile('class[ \t]+([^(:]+).*')
|
||||||
classRE = re.compile('class[ \t]+([a-zA-Z0-9_]+)[ \t]*([(:].*|$)')
|
# regexp used to extract a method or function name
|
||||||
# regexp used to get method or function name
|
METHOD_RE = re.compile('def[ \t]+([^(]+).*')
|
||||||
methodRE = re.compile('def[ \t]+([^(]+).*')
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -158,7 +146,7 @@ class SimplePythonTagsParser:
|
|||||||
|
|
||||||
def __init__(self, source):
|
def __init__(self, source):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Initializes the instance of class SimplePythonTagsParser().
|
"""Initializes instances of SimplePythonTagsParser().
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
@@ -169,8 +157,8 @@ class SimplePythonTagsParser:
|
|||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
# make sure source has readline() method {{{
|
# make sure source has readline() method {{{
|
||||||
if (not(hasattr(source, 'readline') and
|
if ((hasattr(source, 'readline') == 0) or
|
||||||
callable(source.readline))):
|
(callable(source.readline) == 0)):
|
||||||
raise AttributeError("Source must have callable readline method.")
|
raise AttributeError("Source must have callable readline method.")
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -181,19 +169,23 @@ class SimplePythonTagsParser:
|
|||||||
|
|
||||||
def getTags(self):
|
def getTags(self):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Determines all the tags for the buffer. Returns tuple in format
|
"""Determines all the tags for the buffer. Returns a tuple in format
|
||||||
(tagLineNumbers, tags,).
|
(tagLineNumbers, tags,).
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# initialize the resulting list of the tag line numbers and the tag information {{{
|
||||||
tagLineNumbers = []
|
tagLineNumbers = []
|
||||||
tags = {}
|
tags = {}
|
||||||
|
# }}}
|
||||||
|
|
||||||
# list (stack) of all currently active tags
|
# initalize local auxiliary variables {{{
|
||||||
tagsStack = []
|
tagsStack = []
|
||||||
|
|
||||||
lineNumber = 0
|
lineNumber = 0
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# go through all the lines in the source and localize all python tags in it {{{
|
||||||
while 1:
|
while 1:
|
||||||
# get next line
|
# get next line
|
||||||
line = self.source.readline()
|
line = self.source.readline()
|
||||||
@@ -203,57 +195,73 @@ class SimplePythonTagsParser:
|
|||||||
break
|
break
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
# increase the line number
|
||||||
lineNumber += 1
|
lineNumber += 1
|
||||||
lineMatch = self.commentsIndentStripRE.match(line)
|
|
||||||
lineContents = lineMatch.group(2)
|
# extract the line indentation characters and its content {{{
|
||||||
# class tag {{{
|
lineMatch = self.COMMENTS_INDENT_RE.match(line)
|
||||||
tagMatch = self.classRE.match(lineContents)
|
lineContent = lineMatch.group(2)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# handle the class tag {{{
|
||||||
|
# match for the class tag
|
||||||
|
tagMatch = self.CLASS_RE.match(lineContent)
|
||||||
|
|
||||||
|
# if the class tag has been found, store some information on it {{{
|
||||||
if (tagMatch):
|
if (tagMatch):
|
||||||
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
|
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
|
||||||
tagMatch.group(1), self.tagClassTypeDecidingMethod)
|
tagMatch.group(1), self.tagClassTypeDecidingMethod)
|
||||||
tagLineNumbers.append(lineNumber)
|
tagLineNumbers.append(lineNumber)
|
||||||
tags[lineNumber] = currentTag
|
tags[lineNumber] = currentTag
|
||||||
# }}}
|
# }}}
|
||||||
# function/method/none tag {{{
|
# }}}
|
||||||
|
# handle the function/method/none tag {{{
|
||||||
else:
|
else:
|
||||||
tagMatch = self.methodRE.match(lineContents)
|
# match for the method/function tag
|
||||||
|
tagMatch = self.METHOD_RE.match(lineContent)
|
||||||
|
|
||||||
|
# if the method/function tag has been found, store some information on it {{{
|
||||||
if (tagMatch):
|
if (tagMatch):
|
||||||
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
|
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
|
||||||
tagMatch.group(1), self.tagFunctionTypeDecidingMethod)
|
tagMatch.group(1), self.tagFunctionTypeDecidingMethod)
|
||||||
tagLineNumbers.append(lineNumber)
|
tagLineNumbers.append(lineNumber)
|
||||||
tags[lineNumber] = currentTag
|
tags[lineNumber] = currentTag
|
||||||
# }}}
|
# }}}
|
||||||
|
# }}}
|
||||||
|
# }}}
|
||||||
|
|
||||||
# return the tags data for the source
|
# return the tags data for the source
|
||||||
return (tagLineNumbers, tags,)
|
return (tagLineNumbers, tags,)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def getPreviousTag(self, tagsStack):
|
def getParentTag(self, tagsStack):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Returns the previous tag (instance of PythonTag()) from the
|
"""Returns the parent/enclosing tag (instance of PythonTag()) from the
|
||||||
specified tag list if possible. If not, returns None.
|
specified tag list. If no such parent tag exists, returns None.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
tagsStack -- list (stack) of currently active PythonTag() instances
|
tagsStack -- list (stack) of currently open PythonTag() instances
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# determine the parent tag {{{
|
||||||
if (len(tagsStack)):
|
if (len(tagsStack)):
|
||||||
previousTag = tagsStack[-1]
|
parentTag = tagsStack[-1]
|
||||||
else:
|
else:
|
||||||
previousTag = None
|
parentTag = None
|
||||||
|
# }}}
|
||||||
|
|
||||||
# return the tag
|
# return the tag
|
||||||
return previousTag
|
return parentTag
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def computeIndentLevel(self, indentChars):
|
def computeIndentationLevel(indentChars):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Computes indent level from the specified string.
|
"""Computes the indentation level from the specified string.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
@@ -262,15 +270,21 @@ class SimplePythonTagsParser:
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# initialize the indentation level
|
||||||
indentLevel = 0
|
indentLevel = 0
|
||||||
|
|
||||||
|
# compute the indentation level (expand tabs) {{{
|
||||||
for char in indentChars:
|
for char in indentChars:
|
||||||
if (char == '\t'):
|
if (char == '\t'):
|
||||||
indentLevel += self.TABSIZE
|
indentLevel += SimplePythonTagsParser.TABSIZE
|
||||||
else:
|
else:
|
||||||
indentLevel += 1
|
indentLevel += 1
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# return the computed indentation level
|
||||||
return indentLevel
|
return indentLevel
|
||||||
# }}}
|
# }}}
|
||||||
|
computeIndentationLevel = staticmethod(computeIndentationLevel)
|
||||||
|
|
||||||
|
|
||||||
def getPythonTag(self, tagsStack, lineNumber, indentChars, tagName, tagTypeDecidingMethod):
|
def getPythonTag(self, tagsStack, lineNumber, indentChars, tagName, tagTypeDecidingMethod):
|
||||||
@@ -290,58 +304,81 @@ class SimplePythonTagsParser:
|
|||||||
tagName -- short name of the current tag
|
tagName -- short name of the current tag
|
||||||
|
|
||||||
tagTypeDecidingMethod -- reference to method that is called to
|
tagTypeDecidingMethod -- reference to method that is called to
|
||||||
determine type of the current tag
|
determine the type of the current tag
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
indentLevel = self.computeIndentLevel(indentChars)
|
# compute the indentation level
|
||||||
previousTag = self.getPreviousTag(tagsStack)
|
indentLevel = self.computeIndentationLevel(indentChars)
|
||||||
# code for enclosed tag {{{
|
# get the parent tag
|
||||||
while (previousTag):
|
parentTag = self.getParentTag(tagsStack)
|
||||||
if (previousTag.indentLevel >= indentLevel):
|
|
||||||
|
# handle an enclosed tag {{{
|
||||||
|
while (parentTag):
|
||||||
|
# if the indent level of the parent tag is greater than of the current tag, use parent tag of the parent tag {{{
|
||||||
|
if (parentTag.indentLevel >= indentLevel):
|
||||||
del tagsStack[-1]
|
del tagsStack[-1]
|
||||||
else:
|
|
||||||
tagType = tagTypeDecidingMethod(previousTag.type)
|
|
||||||
tag = PythonTag(tagType, tagName, "%s.%s" % (previousTag.fullName, tagName,), lineNumber, indentLevel, previousTag)
|
|
||||||
tagsStack.append(tag)
|
|
||||||
return tag
|
|
||||||
previousTag = self.getPreviousTag(tagsStack)
|
|
||||||
# }}}
|
# }}}
|
||||||
# code for tag in top indent level {{{
|
# otherwise we have all information on the current tag and can return it {{{
|
||||||
else:
|
else:
|
||||||
tagType = tagTypeDecidingMethod(None)
|
# create the tag
|
||||||
tag = PythonTag(tagType, tagName, tagName, lineNumber, indentLevel, None)
|
tag = PythonTag(tagTypeDecidingMethod(parentTag.type), tagName, "%s.%s" % (parentTag.fullName, tagName,), lineNumber, indentLevel)
|
||||||
tagsStack.append(tag)
|
|
||||||
return tag
|
# break the loop
|
||||||
|
break
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
# use parent tag of the parent tag
|
||||||
|
parentTag = self.getParentTag(tagsStack)
|
||||||
|
# }}}
|
||||||
|
# handle a top-indent level tag {{{
|
||||||
|
else:
|
||||||
|
# create the tag
|
||||||
|
tag = PythonTag(tagTypeDecidingMethod(None), tagName, tagName, lineNumber, indentLevel)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# add the tag to the list of tags
|
||||||
|
tagsStack.append(tag)
|
||||||
|
|
||||||
|
# return the tag
|
||||||
|
return tag
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def tagClassTypeDecidingMethod(self, previousTagsType):
|
def tagClassTypeDecidingMethod(self, parentTagType):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Returns tag type of the current tag based on its previous tag (super
|
"""Returns tag type of the current tag based on its previous tag (super
|
||||||
tag) for classes.
|
tag) for classes.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
|
||||||
|
parentTagType -- type of the enclosing/parent tag
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
return PythonTag.TAGTYPE_CLASS
|
# is always class no matter what
|
||||||
|
return PythonTag.TT_CLASS
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def tagFunctionTypeDecidingMethod(self, previousTagsType):
|
def tagFunctionTypeDecidingMethod(self, parentTagType):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Returns tag type of the current tag based on its previous tag (super
|
"""Returns tag type of the current tag based on its previous tag (super
|
||||||
tag) for functions/methods.
|
tag) for functions/methods.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
|
||||||
|
parentTagType -- type of the enclosing/parent tag
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
if (previousTagsType == PythonTag.TAGTYPE_CLASS):
|
if (parentTagType == PythonTag.TT_CLASS):
|
||||||
return PythonTag.TAGTYPE_METHOD
|
return PythonTag.TT_METHOD
|
||||||
else:
|
else:
|
||||||
return PythonTag.TAGTYPE_FUNCTION
|
return PythonTag.TT_FUNCTION
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
@@ -350,7 +387,7 @@ class SimplePythonTagsParser:
|
|||||||
|
|
||||||
|
|
||||||
# class VimReadlineBuffer() {{{
|
# class VimReadlineBuffer() {{{
|
||||||
class VimReadlineBuffer:
|
class VimReadlineBuffer(object):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""A simple wrapper class around vim's buffer that provides readline
|
"""A simple wrapper class around vim's buffer that provides readline
|
||||||
method.
|
method.
|
||||||
@@ -362,7 +399,7 @@ class VimReadlineBuffer:
|
|||||||
|
|
||||||
def __init__(self, vimBuffer):
|
def __init__(self, vimBuffer):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Initializes the instance of class VimReadlineBuffer().
|
"""Initializes instances of VimReadlineBuffer().
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
@@ -371,10 +408,14 @@ class VimReadlineBuffer:
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# remember the settings
|
||||||
self.vimBuffer = vimBuffer
|
self.vimBuffer = vimBuffer
|
||||||
|
|
||||||
|
# initialize instance attributes {{{
|
||||||
self.currentLine = -1
|
self.currentLine = -1
|
||||||
self.bufferLines = len(vimBuffer)
|
self.bufferLines = len(vimBuffer)
|
||||||
# }}}
|
# }}}
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
@@ -385,6 +426,7 @@ class VimReadlineBuffer:
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# increase the current line counter
|
||||||
self.currentLine += 1
|
self.currentLine += 1
|
||||||
|
|
||||||
# notify end of file if we reached beyond the last line {{{
|
# notify end of file if we reached beyond the last line {{{
|
||||||
@@ -392,18 +434,19 @@ class VimReadlineBuffer:
|
|||||||
return ''
|
return ''
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# return the line with added newline (vim stores the lines without newline)
|
# return the line with an added newline (vim stores the lines without it)
|
||||||
return "%s\n" % (self.vimBuffer[self.currentLine],)
|
return "%s\n" % (self.vimBuffer[self.currentLine],)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def getNearestLineIndex(row, tagLineNumbers):
|
def getNearestLineIndex(row, tagLineNumbers):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Returns index of line in tagLineNumbers list that is nearest to the
|
"""Returns the index of line in 'tagLineNumbers' list that is nearest to the
|
||||||
current cursor row.
|
specified cursor row.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
@@ -414,27 +457,33 @@ def getNearestLineIndex(row, tagLineNumbers):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# initialize local auxiliary variables {{{
|
||||||
nearestLineNumber = -1
|
nearestLineNumber = -1
|
||||||
nearestLineIndex = -1
|
nearestLineIndex = -1
|
||||||
i = 0
|
# }}}
|
||||||
for lineNumber in tagLineNumbers:
|
|
||||||
|
# go through all tag line numbers and find the one nearest to the specified row {{{
|
||||||
|
for lineIndex, lineNumber in enumerate(tagLineNumbers):
|
||||||
# if the current line is nearer the current cursor position, take it {{{
|
# if the current line is nearer the current cursor position, take it {{{
|
||||||
if (nearestLineNumber < lineNumber <= row):
|
if (nearestLineNumber < lineNumber <= row):
|
||||||
nearestLineNumber = lineNumber
|
nearestLineNumber = lineNumber
|
||||||
nearestLineIndex = i
|
nearestLineIndex = lineIndex
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# if we've got past the current cursor position, let's end the search {{{
|
# if we've got past the current cursor position, let's end the search {{{
|
||||||
if (lineNumber >= row):
|
if (lineNumber >= row):
|
||||||
break
|
break
|
||||||
# }}}
|
# }}}
|
||||||
i += 1
|
# }}}
|
||||||
|
|
||||||
|
# return index of the line with the nearest tag
|
||||||
return nearestLineIndex
|
return nearestLineIndex
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def getTags(bufferNumber, changedTick):
|
def getTags(bufferNumber, changedTick):
|
||||||
# DOC {{{
|
# DOC {{{
|
||||||
"""Reads the tags for the specified buffer number. Returns tuple
|
"""Reads the tags for the specified buffer number. Returns a tuple
|
||||||
(taglinenumber[buffer], tags[buffer],).
|
(taglinenumber[buffer], tags[buffer],).
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -447,10 +496,11 @@ def getTags(bufferNumber, changedTick):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# define global variables
|
||||||
global TAGLINENUMBERS, TAGS, BUFFERTICKS
|
global TAGLINENUMBERS, TAGS, BUFFERTICKS
|
||||||
|
|
||||||
# return immediately if there's no need to update the tags {{{
|
# return immediately if there's no need to update the tags {{{
|
||||||
if ((BUFFERTICKS.has_key(bufferNumber)) and (BUFFERTICKS[bufferNumber] == changedTick)):
|
if (BUFFERTICKS.get(bufferNumber, None) == changedTick):
|
||||||
return (TAGLINENUMBERS[bufferNumber], TAGS[bufferNumber],)
|
return (TAGLINENUMBERS[bufferNumber], TAGS[bufferNumber],)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -465,7 +515,7 @@ def getTags(bufferNumber, changedTick):
|
|||||||
BUFFERTICKS[bufferNumber] = changedTick
|
BUFFERTICKS[bufferNumber] = changedTick
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# return the tags data
|
# return the tuple (tagLineNumbers, tags,)
|
||||||
return (tagLineNumbers, tags,)
|
return (tagLineNumbers, tags,)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -484,12 +534,12 @@ def findTag(bufferNumber, changedTick):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# try to find the best tag {{{
|
||||||
try:
|
try:
|
||||||
# get the tags data for the current buffer {{{
|
# get the tags data for the current buffer
|
||||||
tagLineNumbers, tags = getTags(bufferNumber, changedTick)
|
tagLineNumbers, tags = getTags(bufferNumber, changedTick)
|
||||||
# }}}
|
|
||||||
|
|
||||||
# link to vim internal data {{{
|
# link to vim's internal data {{{
|
||||||
currentBuffer = vim.current.buffer
|
currentBuffer = vim.current.buffer
|
||||||
currentWindow = vim.current.window
|
currentWindow = vim.current.window
|
||||||
row, col = currentWindow.cursor
|
row, col = currentWindow.cursor
|
||||||
@@ -497,66 +547,97 @@ def findTag(bufferNumber, changedTick):
|
|||||||
|
|
||||||
# get the index of the nearest line
|
# get the index of the nearest line
|
||||||
nearestLineIndex = getNearestLineIndex(row, tagLineNumbers)
|
nearestLineIndex = getNearestLineIndex(row, tagLineNumbers)
|
||||||
|
|
||||||
# if any line was found, try to find if the tag is appropriate {{{
|
# if any line was found, try to find if the tag is appropriate {{{
|
||||||
# (ie. the cursor can be below the last tag but on a code that has nothing
|
# (ie. the cursor can be below the last tag but on a code that has nothing
|
||||||
# to do with the tag, because it's indented differently, in such case no
|
# to do with the tag, because it's indented differently, in such case no
|
||||||
# appropriate tag has been found.)
|
# appropriate tag has been found.)
|
||||||
if (nearestLineIndex > -1):
|
while (nearestLineIndex > -1):
|
||||||
|
# get the line number of the nearest tag
|
||||||
nearestLineNumber = tagLineNumbers[nearestLineIndex]
|
nearestLineNumber = tagLineNumbers[nearestLineIndex]
|
||||||
tagInfo = tags[nearestLineNumber]
|
|
||||||
# walk through all the lines in range (nearestTagLine, cursorRow) {{{
|
# walk through all the lines in range (nearestTagLine, cursorRow) {{{
|
||||||
for i in xrange(nearestLineNumber + 1, row):
|
for lineNumber in xrange(nearestLineNumber + 1, row):
|
||||||
line = currentBuffer[i]
|
# get the current line
|
||||||
# count the indentation of the line, if it's lower that the tag's, the found tag is wrong {{{
|
line = currentBuffer[lineNumber]
|
||||||
|
|
||||||
|
# count the indentation of the line, if it's lower than the tag's, the tag is invalid {{{
|
||||||
if (len(line)):
|
if (len(line)):
|
||||||
# compute the indentation of the line {{{
|
# initialize local auxiliary variables {{{
|
||||||
lineStart = 0
|
lineStart = 0
|
||||||
j = 0
|
i = 0
|
||||||
while ((j < len(line)) and (line[j].isspace())):
|
# }}}
|
||||||
if (line[j] == '\t'):
|
|
||||||
|
# compute the indentation of the line {{{
|
||||||
|
while ((i < len(line)) and (line[i].isspace())):
|
||||||
|
# move the start of the line code {{{
|
||||||
|
if (line[i] == '\t'):
|
||||||
lineStart += SimplePythonTagsParser.TABSIZE
|
lineStart += SimplePythonTagsParser.TABSIZE
|
||||||
else:
|
else:
|
||||||
lineStart += 1
|
lineStart += 1
|
||||||
j += 1
|
# }}}
|
||||||
# if the line contains only spaces, it doesn't count {{{
|
|
||||||
if (j == len(line)):
|
# go to the next character on the line
|
||||||
|
i += 1
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# if the line contains only spaces, skip it {{{
|
||||||
|
if (i == len(line)):
|
||||||
continue
|
continue
|
||||||
# }}}
|
# }}}
|
||||||
# if the next character is # (python comment), this line doesn't count {{{
|
# if the next character is a '#' (python comment), skip the line {{{
|
||||||
if (line[j] == '#'):
|
if (line[i] == '#'):
|
||||||
continue
|
continue
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
|
||||||
# if the line's indentation starts before or at the nearest tag's one, the tag is wrong {{{
|
# if the line's indentation starts before or at the nearest tag's one, the tag is invalid {{{
|
||||||
while tagInfo is not None and lineStart <= tagInfo.indentLevel:
|
if (lineStart <= tags[nearestLineNumber].indentLevel):
|
||||||
tagInfo = tagInfo.parentTag
|
nearestLineIndex -= 1
|
||||||
|
break
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
# the tag is appropriate, so use it {{{
|
||||||
else:
|
else:
|
||||||
tagInfo = None
|
break
|
||||||
|
# }}}
|
||||||
|
# }}}
|
||||||
|
# no appropriate tag has been found {{{
|
||||||
|
else:
|
||||||
|
nearestLineNumber = -1
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# describe the cursor position (what tag it's in) {{{
|
# describe the cursor position (what tag the cursor is on) {{{
|
||||||
|
# reset the description
|
||||||
tagDescription = ""
|
tagDescription = ""
|
||||||
if tagInfo is not None:
|
|
||||||
## tagDescription = "[in %s (%s)]" % (tagInfo.fullName, PythonTag.typeName[tagInfo.type],)
|
# if an appropriate tag has been found, set the description accordingly {{{
|
||||||
tagDescription = "[%s]" % (tagInfo.fullName, )
|
if (nearestLineNumber > -1):
|
||||||
|
tagInfo = tags[nearestLineNumber]
|
||||||
|
tagDescription = "[in %s (%s)]" % (tagInfo.fullName, PythonTag.TAG_TYPE_NAME[tagInfo.type],)
|
||||||
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# update the variable for the status line so it will be updated next time
|
# update the variable for the status line so it get updated with the new description
|
||||||
vim.command("let w:PHStatusLine=\"%s\"" % (tagDescription,))
|
vim.command("let w:PHStatusLine=\"%s\"" % (tagDescription,))
|
||||||
except:
|
# }}}
|
||||||
# spit out debugging information {{{
|
|
||||||
|
# handle possible exceptions {{{
|
||||||
|
except Exception:
|
||||||
|
# bury into the traceback {{{
|
||||||
ec, ei, tb = sys.exc_info()
|
ec, ei, tb = sys.exc_info()
|
||||||
while (tb != None):
|
while (tb != None):
|
||||||
if (tb.tb_next == None):
|
if (tb.tb_next == None):
|
||||||
break
|
break
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# spit out the error {{{
|
||||||
print "ERROR: %s %s %s:%u" % (ec.__name__, ei, tb.tb_frame.f_code.co_filename, tb.tb_lineno,)
|
print "ERROR: %s %s %s:%u" % (ec.__name__, ei, tb.tb_frame.f_code.co_filename, tb.tb_lineno,)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def deleteTags(bufferNumber):
|
def deleteTags(bufferNumber):
|
||||||
@@ -570,8 +651,10 @@ def deleteTags(bufferNumber):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# CODE {{{
|
# CODE {{{
|
||||||
|
# define global variables
|
||||||
global TAGS, TAGLINENUMBERS, BUFFERTICKS
|
global TAGS, TAGLINENUMBERS, BUFFERTICKS
|
||||||
|
|
||||||
|
# try to delete the tags for the buffer {{{
|
||||||
try:
|
try:
|
||||||
del TAGS[bufferNumber]
|
del TAGS[bufferNumber]
|
||||||
del TAGLINENUMBERS[bufferNumber]
|
del TAGLINENUMBERS[bufferNumber]
|
||||||
@@ -579,6 +662,7 @@ def deleteTags(bufferNumber):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# }}}
|
# }}}
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
EOS
|
EOS
|
||||||
@@ -617,33 +701,63 @@ function! TagInStatusLine()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! PHPreviousClassMethod()
|
||||||
|
call search('^[ \t]*\(class\|def\)\>', 'bw')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! PHNextClassMethod()
|
||||||
|
call search('^[ \t]*\(class\|def\)\>', 'w')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! PHPreviousClass()
|
||||||
|
call search('^[ \t]*class\>', 'bw')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! PHNextClass()
|
||||||
|
call search('^[ \t]*class\>', 'w')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! PHPreviousMethod()
|
||||||
|
call search('^[ \t]*def\>', 'bw')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! PHNextMethod()
|
||||||
|
call search('^[ \t]*def\>', 'w')
|
||||||
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
" event binding, vim customizing {{{
|
" event binding, vim customizing {{{
|
||||||
|
|
||||||
" autocommands binding
|
" autocommands binding
|
||||||
if v:version >= 700
|
autocmd CursorHold * call PHCursorHold()
|
||||||
autocmd CursorMoved * call PHCursorHold()
|
autocmd CursorHoldI * call PHCursorHold()
|
||||||
else
|
|
||||||
autocmd CursorHold * call PHCursorHold()
|
|
||||||
endif
|
|
||||||
autocmd BufDelete * silent call PHBufferDelete()
|
autocmd BufDelete * silent call PHBufferDelete()
|
||||||
|
|
||||||
"" " time that determines after how long time of no activity the CursorHold event
|
" time that determines after how long time of no activity the CursorHold event
|
||||||
"" " is fired up
|
" is fired up
|
||||||
"" set updatetime=1000
|
set updatetime=1000
|
||||||
""
|
|
||||||
"" " color of the current tag in the status line (bold cyan on black)
|
" color of the current tag in the status line (bold cyan on black)
|
||||||
"" highlight User1 gui=bold guifg=cyan guibg=black
|
" gryf: i don't like coloring apart from current colorscheme. keep it simple.
|
||||||
"" " color of the modified flag in the status line (bold black on red)
|
"highlight User1 gui=bold guifg=cyan guibg=black
|
||||||
"" highlight User2 gui=bold guifg=black guibg=red
|
" color of the modified flag in the status line (bold black on red)
|
||||||
"" " the status line will be displayed for every window
|
" gryf: i don't like coloring apart from current colorscheme. keep it simple.
|
||||||
"" set laststatus=2
|
"highlight User2 gui=bold guifg=black guibg=red
|
||||||
"" " set the status line to display some useful information
|
" the status line will be displayed for every window
|
||||||
"" set stl=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ \ \ \ [buf\ %n]
|
set laststatus=2
|
||||||
|
" set the status line to display some useful information
|
||||||
|
"set stl=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ \ \ \ [buf\ %n]
|
||||||
|
" gryf: I like my status bar. Don't change it. Just add information.
|
||||||
|
setlocal statusline=%<%F\ \ \ %{TagInStatusLine()}\ %h%m%r%=%(%l,%c%V%)\ %3p%%
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" vim:foldmethod=marker
|
" vim:foldmethod=marker
|
||||||
endif " has("python")
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ let b:undo_ftplugin = "setlocal ".
|
|||||||
" MISC STUFF {{{
|
" MISC STUFF {{{
|
||||||
|
|
||||||
setlocal autowriteall
|
setlocal autowriteall
|
||||||
setlocal commentstring=<!--%s-->
|
setlocal commentstring=%%%s
|
||||||
|
|
||||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
if g:vimwiki_conceallevel && exists("+conceallevel")
|
||||||
let &conceallevel = g:vimwiki_conceallevel
|
let &conceallevel = g:vimwiki_conceallevel
|
||||||
@@ -47,12 +47,12 @@ if !empty(&langmap)
|
|||||||
" Valid only if langmap is a comma separated pairs of chars
|
" Valid only if langmap is a comma separated pairs of chars
|
||||||
let l_o = matchstr(&langmap, '\C,\zs.\zeo,')
|
let l_o = matchstr(&langmap, '\C,\zs.\zeo,')
|
||||||
if l_o
|
if l_o
|
||||||
exe 'nnoremap <buffer> '.l_o.' :call vimwiki_lst#kbd_oO("o")<CR>a'
|
exe 'nnoremap <buffer> '.l_o.' :call vimwiki#lst#kbd_oO("o")<CR>a'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
|
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
|
||||||
if l_O
|
if l_O
|
||||||
exe 'nnoremap <buffer> '.l_O.' :call vimwiki_lst#kbd_oO("O")<CR>a'
|
exe 'nnoremap <buffer> '.l_O.' :call vimwiki#lst#kbd_oO("O")<CR>a'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -64,19 +64,19 @@ function! VimwikiFoldLevel(lnum) "{{{
|
|||||||
|
|
||||||
" Header folding...
|
" Header folding...
|
||||||
if line =~ g:vimwiki_rxHeader
|
if line =~ g:vimwiki_rxHeader
|
||||||
let n = vimwiki#count_first_sym(line)
|
let n = vimwiki#base#count_first_sym(line)
|
||||||
return '>'.n
|
return '>'.n
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:vimwiki_fold_trailing_empty_lines == 0
|
if g:vimwiki_fold_trailing_empty_lines == 0 && line =~ '^\s*$'
|
||||||
if line =~ '^\s*$'
|
|
||||||
let nnline = getline(nextnonblank(a:lnum + 1))
|
let nnline = getline(nextnonblank(a:lnum + 1))
|
||||||
|
else
|
||||||
|
let nnline = getline(a:lnum + 1)
|
||||||
|
endif
|
||||||
if nnline =~ g:vimwiki_rxHeader
|
if nnline =~ g:vimwiki_rxHeader
|
||||||
let n = vimwiki#count_first_sym(nnline)
|
let n = vimwiki#base#count_first_sym(nnline)
|
||||||
return '<'.n
|
return '<'.n
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" List item folding...
|
" List item folding...
|
||||||
if g:vimwiki_fold_lists
|
if g:vimwiki_fold_lists
|
||||||
@@ -129,7 +129,7 @@ function! s:get_base_level(lnum) "{{{
|
|||||||
let lnum = a:lnum - 1
|
let lnum = a:lnum - 1
|
||||||
while lnum > 0
|
while lnum > 0
|
||||||
if getline(lnum) =~ g:vimwiki_rxHeader
|
if getline(lnum) =~ g:vimwiki_rxHeader
|
||||||
return vimwiki#count_first_sym(getline(lnum))
|
return vimwiki#base#count_first_sym(getline(lnum))
|
||||||
endif
|
endif
|
||||||
let lnum -= 1
|
let lnum -= 1
|
||||||
endwhile
|
endwhile
|
||||||
@@ -169,7 +169,7 @@ endfunction "}}}
|
|||||||
|
|
||||||
function! s:get_li_level(lnum) "{{{
|
function! s:get_li_level(lnum) "{{{
|
||||||
if VimwikiGet('syntax') == 'media'
|
if VimwikiGet('syntax') == 'media'
|
||||||
let level = vimwiki#count_first_sym(getline(a:lnum))
|
let level = vimwiki#base#count_first_sym(getline(a:lnum))
|
||||||
else
|
else
|
||||||
let level = (indent(a:lnum) / &sw)
|
let level = (indent(a:lnum) / &sw)
|
||||||
endif
|
endif
|
||||||
@@ -198,42 +198,48 @@ endfunction "}}}
|
|||||||
|
|
||||||
" COMMANDS {{{
|
" COMMANDS {{{
|
||||||
command! -buffer Vimwiki2HTML
|
command! -buffer Vimwiki2HTML
|
||||||
\ call vimwiki_html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
\ w <bar> call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||||
\ expand('%'))
|
\ expand('%'))
|
||||||
|
command! -buffer Vimwiki2HTMLBrowse
|
||||||
|
\ w <bar> call VimwikiWeblinkHandler(
|
||||||
|
\ vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||||
|
\ expand('%')))
|
||||||
command! -buffer VimwikiAll2HTML
|
command! -buffer VimwikiAll2HTML
|
||||||
\ call vimwiki_html#WikiAll2HTML(expand(VimwikiGet('path_html')))
|
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
|
||||||
|
|
||||||
command! -buffer VimwikiNextLink call vimwiki#find_next_link()
|
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
|
||||||
command! -buffer VimwikiPrevLink call vimwiki#find_prev_link()
|
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
|
||||||
command! -buffer VimwikiDeleteLink call vimwiki#delete_link()
|
command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
|
||||||
command! -buffer VimwikiRenameLink call vimwiki#rename_link()
|
command! -buffer VimwikiRenameLink call vimwiki#base#rename_link()
|
||||||
command! -buffer VimwikiFollowLink call vimwiki#follow_link('nosplit')
|
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit')
|
||||||
command! -buffer VimwikiGoBackLink call vimwiki#go_back_link()
|
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
|
||||||
command! -buffer VimwikiSplitLink call vimwiki#follow_link('split')
|
command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split')
|
||||||
command! -buffer VimwikiVSplitLink call vimwiki#follow_link('vsplit')
|
command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit')
|
||||||
|
|
||||||
command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(<line1>, <line2>)
|
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
|
||||||
|
|
||||||
command! -buffer VimwikiGenerateLinks call vimwiki#generate_links()
|
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
|
||||||
|
|
||||||
exe 'command! -buffer -nargs=* VimwikiSearch vimgrep <args> '.
|
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
|
||||||
|
|
||||||
|
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
|
||||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||||
|
|
||||||
exe 'command! -buffer -nargs=* VWS vimgrep <args> '.
|
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
|
||||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||||
|
|
||||||
command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("<args>")
|
command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("<args>")
|
||||||
|
|
||||||
" table commands
|
" table commands
|
||||||
command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create(<f-args>)
|
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
|
||||||
command! -buffer VimwikiTableAlignQ call vimwiki_tbl#align_or_cmd('gqq')
|
command! -buffer VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq')
|
||||||
command! -buffer VimwikiTableAlignW call vimwiki_tbl#align_or_cmd('gww')
|
command! -buffer VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww')
|
||||||
command! -buffer VimwikiTableMoveColumnLeft call vimwiki_tbl#move_column_left()
|
command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left()
|
||||||
command! -buffer VimwikiTableMoveColumnRight call vimwiki_tbl#move_column_right()
|
command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right()
|
||||||
|
|
||||||
" diary commands
|
" diary commands
|
||||||
command! -buffer VimwikiDiaryNextDay call vimwiki_diary#goto_next_day()
|
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
||||||
command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day()
|
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
||||||
|
|
||||||
" COMMANDS }}}
|
" COMMANDS }}}
|
||||||
|
|
||||||
@@ -241,58 +247,78 @@ command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day()
|
|||||||
if g:vimwiki_use_mouse
|
if g:vimwiki_use_mouse
|
||||||
nmap <buffer> <S-LeftMouse> <NOP>
|
nmap <buffer> <S-LeftMouse> <NOP>
|
||||||
nmap <buffer> <C-LeftMouse> <NOP>
|
nmap <buffer> <C-LeftMouse> <NOP>
|
||||||
noremap <silent><buffer> <2-LeftMouse> :VimwikiFollowLink<CR>
|
nnoremap <silent><buffer> <2-LeftMouse> :VimwikiFollowLink<CR>
|
||||||
noremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
||||||
noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
||||||
noremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>Vimwiki2HTML')
|
||||||
|
nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
|
||||||
|
endif
|
||||||
|
nnoremap <script><buffer>
|
||||||
|
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
|
||||||
|
nmap <buffer> <Leader>whh <Plug>Vimwiki2HTMLBrowse
|
||||||
|
endif
|
||||||
|
nnoremap <script><buffer>
|
||||||
|
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiFollowLink')
|
if !hasmapto('<Plug>VimwikiFollowLink')
|
||||||
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
|
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
|
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiSplitLink')
|
if !hasmapto('<Plug>VimwikiSplitLink')
|
||||||
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
|
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
|
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiVSplitLink')
|
if !hasmapto('<Plug>VimwikiVSplitLink')
|
||||||
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
|
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
|
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>VimwikiTabnewLink')
|
||||||
|
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
|
||||||
|
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
|
||||||
|
endif
|
||||||
|
nnoremap <silent><script><buffer>
|
||||||
|
\ <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiGoBackLink')
|
if !hasmapto('<Plug>VimwikiGoBackLink')
|
||||||
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
|
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
|
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiNextLink')
|
if !hasmapto('<Plug>VimwikiNextLink')
|
||||||
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
|
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
|
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiPrevLink')
|
if !hasmapto('<Plug>VimwikiPrevLink')
|
||||||
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
|
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDeleteLink')
|
if !hasmapto('<Plug>VimwikiDeleteLink')
|
||||||
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
|
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiRenameLink')
|
if !hasmapto('<Plug>VimwikiRenameLink')
|
||||||
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
|
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiToggleListItem')
|
if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||||
@@ -302,25 +328,25 @@ if !hasmapto('<Plug>VimwikiToggleListItem')
|
|||||||
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
||||||
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
|
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
|
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
|
||||||
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
|
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
||||||
|
|
||||||
function! s:CR() "{{{
|
function! s:CR() "{{{
|
||||||
let res = vimwiki_lst#kbd_cr()
|
let res = vimwiki#lst#kbd_cr()
|
||||||
if res == "\<CR>" && g:vimwiki_table_auto_fmt
|
if res == "\<CR>" && g:vimwiki_table_auto_fmt
|
||||||
let res = vimwiki_tbl#kbd_cr()
|
let res = vimwiki#tbl#kbd_cr()
|
||||||
endif
|
endif
|
||||||
return res
|
return res
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@@ -329,45 +355,53 @@ endfunction "}}}
|
|||||||
inoremap <buffer> <expr> <CR> <SID>CR()
|
inoremap <buffer> <expr> <CR> <SID>CR()
|
||||||
|
|
||||||
" List mappings
|
" List mappings
|
||||||
nnoremap <buffer> o :call vimwiki_lst#kbd_oO('o')<CR>a
|
nnoremap <buffer> o :<C-U>call vimwiki#lst#kbd_oO('o')<CR>
|
||||||
nnoremap <buffer> O :call vimwiki_lst#kbd_oO('O')<CR>a
|
nnoremap <buffer> O :<C-U>call vimwiki#lst#kbd_oO('O')<CR>
|
||||||
|
|
||||||
" Table mappings
|
" Table mappings
|
||||||
if g:vimwiki_table_auto_fmt
|
if g:vimwiki_table_auto_fmt
|
||||||
inoremap <expr> <buffer> <Tab> vimwiki_tbl#kbd_tab()
|
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
|
||||||
inoremap <expr> <buffer> <S-Tab> vimwiki_tbl#kbd_shift_tab()
|
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
|
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
|
||||||
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
|
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
|
||||||
nnoremap <buffer> <A-Left> :VimwikiTableMoveColumnLeft<CR>
|
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
|
||||||
nnoremap <buffer> <A-Right> :VimwikiTableMoveColumnRight<CR>
|
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
|
||||||
|
endif
|
||||||
|
nnoremap <silent><script><buffer>
|
||||||
|
\ <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
|
||||||
|
if !hasmapto('<Plug>VimwikiTableMoveColumnRight')
|
||||||
|
nmap <silent><buffer> <A-Right> <Plug>VimwikiTableMoveColumnRight
|
||||||
|
endif
|
||||||
|
nnoremap <silent><script><buffer>
|
||||||
|
\ <Plug>VimwikiTableMoveColumnRight :VimwikiTableMoveColumnRight<CR>
|
||||||
|
|
||||||
" Misc mappings
|
" Misc mappings
|
||||||
inoremap <buffer> <S-CR> <br /><CR>
|
inoremap <buffer> <S-CR> <br /><CR>
|
||||||
|
|
||||||
|
|
||||||
" Text objects {{{
|
" Text objects {{{
|
||||||
onoremap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 0)<CR>
|
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0)<CR>
|
||||||
vnoremap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 1)<CR>
|
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 1)<CR>
|
||||||
|
|
||||||
onoremap <silent><buffer> ih :<C-U>call vimwiki#TO_header(1, 0)<CR>
|
onoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 0)<CR>
|
||||||
vnoremap <silent><buffer> ih :<C-U>call vimwiki#TO_header(1, 1)<CR>
|
vnoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 1)<CR>
|
||||||
|
|
||||||
onoremap <silent><buffer> a\ :<C-U>call vimwiki#TO_table_cell(0, 0)<CR>
|
onoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 0)<CR>
|
||||||
vnoremap <silent><buffer> a\ :<C-U>call vimwiki#TO_table_cell(0, 1)<CR>
|
vnoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 1)<CR>
|
||||||
|
|
||||||
onoremap <silent><buffer> i\ :<C-U>call vimwiki#TO_table_cell(1, 0)<CR>
|
onoremap <silent><buffer> i\ :<C-U>call vimwiki#base#TO_table_cell(1, 0)<CR>
|
||||||
vnoremap <silent><buffer> i\ :<C-U>call vimwiki#TO_table_cell(1, 1)<CR>
|
vnoremap <silent><buffer> i\ :<C-U>call vimwiki#base#TO_table_cell(1, 1)<CR>
|
||||||
|
|
||||||
onoremap <silent><buffer> ac :<C-U>call vimwiki#TO_table_col(0, 0)<CR>
|
onoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 0)<CR>
|
||||||
vnoremap <silent><buffer> ac :<C-U>call vimwiki#TO_table_col(0, 1)<CR>
|
vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
|
||||||
|
|
||||||
onoremap <silent><buffer> ic :<C-U>call vimwiki#TO_table_col(1, 0)<CR>
|
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
|
||||||
vnoremap <silent><buffer> ic :<C-U>call vimwiki#TO_table_col(1, 1)<CR>
|
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
|
||||||
|
|
||||||
noremap <silent><buffer> = :call vimwiki#AddHeaderLevel()<CR>
|
nnoremap <silent><buffer> = :call vimwiki#base#AddHeaderLevel()<CR>
|
||||||
noremap <silent><buffer> - :call vimwiki#RemoveHeaderLevel()<CR>
|
nnoremap <silent><buffer> - :call vimwiki#base#RemoveHeaderLevel()<CR>
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
" Vimwiki indent file
|
|
||||||
" Author: Maxim Kim <habamax@gmail.com>
|
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
|
||||||
|
|
||||||
" Only load this indent file when no other was loaded.
|
|
||||||
if exists("b:did_indent")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let b:did_indent = 1
|
|
||||||
|
|
||||||
" Some preliminary settings
|
|
||||||
setlocal nolisp " Make sure lisp indenting doesn't supersede us
|
|
||||||
setlocal autoindent " indentexpr isn't much help otherwise
|
|
||||||
|
|
||||||
setlocal indentexpr=GetVimwikiIndent(v:lnum)
|
|
||||||
setlocal indentkeys+=<:>
|
|
||||||
|
|
||||||
" Only define the function once.
|
|
||||||
if exists("*GetVimwikiIndent")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Come here when loading the script the first time.
|
|
||||||
|
|
||||||
function GetVimwikiIndent(lnum)
|
|
||||||
" Search backwards for the previous non-empty line.
|
|
||||||
let plnum = prevnonblank(v:lnum - 1)
|
|
||||||
if plnum == 0
|
|
||||||
" This is the first non-empty line, use zero indent.
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" TODO: use g:vimwiki_rxList here
|
|
||||||
let lst_indent = len(matchstr(getline(a:lnum), '^\s\+\ze\(\*\|#\)'))
|
|
||||||
if lst_indent > 0
|
|
||||||
if lst_indent < &sw
|
|
||||||
return &sw
|
|
||||||
endif
|
|
||||||
|
|
||||||
if has("float")
|
|
||||||
let mul = round(lst_indent * 1.0 / &sw)
|
|
||||||
let ind = float2nr(mul * &sw)
|
|
||||||
else
|
|
||||||
let mul = lst_indent / &sw
|
|
||||||
let ind = mul * &sw
|
|
||||||
endif
|
|
||||||
|
|
||||||
return ind
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
return -1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" vim:sw=2
|
|
||||||
1237
plugin/buffergator.vim
Normal file
1237
plugin/buffergator.vim
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,9 @@ endif
|
|||||||
|
|
||||||
" Key bind
|
" Key bind
|
||||||
nnoremap <silent> <unique> <Leader>oc :Occur<CR>
|
nnoremap <silent> <unique> <Leader>oc :Occur<CR>
|
||||||
|
" gryf: Changed followin mapping due to confilct with showmarks plugin
|
||||||
nnoremap <silent> <unique> <Leader>om :Moccur<CR>
|
nnoremap <silent> <unique> <Leader>om :Moccur<CR>
|
||||||
|
" gryf: Changed followin mapping due to confilct with marks plugin
|
||||||
nnoremap <silent> <unique> <Leader>8 *<C-o>:Moccur<CR>
|
nnoremap <silent> <unique> <Leader>8 *<C-o>:Moccur<CR>
|
||||||
|
|
||||||
" Create commands
|
" Create commands
|
||||||
|
|||||||
@@ -1031,6 +1031,7 @@ endfunction
|
|||||||
" Multiple inexact matches is currently considered an error.
|
" Multiple inexact matches is currently considered an error.
|
||||||
|
|
||||||
function! VCSCommandGetVCSType(buffer)
|
function! VCSCommandGetVCSType(buffer)
|
||||||
|
" gryf: if there is such variable, use defined VCS type
|
||||||
if exists("g:VCSTypeOverride")
|
if exists("g:VCSTypeOverride")
|
||||||
return g:VCSTypeOverride
|
return g:VCSTypeOverride
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -19,22 +19,30 @@ function! s:default(varname, value) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
" return longest common prefix of 2 given strings.
|
" return longest common path prefix of 2 given paths.
|
||||||
" 'Hello world', 'Hello worm' => 'Hello wor'
|
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
|
||||||
function! s:str_common_pfx(str1, str2) "{{{
|
function! s:path_common_pfx(path1, path2) "{{{
|
||||||
|
let p1 = split(a:path1, '[/\\]', 1)
|
||||||
|
let p2 = split(a:path2, '[/\\]', 1)
|
||||||
|
|
||||||
let idx = 0
|
let idx = 0
|
||||||
let minlen = min([len(a:str1), len(a:str2)])
|
let minlen = min([len(p1), len(p2)])
|
||||||
while (idx < minlen) && (a:str1[idx] ==? a:str2[idx])
|
while (idx < minlen) && (p1[idx] ==? p2[idx])
|
||||||
let idx = idx + 1
|
let idx = idx + 1
|
||||||
endwhile
|
endwhile
|
||||||
return strpart(a:str1, 0, idx)
|
if idx == 0
|
||||||
|
return ''
|
||||||
|
else
|
||||||
|
return join(p1[: idx-1], '/')
|
||||||
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:find_wiki(path) "{{{
|
function! s:find_wiki(path) "{{{
|
||||||
let idx = 0
|
let idx = 0
|
||||||
while idx < len(g:vimwiki_list)
|
while idx < len(g:vimwiki_list)
|
||||||
let path = vimwiki#chomp_slash(expand(VimwikiGet('path', idx)))
|
let path = vimwiki#base#chomp_slash(expand(VimwikiGet('path', idx)))
|
||||||
if s:str_common_pfx(path, a:path) == path
|
let path = vimwiki#base#path_norm(path)
|
||||||
|
if s:path_common_pfx(path, a:path) == path
|
||||||
return idx
|
return idx
|
||||||
endif
|
endif
|
||||||
let idx += 1
|
let idx += 1
|
||||||
@@ -53,6 +61,19 @@ function! s:setup_buffer_leave()"{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! s:setup_filetype() "{{{
|
||||||
|
" Find what wiki current buffer belongs to.
|
||||||
|
let path = expand('%:p:h')
|
||||||
|
let ext = '.'.expand('%:e')
|
||||||
|
let idx = s:find_wiki(path)
|
||||||
|
|
||||||
|
if idx == -1 && g:vimwiki_global_ext == 0
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
set filetype=vimwiki
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:setup_buffer_enter() "{{{
|
function! s:setup_buffer_enter() "{{{
|
||||||
if exists("b:vimwiki_idx")
|
if exists("b:vimwiki_idx")
|
||||||
let g:vimwiki_current_idx = b:vimwiki_idx
|
let g:vimwiki_current_idx = b:vimwiki_idx
|
||||||
@@ -81,8 +102,16 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
let b:vimwiki_idx = g:vimwiki_current_idx
|
let b:vimwiki_idx = g:vimwiki_current_idx
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" If you have
|
||||||
|
" au GUIEnter * VimwikiIndex
|
||||||
|
" Then change it to
|
||||||
|
" au GUIEnter * nested VimwikiIndex
|
||||||
|
if &filetype == ''
|
||||||
|
set filetype=vimwiki
|
||||||
|
endif
|
||||||
|
|
||||||
" Update existed/non-existed links highlighting.
|
" Update existed/non-existed links highlighting.
|
||||||
call vimwiki#highlight_links()
|
call vimwiki#base#highlight_links()
|
||||||
|
|
||||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||||
@@ -158,9 +187,9 @@ if !exists("*VimwikiWeblinkHandler") "{{{
|
|||||||
for browser in g:vimwiki_browsers
|
for browser in g:vimwiki_browsers
|
||||||
if executable(browser)
|
if executable(browser)
|
||||||
if has("win32")
|
if has("win32")
|
||||||
execute '!start "'.browser.'" ' . a:weblink
|
execute '!start "'.browser.'" "' . a:weblink . '"'
|
||||||
else
|
else
|
||||||
execute '!'.browser.' ' . a:weblink
|
execute '!'.browser.' "' . a:weblink . '"'
|
||||||
endif
|
endif
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -178,8 +207,11 @@ let s:vimwiki_defaults.index = 'index'
|
|||||||
let s:vimwiki_defaults.ext = '.wiki'
|
let s:vimwiki_defaults.ext = '.wiki'
|
||||||
let s:vimwiki_defaults.maxhi = 1
|
let s:vimwiki_defaults.maxhi = 1
|
||||||
let s:vimwiki_defaults.syntax = 'default'
|
let s:vimwiki_defaults.syntax = 'default'
|
||||||
let s:vimwiki_defaults.html_header = ''
|
|
||||||
let s:vimwiki_defaults.html_footer = ''
|
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
|
||||||
|
let s:vimwiki_defaults.template_default = 'default'
|
||||||
|
let s:vimwiki_defaults.template_ext = '.html'
|
||||||
|
|
||||||
let s:vimwiki_defaults.nested_syntaxes = {}
|
let s:vimwiki_defaults.nested_syntaxes = {}
|
||||||
let s:vimwiki_defaults.auto_export = 0
|
let s:vimwiki_defaults.auto_export = 0
|
||||||
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
|
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
|
||||||
@@ -217,7 +249,7 @@ call s:default('fold_trailing_empty_lines', 0)
|
|||||||
call s:default('fold_lists', 0)
|
call s:default('fold_lists', 0)
|
||||||
call s:default('menu', 'Vimwiki')
|
call s:default('menu', 'Vimwiki')
|
||||||
call s:default('global_ext', 1)
|
call s:default('global_ext', 1)
|
||||||
call s:default('hl_headers', 1)
|
call s:default('hl_headers', 0)
|
||||||
call s:default('hl_cb_checked', 0)
|
call s:default('hl_cb_checked', 0)
|
||||||
call s:default('camel_case', 1)
|
call s:default('camel_case', 1)
|
||||||
call s:default('list_ignore_newline', 1)
|
call s:default('list_ignore_newline', 1)
|
||||||
@@ -233,6 +265,7 @@ if has("win32")
|
|||||||
else
|
else
|
||||||
call s:default('browsers',
|
call s:default('browsers',
|
||||||
\ [
|
\ [
|
||||||
|
\ 'chromium-browser',
|
||||||
\ 'opera',
|
\ 'opera',
|
||||||
\ 'firefox',
|
\ 'firefox',
|
||||||
\ 'konqueror',
|
\ 'konqueror',
|
||||||
@@ -245,7 +278,8 @@ call s:default('w32_dir_enc', '')
|
|||||||
call s:default('CJK_length', 0)
|
call s:default('CJK_length', 0)
|
||||||
call s:default('dir_link', '')
|
call s:default('dir_link', '')
|
||||||
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
|
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
|
||||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr')
|
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
|
||||||
|
call s:default('user_htmls', '')
|
||||||
|
|
||||||
call s:default('html_header_numbering', 0)
|
call s:default('html_header_numbering', 0)
|
||||||
call s:default('html_header_numbering_sym', '')
|
call s:default('html_header_numbering_sym', '')
|
||||||
@@ -273,9 +307,15 @@ else
|
|||||||
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
|
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
|
||||||
endif
|
endif
|
||||||
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
|
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
|
||||||
|
\'\%('.
|
||||||
|
\'\%('.
|
||||||
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
|
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
|
||||||
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'.
|
\'\%(\%(//\)\|\%(\\\\\)\)'.
|
||||||
\'[().,?]\@<!'
|
\'\)'.
|
||||||
|
\'\|\%(mailto:\)'.
|
||||||
|
\'\)'.
|
||||||
|
\'\+\S\+'.
|
||||||
|
\'[().,?\]]\@<!'
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||||
@@ -297,64 +337,71 @@ augroup end
|
|||||||
augroup vimwiki
|
augroup vimwiki
|
||||||
autocmd!
|
autocmd!
|
||||||
for ext in keys(extensions)
|
for ext in keys(extensions)
|
||||||
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_enter()'
|
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
|
||||||
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
||||||
exe 'autocmd BufNewFile,BufRead, *'.ext.' setlocal filetype=vimwiki'
|
exe 'autocmd BufNewFile,BufRead, *'.ext.' call s:setup_filetype()'
|
||||||
|
|
||||||
" ColorScheme could have or could have not a
|
" ColorScheme could have or could have not a
|
||||||
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
|
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
|
||||||
" syntax after colorscheme change.
|
" syntax after colorscheme change.
|
||||||
exe 'autocmd ColorScheme *'.ext.' call vimwiki#setup_colors()'.
|
exe 'autocmd ColorScheme *'.ext.' syntax enable'.
|
||||||
\ ' | call vimwiki#highlight_links()'
|
\ ' | call vimwiki#base#highlight_links()'
|
||||||
|
|
||||||
" Format tables when exit from insert mode. Do not use textwidth to
|
" Format tables when exit from insert mode. Do not use textwidth to
|
||||||
" autowrap tables.
|
" autowrap tables.
|
||||||
if g:vimwiki_table_auto_fmt
|
if g:vimwiki_table_auto_fmt
|
||||||
exe 'autocmd InsertLeave *'.ext.' call vimwiki_tbl#format(line("."))'
|
exe 'autocmd InsertLeave *'.ext.' call vimwiki#tbl#format(line("."))'
|
||||||
exe 'autocmd InsertEnter *'.ext.' call vimwiki_tbl#reset_tw(line("."))'
|
exe 'autocmd InsertEnter *'.ext.' call vimwiki#tbl#reset_tw(line("."))'
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
augroup END
|
augroup END
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" COMMANDS {{{
|
" COMMANDS {{{
|
||||||
command! VimwikiUISelect call vimwiki#ui_select()
|
command! VimwikiUISelect call vimwiki#base#ui_select()
|
||||||
command! -count VimwikiIndex
|
command! -count VimwikiIndex
|
||||||
\ call vimwiki#goto_index(v:count1)
|
\ call vimwiki#base#goto_index(v:count1)
|
||||||
command! -count VimwikiTabIndex tabedit <bar>
|
command! -count VimwikiTabIndex tabedit <bar>
|
||||||
\ call vimwiki#goto_index(v:count1)
|
\ call vimwiki#base#goto_index(v:count1)
|
||||||
|
|
||||||
|
command! -count VimwikiDiaryIndex
|
||||||
|
\ call vimwiki#diary#goto_index(v:count1)
|
||||||
command! -count VimwikiMakeDiaryNote
|
command! -count VimwikiMakeDiaryNote
|
||||||
\ call vimwiki_diary#make_note(v:count1)
|
\ call vimwiki#diary#make_note(v:count1)
|
||||||
command! -count VimwikiTabMakeDiaryNote tabedit <bar>
|
command! -count VimwikiTabMakeDiaryNote tabedit <bar>
|
||||||
\ call vimwiki_diary#make_note(v:count1)
|
\ call vimwiki#diary#make_note(v:count1)
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" MAPPINGS {{{
|
" MAPPINGS {{{
|
||||||
if !hasmapto('<Plug>VimwikiIndex')
|
if !hasmapto('<Plug>VimwikiIndex')
|
||||||
map <silent><unique> <Leader>ww <Plug>VimwikiIndex
|
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
|
||||||
endif
|
endif
|
||||||
noremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiTabIndex')
|
if !hasmapto('<Plug>VimwikiTabIndex')
|
||||||
map <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
|
nmap <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
|
||||||
endif
|
endif
|
||||||
noremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiUISelect')
|
if !hasmapto('<Plug>VimwikiUISelect')
|
||||||
map <silent><unique> <Leader>ws <Plug>VimwikiUISelect
|
nmap <silent><unique> <Leader>ws <Plug>VimwikiUISelect
|
||||||
endif
|
endif
|
||||||
noremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>VimwikiDiaryIndex')
|
||||||
|
nmap <silent><unique> <Leader>wi <Plug>VimwikiDiaryIndex
|
||||||
|
endif
|
||||||
|
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
|
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
|
||||||
map <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
|
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
|
||||||
endif
|
endif
|
||||||
noremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
||||||
map <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
|
nmap <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
|
||||||
endif
|
endif
|
||||||
noremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
||||||
\ :VimwikiTabMakeDiaryNote<CR>
|
\ :VimwikiTabMakeDiaryNote<CR>
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
@@ -366,9 +413,9 @@ function! s:build_menu(topmenu)
|
|||||||
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
|
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
|
||||||
let norm_path = escape(norm_path, '\ \.')
|
let norm_path = escape(norm_path, '\ \.')
|
||||||
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
||||||
\ ' :call vimwiki#goto_index('.(idx + 1).')<CR>'
|
\ ' :call vimwiki#base#goto_index('.(idx + 1).')<CR>'
|
||||||
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
||||||
\ ' :call vimwiki_diary#make_note('.(idx + 1).')<CR>'
|
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
|
||||||
let idx += 1
|
let idx += 1
|
||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
@@ -390,8 +437,8 @@ endif
|
|||||||
|
|
||||||
" CALENDAR Hook "{{{
|
" CALENDAR Hook "{{{
|
||||||
if g:vimwiki_use_calendar
|
if g:vimwiki_use_calendar
|
||||||
let g:calendar_action = 'vimwiki_diary#calendar_action'
|
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
||||||
let g:calendar_sign = 'vimwiki_diary#calendar_sign'
|
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
||||||
endif
|
endif
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
@@ -15,22 +15,40 @@ command! -narg=0 ZoomOut :call s:ZoomOut()
|
|||||||
command! -narg=0 ZoomReset :call s:ZoomReset()
|
command! -narg=0 ZoomReset :call s:ZoomReset()
|
||||||
|
|
||||||
" map
|
" map
|
||||||
|
"gryf: I like keypad mappings
|
||||||
nmap <kPlus> :ZoomIn<CR>
|
nmap <kPlus> :ZoomIn<CR>
|
||||||
nmap <kMinus> :ZoomOut<CR>
|
nmap <kMinus> :ZoomOut<CR>
|
||||||
nmap <kDivide> :ZoomReset<CR>
|
nmap <kDivide> :ZoomReset<CR>
|
||||||
|
|
||||||
" guifont size + 1
|
" guifont size + 1
|
||||||
function! s:ZoomIn()
|
function! s:ZoomIn()
|
||||||
|
" gryf: Let's check, what system we are dealing with
|
||||||
|
if has("win32")
|
||||||
|
let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '')
|
||||||
|
let l:fsize += 1
|
||||||
|
let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '')
|
||||||
|
let &guifont = l:guifont
|
||||||
|
elseif has('unix')
|
||||||
|
" gryf: might not work on os x though
|
||||||
let l:font = split(&guifont)
|
let l:font = split(&guifont)
|
||||||
let l:size = l:font[1] + 1
|
let l:font[-1] = l:font[-1] + 1
|
||||||
let &guifont = l:font[0] . " " . l:size
|
let &guifont = join(l:font, " ")
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" guifont size - 1
|
" guifont size - 1
|
||||||
function! s:ZoomOut()
|
function! s:ZoomOut()
|
||||||
|
" gryf: same as above
|
||||||
|
if has("win32")
|
||||||
|
let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '')
|
||||||
|
let l:fsize -= 1
|
||||||
|
let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '')
|
||||||
|
let &guifont = l:guifont
|
||||||
|
elseif has('unix')
|
||||||
let l:font = split(&guifont)
|
let l:font = split(&guifont)
|
||||||
let l:size = l:font[1] - 1
|
let l:font[-1] = l:font[-1] - 1
|
||||||
let &guifont = l:font[0] . " " . l:size
|
let &guifont = join(l:font, " ")
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" reset guifont size
|
" reset guifont size
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ elseif exists("b:current_syntax")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Links highlighting is controlled by vimwiki#highlight_links() function.
|
" Links highlighting is controlled by vimwiki#base#highlight_links() function.
|
||||||
" It is called from setup_buffer_enter() function in the BufEnter autocommand.
|
" It is called from setup_buffer_enter() function in the BufEnter autocommand.
|
||||||
|
|
||||||
" Load concrete Wiki syntax
|
" Load concrete Wiki syntax
|
||||||
@@ -20,6 +20,9 @@ execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
|
|||||||
if exists("+conceallevel")
|
if exists("+conceallevel")
|
||||||
syntax conceal on
|
syntax conceal on
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
syntax spell toplevel
|
||||||
|
|
||||||
syn match VimwikiLinkChar contained /\[\[/
|
syn match VimwikiLinkChar contained /\[\[/
|
||||||
syn match VimwikiLinkChar contained /\]\]/
|
syn match VimwikiLinkChar contained /\]\]/
|
||||||
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.\{-}]]/
|
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.\{-}]]/
|
||||||
@@ -62,12 +65,12 @@ execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
|
|||||||
|
|
||||||
|
|
||||||
" Tables
|
" Tables
|
||||||
" execute 'syntax match VimwikiTable /'.g:vimwiki_rxTable.'/'
|
|
||||||
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
||||||
\ transparent contains=VimwikiCellSeparator,VimwikiLinkT,
|
\ transparent contains=VimwikiCellSeparator,VimwikiLinkT,
|
||||||
\ VimwikiNoExistsLinkT,VimwikiEmoticons,VimwikiTodo,
|
\ VimwikiNoExistsLinkT,VimwikiEmoticons,VimwikiTodo,
|
||||||
\ VimwikiBoldT,VimwikiItalicT,VimwikiBoldItalicT,VimwikiItalicBoldT,
|
\ VimwikiBoldT,VimwikiItalicT,VimwikiBoldItalicT,VimwikiItalicBoldT,
|
||||||
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT
|
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT,
|
||||||
|
\ @Spell
|
||||||
syntax match VimwikiCellSeparator
|
syntax match VimwikiCellSeparator
|
||||||
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
||||||
|
|
||||||
@@ -76,35 +79,36 @@ execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
|
|||||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
|
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
|
||||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
||||||
|
|
||||||
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar'
|
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
|
||||||
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT'
|
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar'
|
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar,@Spell'
|
||||||
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT'
|
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar'
|
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||||
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT'
|
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar'
|
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||||
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT'
|
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar'
|
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar,@Spell'
|
||||||
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar'
|
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar'
|
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar,@Spell'
|
||||||
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT'
|
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar'
|
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar,@Spell'
|
||||||
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT'
|
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
|
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
|
||||||
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
|
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
|
||||||
|
|
||||||
|
|
||||||
" <hr> horizontal rule
|
" <hr> horizontal rule
|
||||||
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
|
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
|
||||||
|
|
||||||
execute 'syntax region VimwikiPre start=/'.g:vimwiki_rxPreStart.
|
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
|
||||||
\ '/ end=/'.g:vimwiki_rxPreEnd.'/ contains=VimwikiComment'
|
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
|
||||||
|
|
||||||
" List item checkbox
|
" List item checkbox
|
||||||
syntax match VimwikiCheckBox /\[.\?\]/
|
syntax match VimwikiCheckBox /\[.\?\]/
|
||||||
@@ -121,6 +125,7 @@ endif
|
|||||||
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||||
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
|
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
|
||||||
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||||
|
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||||
syntax match VimwikiPlaceholderParam /\s.*/ contained
|
syntax match VimwikiPlaceholderParam /\s.*/ contained
|
||||||
|
|
||||||
" html tags
|
" html tags
|
||||||
@@ -130,23 +135,44 @@ execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
|
|||||||
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
||||||
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
||||||
|
|
||||||
syntax region VimwikiComment start='<!--' end='-->'
|
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
|
||||||
|
|
||||||
if g:vimwiki_hl_headers == 0
|
" Header levels, 1-6
|
||||||
execute 'syntax match VimwikiHeader /'.g:vimwiki_rxHeader.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
else
|
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
" Header levels, 1-6
|
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
|
||||||
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
|
||||||
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" group names "{{{
|
" group names "{{{
|
||||||
|
|
||||||
call vimwiki#setup_colors()
|
if g:vimwiki_hl_headers == 0
|
||||||
|
hi link VimwikiHeader1 Title
|
||||||
|
hi link VimwikiHeader2 Title
|
||||||
|
hi link VimwikiHeader3 Title
|
||||||
|
hi link VimwikiHeader4 Title
|
||||||
|
hi link VimwikiHeader5 Title
|
||||||
|
hi link VimwikiHeader6 Title
|
||||||
|
else
|
||||||
|
if &background == 'light'
|
||||||
|
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black term=bold cterm=bold
|
||||||
|
else
|
||||||
|
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White term=bold cterm=bold
|
||||||
|
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White term=bold cterm=bold
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
hi def link VimwikiMarkers Normal
|
||||||
|
|
||||||
hi def VimwikiBold term=bold cterm=bold gui=bold
|
hi def VimwikiBold term=bold cterm=bold gui=bold
|
||||||
hi def link VimwikiBoldT VimwikiBold
|
hi def link VimwikiBoldT VimwikiBold
|
||||||
@@ -164,16 +190,16 @@ hi def VimwikiUnderline gui=underline
|
|||||||
hi def link VimwikiCode PreProc
|
hi def link VimwikiCode PreProc
|
||||||
hi def link VimwikiCodeT VimwikiCode
|
hi def link VimwikiCodeT VimwikiCode
|
||||||
|
|
||||||
hi def link VimwikiNoExistsLink Error
|
|
||||||
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
|
|
||||||
|
|
||||||
hi def link VimwikiPre PreProc
|
hi def link VimwikiPre PreProc
|
||||||
hi def link VimwikiPreT VimwikiPre
|
hi def link VimwikiPreT VimwikiPre
|
||||||
|
|
||||||
hi def link VimwikiLink Underlined
|
hi def link VimwikiNoExistsLink SpellBad
|
||||||
hi def link VimwikiLinkT Underlined
|
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
|
||||||
|
|
||||||
hi def link VimwikiList Function
|
hi def link VimwikiLink Underlined
|
||||||
|
hi def link VimwikiLinkT VimwikiLink
|
||||||
|
|
||||||
|
hi def link VimwikiList Identifier
|
||||||
hi def link VimwikiCheckBox VimwikiList
|
hi def link VimwikiCheckBox VimwikiList
|
||||||
hi def link VimwikiCheckBoxDone Comment
|
hi def link VimwikiCheckBoxDone Comment
|
||||||
hi def link VimwikiEmoticons Character
|
hi def link VimwikiEmoticons Character
|
||||||
@@ -190,33 +216,32 @@ hi def link VimwikiSubScriptT VimwikiSubScript
|
|||||||
hi def link VimwikiTodo Todo
|
hi def link VimwikiTodo Todo
|
||||||
hi def link VimwikiComment Comment
|
hi def link VimwikiComment Comment
|
||||||
|
|
||||||
hi def link VimwikiCellSeparator PreProc
|
|
||||||
|
|
||||||
hi def link VimwikiPlaceholder SpecialKey
|
hi def link VimwikiPlaceholder SpecialKey
|
||||||
hi def link VimwikiPlaceholderParam String
|
hi def link VimwikiPlaceholderParam String
|
||||||
hi def link VimwikiHTMLtag SpecialKey
|
hi def link VimwikiHTMLtag SpecialKey
|
||||||
|
|
||||||
hi def link VimwikiBoldChar VimwikiIgnore
|
hi def link VimwikiCellSeparator VimwikiMarkers
|
||||||
hi def link VimwikiItalicChar VimwikiIgnore
|
hi def link VimwikiBoldChar VimwikiMarkers
|
||||||
hi def link VimwikiBoldItalicChar VimwikiIgnore
|
hi def link VimwikiItalicChar VimwikiMarkers
|
||||||
hi def link VimwikiItalicBoldChar VimwikiIgnore
|
hi def link VimwikiBoldItalicChar VimwikiMarkers
|
||||||
hi def link VimwikiDelTextChar VimwikiIgnore
|
hi def link VimwikiItalicBoldChar VimwikiMarkers
|
||||||
hi def link VimwikiSuperScriptChar VimwikiIgnore
|
hi def link VimwikiDelTextChar VimwikiMarkers
|
||||||
hi def link VimwikiSubScriptChar VimwikiIgnore
|
hi def link VimwikiSuperScriptChar VimwikiMarkers
|
||||||
hi def link VimwikiCodeChar VimwikiIgnore
|
hi def link VimwikiSubScriptChar VimwikiMarkers
|
||||||
hi def link VimwikiHeaderChar VimwikiIgnore
|
hi def link VimwikiCodeChar VimwikiMarkers
|
||||||
|
hi def link VimwikiHeaderChar VimwikiMarkers
|
||||||
hi def link VimwikiLinkChar VimwikiLink
|
hi def link VimwikiLinkChar VimwikiLink
|
||||||
hi def link VimwikiNoLinkChar VimwikiNoExistsLink
|
hi def link VimwikiNoLinkChar VimwikiNoExistsLink
|
||||||
|
|
||||||
hi def link VimwikiBoldCharT VimwikiIgnore
|
hi def link VimwikiBoldCharT VimwikiMarkers
|
||||||
hi def link VimwikiItalicCharT VimwikiIgnore
|
hi def link VimwikiItalicCharT VimwikiMarkers
|
||||||
hi def link VimwikiBoldItalicCharT VimwikiIgnore
|
hi def link VimwikiBoldItalicCharT VimwikiMarkers
|
||||||
hi def link VimwikiItalicBoldCharT VimwikiIgnore
|
hi def link VimwikiItalicBoldCharT VimwikiMarkers
|
||||||
hi def link VimwikiDelTextCharT VimwikiIgnore
|
hi def link VimwikiDelTextCharT VimwikiMarkers
|
||||||
hi def link VimwikiSuperScriptCharT VimwikiIgnore
|
hi def link VimwikiSuperScriptCharT VimwikiMarkers
|
||||||
hi def link VimwikiSubScriptCharT VimwikiIgnore
|
hi def link VimwikiSubScriptCharT VimwikiMarkers
|
||||||
hi def link VimwikiCodeCharT VimwikiIgnore
|
hi def link VimwikiCodeCharT VimwikiMarkers
|
||||||
hi def link VimwikiHeaderCharT VimwikiIgnore
|
hi def link VimwikiHeaderCharT VimwikiMarkers
|
||||||
hi def link VimwikiLinkCharT VimwikiLinkT
|
hi def link VimwikiLinkCharT VimwikiLinkT
|
||||||
hi def link VimwikiNoLinkCharT VimwikiNoExistsLinkT
|
hi def link VimwikiNoLinkCharT VimwikiNoExistsLinkT
|
||||||
"}}}
|
"}}}
|
||||||
@@ -227,7 +252,7 @@ let b:current_syntax="vimwiki"
|
|||||||
let nested = VimwikiGet('nested_syntaxes')
|
let nested = VimwikiGet('nested_syntaxes')
|
||||||
if !empty(nested)
|
if !empty(nested)
|
||||||
for [hl_syntax, vim_syntax] in items(nested)
|
for [hl_syntax, vim_syntax] in items(nested)
|
||||||
call vimwiki#nested_syntax(vim_syntax,
|
call vimwiki#base#nested_syntax(vim_syntax,
|
||||||
\ '^\s*{{{\%(.*[[:blank:][:punct:]]\)\?'.
|
\ '^\s*{{{\%(.*[[:blank:][:punct:]]\)\?'.
|
||||||
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||||
\ '^\s*}}}', 'VimwikiPre')
|
\ '^\s*}}}', 'VimwikiPre')
|
||||||
|
|||||||
@@ -81,3 +81,5 @@ let g:vimwiki_rxListDefine = '::\(\s\|$\)'
|
|||||||
" Preformatted text
|
" Preformatted text
|
||||||
let g:vimwiki_rxPreStart = '{{{'
|
let g:vimwiki_rxPreStart = '{{{'
|
||||||
let g:vimwiki_rxPreEnd = '}}}'
|
let g:vimwiki_rxPreEnd = '}}}'
|
||||||
|
|
||||||
|
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||||
|
|||||||
@@ -65,3 +65,5 @@ let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
|
|||||||
" Preformatted text
|
" Preformatted text
|
||||||
let g:vimwiki_rxPreStart = '<pre>'
|
let g:vimwiki_rxPreStart = '<pre>'
|
||||||
let g:vimwiki_rxPreEnd = '<\/pre>'
|
let g:vimwiki_rxPreEnd = '<\/pre>'
|
||||||
|
|
||||||
|
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||||
|
|||||||
Reference in New Issue
Block a user