From b66769d04379dbb6335f98e7ed123f514907ff33 Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 12 Jun 2011 14:28:41 +0200 Subject: [PATCH] Commented changes in plugins, updated vimwiki, repaired zoom plugin, added buffergator, updated pythonhelper, removed leftovers --- .vimrc | 5 + GetLatest/GetLatestVimScripts.dat | 25 +- autoload/delimitMate.vim | 748 ---------- autoload/getscript.vim | 591 -------- autoload/{vimwiki.vim => vimwiki/base.vim} | 238 ++-- autoload/vimwiki/default.tpl | 11 + .../{vimwiki_diary.vim => vimwiki/diary.vim} | 27 +- .../{vimwiki_html.vim => vimwiki/html.vim} | 514 ++++--- autoload/{vimwiki_lst.vim => vimwiki/lst.vim} | 70 +- autoload/vimwiki/style.css | 39 + autoload/{vimwiki_tbl.vim => vimwiki/tbl.vim} | 28 +- colors/github.vim | 1 + colors/inkpot.vim | 1 + colors/jellybeans.vim | 1 + doc/buffergator.txt | 200 +++ doc/delimitMate.txt | 649 --------- doc/tags | 23 +- doc/vimwiki.txt | 694 +++++---- doc2/vst-s5.html | 783 ----------- ftplugin/diff/common.vim | 3 - ftplugin/python/common.vim | 2 - ftplugin/python/pyflakes/pyflakes/ast.py | 311 ----- ftplugin/python/pythonhelper.vim | 460 +++--- ftplugin/vimwiki.vim | 180 ++- indent/vimwiki.vim | 55 - plugin/buffergator.vim | 1237 +++++++++++++++++ plugin/occur.vim | 2 + plugin/vcscommand.vim | 1 + plugin/vimwiki.vim | 133 +- plugin/zoom.vim | 30 +- syntax/vimwiki.vim | 143 +- syntax/vimwiki_default.vim | 2 + syntax/vimwiki_media.vim | 2 + 33 files changed, 3064 insertions(+), 4145 deletions(-) delete mode 100644 autoload/delimitMate.vim delete mode 100644 autoload/getscript.vim rename autoload/{vimwiki.vim => vimwiki/base.vim} (82%) create mode 100644 autoload/vimwiki/default.tpl rename autoload/{vimwiki_diary.vim => vimwiki/diary.vim} (89%) rename autoload/{vimwiki_html.vim => vimwiki/html.vim} (75%) rename autoload/{vimwiki_lst.vim => vimwiki/lst.vim} (87%) create mode 100644 autoload/vimwiki/style.css rename autoload/{vimwiki_tbl.vim => vimwiki/tbl.vim} (94%) create mode 100644 doc/buffergator.txt delete mode 100644 doc/delimitMate.txt delete mode 100644 doc2/vst-s5.html delete mode 100644 ftplugin/diff/common.vim delete mode 100644 ftplugin/python/pyflakes/pyflakes/ast.py delete mode 100644 indent/vimwiki.vim create mode 100644 plugin/buffergator.vim diff --git a/.vimrc b/.vimrc index de323bc..7f21b0f 100644 --- a/.vimrc +++ b/.vimrc @@ -168,6 +168,11 @@ autocmd ColorScheme * call CustomHighlightings() "}}} " DirDiff{{{ let g:DirDiffExcludes = "CVS,*.class,*.exe,.*.swp,*.pyc,*.pyo" +" Make use of cursor keys +nmap [c +nmap ]c +nmap \dk +nmap \d " }}} "}}} "KEYS: User definied keyboard shortcuts {{{ diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat index 94b6d7a..a6c003a 100644 --- a/GetLatest/GetLatestVimScripts.dat +++ b/GetLatest/GetLatestVimScripts.dat @@ -1,43 +1,41 @@ ScriptID SourceID Filename -------------------------- ### plugins +3619 15858 buffergator 102 13435 DirDiff.vim -#2754 13139 :AutoInstall: delimitMate.vim -1984 13961 fuzzyfinder.vim +1984 13961 :AutoInstall: FuzzyFinder 311 7645 grep.vim 3304 15744 gundo.vim 2727 11120 jsbeautify.vim +3252 13948 :AutoInstall: L9 +2289 8922 loremipsum 2666 15663 Mark 2262 8944 occur.vim -910 14691 pydoc.vim -#2421 9423 pysmell.vim +2136 8206 repeat.vim 152 3342 showmarks.vim 2540 11006 snipMate.vim 1697 12566 :AutoInstall: surround.vim -#273 7701 taglist.vim # exchanged with taglisttoo -#and taglisttoo was exchanged by tagbar 3465 15751 Tagbar 90 15797 vcscommand.vim -2226 13756 vimwiki.vim -2289 0 loremipsum.vim +2226 15854 vimwiki.vim 1334 6377 vst.vim -1984 13961 :AutoInstall: FuzzyFinder -3252 13948 :AutoInstall: L9 +2321 9055 zoom.vim ### colors 2855 12456 github.vim 1143 11833 inkpot.vim 2555 15432 jellybeans.vim 2536 15197 lucius.vim 3299 14475 sorcerer.vim +1165 3741 tolerable.vim 3309 15759 vydark 2589 15760 vylight -1165 3741 tolerable.vim 415 15531 zenburn -# compiler -891 10365 pylint.vim # ftplugin +910 14691 pydoc.vim 2441 14403 pyflakes.vim 30 9196 python_fn.vim +435 12010 pythonhelper.vim +2527 10034 jpythonfold.vim ### indent 1936 7708 javascript.vim # there is also python.vim, which is close to PEP8, but author of @@ -48,4 +46,3 @@ ScriptID SourceID Filename 2651 10658 fitnesse.vim ### doc 3277 14056 py2stdlib - diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim deleted file mode 100644 index 731368e..0000000 --- a/autoload/delimitMate.vim +++ /dev/null @@ -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. -" 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() == "\" - 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 == "\" - 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 = "\" - 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 . "\\"" . dchar . rd . "\:call delimitMate#RestoreRegister()\" -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 = "\" . getline(line('.') + 1)[0] . "\" - let b:delimitMate_buffer = [] - return "\" . getline(line('.') + 1)[0] . "\" - 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 "\" - endif - if delimitMate#WithinEmptyPair() - " Expand: - call delimitMate#FlushBuffer() - "return "\a\x\\k$\"_xa" - return "\\\o" - else - return "\" - endif -endfunction "}}} - -function! delimitMate#ExpandSpace() "{{{ - if delimitMate#IsForbidden("\") - return "\" - endif - if delimitMate#WithinEmptyPair() - " Expand: - call insert(b:delimitMate_buffer, 's') - return delimitMate#WriteAfter(' ') . "\" - else - return "\" - endif -endfunction "}}} - -function! delimitMate#BS() " {{{ - if delimitMate#IsForbidden("") - return "\" - endif - if delimitMate#WithinEmptyPair() - "call delimitMate#RmBuffer(1) - return "\" . delimitMate#Del() -" return "\\\" - elseif delimitMate#IsSpaceExpansion() - "call delimitMate#RmBuffer(1) - return "\" . delimitMate#Del() - elseif delimitMate#IsCRExpansion() - return "\\" - else - return "\" - 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 "\" - 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 = "\" - while i < len - let lefts = lefts . "\" - let i += 1 - endwhile - return substitute(buffer, "s", "\", '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 ) =delimitMate#SkipDelim('\)') - for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list - exec 'inoremap ' . delim . ' =delimitMate#SkipDelim("' . escape(delim,'"\|') . '")' - endfor -endfunction "}}} - -function! delimitMate#AutoClose() "{{{ - " Add matching pair and jump to the midle: - " inoremap ( () - 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 ' . ld . ' ' . ld . '=delimitMate#JumpIn("' . rd . '")' - let i += 1 - endwhile - - " Exit from inside the matching pair: - for delim in b:delimitMate_right_delims - exec 'inoremap ' . delim . ' =delimitMate#JumpOut("\' . delim . '")' - endfor - - " Add matching quote and jump to the midle, or exit if inside a pair of matching quotes: - " inoremap " =delimitMate#QuoteDelim("\"") - for delim in b:delimitMate_quotes_list - exec 'inoremap ' . delim . ' =delimitMate#QuoteDelim("\' . delim . '")' - endfor - - " Try to fix the use of apostrophes (de-activated by default): - " inoremap n't n't - for map in b:delimitMate_apostrophes_list - exec "inoremap " . 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 " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")' - endfor -endfunction "}}} - -function! delimitMate#ExtraMappings() "{{{ - " If pair is empty, delete both delimiters: - inoremap =delimitMate#BS() - - " If pair is empty, delete closing delimiter: - inoremap delimitMate#WithinEmptyPair() && !delimitMate#IsForbidden("") ? "\" : "\" - - " Expand return if inside an empty pair: - if b:delimitMate_expand_cr != 0 - inoremap =delimitMate#ExpandReturn() - endif - - " Expand space if inside an empty pair: - if b:delimitMate_expand_space != 0 - inoremap =delimitMate#ExpandSpace() - endif - - " Jump out ot any empty pair: - if b:delimitMate_tab2exit - inoremap =delimitMate#JumpAny("\") - endif - - " Fix the re-do feature: - inoremap =delimitMate#Finish() - - " Flush the char buffer on mouse click: - inoremap =delimitMate#Finish() - inoremap =delimitMate#Finish() - - " Flush the char buffer on key movements: - inoremap =delimitMate#Finish() - inoremap =delimitMate#Finish() - inoremap =delimitMate#Finish() - inoremap =delimitMate#Finish() - - inoremap =delimitMate#Del() - - "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 OC - endif -endfunction "}}} - -function! delimitMate#UnMap() " {{{ - let imaps = - \ b:delimitMate_right_delims + - \ b:delimitMate_left_delims + - \ b:delimitMate_quotes_list + - \ b:delimitMate_apostrophes_list + - \ ['', '', '', '', '', '', ''] + - \ ['', '', '', '', '', ''] - - 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 ' . 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 ' . 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 . "\" - exec "normal i*b:delimitMate_expand_space = " . b:delimitMate_expand_space . "\" - exec "normal i*b:delimitMate_expand_cr = " . b:delimitMate_expand_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\Delete: " . b:delimitMate_left_delims[i] . "\|" - exec "normal A\Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|" - exec "normal A\Space: " . b:delimitMate_left_delims[i] . " |" - exec "normal A\Delete space: " . b:delimitMate_left_delims[i] . " \|" - exec "normal GGA\Visual-L: v\v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i] - exec "normal A\Visual-R: v\v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i] - exec "normal A\Car return: " . b:delimitMate_left_delims[i] . "\|" - exec "normal GGA\Delete car return: " . b:delimitMate_left_delims[i] . "\\|\GGA\\" - endfor - for i in range(len(b:delimitMate_quotes_list)) - exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|" - exec "normal A\Delete: " - exec "normal A\Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|" - exec "normal A\Space: " . b:delimitMate_quotes_list[i] . " |" - exec "normal A\Delete space: " . b:delimitMate_quotes_list[i] . " \|" - exec "normal GGA\Visual: v\v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i] - exec "normal A\Car return: " . b:delimitMate_quotes_list[i] . "\|" - exec "normal GGA\Delete car return: " . b:delimitMate_quotes_list[i] . "\\|\GGA\\" - 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\Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\|" - exec "normal A\Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|" - exec "normal A\Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |" - exec "normal A\Delete space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " \|" - exec "normal GGA\Visual-L: v\v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i] - exec "normal A\Visual-R: v\v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i] - exec "normal A\Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\|" - exec "normal GGA\Delete car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\\|\GGA\\" - 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\Delete: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\|" - exec "normal A\Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|" - exec "normal A\Space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " |" - exec "normal A\Delete space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " \|" - exec "normal GGA\Visual: v\v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i] - exec "normal A\Car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\|" - exec "normal GGA\Delete car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\\|\GGA\\" - endfor - endif - exec "normal \i" -endfunction "}}} - -"}}} - -" vim:foldmethod=marker:foldcolumn=4 diff --git a/autoload/getscript.vim b/autoload/getscript.vim deleted file mode 100644 index 44d5668..0000000 --- a/autoload/getscript.vim +++ /dev/null @@ -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 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 =~ '\%(\\|\\)\%(\.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\" - 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*\([^<]\+\)<.*$' - 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 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\" - 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 diff --git a/autoload/vimwiki.vim b/autoload/vimwiki/base.vim similarity index 82% rename from autoload/vimwiki.vim rename to autoload/vimwiki/base.vim index db98cc1..b56eff6 100644 --- a/autoload/vimwiki.vim +++ b/autoload/vimwiki/base.vim @@ -18,14 +18,18 @@ let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]' " MISC helper functions {{{ -function! vimwiki#chomp_slash(str) "{{{ +function! vimwiki#base#chomp_slash(str) "{{{ return substitute(a:str, '[/\\]\+$', '', '') 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) 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) let path = iconv(path, &enc, g:vimwiki_w32_dir_enc) endif @@ -34,17 +38,30 @@ function! vimwiki#mkdir(path) "{{{ endfunction " }}} -function! vimwiki#safe_link(string) "{{{ - return substitute(a:string, s:badsymbols, g:vimwiki_stripsym, 'g') +function! vimwiki#base#safe_link(link) "{{{ + " 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 "}}} -function! vimwiki#unsafe_link(string) "{{{ - return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g') +function! vimwiki#base#unsafe_link(string) "{{{ + if len(g:vimwiki_stripsym) > 0 + return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g') + else + return a:string + endif endfunction "}}} -function! vimwiki#subdir(path, filename)"{{{ +function! vimwiki#base#subdir(path, filename)"{{{ let path = expand(a:path) let filename = expand(a:filename) let idx = 0 @@ -60,13 +77,17 @@ function! vimwiki#subdir(path, filename)"{{{ return res endfunction"}}} -function! vimwiki#current_subdir()"{{{ - return vimwiki#subdir(VimwikiGet('path'), expand('%:p')) +function! vimwiki#base#current_subdir()"{{{ + return vimwiki#base#subdir(VimwikiGet('path'), expand('%:p')) endfunction"}}} -function! vimwiki#open_link(cmd, link, ...) "{{{ - if vimwiki#is_non_wiki_link(a:link) - call s:edit_file(a:cmd, a:link) +function! vimwiki#base#open_link(cmd, link, ...) "{{{ + if vimwiki#base#is_non_wiki_link(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 if a:0 let vimwiki_prev_link = [a:1, []] @@ -74,17 +95,17 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ let vimwiki_prev_link = [expand('%:p'), getpos('.')] endif - if vimwiki#is_link_to_dir(a:link) + if vimwiki#base#is_link_to_dir(a: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 - call s:edit_file(a:cmd, + call vimwiki#base#edit_file(a:cmd, \ VimwikiGet('path').a:link. \ g:vimwiki_dir_link. \ VimwikiGet('ext')) endif 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 if exists('vimwiki_prev_link') @@ -94,7 +115,7 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ endfunction " }}} -function! vimwiki#select(wnum)"{{{ +function! vimwiki#base#select(wnum)"{{{ if a:wnum < 1 || a:wnum > len(g:vimwiki_list) return endif @@ -105,7 +126,7 @@ function! vimwiki#select(wnum)"{{{ endfunction " }}} -function! vimwiki#generate_links()"{{{ +function! vimwiki#base#generate_links()"{{{ let links = s:get_links('*'.VimwikiGet('ext')) " We don't want link to itself. @@ -127,8 +148,8 @@ function! vimwiki#generate_links()"{{{ endfor endfunction " }}} -function! vimwiki#goto(key) "{{{ - call s:edit_file(':e', +function! vimwiki#base#goto(key) "{{{ + call vimwiki#base#edit_file(':e', \ VimwikiGet('path'). \ a:key. \ VimwikiGet('ext')) @@ -138,9 +159,13 @@ function! s:is_windows() "{{{ return has("win32") || has("win64") || has("win95") || has("win16") endfunction "}}} +function! s:is_path_absolute(path) "{{{ + return a:path =~ '^/.*' || a:path =~ '^[[:alpha:]]:[/\\].*' +endfunction "}}} + function! s:get_links(pat) "{{{ " 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 " not search wiki files in subdirectories. Or it would hang the system if @@ -173,11 +198,11 @@ function! s:cursor(lnum, cnum) "{{{ endfunction "}}} function! s:filename(link) "{{{ - let result = vimwiki#safe_link(a:link) + let result = vimwiki#base#safe_link(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 =~ '][' - let result = vimwiki#safe_link(split(a:link, '][')[0]) + let result = vimwiki#base#safe_link(split(a:link, '][')[0]) endif return result endfunction @@ -191,10 +216,15 @@ function! s:is_wiki_word(str) "{{{ endfunction " }}} -function! s:edit_file(command, filename) "{{{ +function! vimwiki#base#edit_file(command, filename) "{{{ let fname = escape(a:filename, '% ') - call vimwiki#mkdir(fnamemodify(a:filename, ":p:h")) - execute a:command.' '.fname + call vimwiki#base#mkdir(fnamemodify(a:filename, ":p:h")) + try + 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 " }}} @@ -242,13 +272,13 @@ function! s:strip_word(word) "{{{ let w = split(w, "][")[0] endif - let result = vimwiki#safe_link(w) + let result = vimwiki#base#safe_link(w) endif return result endfunction " }}} -function! vimwiki#is_non_wiki_link(lnk) "{{{ +function! vimwiki#base#is_non_wiki_link(lnk) "{{{ let exts = '.\+\.\%('. \ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). \ '\)$' @@ -258,7 +288,7 @@ function! vimwiki#is_non_wiki_link(lnk) "{{{ return 0 endfunction "}}} -function! vimwiki#is_link_to_dir(link) "{{{ +function! vimwiki#base#is_link_to_dir(link) "{{{ " Check if link is to a directory. " It should be ended with \ or /. if a:link =~ '.\+[/\\]$' @@ -314,10 +344,10 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{ endif 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\%(|.*\)\?\%(\]\[.*\)\?\]\]' else - let old_fname_r = '\<'.old_fname.'\>' + let old_fname_r = '!\@' endif let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n') @@ -383,7 +413,7 @@ function! s:get_wiki_buffers() "{{{ endfunction " }}} 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]) call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1]) endif @@ -392,7 +422,7 @@ endfunction " }}} " }}} " SYNTAX highlight {{{ -function! vimwiki#highlight_links() "{{{ +function! vimwiki#base#highlight_links() "{{{ try syntax clear VimwikiNoExistsLink syntax clear VimwikiNoExistsLinkT @@ -442,21 +472,21 @@ function! s:highlight_existed_links() "{{{ for link in links 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 /!\@/ display' endif execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\%(|\+.\{-}\)\{-}\]\]/ display contained' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\]\[.\{-1,}\]\]/ display contained' endfor 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")') for dir in dirs execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(|\+.*\)*\]\]/ display contained' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contained' endfor endfunction "}}} -function! vimwiki#setup_colors() "{{{ - - 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) "{{{ +function! vimwiki#base#hl_exists(hl) "{{{ if !hlexists(a:hl) return 0 endif @@ -565,7 +541,7 @@ function! vimwiki#hl_exists(hl) "{{{ 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 let ft=toupper(a:filetype) let group='textGroup'.ft @@ -615,21 +591,23 @@ endfunction "}}} "}}} " WIKI functions {{{ -function! vimwiki#find_next_link() "{{{ +function! vimwiki#base#find_next_link() "{{{ call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '') endfunction " }}} -function! vimwiki#find_prev_link() "{{{ +function! vimwiki#base#find_prev_link() "{{{ call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b') endfunction " }}} -function! vimwiki#follow_link(split) "{{{ +function! vimwiki#base#follow_link(split) "{{{ if a:split == "split" let cmd = ":split " elseif a:split == "vsplit" let cmd = ":vsplit " + elseif a:split == "tabnew" + let cmd = ":tabnew " else let cmd = ":e " endif @@ -645,12 +623,12 @@ function! vimwiki#follow_link(split) "{{{ return endif - let subdir = vimwiki#current_subdir() - call vimwiki#open_link(cmd, subdir.link) + let subdir = vimwiki#base#current_subdir() + call vimwiki#base#open_link(cmd, subdir.link) endfunction " }}} -function! vimwiki#go_back_link() "{{{ +function! vimwiki#base#go_back_link() "{{{ if exists("b:vimwiki_prev_link") " go back to saved WikiWord let prev_word = b:vimwiki_prev_link @@ -659,23 +637,13 @@ function! vimwiki#go_back_link() "{{{ endif endfunction " }}} -function! vimwiki#goto_index(index) "{{{ - call vimwiki#select(a:index) - call vimwiki#mkdir(VimwikiGet('path')) - - try - execute ':e '.fnameescape( - \ 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 +function! vimwiki#base#goto_index(index) "{{{ + call vimwiki#base#select(a:index) + call vimwiki#base#edit_file('e', + \ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext')) endfunction "}}} -function! vimwiki#delete_link() "{{{ +function! vimwiki#base#delete_link() "{{{ "" file system funcs "" Delete WikiWord you are in from filesystem let val = input('Delete ['.expand('%').'] (y/n)? ', "") @@ -697,9 +665,9 @@ function! vimwiki#delete_link() "{{{ endif endfunction "}}} -function! vimwiki#rename_link() "{{{ +function! vimwiki#base#rename_link() "{{{ "" 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') " there is no file (new one maybe) @@ -727,7 +695,7 @@ function! vimwiki#rename_link() "{{{ echomsg 'vimwiki: Cannot rename to an empty filename!' return 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)!' return endif @@ -797,13 +765,13 @@ function! vimwiki#rename_link() "{{{ let &more = setting_more endfunction " }}} -function! vimwiki#ui_select()"{{{ +function! vimwiki#base#ui_select()"{{{ call s:print_wiki_list() let idx = input("Select Wiki (specify number): ") if idx == "" return endif - call vimwiki#goto_index(idx) + call vimwiki#base#goto_index(idx) endfunction "}}} @@ -811,7 +779,7 @@ endfunction " TEXT OBJECTS functions {{{ -function! vimwiki#TO_header(inner, visual) "{{{ +function! vimwiki#base#TO_header(inner, visual) "{{{ if !search('^\(=\+\).\+\1\s*$', 'bcW') return endif @@ -821,7 +789,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ let block_start = line(".") 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 \ && sel_start != sel_end @@ -854,7 +822,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ endfunction "}}} -function! vimwiki#TO_table_cell(inner, visual) "{{{ +function! vimwiki#base#TO_table_cell(inner, visual) "{{{ if col('.') == col('$')-1 return endif @@ -918,7 +886,7 @@ function! vimwiki#TO_table_cell(inner, visual) "{{{ endif endfunction "}}} -function! vimwiki#TO_table_col(inner, visual) "{{{ +function! vimwiki#base#TO_table_col(inner, visual) "{{{ let t_rows = vimwiki_tbl#get_rows(line('.')) if empty(t_rows) return @@ -1032,12 +1000,12 @@ function! vimwiki#TO_table_col(inner, visual) "{{{ endif endfunction "}}} -function! vimwiki#count_first_sym(line) "{{{ +function! vimwiki#base#count_first_sym(line) "{{{ let first_sym = matchstr(a:line, '\S') return len(matchstr(a:line, first_sym.'\+')) endfunction "}}} -function! vimwiki#AddHeaderLevel() "{{{ +function! vimwiki#base#AddHeaderLevel() "{{{ let lnum = line('.') let line = getline(lnum) @@ -1046,7 +1014,7 @@ function! vimwiki#AddHeaderLevel() "{{{ endif if line =~ '^\s*\(=\+\).\+\1\s*$' - let level = vimwiki#count_first_sym(line) + let level = vimwiki#base#count_first_sym(line) if level < 6 let line = substitute(line, '\(=\+\).\+\1', '=&=', '') call setline(lnum, line) @@ -1059,7 +1027,7 @@ function! vimwiki#AddHeaderLevel() "{{{ endfunction "}}} -function! vimwiki#RemoveHeaderLevel() "{{{ +function! vimwiki#base#RemoveHeaderLevel() "{{{ let lnum = line('.') let line = getline(lnum) @@ -1068,7 +1036,7 @@ function! vimwiki#RemoveHeaderLevel() "{{{ endif 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 new = repeat('=', level - 1) diff --git a/autoload/vimwiki/default.tpl b/autoload/vimwiki/default.tpl new file mode 100644 index 0000000..3e31d99 --- /dev/null +++ b/autoload/vimwiki/default.tpl @@ -0,0 +1,11 @@ + + + + +%title% + + + +%content% + + diff --git a/autoload/vimwiki_diary.vim b/autoload/vimwiki/diary.vim similarity index 89% rename from autoload/vimwiki_diary.vim rename to autoload/vimwiki/diary.vim index 9803cc1..7c7f51e 100644 --- a/autoload/vimwiki_diary.vim +++ b/autoload/vimwiki/diary.vim @@ -197,19 +197,24 @@ function! s:make_date_link(...) "{{{ return VimwikiGet('diary_rel_path').link endfunction "}}} -function! vimwiki_diary#make_note(index, ...) "{{{ - call vimwiki#select(a:index) - call vimwiki#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path')) +function! vimwiki#diary#make_note(index, ...) "{{{ + call vimwiki#base#select(a:index) + call vimwiki#base#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path')) if a:0 let link = s:make_date_link(a:1) else let link = s:make_date_link() 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 "}}} " 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 month = s:prefix_zero(a:month) @@ -228,11 +233,11 @@ function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ endif " 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 "}}} " 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 month = s:prefix_zero(a:month) let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path'). @@ -240,7 +245,7 @@ function vimwiki_diary#calendar_sign(day, month, year) "{{{ return filereadable(expand(sfile)) endfunction "}}} -function! vimwiki_diary#goto_next_day() "{{{ +function! vimwiki#diary#goto_next_day() "{{{ let link = '' let [idx, links] = s:get_position_links(expand('%:t:r')) @@ -256,11 +261,11 @@ function! vimwiki_diary#goto_next_day() "{{{ endif if len(link) - call vimwiki#open_link(':e ', link) + call vimwiki#base#open_link(':e ', link) endif endfunction "}}} -function! vimwiki_diary#goto_prev_day() "{{{ +function! vimwiki#diary#goto_prev_day() "{{{ let link = '' let [idx, links] = s:get_position_links(expand('%:t:r')) @@ -276,6 +281,6 @@ function! vimwiki_diary#goto_prev_day() "{{{ endif if len(link) - call vimwiki#open_link(':e ', link) + call vimwiki#base#open_link(':e ', link) endif endfunction "}}} diff --git a/autoload/vimwiki_html.vim b/autoload/vimwiki/html.vim similarity index 75% rename from autoload/vimwiki_html.vim rename to autoload/vimwiki/html.vim index 1efa539..3d685d6 100644 --- a/autoload/vimwiki_html.vim +++ b/autoload/vimwiki/html.vim @@ -13,12 +13,6 @@ endif 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 "{{{ function! s:root_path(subdir) "{{{ return repeat('../', len(split(a:subdir, '[/\\]'))) @@ -35,7 +29,7 @@ function! s:remove_blank_lines(lines) " {{{ endfunction "}}} 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 endif return 0 @@ -55,104 +49,69 @@ function! s:has_abs_path(fname) "{{{ return 0 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) " {{{ let path = expand(a:path) let css_full_name = path.VimwikiGet('css_name') if glob(css_full_name) == "" - call vimwiki#mkdir(fnamemodify(css_full_name, ':p:h')) - let lines = [] - - call add(lines, 'body {font-family: Tahoma, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}') - 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) - echomsg "Default style.css is created." + call vimwiki#base#mkdir(fnamemodify(css_full_name, ':p:h')) + let default_css = s:find_autoload_file('style.css') + if default_css != '' + let lines = readfile(default_css) + call writefile(lines, css_full_name) + echomsg "Default style.css has been created." + endif endif 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=[] - if VimwikiGet('html_header') != "" && !s:warn_html_header + let template_name = s:template_full_name(a:template) + if template_name != '' try - let lines = readfile(expand(VimwikiGet('html_header'))) - call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")') - call map(lines, 'substitute(v:val, "%root_path%", "'. - \ s:root_path(a:subdir) .'", "g")') + let lines = readfile(template_name) return lines catch /E484/ - let s:warn_html_header = 1 - echomsg 'vimwiki: Header template '.VimwikiGet('html_header'). + echomsg 'vimwiki: html template '.template_name. \ ' does not exist!' endtry endif - let css_name = expand(VimwikiGet('css_name')) - let css_name = substitute(css_name, '\', '/', 'g') - if !s:has_abs_path(css_name) - " Relative css file for deep links: [[dir1/dir2/dir3/filename]] - let css_name = s:root_path(a:subdir).css_name + " if no VimwikiGet('html_template') set up or error while reading template + " file -- use default one. + let default_tpl = s:find_autoload_file('default.tpl') + if default_tpl != '' + let lines = readfile(default_tpl) endif - - " if no VimwikiGet('html_header') set up or error while reading template - " file -- use default header. - call add(lines, '') - call add(lines, '') - call add(lines, '') - call add(lines, ''.a:title.'') - call add(lines, '') - call add(lines, '') - call add(lines, '') - - 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, '') - call add(lines, '') - return lines endfunction "}}} @@ -174,6 +133,19 @@ endfunction "}}} function! s:delete_html_files(path) "{{{ let htmlfiles = split(glob(a:path.'**/*.html'), '\n') 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 call delete(fname) catch @@ -182,45 +154,6 @@ function! s:delete_html_files(path) "{{{ endfor 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, ' is a comment. -Ex: > - +Text line started with %% is a comment. +E.g.: > + %% this text would not be in HTML < + +------------------------------------------------------------------------------ +5.10. Horizontal line *vimwiki-syntax-hr* + +4 or more dashes at the start of the line is a 'horizontal line' (
): > + ---- +< + + ============================================================================== 6. Folding/Outline *vimwiki-folding* @@ -761,25 +832,26 @@ Hit |zr| one more time: * [ ] Do stuff 2~ * [ ] Do stuff 3~ -NOTE: Whether you use default syntax, folding on list items should work +NOTE:If you use default vimwiki syntax, folding on list items will work properly only if all of them are indented using current |shiftwidth|. -For MediaWiki * or # should be in the first column. +For MediaWiki, * or # should be in the first column. To turn folding on/off check |g:vimwiki_folding|. + ============================================================================== 7. Placeholders *vimwiki-placeholders* ------------------------------------------------------------------------------ %toc Table of Contents *vimwiki-toc* *vimwiki-table-of-contents* -You can add 'table of contents' to your html page generated from wiki one. +You can add 'table of contents' to your HTML page generated from wiki one. Just place > %toc into your wiki page. -You can also add caption to your 'toc': > +You can also add a caption to your 'toc': > %toc Table of Contents @@ -791,9 +863,8 @@ or > ------------------------------------------------------------------------------ %title Title of the page *vimwiki-title* -When you htmlize your wiki page you have default title which is the filename -of the page. -Place > +When you htmlize your wiki page, the default title is the filename of the +page. Place > %title My books @@ -803,13 +874,25 @@ into your wiki page if you want another title. ------------------------------------------------------------------------------ %nohtml *vimwiki-nohtml* -If you do not want a wiki page to be converted to html, place: +If you do not want a wiki page to be converted to HTML, place: %nohtml into it. +------------------------------------------------------------------------------ +%template *vimwiki-template* + +To apply a concrete HTML template to a wiki page, place: + +%template name + +into it. + +See |vimwiki-option-template_path| for details. + + ============================================================================== 8. Todo lists *vimwiki-todo-lists* @@ -826,33 +909,33 @@ Consider the following example: * [X] Add highlighting to list item boxes * [X] Add [ ] to the next created with o, O and list item. - -Pressing on the first list item will toggle it and all of it's child +Pressing on the first list item will toggle it and all of its child items: = Toggleable list of todo items = * [ ] Toggle list item on/off. * [ ] Simple toggling between [ ] and [X]. - * [ ] All list's subitems should be toggled on/off appropriately. - * [ ] Toggle child subitems only if current line is list item - * [ ] Parent list item should be toggled depending on it's child items. - * [X] Make numbered list items toggleable too - * [X] Add highlighting to list item boxes - * [X] Add [ ] to the next created with o, O and list item. + * [ ] All of a list's subitems should be toggled on/off appropriately. + * [ ] Toggle child subitems only if the current line is a list item. + * [ ] Parent list item should be toggled depending on their child items. + * [X] Make numbered list items toggleable too. + * [X] Add highlighting to list item boxes. + * [X] Add [ ] to the next list item created using o, O or . -Pressing on the third list item will toggle it and all of it's +Pressing on the third list item will toggle it and adjust all of its parent items: = Toggleable list of todo items = * [.] Toggle list item on/off. * [ ] Simple toggling between [ ] and [X]. - * [X] All list's subitems should be toggled on/off appropriately. - * [ ] Toggle child subitems only if current line is list item + * [X] All of a list's subitems should be toggled on/off appropriately. + * [ ] Toggle child subitems only if current line is list item. * [ ] Parent list item should be toggled depending on it's child items. - * [ ] Make numbered list items toggleable too - * [ ] Add highlighting to list item boxes - * [ ] Add [ ] to the next created with o, O and list item. + * [ ] Make numbered list items toggleable too. + * [ ] Add highlighting to list item boxes. + * [ ] Add [ ] to the next list item created using o, O or . -Parent items could be toggled by its child items. Symbol inside [ ] depends on -percentage of toggled child items(see also |g:vimwiki_listsyms|): > +Parent items could be changed when their child items change. The symbol +between [ ] depends on the percentage of toggled child items (see also +|g:vimwiki_listsyms|): > [ ] -- 0% [.] -- 1-33% [o] -- 34-66% @@ -865,7 +948,8 @@ It is possible to toggle several list items using visual mode. ============================================================================== 9. Tables *vimwiki-tables* -Use :VimwikiTable command to create default table with 5 columns and 2 rows: > +Use the :VimwikiTable command to create a default table with 5 columns and 2 +rows: > | | | | | | |---+---+---+---+---| @@ -879,14 +963,14 @@ Tables are auto-formattable. Let's add some text into first cell: > | | | | | | < -Whenever you press , or leave Insert mode table is formatted: > +Whenever you press , or leave Insert mode, the table is formatted: > | First Name | | | | | |------------+---+---+---+---| | | | | | | < -You can easily create nice looking text tables, just press and enter new +You can easily create nice-looking text tables, just press and enter new values: > | First Name | Last Name | Age | City | e-mail | @@ -898,11 +982,10 @@ values: > To indent table indent the first row. Then format it with 'gqq'. - ============================================================================== 10. Diary *vimwiki-diary* -Diary helps you make daily notes. You can really easy add information into +The diary helps you make daily notes. You can easily add information into vimwiki that should be sorted out later. Just hit ww to create new daily note with name based on current date. The link to this newly created file is added to a diary wiki file. @@ -937,30 +1020,29 @@ By default there are 4 links on the line. All links are sorted by their dates. Calendar integration *vimwiki-calendar* ------------------------------------------------------------------------------ If you have Calendar.vim installed you can use it to create diary notes. -Just open calendar with :Calendar and tap on the date. Wiki file would -be created in default wiki's diary. +Just open calendar with :Calendar and tap on the date. A wiki file +will be created in the default wiki's diary. Get it from http://www.vim.org/scripts/script.php?script_id=52 See |g:vimwiki_use_calendar| option to turn it off/on. - ============================================================================== 11. Options *vimwiki-options* -There are global and per wiki(local) options available to tune vimwiki. -All global options are set using the following template: > +There are global and per-wiki (local) options available to tune vimwiki. +All global options are set using the following pattern: > let g:option_name=option_value -All per wiki options are |Dictionary|'s pairs in a list of wikies -(dictionaries). See |g:vimwiki_list| option for more details. +All per-wiki options are dictionaries (see |Dictionary|) in a list of wikies. +See |g:vimwiki_list| option for more details. ------------------------------------------------------------------------------ *g:vimwiki_list* *vimwiki-multiple-wikies* Each item in g:vimwiki_list is a |Dictionary| that holds all customization -available for a wiki represented by that item. It is in form of > +available for a wiki represented by that item. It is in the form: > {'option1': 'value1', 'option2: 'value2', ...} Consider the following example: > @@ -972,20 +1054,20 @@ It gives us one wiki located at ~/my_site/ that could be htmlized to The next example: > let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}, \ {'path': '~/my_docs/', 'ext': '.mdox'}] -gives us 2 wikies, first wiki as in previous example, second one is located in -~/my_docs/ and its files have .mdox extension. +gives us 2 wikies, the first wiki as in the previous example, and the second +one located in ~/my_docs/, with files that have the .mdox extension. -Empty |Dictionary| in the g:vimwiki_list is the wiki with default options: > +An empty |Dictionary| in g:vimwiki_list is the wiki with default options: > let g:vimwiki_list = [{}, \ {'path': '~/my_docs/', 'ext': '.mdox'}] < -You can also create wikis as a separate |Dictionary|s. > +You can also create wikis as separate |Dictionary|s. > let wiki_1 = {} let wiki_1.path = '~/my_docs/' - let wiki_1.html_header = '~/public_html/header.tpl' + let wiki_1.html_template = '~/public_html/template.tpl' let wiki_1.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} let wiki_2 = {} @@ -999,7 +1081,6 @@ You can also create wikis as a separate |Dictionary|s. > PER WIKI OPTIONS *viwmiki-local-options* - *vimwiki-option-path* ------------------------------------------------------------------------------ Key Default value~ @@ -1016,14 +1097,15 @@ Key Default value~ path_html ~/vimwiki_html/ Description~ -HTML files converted from wiki files location: > +Location of HTML files converted from wiki files: > let g:vimwiki_list = [{'path': '~/my_site/', \ 'path_html': '~/my_site_html/'}] -If you omit this option path_html would be path - '/' + '_html/': > +If you omit this option, the value of path_html would be set to the value of +path with the trailing slash ('/') removed and '_html' added; i.e. for: > let g:vimwiki_list = [{'path': '~/okidoki/'}] -ie, path_html = '~/okidoki_html/' +path_html will be set to '~/okidoki_html/'. *vimwiki-option-auto_export* ------------------------------------------------------------------------------ @@ -1031,11 +1113,11 @@ Key Default value Values~ auto_export 0 0, 1 Description~ -Set this option to 1 to automatically generate HTML file when corresponding -wiki page is saved: > +Set this option to 1 to automatically generate the HTML file when the +corresponding wiki page is saved: > let g:vimwiki_list = [{'path': '~/my_site/', 'auto_export': 1}] -This will keep you HTML files up to date. +This will keep your HTML files up to date. *vimwiki-option-index* ------------------------------------------------------------------------------ @@ -1046,7 +1128,7 @@ Description~ Name of wiki index file: > let g:vimwiki_list = [{'path': '~/my_site/', 'index': 'main'}] -NOTE: Do not add extension. +NOTE: Do not include the extension. *vimwiki-option-ext* @@ -1068,23 +1150,32 @@ syntax default default, media Description~ Wiki syntax. You can use different markup languages (currently default vimwiki and -MediaWiki) but only vimwiki's default markup could be converted to HTML at the +MediaWiki), but only vimwiki's default markup will be converted to HTML at the moment. To use MediaWiki's wiki markup: > let g:vimwiki_list = [{'path': '~/my_site/', 'syntax': 'media'}] < -*vimwiki-option-html_header* +*vimwiki-option-template_path* ------------------------------------------------------------------------------ -Key Default value~ -html_header +Key Default value~ +template_path ~/vimwiki/templates/ Description~ -Set up file name for html header template: > +Setup path for HTML templates: > let g:vimwiki_list = [{'path': '~/my_site/', - \ 'html_header': '~/public_html/header.tpl'}] + \ 'template_path': '~/public_html/templates/', + \ 'template_default': 'def_template', + \ 'template_ext': '.html'}] -This header.tpl could look like: > +There could be a bunch of templates: > + def_template.html + index.html + bio.html + person.html +etc. + +Each template could look like: > @@ -1092,7 +1183,11 @@ This header.tpl could look like: > -
+
+ %content% +
+ + where %title% is replaced by a wiki page name or by a |vimwiki-title| @@ -1100,22 +1195,37 @@ where if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then %root_path% is replaced by '../../../'. + %content% is replaced by a wiki file content. -*vimwiki-option-html_footer* + +The default template will be applied to all wiki pages unless a page specifies +a template. Consider you have wiki page named 'Maxim.wiki' and you want apply +'person.html' template to it. Just add: > + %template person +to that page. + + +*vimwiki-option-template_default* ------------------------------------------------------------------------------ -Key Default value~ -html_footer +Key Default value~ +template_default default Description~ -Set up file name for html footer template: > - let g:vimwiki_list = [{'path': '~/my_site/', - \ 'html_footer': '~/public_html/footer.tpl'}] +Setup default template name (without extension). + +See |vimwiki-option-template_path| for details. + + +*vimwiki-option-template_ext* +------------------------------------------------------------------------------ +Key Default value~ +template_ext .html + +Description~ +Setup template filename extension. + +See |vimwiki-option-template_path| for details. -This footer.tpl could look like: > -
- - -< *vimwiki-option-css_name* ------------------------------------------------------------------------------ @@ -1123,7 +1233,7 @@ Key Default value~ css_name style.css Description~ -Set up css file name: > +Setup CSS file name: > let g:vimwiki_list = [{'path': '~/my_pages/', \ 'css_name': 'main.css'}] < @@ -1139,8 +1249,8 @@ Key Default value Values~ maxhi 1 0, 1 Description~ -Non-existent wiki links highlighting could be quite slow and if you don't want -it set maxhi to 0: > +Non-existent wiki links highlighting can be quite slow. If you don't want it, +set maxhi to 0: > let g:vimwiki_list = [{'path': '~/my_site/', 'maxhi': 0}] This disables filesystem checks for wiki links. @@ -1152,7 +1262,7 @@ Key Default value Values~ nested_syntaxes {} pairs of highlight keyword and vim filetype Description~ -You can make preformatted text to be highlighted with a different syntaxes +You can configure preformatted text to be highlighted with any syntax available for vim. For example the following setup in your vimrc: > let wiki = {} @@ -1160,7 +1270,7 @@ For example the following setup in your vimrc: > let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} let g:vimwiki_list = [wiki] -would give you python and c++ highlighting in: > +would give you Python and C++ highlighting in: > {{{class="brush: python" for i in range(1, 5): print(i) @@ -1189,7 +1299,6 @@ or in: > }}} - *vimwiki-option-diary_rel_path* ------------------------------------------------------------------------------ Key Default value~ @@ -1239,25 +1348,24 @@ Use: > let g:option_name=option_value to set them. ------------------------------------------------------------------------------- +----------------------------------------------------------------------------- *g:vimwiki_hl_headers* Highlight headers with =Reddish=, ==Greenish==, ===Blueish=== colors. Value Description~ -1 Use predefined colors to highlight different header levels. -0 Use |hl-Title| or VimwikiHeader1-VimwikiHeader6 (if defined - in a colorscheme) - -Default: 1 +1 Use VimwikiHeader1-VimwikiHeader6 group colors to highlight + different header levels. +0 Use |hl-Title| color for headers. +Default: 0 ------------------------------------------------------------------------------ *g:vimwiki_hl_cb_checked* -Checked list items could be highlighted with a color: +Checked list items can be highlighted with a color: - * [X] the whole line could be highlighted with the option set to 1. + * [X] the whole line can be highlighted with the option set to 1. * [ ] I wish vim could use strikethru. Value Description~ @@ -1270,12 +1378,20 @@ Default: 0 ------------------------------------------------------------------------------ *g:vimwiki_global_ext* *vimwiki-temporary-wiki* -If a file with a registered wiki extension is opened in a dir that is not -listed in |g:vimwiki_list| then: +If a file with a registered wiki extension is opened in a directory that is +not listed in |g:vimwiki_list| then: Value Description~ 1 make a temporary wiki in that dir. -0 don't make temporary wiki it that dir. +0 don't make temporary wiki in that dir. + +A temporary wiki is created to scan the filesystem for available links to +highlight. + +Consider your wiki extension is .txt then you can > + let g:vimwiki_global_ext = 0 +to make it local to vimwiki paths listed in g:vimwiki_list. So other text +files wouldn't be treated as wiki pages. Default: 1 @@ -1293,7 +1409,7 @@ You can set up your own: > ------------------------------------------------------------------------------ *g:vimwiki_auto_checkbox* -if on, creates checkbox while toggling list item. +If on, creates checkbox while toggling list item. Value Description~ 0 Do not create checkbox. @@ -1301,11 +1417,11 @@ Value Description~ Default: 1 -Ex: +E.g.: Press (|:VimwikiToggleListItem|) on a list item without checkbox to create it: > * List item -result: > +Result: > * [ ] List item @@ -1322,21 +1438,23 @@ etc. Default: 'Vimwiki' + ------------------------------------------------------------------------------ *g:vimwiki_stripsym* -Change strip symbol -- in Windows you cannot use /*?<>:" in file names so -vimwiki replaces them with neutral symbol (_ is default): > +Change strip symbol -- in Windows you cannot use /*?<>:" in filenames, so +vimwiki replaces them with a neutral symbol (_ is default): > let g:vimwiki_stripsym = '_' You can change it to a for example: > let g:vimwiki_stripsym = ' ' + ------------------------------------------------------------------------------ *g:vimwiki_badsyms* -Consider you do not like spaces in filenames (as some vimwiki users do). -In that case you can set up bad symbols that would be converted to +If you do not like spaces in filenames (as some vimwiki users do), you can set +up bad symbols to include spaces, so that they are also converted: |g:vimwiki_stripsym|: > let g:vimwiki_badsyms = ' ' @@ -1345,6 +1463,7 @@ Now files for all [[links with spaces]] would be created like This option is a complement one to |g:vimwiki_stripsym|. + ------------------------------------------------------------------------------ *g:vimwiki_listsyms* @@ -1354,6 +1473,7 @@ Default value is ' .oOX'. g:vimwiki_listsyms[0] is for 0% done items. g:vimwiki_listsyms[4] is for 100% done items. + ------------------------------------------------------------------------------ *g:vimwiki_use_mouse* @@ -1365,11 +1485,12 @@ Value Description~ Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_folding* -Enable/disable vimwiki's folding/outline. Folding in vimwiki is using 'expr' -foldmethod which is very flexible but really slow. +Enable/disable vimwiki's folding/outline functionality. Folding in vimwiki +uses the 'expr' foldmethod which is very flexible but really slow. Value Description~ 0 Disable folding. @@ -1377,6 +1498,7 @@ Value Description~ Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_fold_lists* @@ -1388,21 +1510,23 @@ Value Description~ Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_fold_trailing_empty_lines* Fold or do not fold empty lines between folded headers. Value Description~ -0 Fold only one empty line. The rest empty lines are unfolded. +0 Fold only one empty line. Leave the rest of the empty lines. 1 Fold in all empty lines. Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_camel_case* -If you do not want WikiWord to be a link this setting is just for you. +If you do not want WikiWord to be a link, this setting is just for you. Value Description~ 0 Do not make links from CamelCased words. @@ -1410,18 +1534,20 @@ Value Description~ Default: 1 + ------------------------------------------------------------------------------ *g:vimwiki_list_ignore_newline* This is HTML related. -Convert newlines to
s in multiline list items. +Convert newlines to
s in multiline list items. Value Description~ -0 Newlines in a list item are converted to
s. +0 Newlines in a list item are converted to
s. 1 Ignore newlines. Default: 1 + ------------------------------------------------------------------------------ *g:vimwiki_use_calendar* @@ -1444,9 +1570,9 @@ You can open external weblinks in a webbrowser. Webbrowsers are listed in For win32 it is: chrome, opera, firefox and explorer. For other OSes it is: opera, firefox and konqueror. -The first available browser from the list is used to open weblink. -If you have opera and firefox and want weblinks to be opened in the latter -just: > +The first available browser from the list is used to open the weblink. +If you have opera and firefox and want weblinks to be opened in the latter, +just specify: > let g:vimwiki_browsers=['C:\Program Files\Firefox\firefox.exe'] or redefine VimwikiWeblinkHandler function: > @@ -1488,8 +1614,8 @@ Default: '' ------------------------------------------------------------------------------ *g:vimwiki_CJK_length* -Use special method to calculate correct length of the strings with double wide -characters. (To align table cells properly) +Use special method to calculate correct length of the strings with double-wide +characters (to align table cells properly). Value Description~ 0 Do not use it. @@ -1497,8 +1623,8 @@ Value Description~ Default: 0 -Note: Vim73 has new function |strdisplaywidth|, so for Vim73 users this option -is obsolete. +Note: Vim73 has a new function |strdisplaywidth|, so for Vim73 users this +option is obsolete. ------------------------------------------------------------------------------ @@ -1519,9 +1645,9 @@ Default: '' (empty string) ------------------------------------------------------------------------------ *g:vimwiki_html_header_numbering* -Set this option if you want headers to be auto numbered in html. +Set this option if you want headers to be auto-numbered in HTML. -ex: > +E.g.: > 1 Header1 1.1 Header2 1.2 Header2 @@ -1560,8 +1686,8 @@ Default: 0 Ending symbol for |g:vimwiki_html_header_numbering|. Value Description~ -'.' Dot would be added to the end of header's number. -')' Closing bracket would be added to the end of header's number. +'.' Dot will be added after a header's number. +')' Closing bracket will be added after a header's number. etc. With @@ -1583,11 +1709,11 @@ Default: '' (empty) ------------------------------------------------------------------------------ *g:vimwiki_file_exts* -Comma separated list of file extensions. +Comma-separated list of file extensions. Consider you have the following link: [[my_script.php][my script]]. -If there is 'php' extension in g:vimwiki_file_exts this link would be htmlized -to my script. +If there is a 'php' extension in g:vimwiki_file_exts, this link would be +htmlized to my script. Otherwise it would be my script (note .html) @@ -1597,11 +1723,26 @@ Default: 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz' ------------------------------------------------------------------------------ *g:vimwiki_valid_html_tags* -Comma separated list of html tags that can be used in vimwiki. +Comma-separated list of HTML tags that can be used in vimwiki. Default: 'b,i,s,u,sub,sup,kbd,br,hr' +------------------------------------------------------------------------------ +*g:vimwiki_user_htmls* + +Comma-separated list of HTML files that have no corresponding wiki files and +should not be deleted after |:VimwikiAll2HTML|. + +Default: '' + +Example: +Consider you have 404.html and search.html in your vimwiki 'path_html'. +With: > + let g:vimwiki_user_htmls = '404.html,search.html' +they would not be deleted after |:VimwikiAll2HTML|. + + ------------------------------------------------------------------------------ *g:vimwiki_conceallevel* @@ -1614,42 +1755,93 @@ is entered. Default: 3 - - ============================================================================== 12. Help *vimwiki-help* Your help in making vimwiki better is really appreciated! -Any help. Would it be spell correction or code snippet to patch -- everything -is welcomed. +Any help, whether it is a spelling correction or a code snippet to patch -- +everything is welcomed. -Issues could be filled in at http://code.google.com/p/vimwiki/issues . +Issues can be filed at http://code.google.com/p/vimwiki/issues . ============================================================================== 13. Developers *vimwiki-developers* - - Maxim Kim - Original author. - - Mikhail Trishchenkov - Joined in at Dec 2009. + - Maxim Kim as original author. + - See the http://code.google.com/p/vimwiki/people/list for the others. -Vimwiki's website: http://code.google.com/p/vimwiki/ -Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 - -... afterword - -Many thanks to all of you for voting vimwiki up on www.vim.org. I do vimwiki -in my spare time I could use to dance argentine tango with beautiful women. -Your votes are kind of a good replacement. ;) - -Sincerely yours, -Maxim Kim. +Web: http://code.google.com/p/vimwiki/ +Mail-List: https://groups.google.com/forum/#!forum/vimwiki +Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226 ============================================================================== 14. Changelog *vimwiki-changelog* +1.2~ + * Issue 70: Table spanning cell support. + * Issue 72: Do not convert again for unchanged file. |:VimwikiAll2HTML| + converts only changed wiki files. + * Issue 117: |VimwikiDiaryIndex| command that opens diary index wiki page. + * Issue 120: Links in headers are not highlighted in vimwiki but are + highlighted in HTML. + * Issue 138: Added possibility to remap table-column move bindings. See + |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight| + commands. For remap instructions see |vimwiki_| + and |vimwiki_|. + * Issue 125: Problem with 'o' command given while at the of the file. + * Issue 131: FileType is not set up when GUIEnter autocommand is used in + vimrc. Use 'nested' in 'au GUIEnter * nested VimwikiIndex' + * Issue 132: Link to perl (or any non-wiki) file in vimwiki subdirectory + doesn't work as intended. + * Issue 135: %title and %toc used together cause TOC to appear in an + unexpected place in HTML. + * Issue 139: |:VimwikiTabnewLink| command is added. + * Fix of g:vimwiki_stripsym = '' (i.e. an empty string) -- it removes bad + symbols from filenames. + * Issue 145: With modeline 'set ft=vimwiki' links are not correctly + highlighted when open wiki files. + * Issue 146: Filetype difficulty with ".txt" as a vimwiki extension. + * Issue 148: There are no mailto links. + * Issue 151: Use location list instead of quickfix list for :VimwikiSearch + command result. Use :lopen instead of :copen, :lnext instead of :cnext + etc. + * Issue 152: Add the list of HTML files that would not be deleted after + |:VimwikiAll2HTML|. + * Issue 153: Delete HTML files that has no corresponding wiki ones with + |:VimwikiAll2HTML|. + * Issue 156: Add multiple HTML templates. See + |vimwiki-option-template_path|. Options html_header and html_footer are + no longer exist. + * Issue 173: When virtualedit=all option is enabled the 'o' command behave + strange. + * Issue 178: Problem with alike wikie's paths. + * Issue 182: Browser command does not quote url. + * Issue 183: Spelling error highlighting is not possible with nested + syntaxes. + * Issue 184: Wrong foldlevel in some cases. + * Issue 195: Page renaming issue. + * Issue 196: vim: modeline bug -- syn=vim doesn't work. + * Issue 199: Generated HTML for sublists is invalid. + * Issue 200: Generated HTML for todo lists does not show completion status + the fix relies on CSS, thus your old stylesheets need to be updated!; + may not work in obsolete browsers or font-deficient systems. + * Issue 205: Block code: highlighting differs from processing. Inline code + block {{{ ... }}} is removed. Use `...` instead. + * Issue 208: Default highlight colors are problematic in many + colorschemes. Headers are highlighted as |hl-Title| by default, use + |g:vimwiki_hl_headers| to restore previous default Red, Green, Blue or + custom header colors. Some other changes in highlighting. + * Issue 209: Wild comments slow down html generation. Comments are + changed, use %% to comment out entire line. + * Issue 210: HTML: para enclose header. + * Issue 214: External links containing Chinese characters get trimmed. + * Issue 218: Command to generate HTML file and open it in webbrowser. See + |:Vimwiki2HTMLBrowse|(bind to whh) + * NEW: Added wh mapping to call |:Vimwiki2HTML| + + 1.1.1~ * FIX: Issue 122: Dot character in vimwiki's directory path isn't escaped. * FIX: Issue 123: Where is Vimwiki2HTML and other commands? Sometimes @@ -1667,7 +1859,7 @@ Maxim Kim. highlighted as a single link. * FIX: Issue 88: Underline text. See |g:vimwiki_valid_html_tags|. * FIX: Issue 92: Wikies in a subdir could be renamed to an empty file. - * FIX: Issue 93: Use alias name in html title. See |vimwiki-title|. + * FIX: Issue 93: Use alias name in HTML title. See |vimwiki-title|. * FIX: Issue 94: Relative links to PHP files are broken. See |g:vimwiki_file_exts| for details. * FIX: Issue 96: Closing bracket at the end of weblink shouldn't be a part @@ -1702,7 +1894,7 @@ Maxim Kim. |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight|. * NEW: Issue 44: should move cursor to the previous table cell. * NEW: Issue 45: It should be possible to indent tables. Indented tables - are centered in html. + are centered in HTML. * NEW: Issue 46: Do not htmlize some wiki pages (blacklist). New placeholder is added: %nohtml. See |vimwiki-nohtml|. * FIX: Issue 47: Lists aren't HTMLized properly. @@ -1725,11 +1917,11 @@ Maxim Kim. * NEW: Issue 60: Links inside completed gtd-items. * NEW: Issue 61: Headers numbering. See |g:vimwiki_html_header_numbering| and |g:vimwiki_html_header_numbering_sym| options. - * FIX: Issue 63: Table cannot have leading empty cells in html. + * FIX: Issue 63: Table cannot have leading empty cells in HTML. * FIX: Issue 65: Table separator is not htmlized right if on top of the table. - * FIX: Issue 66: Table empty cells are very small in html. - * FIX: Issue 67: Wrong html conversion of multilined list item with bold + * FIX: Issue 66: Table empty cells are very small in HTML. + * FIX: Issue 67: Wrong HTML conversion of multilined list item with bold text on the start of next line. * FIX: Issue 68: auto-indent problem with langmap. * FIX: Issue 73: Link navigation by Tab. "Escaped" wiki-word should be @@ -1741,7 +1933,7 @@ Maxim Kim. date if it has corresponding diary page. * FIX: Issue 80: Debian Lenny GUI Vim 7.2 has problems with toggling inner todo list items. - * FIX: Issue 81: Don't convert WikiWord as a link in html when + * FIX: Issue 81: Don't convert WikiWord as a link in HTML when `let g:vimwiki_camel_case = 0` 0.9.9~ @@ -1754,7 +1946,7 @@ Maxim Kim. * NEW: Keyword STARTED: is added. * NEW: Words TODO:, DONE:, STARTED:, XXX:, FIXME:, FIXED: are highlighed inside headers. - * FIX: Export to html external links with 'file://' protocol. Ex: + * FIX: Export to HTML external links with 'file://' protocol. Ex: [file:///home/user1/book.pdf my book]. * FIX: Menu is corrupted if wiki's path contains spaces. * FIX: Settings |wrap| and |linebreak| are removed from ftplugin. Add them @@ -1780,10 +1972,10 @@ Maxim Kim. * NEW: Speed up vimwiki's folding a bit. Should lag a bit less in a long todo lists. * NEW: Centered headers. Start header with at least one space to make it - html centered. - * NEW: Change in default css: header's colors. + HTML centered. + * NEW: Change in default CSS: header's colors. * NEW: Vimwiki is aware of |GetLatestVimScripts| now. - * FIX: Use tag instead of custom in html. + * FIX: Use tag instead of custom in HTML. * FIX: There are no text styling in htmlized quoted text. * FIX: set default value of g:vimwiki_fold_lists to 0 as written in this help. @@ -1813,8 +2005,8 @@ Maxim Kim. (in VISUAL and in VISUAL LINE modes) * NEW: Issue 26: Highlight code snippets in vimwiki's pre. See |vimwiki-option-nested_syntaxes|. Thanks kriomant. - * NEW: Issue 27: Automatic garbage deletion from html directory. - * NEW: Save all open vimwiki buffers before export to html. + * NEW: Issue 27: Automatic garbage deletion from HTML directory. + * NEW: Save all open vimwiki buffers before export to HTML. * NEW: Issue 29: Custom :Search command. * NEW: Header text objects are now expandable in VISUAL mode. Tap 'vah' to select a header. Tap again 'ah' to expand selection further. Thanks Andy @@ -1822,12 +2014,12 @@ Maxim Kim. * FIX: Folding settings are reset to vim defaults in a new tab (think of \wt) so you cannot hide things in folds. * FIX: https links in form of [https://hello.world.com] are not exported - into html. Thanks Saurabh Sarpal for the patch. + into HTML. Thanks Saurabh Sarpal for the patch. 0.9.6~ * NEW: You can have multiline list items. See |vimwiki-syntax-lists|. * NEW: You can ignore newlines in multiline list items when do export to - html. See |g:vimwiki_list_ignore_newline| option. + HTML. See |g:vimwiki_list_ignore_newline| option. * NEW: Different checkbox symbols [.], [:], [o] are added. See |vimwiki-todo-lists|. * NEW: Now there is no longer syntax of preformatted text that is started @@ -1843,7 +2035,7 @@ Maxim Kim. wikies opened at the same time with different syntaxes. * FIX: Command |:VimwikiToggleListItem| do not switch parent checkboxes if there are non-checkbox list items available. - * FIX: Issue 24: Link error in html when write [[one.two.three]]. + * FIX: Issue 24: Link error in HTML when write [[one.two.three]]. * FIX: Rename WikiWord to something with a colon (:) does nasty things. * FIX: Command |:VimwikiToggleListItem| do not switch right if there are list items without checkboxes in the list. @@ -1864,9 +2056,9 @@ Maxim Kim. * FIX: indent/vimwiki.vim is obsolete. If you upgrade from previous versions remove it. It causes wrong list indentation if noexpandtab is set. - * FIX: If tabs and spaces are used to indent list items html export gives + * FIX: If tabs and spaces are used to indent list items HTML export gives error. Thanks Klaus Ethgen for report. - * FIX: Some html export fixes. + * FIX: Some HTML export fixes. 0.9.4~ * NEW: Links with directories: [[dir1/dir2/Link|Text]]. Thanks Jie Wu. @@ -1874,12 +2066,12 @@ Maxim Kim. path_html. See |vimwiki-option-html_header|. * FIX: Indent is incorrect for vim without "float" compile option. Thanks Julian Kooij. - * FIX: Convert to html doesn't work right with links like [[foo::bar]]. + * FIX: Convert to HTML doesn't work right with links like [[foo::bar]]. * FIX: Rename wikiword doesn't work right when rename WikiWord to [[WikiWord blablabla]]. * FIX: Renaming of links with description doesn't work. * FIX: Weblinks with commas are not highlighted. - * MISC: Some changes in default css file. + * MISC: Some changes in default CSS file. 0.9.3~ * NEW: g:vimwiki_menu option is a string which is menu path. So one can @@ -1899,7 +2091,7 @@ Maxim Kim. * FIX: Clear out FlexWiki ftplugin's setup. Now you don't have to hack filetype.vim to get rid of unexpected ':setlocal bomb' from FlexWiki's ftplugin. - * FIX: When write done: it will show another done: in html file. + * FIX: When write done: it will show another done: in HTML file. 0.9.2a~ * FIX: Installation on Linux doesn't work. (Dos line endings in @@ -1910,7 +2102,7 @@ Maxim Kim. * NEW: Header text object. See |vimwiki-text-objects|. * NEW: Add/remove Header levels with '=' and '-'. See |vimwiki_=|. * NEW: Vimwiki GUI menu to select available wikies. See |g:vimwiki_menu|. - * NEW: You can specify the name of your css file now. See + * NEW: You can specify the name of your CSS file now. See |vimwiki-option-css_name| * NEW: You can add styles to image links, see |vimwiki-syntax-links|. * FIX: History doesn't work after |VimwikiRenameWord|. @@ -1963,7 +2155,7 @@ Maxim Kim. * DEL: Removed setlocal textwidth = 0 from ftplugin. * FIX: New regexps for bold, italic, bolditalic. * FIX: The last item in List sometimes fold-in incorrectly. - * FIX: Minor tweaks on default css. + * FIX: Minor tweaks on default CSS. 0.8.1~ * NEW: Vimwiki's foldmethod changed from syntax to expr. Foldtext is diff --git a/doc2/vst-s5.html b/doc2/vst-s5.html deleted file mode 100644 index 224e1fe..0000000 --- a/doc2/vst-s5.html +++ /dev/null @@ -1,783 +0,0 @@ - - - - -Vim reStructured Text - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - -
-
- - - -
-
-

Vim reStructured Text

- - - - - -
Title: Vim reStructured Text - A Quick Introduction
Author: George V. Reilly <george@reilly.org>
Date: 2006/05/12
-
-
-

What is VST?

- -

-VST is an easy way to produce: -

- -
    -
  • - -

    -HTML -

    - -
  • -
  • - -

    -S5 Slides, like this document -

    - -
  • -
  • - -

    -LaTeX and PDF -

    - - -
  • -
- -

-from reStructured text: plain text -with minimal markup. -

- -

-The powerful Vim editor is used to prepare the -material. -

- -

-Please read the source of these slides to see how the effects used herein are -achieved. -

- -
-
-

Simple markup

-
    -
  • - -

    -Bulleted Lists -

    - -
  • -
  • - -

    -Numeric lists (nested) -

    - - -
      -
    1. - -

      -Bold text -

      - -
    2. -
    3. - -

      -Italics text -

      - -
    4. -
    5. - -

      -typewriter text -

      - - -
    -
  • - -
  • - -

    -Subscripts, H2O. -

    - -
  • -
  • - -

    -Replacement -- Vim reStructured Text -- of text. -

    - - -
  • -
-
-
-

Blockquotes

- -

-You can embed blockquotes inside your text: -

- -
- Simple markup
- ==============
-
- + Bulleted Lists
- + Numeric lists (nested)
-
-     #. **Bold** text
-     2. *Italics* text
-     #. ``typewriter`` text
-
- + Replacement -- |VST| -- of text.
-
- -

-is most of the text of the previous slide. -

- -
-
-

Links

- -

-VST supports a variety of hyperlink notations. -

- - - -

-The full effect of these links cannot be seen in the S5 slides. -Regenerate with :Vst instead. -

- - -
-
-

Images

-

- -http://www.vim.org/images/vim_header.gif - -

-
-

Tip

- -

-You can apply a variety of attributes to images. -

- - -
- -

- If you need really fine control, you may need to use .. raw:: html -

- -
-
-
-
-

Simple Tables

-- - - - - - - - - - -
- -

-su -

- -
- -

-mo -

- -
- -

-tu -

- -
- -

-we -

- -
- -

-th -

- -
- -

-fr -

- -
- -

-sa -

- -
- - - - - - - -

-1 -

- -
- -

-2 -

- -
- -

-3 -

- -
- -

-4 -

- -
- -

-5 -

- -
- -

-6 -

- -
- -

-7 -

- -
- -

-8 -

- -
- -

-9 -

- -
- -

-10 -

- -
- -

-11 -

- -
- -

-12 -

- -
- -

-13 -

- -
- -

-14 -

- -
- -

-15 -

- -
- -

-16 -

- -
- -

-17 -

- -
- -

-18 -

- -
- -

-19 -

- -
- -

-20 -

- -
- -

-21 -

- -
- -

-22 -

- -
- -

-23 -

- -
- -

-24 -

- -
- -

-25 -

- -
- -

-26 -

- -
- -

-27 -

- -
- -

-28 -

- -
- -

-29 -

- -
- -

-30 -

- -
- -

-31 -

- -
- - - - -
-
-
-

Rich Tables

-- - - - -
- -

-Cells are -separated -

- -
- -

-by bar with -spaces around -

- -
- -

-<Space>|<Space> -

- -
- -

-You may use -inline -

- -
- -

-markup, -links -

- -
- -

-included. -

- -
- -

-You can use various -types of structure -elements: -

- -
- Welcome to world  
- of preformatted   
- text.
-
- - -
-
    -
  • - -

    -like lists -

    - - -
      -
    • - -

      -various -

      - - -
    • -
    -
  • - -
  • - -

    -embedded -

    - -
  • -
  • - -

    -one into -other -

    - - -
  • -
-
- -

-VST will -interpret them. -

- -

-Even paragraphs. -

- -
    -
  1. - -

    -And -

    - -
  2. -
  3. - -

    -not -

    - - -
-
- -

-Text may span across several -columns. Cell can be also empty -> -

- -
-
-
-
-

Conclusion

- -

-VST is an easy way to produce marked-up documents with easy-to-read source, in -Vim. -

- -

-This slideshow displays only a few features of VST. Be sure to read the -manual. -

- - - - -
- - - - diff --git a/ftplugin/diff/common.vim b/ftplugin/diff/common.vim deleted file mode 100644 index 40476b7..0000000 --- a/ftplugin/diff/common.vim +++ /dev/null @@ -1,3 +0,0 @@ -"Fast jump between differnces -nmap [c -nmap ]c diff --git a/ftplugin/python/common.vim b/ftplugin/python/common.vim index 9d2ac56..4f90aaf 100644 --- a/ftplugin/python/common.vim +++ b/ftplugin/python/common.vim @@ -13,8 +13,6 @@ setlocal softtabstop=4 setlocal tabstop=4 setlocal textwidth=78 setlocal colorcolumn=+1 -" overwrite status line -setlocal statusline=%<%F\ %{TagInStatusLine()}\ %h%m%r%=%(%l,%c%V%)\ %3p%% set wildignore+=*.pyc diff --git a/ftplugin/python/pyflakes/pyflakes/ast.py b/ftplugin/python/pyflakes/pyflakes/ast.py deleted file mode 100644 index d52025f..0000000 --- a/ftplugin/python/pyflakes/pyflakes/ast.py +++ /dev/null @@ -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='', 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 diff --git a/ftplugin/python/pythonhelper.vim b/ftplugin/python/pythonhelper.vim index 731b6b7..dd3a9cf 100644 --- a/ftplugin/python/pythonhelper.vim +++ b/ftplugin/python/pythonhelper.vim @@ -1,9 +1,7 @@ " File: pythonhelper.vim " Author: Michal Vitecek -" Version: 0.81 -" Last Modified: Oct 24, 2002 -" -" Modified by Marius Gedminas +" Version: 0.83 +" Last Modified: Jan 4, 2010 " " Overview " -------- @@ -20,12 +18,6 @@ " support by issuing command :ver and looking for +python in the list of " 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 " ------------ " 1. Make sure your Vim has python feature on (+python). If not, you will need @@ -33,30 +25,26 @@ " 2. Copy script pythonhelper.vim to the $HOME/.vim/plugin directory " 3. Run Vim and open any python file. " -" Marius Gedminas : -" 4. change 'statusline' to include -" %{TagInStatusLine()} -" -if has("python") python << EOS # import of required modules {{{ -import vim -import time -import sys import re +import sys +import time +import traceback +import vim # }}} # global dictionaries of tags and their line numbers, keys are buffer numbers {{{ -TAGS = {} -TAGLINENUMBERS = {} -BUFFERTICKS = {} +TAGS = {} +TAGLINENUMBERS = {} +BUFFERTICKS = {} # }}} # class PythonTag() {{{ -class PythonTag: +class PythonTag(object): # DOC {{{ """A simple storage class representing a python tag. """ @@ -65,17 +53,17 @@ class PythonTag: # STATIC VARIABLES {{{ - # tag type IDs {{{ - TAGTYPE_CLASS = 0 - TAGTYPE_METHOD = 1 - TAGTYPE_FUNCTION = 2 + # possible tag types {{{ + TT_CLASS = 0 + TT_METHOD = 1 + TT_FUNCTION = 2 # }}} # tag type names {{{ - typeName = { - TAGTYPE_CLASS : "class", - TAGTYPE_METHOD : "method", - TAGTYPE_FUNCTION : "function", + TAG_TYPE_NAME = { + TT_CLASS : "class", + TT_METHOD : "method", + TT_FUNCTION : "function", } # }}} @@ -84,9 +72,9 @@ class PythonTag: # METHODS {{{ - def __init__(self, type, name, fullName, lineNumber, indentLevel, parentTag): + def __init__(self, type, name, fullName, lineNumber, indentLevel): # DOC {{{ - """Initializes instances of class PythonTag(). + """Initializes instances of PythonTag(). Parameters @@ -103,12 +91,13 @@ class PythonTag: # }}} # CODE {{{ - self.type = type - self.name = name - self.fullName = fullName - self.lineNumber = lineNumber - self.indentLevel = indentLevel - self.parentTag = parentTag + # remember the settings {{{ + self.type = type + self.name = name + self.fullName = fullName + self.lineNumber = lineNumber + self.indentLevel = indentLevel + # }}} # }}} @@ -119,10 +108,11 @@ class PythonTag: # }}} # 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,) # }}} + __repr__ = __str__ @@ -131,10 +121,9 @@ class PythonTag: # class SimplePythonTagsParser() {{{ -class SimplePythonTagsParser: +class SimplePythonTagsParser(object): # DOC {{{ - """Provides a simple python tag parser. Returns list of PythonTag() - instances. + """Provides a simple python tag parser. """ # }}} @@ -143,13 +132,12 @@ class SimplePythonTagsParser: # how many chars a single tab represents (visually) TABSIZE = 8 - - # regexp used to get indentation and strip comments - commentsIndentStripRE = re.compile('([ \t]*)([^\n#]*).*') - # regexp used to get class name - classRE = re.compile('class[ \t]+([a-zA-Z0-9_]+)[ \t]*([(:].*|$)') - # regexp used to get method or function name - methodRE = re.compile('def[ \t]+([^(]+).*') + # regexp used to extract indentation and strip comments + COMMENTS_INDENT_RE = re.compile('([ \t]*)([^\n#]*).*') + # regexp used to extract a class name + CLASS_RE = re.compile('class[ \t]+([^(:]+).*') + # regexp used to extract a method or function name + METHOD_RE = re.compile('def[ \t]+([^(]+).*') # }}} @@ -158,7 +146,7 @@ class SimplePythonTagsParser: def __init__(self, source): # DOC {{{ - """Initializes the instance of class SimplePythonTagsParser(). + """Initializes instances of SimplePythonTagsParser(). Parameters @@ -169,8 +157,8 @@ class SimplePythonTagsParser: # CODE {{{ # make sure source has readline() method {{{ - if (not(hasattr(source, 'readline') and - callable(source.readline))): + if ((hasattr(source, 'readline') == 0) or + (callable(source.readline) == 0)): raise AttributeError("Source must have callable readline method.") # }}} @@ -181,19 +169,23 @@ class SimplePythonTagsParser: def getTags(self): # 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,). """ # }}} # CODE {{{ - tagLineNumbers = [] - tags = {} + # initialize the resulting list of the tag line numbers and the tag information {{{ + tagLineNumbers = [] + tags = {} + # }}} - # list (stack) of all currently active tags - tagsStack = [] + # initalize local auxiliary variables {{{ + tagsStack = [] + lineNumber = 0 + # }}} - lineNumber = 0 + # go through all the lines in the source and localize all python tags in it {{{ while 1: # get next line line = self.source.readline() @@ -203,57 +195,73 @@ class SimplePythonTagsParser: break # }}} + # increase the line number lineNumber += 1 - lineMatch = self.commentsIndentStripRE.match(line) - lineContents = lineMatch.group(2) - # class tag {{{ - tagMatch = self.classRE.match(lineContents) + + # extract the line indentation characters and its content {{{ + lineMatch = self.COMMENTS_INDENT_RE.match(line) + 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): currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1), tagMatch.group(1), self.tagClassTypeDecidingMethod) tagLineNumbers.append(lineNumber) tags[lineNumber] = currentTag # }}} - # function/method/none tag {{{ + # }}} + # handle the function/method/none tag {{{ 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): currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1), tagMatch.group(1), self.tagFunctionTypeDecidingMethod) tagLineNumbers.append(lineNumber) tags[lineNumber] = currentTag + # }}} # }}} + # }}} # return the tags data for the source return (tagLineNumbers, tags,) # }}} - def getPreviousTag(self, tagsStack): + def getParentTag(self, tagsStack): # DOC {{{ - """Returns the previous tag (instance of PythonTag()) from the - specified tag list if possible. If not, returns None. + """Returns the parent/enclosing tag (instance of PythonTag()) from the + specified tag list. If no such parent tag exists, returns None. Parameters - tagsStack -- list (stack) of currently active PythonTag() instances + tagsStack -- list (stack) of currently open PythonTag() instances """ # }}} # CODE {{{ + # determine the parent tag {{{ if (len(tagsStack)): - previousTag = tagsStack[-1] + parentTag = tagsStack[-1] else: - previousTag = None + parentTag = None + # }}} # return the tag - return previousTag + return parentTag # }}} - def computeIndentLevel(self, indentChars): + def computeIndentationLevel(indentChars): # DOC {{{ - """Computes indent level from the specified string. + """Computes the indentation level from the specified string. Parameters @@ -262,15 +270,21 @@ class SimplePythonTagsParser: # }}} # CODE {{{ + # initialize the indentation level indentLevel = 0 + + # compute the indentation level (expand tabs) {{{ for char in indentChars: if (char == '\t'): - indentLevel += self.TABSIZE + indentLevel += SimplePythonTagsParser.TABSIZE else: indentLevel += 1 + # }}} + # return the computed indentation level return indentLevel # }}} + computeIndentationLevel = staticmethod(computeIndentationLevel) def getPythonTag(self, tagsStack, lineNumber, indentChars, tagName, tagTypeDecidingMethod): @@ -290,58 +304,81 @@ class SimplePythonTagsParser: tagName -- short name of the current tag tagTypeDecidingMethod -- reference to method that is called to - determine type of the current tag + determine the type of the current tag """ # }}} # CODE {{{ - indentLevel = self.computeIndentLevel(indentChars) - previousTag = self.getPreviousTag(tagsStack) - # code for enclosed tag {{{ - while (previousTag): - if (previousTag.indentLevel >= indentLevel): + # compute the indentation level + indentLevel = self.computeIndentationLevel(indentChars) + # get the parent tag + parentTag = self.getParentTag(tagsStack) + + # 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] + # }}} + # otherwise we have all information on the current tag and can return it {{{ 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) + # create the tag + tag = PythonTag(tagTypeDecidingMethod(parentTag.type), tagName, "%s.%s" % (parentTag.fullName, tagName,), lineNumber, indentLevel) + + # break the loop + break + # }}} + + # use parent tag of the parent tag + parentTag = self.getParentTag(tagsStack) # }}} - # code for tag in top indent level {{{ + # handle a top-indent level tag {{{ else: - tagType = tagTypeDecidingMethod(None) - tag = PythonTag(tagType, tagName, tagName, lineNumber, indentLevel, None) - tagsStack.append(tag) - return tag + # 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 {{{ """Returns tag type of the current tag based on its previous tag (super tag) for classes. + + Parameters + + parentTagType -- type of the enclosing/parent tag """ # }}} # CODE {{{ - return PythonTag.TAGTYPE_CLASS + # is always class no matter what + return PythonTag.TT_CLASS # }}} - def tagFunctionTypeDecidingMethod(self, previousTagsType): + def tagFunctionTypeDecidingMethod(self, parentTagType): # DOC {{{ """Returns tag type of the current tag based on its previous tag (super tag) for functions/methods. + + Parameters + + parentTagType -- type of the enclosing/parent tag """ # }}} # CODE {{{ - if (previousTagsType == PythonTag.TAGTYPE_CLASS): - return PythonTag.TAGTYPE_METHOD + if (parentTagType == PythonTag.TT_CLASS): + return PythonTag.TT_METHOD else: - return PythonTag.TAGTYPE_FUNCTION + return PythonTag.TT_FUNCTION # }}} @@ -350,7 +387,7 @@ class SimplePythonTagsParser: # class VimReadlineBuffer() {{{ -class VimReadlineBuffer: +class VimReadlineBuffer(object): # DOC {{{ """A simple wrapper class around vim's buffer that provides readline method. @@ -362,7 +399,7 @@ class VimReadlineBuffer: def __init__(self, vimBuffer): # DOC {{{ - """Initializes the instance of class VimReadlineBuffer(). + """Initializes instances of VimReadlineBuffer(). Parameters @@ -371,9 +408,13 @@ class VimReadlineBuffer: # }}} # CODE {{{ - self.vimBuffer = vimBuffer - self.currentLine = -1 - self.bufferLines = len(vimBuffer) + # remember the settings + self.vimBuffer = vimBuffer + + # initialize instance attributes {{{ + self.currentLine = -1 + self.bufferLines = len(vimBuffer) + # }}} # }}} @@ -385,6 +426,7 @@ class VimReadlineBuffer: # }}} # CODE {{{ + # increase the current line counter self.currentLine += 1 # notify end of file if we reached beyond the last line {{{ @@ -392,9 +434,10 @@ class VimReadlineBuffer: 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],) # }}} + # }}} # }}} @@ -402,8 +445,8 @@ class VimReadlineBuffer: def getNearestLineIndex(row, tagLineNumbers): # DOC {{{ - """Returns index of line in tagLineNumbers list that is nearest to the - current cursor row. + """Returns the index of line in 'tagLineNumbers' list that is nearest to the + specified cursor row. Parameters @@ -414,27 +457,33 @@ def getNearestLineIndex(row, tagLineNumbers): # }}} # CODE {{{ - nearestLineNumber = -1 - nearestLineIndex = -1 - i = 0 - for lineNumber in tagLineNumbers: + # initialize local auxiliary variables {{{ + nearestLineNumber = -1 + nearestLineIndex = -1 + # }}} + + # 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 (nearestLineNumber < lineNumber <= row): - nearestLineNumber = lineNumber - nearestLineIndex = i + nearestLineNumber = lineNumber + nearestLineIndex = lineIndex # }}} + # if we've got past the current cursor position, let's end the search {{{ if (lineNumber >= row): break # }}} - i += 1 + # }}} + + # return index of the line with the nearest tag return nearestLineIndex # }}} def getTags(bufferNumber, changedTick): # 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],). Parameters @@ -447,10 +496,11 @@ def getTags(bufferNumber, changedTick): # }}} # CODE {{{ - global TAGLINENUMBERS, TAGS, BUFFERTICKS + # define global variables + global TAGLINENUMBERS, TAGS, BUFFERTICKS # 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],) # }}} @@ -460,12 +510,12 @@ def getTags(bufferNumber, changedTick): # }}} # update the global variables {{{ - TAGS[bufferNumber] = tags - TAGLINENUMBERS[bufferNumber] = tagLineNumbers - BUFFERTICKS[bufferNumber] = changedTick + TAGS[bufferNumber] = tags + TAGLINENUMBERS[bufferNumber] = tagLineNumbers + BUFFERTICKS[bufferNumber] = changedTick # }}} - # return the tags data + # return the tuple (tagLineNumbers, tags,) return (tagLineNumbers, tags,) # }}} @@ -484,12 +534,12 @@ def findTag(bufferNumber, changedTick): # }}} # CODE {{{ + # try to find the best tag {{{ try: - # get the tags data for the current buffer {{{ + # get the tags data for the current buffer tagLineNumbers, tags = getTags(bufferNumber, changedTick) - # }}} - # link to vim internal data {{{ + # link to vim's internal data {{{ currentBuffer = vim.current.buffer currentWindow = vim.current.window row, col = currentWindow.cursor @@ -497,66 +547,97 @@ def findTag(bufferNumber, changedTick): # get the index of the nearest line nearestLineIndex = getNearestLineIndex(row, tagLineNumbers) + # 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 # to do with the tag, because it's indented differently, in such case no # appropriate tag has been found.) - if (nearestLineIndex > -1): - nearestLineNumber = tagLineNumbers[nearestLineIndex] - tagInfo = tags[nearestLineNumber] - # walk through all the lines in range (nearestTagLine, cursorRow) {{{ - for i in xrange(nearestLineNumber + 1, row): - line = currentBuffer[i] - # count the indentation of the line, if it's lower that the tag's, the found tag is wrong {{{ - if (len(line)): + while (nearestLineIndex > -1): + # get the line number of the nearest tag + nearestLineNumber = tagLineNumbers[nearestLineIndex] + + # walk through all the lines in range (nearestTagLine, cursorRow) {{{ + for lineNumber in xrange(nearestLineNumber + 1, row): + # get the current line + line = currentBuffer[lineNumber] + + # count the indentation of the line, if it's lower than the tag's, the tag is invalid {{{ + if (len(line)): + # initialize local auxiliary variables {{{ + lineStart = 0 + i = 0 + # }}} + # compute the indentation of the line {{{ - lineStart = 0 - j = 0 - while ((j < len(line)) and (line[j].isspace())): - if (line[j] == '\t'): - lineStart += SimplePythonTagsParser.TABSIZE - else: - lineStart += 1 - j += 1 - # if the line contains only spaces, it doesn't count {{{ - if (j == len(line)): + while ((i < len(line)) and (line[i].isspace())): + # move the start of the line code {{{ + if (line[i] == '\t'): + lineStart += SimplePythonTagsParser.TABSIZE + else: + lineStart += 1 + # }}} + + # go to the next character on the line + i += 1 + # }}} + + # if the line contains only spaces, skip it {{{ + if (i == len(line)): continue # }}} - # if the next character is # (python comment), this line doesn't count {{{ - if (line[j] == '#'): + # if the next character is a '#' (python comment), skip the line {{{ + if (line[i] == '#'): continue # }}} + + # if the line's indentation starts before or at the nearest tag's one, the tag is invalid {{{ + if (lineStart <= tags[nearestLineNumber].indentLevel): + nearestLineIndex -= 1 + break # }}} - # if the line's indentation starts before or at the nearest tag's one, the tag is wrong {{{ - while tagInfo is not None and lineStart <= tagInfo.indentLevel: - tagInfo = tagInfo.parentTag - # }}} - # }}} + # }}} + # }}} + # the tag is appropriate, so use it {{{ + else: + break # }}} + # }}} + # no appropriate tag has been found {{{ else: - tagInfo = None + 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 = "" - if tagInfo is not None: - ## tagDescription = "[in %s (%s)]" % (tagInfo.fullName, PythonTag.typeName[tagInfo.type],) - tagDescription = "[%s]" % (tagInfo.fullName, ) + + # if an appropriate tag has been found, set the description accordingly {{{ + 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,)) - except: - # spit out debugging information {{{ + # }}} + + # handle possible exceptions {{{ + except Exception: + # bury into the traceback {{{ ec, ei, tb = sys.exc_info() while (tb != None): if (tb.tb_next == None): break 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,) time.sleep(0.5) # }}} # }}} + # }}} def deleteTags(bufferNumber): @@ -570,8 +651,10 @@ def deleteTags(bufferNumber): # }}} # CODE {{{ - global TAGS, TAGLINENUMBERS, BUFFERTICKS + # define global variables + global TAGS, TAGLINENUMBERS, BUFFERTICKS + # try to delete the tags for the buffer {{{ try: del TAGS[bufferNumber] del TAGLINENUMBERS[bufferNumber] @@ -579,6 +662,7 @@ def deleteTags(bufferNumber): except: pass # }}} + # }}} EOS @@ -617,33 +701,63 @@ function! TagInStatusLine() endif 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 {{{ " autocommands binding -if v:version >= 700 - autocmd CursorMoved * call PHCursorHold() -else - autocmd CursorHold * call PHCursorHold() -endif +autocmd CursorHold * call PHCursorHold() +autocmd CursorHoldI * call PHCursorHold() autocmd BufDelete * silent call PHBufferDelete() -"" " time that determines after how long time of no activity the CursorHold event -"" " is fired up -"" set updatetime=1000 -"" -"" " color of the current tag in the status line (bold cyan on black) -"" highlight User1 gui=bold guifg=cyan guibg=black -"" " color of the modified flag in the status line (bold black on red) -"" highlight User2 gui=bold guifg=black guibg=red -"" " the status line will be displayed for every window -"" set laststatus=2 -"" " set the status line to display some useful information -"" set stl=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ \ \ \ [buf\ %n] +" time that determines after how long time of no activity the CursorHold event +" is fired up +set updatetime=1000 + +" color of the current tag in the status line (bold cyan on black) +" gryf: i don't like coloring apart from current colorscheme. keep it simple. +"highlight User1 gui=bold guifg=cyan guibg=black +" color of the modified flag in the status line (bold black on red) +" gryf: i don't like coloring apart from current colorscheme. keep it simple. +"highlight User2 gui=bold guifg=black guibg=red +" the status line will be displayed for every window +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 -endif " has("python") diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index be97b29..5d31b37 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -20,7 +20,7 @@ let b:undo_ftplugin = "setlocal ". " MISC STUFF {{{ setlocal autowriteall -setlocal commentstring= +setlocal commentstring=%%%s if g:vimwiki_conceallevel && exists("+conceallevel") let &conceallevel = g:vimwiki_conceallevel @@ -47,12 +47,12 @@ if !empty(&langmap) " Valid only if langmap is a comma separated pairs of chars let l_o = matchstr(&langmap, '\C,\zs.\zeo,') if l_o - exe 'nnoremap '.l_o.' :call vimwiki_lst#kbd_oO("o")a' + exe 'nnoremap '.l_o.' :call vimwiki#lst#kbd_oO("o")a' endif let l_O = matchstr(&langmap, '\C,\zs.\zeO,') if l_O - exe 'nnoremap '.l_O.' :call vimwiki_lst#kbd_oO("O")a' + exe 'nnoremap '.l_O.' :call vimwiki#lst#kbd_oO("O")a' endif endif @@ -64,18 +64,18 @@ function! VimwikiFoldLevel(lnum) "{{{ " Header folding... if line =~ g:vimwiki_rxHeader - let n = vimwiki#count_first_sym(line) + let n = vimwiki#base#count_first_sym(line) return '>'.n endif - if g:vimwiki_fold_trailing_empty_lines == 0 - if line =~ '^\s*$' - let nnline = getline(nextnonblank(a:lnum + 1)) - if nnline =~ g:vimwiki_rxHeader - let n = vimwiki#count_first_sym(nnline) - return '<'.n - endif - endif + if g:vimwiki_fold_trailing_empty_lines == 0 && line =~ '^\s*$' + let nnline = getline(nextnonblank(a:lnum + 1)) + else + let nnline = getline(a:lnum + 1) + endif + if nnline =~ g:vimwiki_rxHeader + let n = vimwiki#base#count_first_sym(nnline) + return '<'.n endif " List item folding... @@ -129,7 +129,7 @@ function! s:get_base_level(lnum) "{{{ let lnum = a:lnum - 1 while lnum > 0 if getline(lnum) =~ g:vimwiki_rxHeader - return vimwiki#count_first_sym(getline(lnum)) + return vimwiki#base#count_first_sym(getline(lnum)) endif let lnum -= 1 endwhile @@ -169,7 +169,7 @@ endfunction "}}} function! s:get_li_level(lnum) "{{{ if VimwikiGet('syntax') == 'media' - let level = vimwiki#count_first_sym(getline(a:lnum)) + let level = vimwiki#base#count_first_sym(getline(a:lnum)) else let level = (indent(a:lnum) / &sw) endif @@ -198,42 +198,48 @@ endfunction "}}} " COMMANDS {{{ command! -buffer Vimwiki2HTML - \ call vimwiki_html#Wiki2HTML(expand(VimwikiGet('path_html')), + \ w call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')), \ expand('%')) +command! -buffer Vimwiki2HTMLBrowse + \ w call VimwikiWeblinkHandler( + \ vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')), + \ expand('%'))) 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 VimwikiPrevLink call vimwiki#find_prev_link() -command! -buffer VimwikiDeleteLink call vimwiki#delete_link() -command! -buffer VimwikiRenameLink call vimwiki#rename_link() -command! -buffer VimwikiFollowLink call vimwiki#follow_link('nosplit') -command! -buffer VimwikiGoBackLink call vimwiki#go_back_link() -command! -buffer VimwikiSplitLink call vimwiki#follow_link('split') -command! -buffer VimwikiVSplitLink call vimwiki#follow_link('vsplit') +command! -buffer VimwikiNextLink call vimwiki#base#find_next_link() +command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link() +command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link() +command! -buffer VimwikiRenameLink call vimwiki#base#rename_link() +command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit') +command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link() +command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split') +command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit') -command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(, ) +command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew') -command! -buffer VimwikiGenerateLinks call vimwiki#generate_links() +command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(, ) -exe 'command! -buffer -nargs=* VimwikiSearch vimgrep '. +command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links() + +exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') -exe 'command! -buffer -nargs=* VWS vimgrep '. +exe 'command! -buffer -nargs=* VWS lvimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') -command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("") +command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("") " table commands -command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create() -command! -buffer VimwikiTableAlignQ call vimwiki_tbl#align_or_cmd('gqq') -command! -buffer VimwikiTableAlignW call vimwiki_tbl#align_or_cmd('gww') -command! -buffer VimwikiTableMoveColumnLeft call vimwiki_tbl#move_column_left() -command! -buffer VimwikiTableMoveColumnRight call vimwiki_tbl#move_column_right() +command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create() +command! -buffer VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq') +command! -buffer VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww') +command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left() +command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right() " diary commands -command! -buffer VimwikiDiaryNextDay call vimwiki_diary#goto_next_day() -command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day() +command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day() +command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day() " COMMANDS }}} @@ -241,58 +247,78 @@ command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day() if g:vimwiki_use_mouse nmap nmap - noremap <2-LeftMouse> :VimwikiFollowLink - noremap :VimwikiSplitLink - noremap :VimwikiVSplitLink - noremap :VimwikiGoBackLink + nnoremap <2-LeftMouse> :VimwikiFollowLink + nnoremap :VimwikiSplitLink + nnoremap :VimwikiVSplitLink + nnoremap :VimwikiGoBackLink endif + +if !hasmapto('Vimwiki2HTML') + nmap wh Vimwiki2HTML +endif +nnoremap