From 711eaed286629f3741f5870709925c857367da6b Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 27 Jun 2010 20:14:22 +0200 Subject: [PATCH] Plugins update, PySmell remove, some cosmetic changes in vimrc. --- .vimrc | 14 +- GetLatest/GetLatestVimScripts.dat | 8 +- autoload/delimitMate.vim | 748 +++++++++++++++++++ autoload/vimwiki.vim | 356 +++++++-- autoload/vimwiki_diary.vim | 16 +- autoload/vimwiki_html.vim | 490 ++++++++---- autoload/vimwiki_lst.vim | 5 +- autoload/vimwiki_tbl.vim | 245 +++++- colors/lucius.vim | 63 +- compiler/rubber.vim | 4 - doc/delimitMate.txt | 224 ++++-- doc/tags | 87 +-- doc/vimwiki.txt | 300 ++++++-- ftplugin/python/pyflakes/pyflakes/checker.py | 25 +- ftplugin/vimwiki.vim | 48 +- plugin/delimitMate.vim | 613 ++------------- plugin/pysmell.vim | 102 --- plugin/vimwiki.vim | 43 +- syntax/vimwiki.vim | 40 +- syntax/vimwiki_default.vim | 10 +- syntax/vimwiki_media.vim | 2 +- 21 files changed, 2247 insertions(+), 1196 deletions(-) create mode 100644 autoload/delimitMate.vim delete mode 100644 plugin/pysmell.vim diff --git a/.vimrc b/.vimrc index dc43bf5..6aa3c57 100644 --- a/.vimrc +++ b/.vimrc @@ -79,6 +79,11 @@ set noswapfile " "remove all trailing withitespace for python before write autocmd BufWritePre *.py :call StripTrailingWhitespaces() +autocmd BufWritePre *.rst :call StripTrailingWhitespaces() +autocmd BufWritePre *.wiki :call StripTrailingWhitespaces() +autocmd BufWritePre *.js :call StripTrailingWhitespaces() +autocmd BufWritePre *.css :call StripTrailingWhitespaces() +autocmd BufWritePre *.xml :call StripTrailingWhitespaces() "autocmd BufWritePre *.py :!message.py '%' "Load views for py files autocmd BufWinLeave *.py mkview @@ -91,7 +96,7 @@ autocmd FileType python set expandtab|set smarttab|set noautoindent autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with autocmd FileType python set foldmethod=indent|set foldlevel=100|set list|set textwidth=78|set cinkeys-=0# autocmd FileType python set indentkeys-=0#|inoremap # X# -autocmd FileType python set ofu=syntaxcomplete#Complete +"autocmd FileType python set ofu=syntaxcomplete#Complete autocmd FileType python compiler pylint let g:pylint_onwrite = 0 " I don't want to run pylint on every save @@ -150,6 +155,9 @@ let NERDTreeWinSize = 40 let g:vimwiki_list = [{'html_header': '~/vimwiki/vimwiki_head.tpl', \ 'html_footer': '~/vimwiki/vimwiki_foot.tpl'}] " }}} +"FuzzyFinder {{{2 +let g:fuf_file_exclude = '\v\~$|\.(o|bak|swp|pyc|pyo|pyd)$|(^|[/\\])\.(hg|git|bzr|cvs)($|[/\\])' +"}}} "ShowMarks {{{2 let g:showmarks_ignore_type = "hqprm" let g:showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -220,7 +228,7 @@ nmap ,cn :silent call CopyFileName(1) nmap ,cs :silent call CopyFileName(0) "FuzzyFinder plugin. Keys for file fuf -map :TlistToo!:FufFile **/ +map :FufFile **/ " }}} " FUNCTIONS: usefull functions for all of th files {{{ "Sessions @@ -251,7 +259,7 @@ function PyLintBuf() let cmd = 'pylint --reports=n --output-format=text "' . file . '"' if has('win32') || has('win64') - let command = 'cmd /c "' . command . '"' + let cmd = 'cmd /c "' . cmd . '"' endif exec "bel silent new " . file . ".lint" diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat index a650cab..a6dc50e 100644 --- a/GetLatest/GetLatestVimScripts.dat +++ b/GetLatest/GetLatestVimScripts.dat @@ -3,7 +3,7 @@ ScriptID SourceID Filename ### plugins 102 9375 DirDiff.vim 1658 11834 NERD_tree.vim -2754 12764 :AutoInstall: delimitMate.vim +2754 13139 :AutoInstall: delimitMate.vim 1984 11852 fuzzyfinder.vim 642 8136 :AutoInstall: getscript.vim 311 7645 grep.vim @@ -16,17 +16,17 @@ ScriptID SourceID Filename #273 7701 taglist.vim # exchanged with taglisttoo 2607 10388 tasklist.vim 90 12743 vcscommand.vim -2226 12476 vimwiki.vim +2226 12995 vimwiki.vim 1334 6377 vst.vim ### colors 1975 7471 lettuce.vim -2536 12154 lucius.vim +2536 13089 lucius.vim 1165 3741 tolerable.vim 2465 11352 wombat256.vim # compiler 891 10365 pylint.vim # ftplugin -2441 12763 pyflakes.vim +2441 13229 pyflakes.vim 30 9196 python_fn.vim 1542 10872 pythoncomplete.vim ### indent diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim new file mode 100644 index 0000000..d24bbf5 --- /dev/null +++ b/autoload/delimitMate.vim @@ -0,0 +1,748 @@ +" ============================================================================ +" 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] == "xterm" + 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/vimwiki.vim b/autoload/vimwiki.vim index 80e6b0f..61c2972 100644 --- a/autoload/vimwiki.vim +++ b/autoload/vimwiki.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ @@ -17,20 +18,14 @@ let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]' " MISC helper functions {{{ -" This function is double defined. -" TODO: refactor common functions into new module. -function! s:chomp_slash(str) "{{{ +function! vimwiki#chomp_slash(str) "{{{ return substitute(a:str, '[/\\]\+$', '', '') endfunction "}}} -function! s:is_windows() - return has("win32") || has("win64") || has("win95") || has("win16") -endfunction - function! vimwiki#mkdir(path) "{{{ let path = expand(a:path) if !isdirectory(path) && exists("*mkdir") - let path = s:chomp_slash(path) + let path = vimwiki#chomp_slash(path) if s:is_windows() && !empty(g:vimwiki_w32_dir_enc) let path = iconv(path, &enc, g:vimwiki_w32_dir_enc) endif @@ -53,7 +48,7 @@ function! vimwiki#subdir(path, filename)"{{{ let path = expand(a:path) let filename = expand(a:filename) let idx = 0 - while path[idx] == filename[idx] + while path[idx] ==? filename[idx] let idx = idx + 1 endwhile @@ -79,7 +74,18 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ let vimwiki_prev_link = [expand('%:p'), getpos('.')] endif - call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext')) + if vimwiki#is_link_to_dir(a:link) + if g:vimwiki_dir_link == '' + call s:edit_file(a:cmd, VimwikiGet('path').a:link) + else + call s: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')) + endif if exists('vimwiki_prev_link') let b:vimwiki_prev_link = vimwiki_prev_link @@ -88,6 +94,71 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ endfunction " }}} +function! vimwiki#select(wnum)"{{{ + if a:wnum < 1 || a:wnum > len(g:vimwiki_list) + return + endif + if &ft == 'vimwiki' + let b:vimwiki_idx = g:vimwiki_current_idx + endif + let g:vimwiki_current_idx = a:wnum - 1 +endfunction +" }}} + +function! vimwiki#generate_links()"{{{ + let links = s:get_links('*'.VimwikiGet('ext')) + + " We don't want link to itself. + let cur_link = expand('%:t:r') + call filter(links, 'v:val != cur_link') + + if len(links) + call append(line('$'), '= Generated Links =') + endif + + call sort(links) + + for link in links + if s:is_wiki_word(link) + call append(line('$'), '- '.link) + else + call append(line('$'), '- [['.link.']]') + endif + endfor +endfunction " }}} + +function! s:is_windows() "{{{ + return has("win32") || has("win64") || has("win95") || has("win16") +endfunction "}}} + +function! s:get_links(pat) "{{{ + " search all wiki files in 'path' and its subdirs. + let subdir = vimwiki#current_subdir() + let globlinks = glob(VimwikiGet('path').subdir.'**/'.a:pat) + + " remove .wiki extensions + let globlinks = substitute(globlinks, '\'.VimwikiGet('ext'), "", "g") + let links = split(globlinks, '\n') + + " remove backup files (.wiki~) + call filter(links, 'v:val !~ ''.*\~$''') + + " remove paths + let rem_path = escape(expand(VimwikiGet('path')).subdir, '\') + call map(links, 'substitute(v:val, rem_path, "", "g")') + + " Remove trailing slashes. + call map(links, 'substitute(v:val, "[/\\\\]*$", "", "g")') + + return links +endfunction "}}} + +" Builtin cursor doesn't work right with unicode characters. +function! s:cursor(lnum, cnum) "{{{ + exe a:lnum + exe 'normal! 0'.a:cnum.'|' +endfunction "}}} + function! s:filename(link) "{{{ let result = vimwiki#safe_link(a:link) if a:link =~ '|' @@ -100,7 +171,7 @@ endfunction " }}} function! s:is_wiki_word(str) "{{{ - if a:str =~ g:vimwiki_word1 && a:str !~ '[[:space:]\\/]' + if a:str =~ g:vimwiki_rxWikiWord && a:str !~ '[[:space:]\\/]' return 1 endif return 0 @@ -164,10 +235,20 @@ function! s:strip_word(word) "{{{ endfunction " }}} -function! s:is_link_to_non_wiki_file(word) "{{{ - " Check if word is link to a non-wiki file. +function! s:is_link_to_non_wiki_file(link) "{{{ + " Check if link is to a non-wiki file. " The easiest way is to check if it has extension like .txt or .html - if a:word =~ '\.\w\{1,4}$' + if a:link =~ '\.\w\{1,4}$' + return 1 + endif + return 0 +endfunction +" }}} + +function! vimwiki#is_link_to_dir(link) "{{{ + " Check if link is to a directory. + " It should be ended with \ or /. + if a:link =~ '.\+[/\\]$' return 1 endif return 0 @@ -191,17 +272,6 @@ function! s:print_wiki_list() "{{{ endfunction " }}} -function! vimwiki#select(wnum)"{{{ - if a:wnum < 1 || a:wnum > len(g:vimwiki_list) - return - endif - if &ft == 'vimwiki' - let b:vimwiki_idx = g:vimwiki_current_idx - endif - let g:vimwiki_current_idx = a:wnum - 1 -endfunction -" }}} - function! s:update_wiki_link(fname, old, new) " {{{ echo "Updating links in ".a:fname let has_updates = 0 @@ -309,42 +379,38 @@ endfunction " }}} " SYNTAX highlight {{{ -function! vimwiki#WikiHighlightWords() "{{{ - " search all wiki files in 'path' and its subdirs. - let subdir = vimwiki#current_subdir() - let wikies = glob(VimwikiGet('path').subdir.'**/*'.VimwikiGet('ext')) - - " remove .wiki extensions - let wikies = substitute(wikies, '\'.VimwikiGet('ext'), "", "g") - let g:vimwiki_wikiwords = split(wikies, '\n') - - " remove backup files (.wiki~) - call filter(g:vimwiki_wikiwords, 'v:val !~ ''.*\~$''') - - " remove paths - let rem_path = escape(expand(VimwikiGet('path')).subdir, '\') - call map(g:vimwiki_wikiwords, 'substitute(v:val, rem_path, "", "g")') +function! vimwiki#WikiHighlightLinks() "{{{ + let links = s:get_links('*'.VimwikiGet('ext')) " Links with subdirs should be highlighted for linux and windows separators " Change \ or / to [/\\] let os_p = '[/\\]' let os_p2 = escape(os_p, '\') - call map(g:vimwiki_wikiwords, 'substitute(v:val, os_p, os_p2, "g")') + call map(links, 'substitute(v:val, os_p, os_p2, "g")') - for word in g:vimwiki_wikiwords + for link in links if g:vimwiki_camel_case && - \ word =~ g:vimwiki_word1 && !s:is_link_to_non_wiki_file(word) - execute 'syntax match VimwikiWord /\%(^\|[^!]\)\@<=\<'.word.'\>/' + \ link =~ g:vimwiki_rxWikiWord && !s:is_link_to_non_wiki_file(link) + execute 'syntax match VimwikiLink /!\@/' endif - execute 'syntax match VimwikiWord /\[\[\<'. - \ vimwiki#unsafe_link(word). + execute 'syntax match VimwikiLink /\[\[\<'. + \ vimwiki#unsafe_link(link). \ '\>\%(|\+.*\)*\]\]/' - execute 'syntax match VimwikiWord /\[\[\<'. - \ vimwiki#unsafe_link(word). + execute 'syntax match VimwikiLink /\[\[\<'. + \ vimwiki#unsafe_link(link). \ '\>\]\[.\+\]\]/' endfor - execute 'syntax match VimwikiWord /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/' - execute 'syntax match VimwikiWord /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/' + execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/' + execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/' + + " highlight dirs + let dirs = s:get_links('*/') + call map(dirs, 'substitute(v:val, os_p, os_p2, "g")') + for dir in dirs + execute 'syntax match VimwikiLink /\[\[\<'. + \ vimwiki#unsafe_link(dir). + \ '\>[/\\]*\%(|\+.*\)*\]\]/' + endfor endfunction " }}} @@ -398,12 +464,12 @@ endfunction "}}} " WIKI functions {{{ function! vimwiki#WikiNextWord() "{{{ - call s:search_word(g:vimwiki_rxWikiWord.'\|'.g:vimwiki_rxWeblink, '') + call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '') endfunction " }}} function! vimwiki#WikiPrevWord() "{{{ - call s:search_word(g:vimwiki_rxWikiWord.'\|'.g:vimwiki_rxWeblink, 'b') + call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b') endfunction " }}} @@ -416,7 +482,7 @@ function! vimwiki#WikiFollowWord(split) "{{{ let cmd = ":e " endif - let link = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiWord)) + let link = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiLink)) if link == "" let weblink = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWeblink)) if weblink != "" @@ -601,7 +667,7 @@ endfunction " TEXT OBJECTS functions {{{ function! vimwiki#TO_header(inner, visual) "{{{ - if !search('^\(=\+\)[^=]\+\1\s*$', 'bcW') + if !search('^\(=\+\).\+\1\s*$', 'bcW') return endif @@ -618,7 +684,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ if a:visual && is_header_selected if level > 1 let level -= 1 - call search('^\(=\{'.level.'\}\)[^=]\+\1\s*$', 'bcW') + call search('^\(=\{'.level.'\}\).\+\1\s*$', 'bcW') else let advance = 1 endif @@ -630,7 +696,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ call cursor(sel_end + advance, 0) endif - if search('^\(=\{1,'.level.'}\)[^=]\+\1\s*$', 'W') + if search('^\(=\{1,'.level.'}\).\+\1\s*$', 'W') call cursor(line('.') - 1, 0) else call cursor(line('$'), 0) @@ -643,6 +709,184 @@ function! vimwiki#TO_header(inner, visual) "{{{ endfunction "}}} +function! vimwiki#TO_table_cell(inner, visual) "{{{ + if col('.') == col('$')-1 + return + endif + + if a:visual + normal! `> + let sel_end = getpos('.') + normal! `< + let sel_start = getpos('.') + + let firsttime = sel_start == sel_end + + if firsttime + if !search('|\|\(-+-\)', 'cb', line('.')) + return + endif + if getline('.')[virtcol('.')] == '+' + normal! l + endif + if a:inner + normal! 2l + endif + let sel_start = getpos('.') + endif + + normal! `> + call search('|\|\(-+-\)', '', line('.')) + if getline('.')[virtcol('.')] == '+' + normal! l + endif + if a:inner + if firsttime || abs(sel_end[2] - getpos('.')[2]) != 2 + normal! 2h + endif + endif + let sel_end = getpos('.') + + call setpos('.', sel_start) + exe "normal! \" + call setpos('.', sel_end) + + " XXX: WORKAROUND. + " if blockwise selection is ended at | character then pressing j to extend + " selection furhter fails. But if we shake the cursor left and right then + " it works. + normal! hl + else + if !search('|\|\(-+-\)', 'cb', line('.')) + return + endif + if a:inner + normal! 2l + endif + normal! v + call search('|\|\(-+-\)', '', line('.')) + if !a:inner && getline('.')[virtcol('.')-1] == '|' + normal! h + elseif a:inner + normal! 2h + endif + endif +endfunction "}}} + +function! vimwiki#TO_table_col(inner, visual) "{{{ + let t_rows = vimwiki_tbl#get_rows(line('.')) + if empty(t_rows) + return + endif + + " TODO: refactor it! + if a:visual + normal! `> + let sel_end = getpos('.') + normal! `< + let sel_start = getpos('.') + + let firsttime = sel_start == sel_end + + if firsttime + " place cursor to the top row of the table + call s:cursor(t_rows[0][0], virtcol('.')) + " do not accept the match at cursor position if cursor is next to column + " separator of the table separator (^ is a cursor): + " |-----^-+-------| + " | bla | bla | + " |-------+-------| + " or it will select wrong column. + if strpart(getline('.'), virtcol('.')-1) =~ '^-+' + let s_flag = 'b' + else + let s_flag = 'cb' + endif + " search the column separator backwards + if !search('|\|\(-+-\)', s_flag, line('.')) + return + endif + " -+- column separator is matched --> move cursor to the + sign + if getline('.')[virtcol('.')] == '+' + normal! l + endif + " inner selection --> reduce selection + if a:inner + normal! 2l + endif + let sel_start = getpos('.') + endif + + normal! `> + if !firsttime && getline('.')[virtcol('.')] == '|' + normal! l + elseif a:inner && getline('.')[virtcol('.')+1] =~ '[|+]' + normal! 2l + endif + " search for the next column separator + call search('|\|\(-+-\)', '', line('.')) + " Outer selection selects a column without border on the right. So we move + " our cursor left if the previous search finds | border, not -+-. + if getline('.')[virtcol('.')] != '+' + normal! h + endif + if a:inner + " reduce selection a bit more if inner. + normal! h + endif + " expand selection to the bottom line of the table + call s:cursor(t_rows[-1][0], virtcol('.')) + let sel_end = getpos('.') + + call setpos('.', sel_start) + exe "normal! \" + call setpos('.', sel_end) + + else + " place cursor to the top row of the table + call s:cursor(t_rows[0][0], virtcol('.')) + " do not accept the match at cursor position if cursor is next to column + " separator of the table separator (^ is a cursor): + " |-----^-+-------| + " | bla | bla | + " |-------+-------| + " or it will select wrong column. + if strpart(getline('.'), virtcol('.')-1) =~ '^-+' + let s_flag = 'b' + else + let s_flag = 'cb' + endif + " search the column separator backwards + if !search('|\|\(-+-\)', s_flag, line('.')) + return + endif + " -+- column separator is matched --> move cursor to the + sign + if getline('.')[virtcol('.')] == '+' + normal! l + endif + " inner selection --> reduce selection + if a:inner + normal! 2l + endif + + exe "normal! \" + + " search for the next column separator + call search('|\|\(-+-\)', '', line('.')) + " Outer selection selects a column without border on the right. So we move + " our cursor left if the previous search finds | border, not -+-. + if getline('.')[virtcol('.')] != '+' + normal! h + endif + " reduce selection a bit more if inner. + if a:inner + normal! h + endif + " expand selection to the bottom line of the table + call s:cursor(t_rows[-1][0], virtcol('.')) + endif +endfunction "}}} + function! vimwiki#count_first_sym(line) "{{{ let first_sym = matchstr(a:line, '\S') return len(matchstr(a:line, first_sym.'\+')) diff --git a/autoload/vimwiki_diary.vim b/autoload/vimwiki_diary.vim index 25d8d33..37b7eed 100644 --- a/autoload/vimwiki_diary.vim +++ b/autoload/vimwiki_diary.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Desc: Handle diary notes " Author: Maxim Kim @@ -85,10 +86,10 @@ endfunction "}}} function! s:get_links() "{{{ let rx = '\d\{4}-\d\d-\d\d' - let s_links = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*.wiki') + let s_links = glob(VimwikiGet('path').VimwikiGet('diary_rel_path'). + \ '*'.VimwikiGet('ext')) - "let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "g") - let s_links = substitute(s_links, '\.wiki', "", "g") + let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "g") let links = split(s_links, '\n') " remove backup files (.wiki~) @@ -191,7 +192,7 @@ function! vimwiki_diary#make_note(index, ...) "{{{ call vimwiki#open_link(':e ', link, s:diary_index()) endfunction "}}} -" Calendar.vim callback. +" Calendar.vim callback and sign functions. function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ let day = s:prefix_zero(a:day) let month = s:prefix_zero(a:month) @@ -214,3 +215,10 @@ function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ call vimwiki_diary#make_note(1, link) endfunction +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'). + \ a:year.'-'.month.'-'.day.VimwikiGet('ext') + return filereadable(expand(sfile)) +endfunction "}}} diff --git a/autoload/vimwiki_html.vim b/autoload/vimwiki_html.vim index e7c7722..3c88ecc 100644 --- a/autoload/vimwiki_html.vim +++ b/autoload/vimwiki_html.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Export to HTML " Author: Maxim Kim @@ -28,7 +29,7 @@ function! s:syntax_supported() " {{{ endfunction " }}} function! s:remove_blank_lines(lines) " {{{ - while a:lines[-1] =~ '^\s*$' + while !empty(a:lines) && a:lines[-1] =~ '^\s*$' call remove(a:lines, -1) endwhile endfunction "}}} @@ -69,7 +70,7 @@ function! s:create_default_CSS(path) " {{{ call vimwiki#mkdir(fnamemodify(css_full_name, ':p:h')) let lines = [] - call add(lines, 'body {font-family: Arial, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}') + 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;}') @@ -94,6 +95,7 @@ function! s:create_default_CSS(path) " {{{ 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." @@ -165,11 +167,15 @@ function! s:get_html_footer() "{{{ endfunction "}}} function! s:safe_html(line) "{{{ - "" change dangerous html symbols: < > & + "" htmlize symbols: < > & let line = substitute(a:line, '&', '\&', 'g') - let line = substitute(line, '<', '\<', 'g') - let line = substitute(line, '>', '\>', 'g') + + " let line = substitute(line, '<', '\<', 'g') + " let line = substitute(line, '>', '\>', 'g') + " XXX: I believe there should be a much nicer way to do it. + let line = substitute(line, '<\(br\|hr\)\@!', '\<', 'g') + let line = substitute(line, '\(\(br\|hr\)\s*/\?\)\@', '\>', 'g') return line endfunction "}}} @@ -257,9 +263,18 @@ function! s:trim(string) "{{{ return res endfunction "}}} -" toc_list is list of [level, header_text, header_id] -" ex: [[1, "Header", "toc1"], [2, "Header2", "toc2"], ...] function! s:get_html_toc(toc_list) "{{{ + " toc_list is list of [level, header_text, header_id] + " ex: [[1, "Header", "toc1"], [2, "Header2", "toc2"], ...] + function! s:close_list(toc, plevel, level) "{{{ + let plevel = a:plevel + while plevel > a:level + call add(a:toc, '') + let plevel -= 1 + endwhile + return plevel + endfunction "}}} + if empty(a:toc_list) return [] endif @@ -271,15 +286,15 @@ function! s:get_html_toc(toc_list) "{{{ if level > plevel call add(toc, '
    ') elseif level < plevel - call add(toc, '
') + let plevel = s:close_list(toc, plevel, level) endif - call add(toc, '
  • '.text.'
  • ') + + let toc_text = s:process_tags_remove_links(text) + let toc_text = s:process_tags_typefaces(toc_text) + call add(toc, '
  • '.toc_text.'
  • ') let plevel = level endfor - while level > 0 - call add(toc, '') - let level -= 1 - endwhile + call s:close_list(toc, level, 0) call add(toc, '') return toc endfunction "}}} @@ -336,6 +351,70 @@ function! s:tag_pre(value) "{{{ return ''.s:mid(a:value, 3).'' endfunction "}}} +function! s:tag_internal_link(value) "{{{ + " Make This is a link + " from [[This is a link]] + " Make This is a link + " from [[link|This is a link]] + " Make This is a link + " from [[link][This is a link]] + " TODO: rename function -- it makes not only internal links. + " TODO: refactor it. + + function! s:linkify(src, caption, style) "{{{ + if a:style == '' + let style_str = '' + else + let style_str = ' style="'.a:style.'"' + endif + + if s:is_img_link(a:caption) + let link = ''. + \ '' + elseif s:is_non_wiki_link(a:src) + let link = ''.a:caption.'' + elseif s:is_img_link(a:src) + let link = ''.a:caption.'' + elseif vimwiki#is_link_to_dir(a:src) + if g:vimwiki_dir_link == '' + let link = ''.a:caption.'' + else + let link = ''.a:caption.'' + endif + else + let link = ''.a:caption.'' + endif + + return link + endfunction "}}} + + let value = s:mid(a:value, 2) + + let line = '' + if value =~ '|' + let link_parts = split(value, "|", 1) + else + let link_parts = split(value, "][", 1) + endif + + + if len(link_parts) > 1 + if len(link_parts) < 3 + let style = "" + else + let style = link_parts[2] + endif + + let line = s:linkify(link_parts[0], link_parts[1], style) + + else + let line = s:linkify(value, value, '') + endif + return line +endfunction "}}} + function! s:tag_external_link(value) "{{{ "" Make link desc "" from [link link desc] @@ -369,16 +448,39 @@ function! s:tag_external_link(value) "{{{ return line endfunction "}}} -function! s:tag_internal_link(value) "{{{ - " Make This is a link - " from [[This is a link]] - " Make This is a link - " from [[link|This is a link]] - " Make This is a link - " from [[link][This is a link]] - " TODO: rename function -- it makes not only internal links. - " TODO: refactor it. +function! s:tag_wikiword_link(value) "{{{ + " Make WikiWord from WikiWord + if a:value[0] == '!' + return a:value[1:] + elseif g:vimwiki_camel_case + let line = ''.a:value.'' + return line + else + return a:value + endif +endfunction "}}} +function! s:tag_barebone_link(value) "{{{ + "" Make http://habamax.ru + "" from http://habamax.ru + + if s:is_img_link(a:value) + let line = '' + else + let line = ''.a:value.'' + endif + return line +endfunction "}}} + +function! s:tag_no_wikiword_link(value) "{{{ + if a:value[0] == '!' + return a:value[1:] + else + return a:value + endif +endfunction "}}} + +function! s:tag_remove_internal_link(value) "{{{ let value = s:mid(a:value, 2) let line = '' @@ -394,53 +496,31 @@ function! s:tag_internal_link(value) "{{{ else let style = link_parts[2] endif - - if s:is_img_link(link_parts[1]) - let line = '' - elseif len(link_parts) < 3 - if s:is_non_wiki_link(link_parts[0]) - let line = ''.link_parts[1].'' - else - let line = ''.link_parts[1].'' - endif - elseif s:is_img_link(link_parts[0]) - let line = ''.
-            \ link_parts[1].'' - endif + let line = link_parts[1] else - if s:is_img_link(value) - let line = '' - elseif s:is_non_wiki_link(link_parts[0]) - let line = ''.value.'' - else - let line = ''.value.'' - endif + let line = value endif return line endfunction "}}} -function! s:tag_wikiword_link(value) "{{{ - " Make WikiWord from WikiWord - " if first symbol is ! then remove it and make no link. - if a:value[0] == '!' - return a:value[1:] - else - let line = ''.a:value.'' - return line - endif -endfunction "}}} +function! s:tag_remove_external_link(value) "{{{ + let value = s:mid(a:value, 1) -function! s:tag_barebone_link(value) "{{{ - "" Make http://habamax.ru - "" from http://habamax.ru - - if s:is_img_link(a:value) - let line = '' + let line = '' + if s:is_web_link(value) + let lnkElements = split(value) + let head = lnkElements[0] + let rest = join(lnkElements[1:]) + if rest=="" + let rest=head + endif + let line = rest + elseif s:is_img_link(value) + let line = '' else - let line = ''.a:value.'' + " [alskfj sfsf] shouldn't be a link. So return it as it was -- + " enclosed in [...] + let line = '['.value.']' endif return line endfunction "}}} @@ -472,13 +552,16 @@ function! s:make_tag(line, regexp, func) "{{{ return res_line endfunction "}}} -function! s:process_inline_tags(line) "{{{ +function! s:process_tags_remove_links(line) " {{{ let line = a:line - let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_internal_link') - let line = s:make_tag(line, '\[.\{-}\]', 's:tag_external_link') - let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_barebone_link') - let line = s:make_tag(line, '!\?'.g:vimwiki_rxWikiWord, - \ 's:tag_wikiword_link') + let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_remove_internal_link') + let line = s:make_tag(line, '\[.\{-}\]', 's:tag_remove_external_link') + return line +endfunction " }}} + +function! s:process_tags_typefaces(line) "{{{ + let line = a:line + let line = s:make_tag(line, g:vimwiki_rxNoWikiWord, 's:tag_no_wikiword_link') let line = s:make_tag(line, g:vimwiki_rxItalic, 's:tag_em') let line = s:make_tag(line, g:vimwiki_rxBold, 's:tag_strong') let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo') @@ -490,6 +573,21 @@ function! s:process_inline_tags(line) "{{{ \ 's:tag_pre') return line endfunction " }}} + +function! s:process_tags_links(line) " {{{ + let line = a:line + let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_internal_link') + let line = s:make_tag(line, '\[.\{-}\]', 's:tag_external_link') + let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_barebone_link') + let line = s:make_tag(line, g:vimwiki_rxWikiWord, 's:tag_wikiword_link') + return line +endfunction " }}} + +function! s:process_inline_tags(line) "{{{ + let line = s:process_tags_links(a:line) + let line = s:process_tags_typefaces(line) + return line +endfunction " }}} "}}} " BLOCK TAGS {{{ @@ -518,17 +616,63 @@ function! s:close_tag_para(para, ldest) "{{{ endfunction "}}} function! s:close_tag_table(table, ldest) "{{{ - if len(a:table) - call insert(a:ldest, "") - return [] + " The first element of table list is a string which tells us if table should be centered. + " The rest elements are rows which are lists of columns: + " ['center', + " ['col1', 'col2', 'col3'], + " ['col1', 'col2', 'col3'], + " ['col1', 'col2', 'col3'] + " ] + let table = a:table + let ldest = a:ldest + if len(table) + if table[0] == 'center' + call add(ldest, "") + else + call add(ldest, "
    ") + endif + + " Empty lists are table separators. + " Search for the last empty list. All the above rows would be a table header. + " We should exclude the first element of the table list as it is a text tag + " that shows if table should be centered or not. + let head = 0 + for idx in range(len(table)-1, 1, -1) + if empty(table[idx]) + let head = idx + break + endif + endfor + if head > 0 + for row in table[1 : head-1] + if !empty(filter(row, '!empty(v:val)')) + call add(ldest, '') + call extend(ldest, map(row, '""')) + call add(ldest, '') + endif + endfor + for row in table[head+1 :] + call add(ldest, '') + call extend(ldest, map(row, '""')) + call add(ldest, '') + endfor + else + for row in table[1 :] + call add(ldest, '') + call extend(ldest, map(row, '""')) + call add(ldest, '') + endfor + endif + call add(ldest, "
    ".s:process_inline_tags(v:val)."
    ".s:process_inline_tags(v:val)."
    ".s:process_inline_tags(v:val)."
    ") + let table = [] endif - return a:table + return table endfunction "}}} function! s:close_tag_list(lists, ldest) "{{{ while len(a:lists) let item = remove(a:lists, -1) - call insert(a:ldest, item[0]) + call add(a:ldest, item[0]) endwhile endfunction! "}}} @@ -605,10 +749,15 @@ function! s:process_tag_list(line, lists) "{{{ return [st_tag, en_tag] endfunction "}}} - " Do not process line that starts from *bold* text as list item. - let pos = match(a:line, g:vimwiki_rxBold) - if pos != -1 && strpart(a:line, 0, pos) =~ '^\s*$' - return [0, []] + let in_list = (len(a:lists) > 0) + + " If it is not list yet then do not process line that starts from *bold* + " text. + if !in_list + let pos = match(a:line, g:vimwiki_rxBold) + if pos != -1 && strpart(a:line, 0, pos) =~ '^\s*$' + return [0, []] + endif endif let lines = [] @@ -631,7 +780,6 @@ function! s:process_tag_list(line, lists) "{{{ let lstRegExp = '' endif - let in_list = (len(a:lists) > 0) if lstSym != '' " To get proper indent level 'retab' the line -- change all tabs " to spaces*tabstop @@ -674,10 +822,7 @@ function! s:process_tag_list(line, lists) "{{{ endif let processed = 1 else - while len(a:lists) - let item = remove(a:lists, -1) - call add(lines, item[0]) - endwhile + call s:close_tag_list(a:lists, lines) endif return [processed, lines] endfunction "}}} @@ -744,6 +889,12 @@ function! s:process_tag_h(line, id) "{{{ let h_level = 1 endif if h_level > 0 + let a:id[h_level] += 1 + " reset higher level ids + for level in range(h_level+1, 6) + let a:id[level] = 0 + endfor + let centered = 0 if a:line =~ '^\s\+' let centered = 1 @@ -751,8 +902,14 @@ function! s:process_tag_h(line, id) "{{{ let line = s:trim(line) - let h_text = s:trim(strpart(line, h_level, len(line) - h_level * 2)) - let h_id = 'toc'.a:id + let h_number = '' + for l in range(1, h_level-1) + let h_number .= a:id[l].'.' + endfor + let h_number .= a:id[h_level] + + let h_id = 'toc_'.h_number + let h_part = '' let processed = 1 endif @@ -777,54 +945,42 @@ function! s:process_tag_hr(line) "{{{ endfunction "}}} function! s:process_tag_table(line, table) "{{{ - " XXX: This should be refactored!!! + function! s:table_empty_cell(value) "{{{ + if a:value =~ '^\s*$' + return ' ' + endif + return a:value + endfunction "}}} + + function! s:table_add_row(table, line) "{{{ + if empty(a:table) + if a:line =~ '^\s\+' + let row = ['center', []] + else + let row = ['normal', []] + endif + else + let row = [[]] + endif + return row + endfunction "}}} + let table = a:table let lines = [] let processed = 0 - if a:line =~ '^\s*|[-+]\+|\s*$' && len(table) - call add(table, []) + if a:line =~ '^\s*|[-+]\+|\s*$' + call extend(table, s:table_add_row(a:table, a:line)) let processed = 1 elseif a:line =~ '^\s*|.\+|\s*$' - if empty(table) - let table = [[]] - else - call add(table, []) - endif + call extend(table, s:table_add_row(a:table, a:line)) + let processed = 1 - - call extend(table[-1], split(a:line, '\s*|\s*')) - - elseif len(table) - call add(lines, "") - - let head = 0 - for idx in range(len(table)) - if empty(table[idx]) - let head = idx - break - endif - endfor - if head > 0 - for row in table[: head-1] - call add(lines, '') - call extend(lines, map(row, '""')) - call add(lines, '') - endfor - for row in table[head+1 :] - call add(lines, '') - call extend(lines, map(row, '""')) - call add(lines, '') - endfor - else - for row in table - call add(lines, '') - call extend(lines, map(row, '""')) - call add(lines, '') - endfor - endif - call add(lines, "
    ".v:val."
    ".v:val."
    ".v:val."
    ") - let table = [] + let cells = split(a:line, '\s*|\s*', 1)[1: -2] + call map(cells, 's:table_empty_cell(v:val)') + call extend(table[-1], cells) + else + let table = s:close_tag_table(table, lines) endif return [processed, lines, table] endfunction "}}} @@ -850,6 +1006,14 @@ function! s:parse_line(line, state) " {{{ let processed = 0 + " nohtml -- placeholder + if !processed + if line =~ '^\s*%nohtml' + let processed = 1 + let state.placeholder = ['nohtml'] + endif + endif + " toc -- placeholder "{{{ if !processed if line =~ '^\s*%toc' @@ -916,17 +1080,23 @@ function! s:parse_line(line, state) " {{{ let state.pre = s:close_tag_pre(state.pre, res_lines) let state.quote = s:close_tag_quote(state.quote, res_lines) - let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo') + let line = s:process_inline_tags(line) call add(res_lines, line) " gather information for table of contents call add(state.toc, [h_level, h_text, h_id]) - let state.toc_id += 1 endif endif "}}} + " tables "{{{ + if !processed + let [processed, lines, state.table] = s:process_tag_table(line, state.table) + call extend(res_lines, lines) + endif + "}}} + " quotes "{{{ if !processed let [processed, lines, state.quote] = s:process_tag_quote(line, state.quote) @@ -952,16 +1122,6 @@ function! s:parse_line(line, state) " {{{ endif "}}} - " tables "{{{ - if !processed - let [processed, lines, state.table] = s:process_tag_table(line, state.table) - - call map(lines, 's:process_inline_tags(v:val)') - - call extend(res_lines, lines) - endif - "}}} - " horizontal rules "{{{ if !processed let [processed, line] = s:process_tag_hr(line) @@ -1025,11 +1185,14 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{ let wikifile = fnamemodify(a:wikifile, ":p") let subdir = vimwiki#subdir(VimwikiGet('path'), wikifile) + let lsource = s:remove_comments(readfile(wikifile)) + let ldest = s:get_html_header(wikifile, subdir, &fileencoding) + let path = expand(a:path).subdir call vimwiki#mkdir(path) - let lsource = s:remove_comments(readfile(wikifile)) - let ldest = s:get_html_header(wikifile, subdir, &fileencoding) + " nohtml placeholder -- to skip html generation. + let nohtml = 0 " for table of contents placeholders. let placeholders = [] @@ -1044,7 +1207,7 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{ let state.lists = [] let state.placeholder = [] let state.toc = [] - let state.toc_id = 1 + let state.toc_id = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0 } for line in lsource let oldquote = state.quote @@ -1053,40 +1216,47 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{ " Hack: There could be a lot of empty strings before s:process_tag_quote " find out `quote` is over. So we should delete them all. Think of the way " to refactor it out. - if (oldquote != state.quote) && ldest[-1] =~ '^\s*$' + if oldquote != state.quote call s:remove_blank_lines(ldest) endif if !empty(state.placeholder) - call add(placeholders, [state.placeholder, len(ldest), len(placeholders)]) - let state.placeholder = [] + if state.placeholder[0] == 'nohtml' + let nohtml = 1 + break + else + call add(placeholders, [state.placeholder, len(ldest), len(placeholders)]) + let state.placeholder = [] + endif endif call extend(ldest, lines) endfor - let toc = s:get_html_toc(state.toc) - call s:process_placeholders(ldest, placeholders, 'toc', toc) + if !nohtml + let toc = s:get_html_toc(state.toc) + call s:process_placeholders(ldest, placeholders, 'toc', toc) - call s:remove_blank_lines(ldest) + call s:remove_blank_lines(ldest) - "" process end of file - "" close opened tags if any - let lines = [] - call s:close_tag_quote(state.quote, lines) - call s:close_tag_para(state.para, lines) - call s:close_tag_pre(state.pre, lines) - call s:close_tag_list(state.lists, lines) - call s:close_tag_def_list(state.deflist, lines) - call s:close_tag_table(state.table, lines) - call extend(ldest, lines) + "" process end of file + "" close opened tags if any + let lines = [] + call s:close_tag_quote(state.quote, lines) + call s:close_tag_para(state.para, lines) + call s:close_tag_pre(state.pre, lines) + call s:close_tag_list(state.lists, lines) + call s:close_tag_def_list(state.deflist, lines) + call s:close_tag_table(state.table, lines) + call extend(ldest, lines) - call extend(ldest, s:get_html_footer()) + call extend(ldest, s:get_html_footer()) - "" make html file. - let wwFileNameOnly = fnamemodify(wikifile, ":t:r") - call writefile(ldest, path.wwFileNameOnly.'.html') + "" make html file. + let wwFileNameOnly = fnamemodify(wikifile, ":t:r") + call writefile(ldest, path.wwFileNameOnly.'.html') + endif endfunction "}}} function! vimwiki_html#WikiAll2HTML(path) "{{{ diff --git a/autoload/vimwiki_lst.vim b/autoload/vimwiki_lst.vim index fd6a8af..497bff3 100644 --- a/autoload/vimwiki_lst.vim +++ b/autoload/vimwiki_lst.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Todo lists related stuff here. " Author: Maxim Kim @@ -237,9 +238,9 @@ function! s:all_siblings_checked(lnum) "{{{ let cnt = 0 let siblings = s:get_sibling_items(a:lnum) for lnum in siblings - let cnt += s:get_state(lnum)/100.0 + let cnt += s:get_state(lnum) endfor - let result = (cnt*100.0)/len(siblings) + let result = cnt/len(siblings) return result endfunction "}}} diff --git a/autoload/vimwiki_tbl.vim b/autoload/vimwiki_tbl.vim index fb174ed..f61ce67 100644 --- a/autoload/vimwiki_tbl.vim +++ b/autoload/vimwiki_tbl.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki autoload plugin file " Desc: Tables " | Easily | manageable | text | tables | ! | @@ -18,7 +19,19 @@ let s:textwidth = &tw " Misc functions {{{ function! s:wide_len(str) "{{{ - return strlen(substitute(a:str, '.', 'x', 'g')) + if !g:vimwiki_CJK_length + let ret = strlen(substitute(a:str, '.', 'x', 'g')) + else + let savemodified = &modified + let save_cursor = getpos('.') + exe "norm! o\" + call setline(line("."), a:str) + let ret = virtcol("$") - 1 + d + call setpos('.', save_cursor) + let &modified = savemodified + endif + return ret endfunction "}}} function! s:is_table(line) "{{{ @@ -26,14 +39,31 @@ function! s:is_table(line) "{{{ endfunction "}}} function! s:is_separator(line) "{{{ - return a:line =~ '^\s*|\s*-\+' + return a:line =~ '^\s*[|+]\s*--[-|+]\+' endfunction "}}} function! s:is_last_column(lnum, cnum) "{{{ return strpart(getline(a:lnum), a:cnum - 1) =~ '^[^|]*|\s*$' endfunction "}}} -function! s:count_separators(lnum) "{{{ +function! s:is_first_column(lnum, cnum) "{{{ + let line = strpart(getline(a:lnum), 0, a:cnum - 1) + return line =~ '^\s*|[^|]*$' || line =~ '^\s*$' +endfunction "}}} + +function! s:count_separators_up(lnum) "{{{ + let lnum = a:lnum - 1 + while lnum > 1 + if !s:is_separator(getline(lnum)) + break + endif + let lnum -= 1 + endwhile + + return (a:lnum-lnum) +endfunction "}}} + +function! s:count_separators_down(lnum) "{{{ let lnum = a:lnum + 1 while lnum < line('$') if !s:is_separator(getline(lnum)) @@ -78,19 +108,38 @@ function! s:create_row_sep(cols) "{{{ endfunction "}}} function! s:get_values(line) "{{{ - let cells = [] - let cnt = 0 - let idx = 0 - while idx != -1 && idx < strlen(a:line) - 1 - let cell = matchstr(a:line, '|\zs[^|]\+\ze|', idx) - let cell = substitute(cell, '^\s*\(.\{-}\)\s*$', '\1', 'g') - call add(cells, [cnt, cell]) - let cnt += 1 - let idx = matchend(a:line, '|\zs[^|]\+\ze|', idx) - endwhile - return cells + return split(a:line, '\s*|\s*', 1)[1:-2] endfunction "}}} +function! s:col_count(lnum) "{{{ + let line = getline(a:lnum) + if !s:is_separator(line) + return len(split(line, '\s*|\s*', 1)[1:-2]) + else + return len(split(line, '-+-', 1)) + endif +endfunction "}}} + +function! s:get_indent(lnum) "{{{ + if !s:is_table(getline(a:lnum)) + return + endif + + let indent = 0 + + let lnum = a:lnum - 1 + while lnum > 1 + let line = getline(lnum) + if !s:is_table(line) + let indent = indent(lnum+1) + break + endif + let lnum -= 1 + endwhile + + return indent +endfunction " }}} + function! s:get_rows(lnum) "{{{ if !s:is_table(getline(a:lnum)) return @@ -131,29 +180,57 @@ function! s:get_cell_max_lens(lnum) "{{{ if s:is_separator(row) continue endif - for [idx, cell] in s:get_values(row) + let cells = s:get_values(row) + for idx in range(len(cells)) + let value = cells[idx] if has_key(max_lens, idx) - let max_lens[idx] = max([s:wide_len(cell), max_lens[idx]]) + let max_lens[idx] = max([s:wide_len(value), max_lens[idx]]) else - let max_lens[idx] = s:wide_len(cell) + let max_lens[idx] = s:wide_len(value) endif endfor endfor return max_lens endfunction "}}} -function! s:get_aligned_rows(lnum, max_lens) "{{{ +function! s:get_aligned_rows(lnum, col1, col2) "{{{ + let max_lens = s:get_cell_max_lens(a:lnum) let rows = [] for [lnum, row] in s:get_rows(a:lnum) if s:is_separator(row) - let new_row = s:fmt_sep(a:max_lens) + let new_row = s:fmt_sep(max_lens, a:col1, a:col2) else - let new_row = s:fmt_row(row, a:max_lens) + let new_row = s:fmt_row(row, max_lens, a:col1, a:col2) endif call add(rows, [lnum, new_row]) endfor return rows endfunction "}}} + +" Number of the current column. Starts from 0. +function! s:cur_column() "{{{ + let line = getline('.') + if !s:is_table(line) + return -1 + endif + if s:is_separator(line) + let sep = '[+|]' + else + let sep = '|' + endif + + let curs_pos = col('.') + let mpos = match(line, '|', 0) + let col = -1 + while mpos < curs_pos && mpos != -1 + let mpos = match(line, sep, mpos+1) + if mpos != -1 + let col += 1 + endif + endwhile + return col +endfunction "}}} + " }}} " Format functions {{{ @@ -169,14 +246,20 @@ function! s:fmt_cell(cell, max_len) "{{{ return cell endfunction "}}} -function! s:fmt_row(line, max_lens) "{{{ +function! s:fmt_row(line, max_lens, col1, col2) "{{{ let new_line = '|' - let values = s:get_values(a:line) - for [idx, cell] in values - let new_line .= s:fmt_cell(cell, a:max_lens[idx]).'|' + let cells = s:get_values(a:line) + for idx in range(len(cells)) + if idx == a:col1 + let idx = a:col2 + elseif idx == a:col2 + let idx = a:col1 + endif + let value = cells[idx] + let new_line .= s:fmt_cell(value, a:max_lens[idx]).'|' endfor - let idx = len(values) + let idx = len(cells) while idx < len(a:max_lens) let new_line .= s:fmt_cell('', a:max_lens[idx]).'|' let idx += 1 @@ -192,9 +275,14 @@ function! s:fmt_cell_sep(max_len) "{{{ endif endfunction "}}} -function! s:fmt_sep(max_lens) "{{{ +function! s:fmt_sep(max_lens, col1, col2) "{{{ let sep = '|' for idx in range(len(a:max_lens)) + if idx == a:col1 + let idx = a:col2 + elseif idx == a:col2 + let idx = a:col1 + endif let sep .= s:fmt_cell_sep(a:max_lens[idx]).'+' endfor let sep = substitute(sep, '+$', '|', '') @@ -207,7 +295,7 @@ function! s:kbd_create_new_row(cols, goto_first) "{{{ let cmd = "\o".s:create_empty_row(a:cols) let cmd .= "\:call vimwiki_tbl#format(line('.'))\" if a:goto_first - let cmd .= "0f|T|a" + let cmd .= "\0:call search('|', 'c', line('.'))\la" else let cmd .= "0".(col('.')-1)."lT|a" endif @@ -219,16 +307,27 @@ function! s:kbd_goto_next_row() "{{{ return cmd endfunction "}}} +function! s:kbd_goto_prev_row() "{{{ + let cmd = "\jt|T|a" + return cmd +endfunction "}}} + function! s:kbd_goto_next_col(last) "{{{ - if col('.') == 1 - let cmd = "\la" + if a:last + let seps = s:count_separators_down(line('.')) + let cmd = "\".seps."j0:call search('|', 'c', line('.'))\la" else - if a:last - let seps = s:count_separators(line('.')) - let cmd = "\".seps."j0f|F|la" - else - let cmd = "\f|la" - endif + let cmd = "\:call search('|', 'c', line('.'))\la" + endif + return cmd +endfunction "}}} + +function! s:kbd_goto_prev_col(first) "{{{ + if a:first + let seps = s:count_separators_up(line('.')) + let cmd = "\".seps."k$:call search('|', 'b', line('.'))\la" + else + let cmd = "\2F|la" endif return cmd endfunction "}}} @@ -264,15 +363,37 @@ function! vimwiki_tbl#kbd_tab() "{{{ return s:kbd_goto_next_col(last) endfunction "}}} -function! vimwiki_tbl#format(lnum) "{{{ +function! vimwiki_tbl#kbd_shift_tab() "{{{ + let lnum = line('.') + if !s:is_table(getline(lnum)) + return "\" + endif + + let first = s:is_first_column(lnum, col('.')) + if first && !s:is_table(getline(lnum-1)) + return "" + endif + return s:kbd_goto_prev_col(first) +endfunction "}}} + +function! vimwiki_tbl#format(lnum, ...) "{{{ let line = getline(a:lnum) if !s:is_table(line) return endif - let max_lens = s:get_cell_max_lens(a:lnum) + if a:0 == 2 + let col1 = a:1 + let col2 = a:2 + else + let col1 = 0 + let col2 = 0 + endif - for [lnum, row] in s:get_aligned_rows(a:lnum, max_lens) + let indent = s:get_indent(a:lnum) + + for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2) + let row = repeat(' ', indent).row call setline(lnum, row) endfor @@ -332,4 +453,52 @@ function! vimwiki_tbl#reset_tw(lnum) "{{{ let &tw = 0 endfunction "}}} +" TODO: move_column_left and move_column_right are good candidates to be +" refactored. +function! vimwiki_tbl#move_column_left() "{{{ + if !s:is_table(getline('.')) + return + endif + + let cur_col = s:cur_column() + if cur_col == -1 + return + endif + + if cur_col > 0 + call vimwiki_tbl#format(line('.'), cur_col-1, cur_col) + call cursor(line('.'), 1) + if !s:is_separator(getline('.')) + call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW') + else + call search('|\%([^+]\++\)\{'.(cur_col-1).'}--', 'eW') + endif + endif +endfunction "}}} + +function! vimwiki_tbl#move_column_right() "{{{ + if !s:is_table(getline('.')) + return + endif + + let cur_col = s:cur_column() + if cur_col == -1 + return + endif + + if cur_col < s:col_count(line('.'))-1 + call vimwiki_tbl#format(line('.'), cur_col, cur_col+1) + call cursor(line('.'), 1) + if !s:is_separator(getline('.')) + call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW') + else + call search('|\%([^+]\++\)\{'.(cur_col+1).'}--', 'eW') + endif + endif +endfunction "}}} + +function! vimwiki_tbl#get_rows(lnum) "{{{ + return s:get_rows(a:lnum) +endfunction "}}} + "}}} diff --git a/colors/lucius.vim b/colors/lucius.vim index f83c92a..410cc55 100644 --- a/colors/lucius.vim +++ b/colors/lucius.vim @@ -1,7 +1,7 @@ " Vim color file " Maintainer: Jonathan Filip -" Last Modified: Wed Oct 21, 2009 11:39AM -" Version: 3.1 +" Last Modified: Mon Apr 19, 2010 10:24AM +" Version: 3.5 " " GUI / 256 color terminal " @@ -65,11 +65,11 @@ hi Float ctermfg=116 cterm=none " Identifier Group " ---------------- " any variable name -hi Identifier guifg=#efaf7f gui=none -hi Identifier ctermfg=216 cterm=none +hi Identifier guifg=#e6c080 gui=none +hi Identifier ctermfg=180 cterm=none " function, method, class -hi Function guifg=#efaf7f gui=none -hi Function ctermfg=216 cterm=none +hi Function guifg=#e6c080 gui=none +hi Function ctermfg=180 cterm=none " Statement Group @@ -100,20 +100,20 @@ hi Keyword ctermfg=150 cterm=none " Preprocessor Group " ------------------ " generic preprocessor -hi PreProc guifg=#f0dfaf gui=none -hi PreProc ctermfg=223 cterm=none +hi PreProc guifg=#e9dfaf gui=none +hi PreProc ctermfg=187 cterm=none " #include -hi Include guifg=#f0dfaf gui=none -hi Include ctermfg=223 cterm=none +hi Include guifg=#e9dfaf gui=none +hi Include ctermfg=187 cterm=none " #define -hi Define guifg=#f0dfaf gui=none -hi Define ctermfg=223 cterm=none +hi Define guifg=#e9dfaf gui=none +hi Define ctermfg=187 cterm=none " same as define -hi Macro guifg=#f0dfaf gui=none -hi Macro ctermfg=223 cterm=none +hi Macro guifg=#e9dfaf gui=none +hi Macro ctermfg=187 cterm=none " #if, #else, #endif -hi PreCondit guifg=#f0dfaf gui=none -hi PreCondit ctermfg=223 cterm=none +hi PreCondit guifg=#e9dfaf gui=none +hi PreCondit ctermfg=187 cterm=none " Type Group @@ -186,16 +186,16 @@ hi Todo ctermfg=228 ctermbg=NONE cterm=underl " -------- " word not recognized hi SpellBad guisp=#ee0000 gui=undercurl -hi SpellBad ctermbg=9 cterm=undercurl +hi SpellBad ctermbg=196 cterm=undercurl " word not capitalized hi SpellCap guisp=#eeee00 gui=undercurl -hi SpellCap ctermbg=12 cterm=undercurl +hi SpellCap ctermbg=226 cterm=undercurl " rare word hi SpellRare guisp=#ffa500 gui=undercurl -hi SpellRare ctermbg=13 cterm=undercurl +hi SpellRare ctermbg=214 cterm=undercurl " wrong spelling for selected region hi SpellLocal guisp=#ffa500 gui=undercurl -hi SpellLocal ctermbg=14 cterm=undercurl +hi SpellLocal ctermbg=214 cterm=undercurl " Cursor @@ -207,10 +207,10 @@ hi Cursor ctermfg=bg ctermbg=153 hi CursorIM guifg=bg guibg=#96cdcd hi CursorIM ctermfg=bg ctermbg=116 " cursor column -hi CursorColumn guifg=NONE guibg=#202438 gui=none +hi CursorColumn guifg=NONE guibg=#404448 gui=none hi CursorColumn ctermfg=NONE ctermbg=236 cterm=none " cursor line/row -hi CursorLine gui=NONE guibg=#202438 gui=none +hi CursorLine gui=NONE guibg=#404448 gui=none hi CursorLine cterm=NONE ctermbg=236 cterm=none @@ -230,7 +230,7 @@ hi SignColumn guifg=#9fafaf guibg=#181818 gui=none hi SignColumn ctermfg=145 ctermbg=233 cterm=none " line numbers hi LineNr guifg=#818698 guibg=#363946 -hi LineNr ctermfg=102 ctermbg=237 +hi LineNr ctermfg=245 ctermbg=237 " match parenthesis, brackets hi MatchParen guifg=#00ff00 guibg=NONE gui=bold hi MatchParen ctermfg=46 ctermbg=NONE cterm=bold @@ -242,13 +242,13 @@ hi ModeMsg guifg=#76d5f8 guibg=NONE gui=none hi ModeMsg ctermfg=117 ctermbg=NONE cterm=none " the '~' and '@' and showbreak, '>' double wide char doesn't fit on line hi NonText guifg=#404040 gui=none -hi NonText ctermfg=235 cterm=none +hi NonText ctermfg=238 cterm=none " the hit-enter prompt (show more output) and yes/no questions hi Question guifg=fg gui=none hi Question ctermfg=fg cterm=none " meta and special keys used with map, unprintable characters -hi SpecialKey guifg=#404040 -hi SpecialKey ctermfg=237 +hi SpecialKey guifg=#405060 +hi SpecialKey ctermfg=239 " titles for output from :set all, :autocmd, etc hi Title guifg=#62bdde gui=none hi Title ctermfg=74 cterm=none @@ -265,13 +265,13 @@ hi WildMenu ctermfg=16 ctermbg=186 cterm=bold " ---- " added line hi DiffAdd guifg=#80a090 guibg=#313c36 gui=none -hi DiffAdd ctermfg=108 ctermbg=22 cterm=none +hi DiffAdd ctermfg=fg ctermbg=22 cterm=none " changed line hi DiffChange guifg=NONE guibg=#4a343a gui=none hi DiffChange ctermfg=fg ctermbg=52 cterm=none " deleted line hi DiffDelete guifg=#6c6661 guibg=#3c3631 gui=none -hi DiffDelete ctermfg=59 ctermbg=58 cterm=none +hi DiffDelete ctermfg=fg ctermbg=58 cterm=none " changed text within line hi DiffText guifg=#f05060 guibg=#4a343a gui=bold hi DiffText ctermfg=203 ctermbg=52 cterm=bold @@ -280,10 +280,13 @@ hi DiffText ctermfg=203 ctermbg=52 cterm=bold " Folds " ----- " line used for closed folds -hi Folded guifg=#91d6f8 guibg=#363946 gui=none -hi Folded ctermfg=117 ctermbg=238 cterm=none +"hi Folded guifg=#91d6f8 guibg=#363946 gui=none +"hi Folded ctermfg=117 ctermbg=238 cterm=none +hi Folded guifg=#d0e0f0 guibg=#202020 gui=none +hi Folded ctermfg=117 ctermbg=235 cterm=none " column on side used to indicated open and closed folds hi FoldColumn guifg=#91d6f8 guibg=#363946 gui=none +hi FoldColumn guifg=#c0c0d0 guibg=#363946 gui=none hi FoldColumn ctermfg=117 ctermbg=238 cterm=none diff --git a/compiler/rubber.vim b/compiler/rubber.vim index fd17759..a0905d9 100644 --- a/compiler/rubber.vim +++ b/compiler/rubber.vim @@ -5,10 +5,6 @@ if exists("current_compiler") endif let current_compiler = "rubber" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal -endif - CompilerSet makeprg=rubber\ -d\ % "CompilerSet efm=%f:%l:\ [%t]%m,%f:%l:%m diff --git a/doc/delimitMate.txt b/doc/delimitMate.txt index 6de8b50..9705319 100644 --- a/doc/delimitMate.txt +++ b/doc/delimitMate.txt @@ -1,18 +1,20 @@ -*delimitMate* Trying to keep those beasts at bay! v.2.0 *delimitMate.txt* +*delimitMate* Trying to keep those beasts at bay! v2.3.1 *delimitMate.txt* + + + + MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM + MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~ + MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM + MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~ + MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM + MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~ + M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M + M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~ + M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M + MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~ + MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM - ========================================================================= ~ - ==== ========= ========================== ===== ===================== ~ - ==== ========= ========================== === ===================== ~ - ==== ========= ===================== === = = ========== ========= ~ - ==== === === == == = = === == == == == === === === == ~ - == == = == ====== ======= === ===== == = === === = = ~ - = = == == == == = = == === === ===== ===== === === = ~ - = = == ===== == == = = == === === ===== === === === ==== ~ - = = == = == == == = = == === === ===== == = === === = = ~ - == === === == == = = == === == ===== === === === == ~ - ========================================================================= ~ - REFERENCE MANUAL * ============================================================================== 0.- CONTENTS *delimitMate-contents* @@ -24,8 +26,10 @@ 2.3 Backspace__________________________|delimitMateBackspace| 2.4 Visual wrapping____________________|delimitMateVisualWrapping| 2.5 Smart Quotes_______________________|delimitMateSmartQuotes| + 2.6 FileType based configuration_______|delimitMateFileType| + 2.7 Syntax awareness___________________|delimitMateSyntax| 3. Customization___________________________|delimitMateOptions| - 3.1 Option summary_____________________|delimitMateOptionSummary| + 3.1 Options summary____________________|delimitMateOptionSummary| 3.2 Options details____________________|delimitMateOptionDetails| 4. Commands________________________________|delimitMateCommands| 5. Functions_______________________________|delimitMateFunctions| @@ -37,23 +41,13 @@ ============================================================================== 1.- INTRODUCTION *delimitMateIntro* -The delimitMate plugin tries to provide some not so dumb help in the work with -delimiters (brackets, quotes, etc.), with some optional auto-completions and -expansions. +This plug-in provides automatic closing of quotes, parenthesis, brackets, +etc.; besides some other related features that should make your time in insert +mode a little bit easier. -When automatic closing is enabled, if an opening delimiter is inserted -delimitMate inserts the closing pair and places the cursor between them. When -automatic closing is disabled, no closing delimiters is inserted by -delimitMate, but if a pair of delimiters is typed, the cursor is placed in the -middle. Also, to get out of a pair of delimiters just type shift+tab or the -right delimiter and the cursor will jump to the right. - -If the cursor is inside an empty pair of delimiters, typing will -insert two spaces and the cursor will be placed in the middle; typing -will insert to car retunrs and place the cursor in the middle line, between -the delimiters. - -All of the operations are undo/redo-wise safe. +Most of the features can be modified or disabled permanently, using global +variables, or on a FileType basis, using autocommands. With a couple of +exceptions and limitations, this features don't brake undo, redo or history. ============================================================================== 2. FUNCTIONALITY *delimitMateFunctionality* @@ -118,6 +112,8 @@ Expand to: > | ) < +NOTE that the expansion of will brake the redo command. + Since and are used everywhere, I have made the functions involved in expansions global, so they can be used to make custom mappings. Read |delimitMateFunctions| for more details. @@ -125,17 +121,26 @@ in expansions global, so they can be used to make custom mappings. Read ------------------------------------------------------------------------------ 2.3 BACKSPACE *delimitMateBackspace* -If you press backspace inside an empty pair, both delimiters are deleted. If -you type shift + backspace instead, only the closing delimiter will be +If you press backspace inside an empty pair, both delimiters are deleted. When +expansions are enabled, will also delete the expansions. NOTE that +deleting expansions will brake the redo command. + +If you type shift + backspace instead, only the closing delimiter will be deleted. e.g. typing at the "|": > - What | Before | After + What | Before | After ============================================== - | call expand(|) | call expand| - ---------|------------------|----------------- - | call expand(|) | call expand(| + | call expand(|) | call expand| + ---------|-------------------|----------------- + | call expand( | ) | call expand(|) + ---------|-------------------|----------------- + | call expand( | call expand(|) + | | | + | ) | + ---------|-------------------|----------------- + | call expand(|) | call expand(| < ------------------------------------------------------------------------------ @@ -144,8 +149,8 @@ e.g. typing at the "|": > When visual mode is active this script allows for the selection to be enclosed with delimiters. But, since brackets have special meaning in visual mode, a leader (the value of 'mapleader' by default) should precede the delimiter. -This feature doesn't currently work on blockwise visual mode, any suggestions -will be welcome. +NOTE that this feature brakes the redo command and doesn't currently work on +blockwise visual mode, any suggestions to fix this will be very welcome. e.g. (selection represented between square brackets): > @@ -170,6 +175,40 @@ e.g. typing at the "|": > " | let i = "| | let i = "|" ' | I| | I'| < +------------------------------------------------------------------------------ + 2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType* + +delimitMate options can be set globally for all buffers using global +("regular") variables in your |vimrc| file. But |:autocmd| can be used to set +options for specific file types (see |'filetype'|) using buffer variables in +the following way: > + + au FileType mail,text let b:delimitMate_autoclose = 0 + ^ ^ ^ ^ ^ + | | | | | + | | | | - Option value. + | | | - Option name. + | | - Buffer variable. + | - File types for which the option will be set. + - Don't forget to put this event. +< +NOTE that you should use buffer variables (|b:var|) only to set options with +|:autocmd|, for global options use regular variables (|g:var|) in your vimrc. + +------------------------------------------------------------------------------ + 2.7 SYNTAX AWARENESS *delimitMateSyntax* + +The features of this plug-in might not be always helpful, comments and strings +usualy don't need auto-completion. delimitMate monitors which region is being +edited and if it detects that the cursor is in a comment it'll turn itself off +until the cursor leaves the comment. The excluded regions can be set using the +option |'delimitMate_excluded_regions'|. Read |group-name| for a list of +regions or syntax group names. + +NOTE that this feature relies on a proper syntax file for the current file +type, if the appropiate syntax file doesn't define a region, delimitMate won't +know about it. + ============================================================================== 3. CUSTOMIZATION *delimitMateOptions* @@ -202,6 +241,9 @@ specific file types, see |delimitMateOptionDetails| for examples. |'delimitMate_excluded_ft'| Turns off the script for the given file types. +|'delimitMate_excluded_regions'|Turns off the script for the given regions or + syntax group names. + |'delimitMate_apostrophes'| Tells delimitMate how it should "fix" balancing of single quotes when used as apostrophes. NOTE: Not needed any more, kept @@ -213,8 +255,13 @@ specific file types, see |delimitMateOptionDetails| for examples. 3.2 OPTIONS DETAILS *delimitMateOptionDetails* Add the shown lines to your vimrc file in order to set the below options. -Local options take precedence over global ones and can be used along with -autocmd to modify delimitMate's behavior for specific file types. +Buffer variables take precedence over global ones and can be used along with +autocmd to modify delimitMate's behavior for specific file types, read more in +|delimitMateFileType|. + +Note: Use buffer variables only to set options for specific file types using +:autocmd, use global variables to set options for every buffer. Read more in +|g:var| and |b:var|. ------------------------------------------------------------------------------ *'loaded_delimitMate'* @@ -245,7 +292,7 @@ Default: &matchpairs ~ Use this option to tell delimitMate which characters should be considered matching pairs. Read |delimitMateAutoClose| for details. e.g: > - let delimitMate = "(:),[:],{:},<:>" + let delimitMate_matchpairs = "(:),[:],{:},<:>" au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>" < ------------------------------------------------------------------------------ @@ -306,6 +353,16 @@ only if you don't want any of the features it provides on those file types. e.g.: > let delimitMate_excluded_ft = "mail,txt" < +------------------------------------------------------------------------------ + *'delimitMate_excluded_regions'* +Values: A string of syntax group names names separated by single commas. ~ +Default: Comment ~ + +This options turns delimitMate off for the listed regions, read |group-name| +for more info about what is a region. +e.g.: > + let delimitMate_excluded_regions = "Comments,String" +< ------------------------------------------------------------------------------ *'delimitMate_apostrophes'* Values: Strings separated by ":". ~ @@ -331,6 +388,11 @@ e.g.: > Re-sets all the mappings used for this script, use it if any option has been changed or if the filetype option hasn't been set yet. +------------------------------------------------------------------------------ +:DelimitMateSwitch *:DelimitMateSwitch* + +Switches the plug-in on and off. + ------------------------------------------------------------------------------ :DelimitMateTest *:DelimitMateTest* @@ -405,46 +467,49 @@ represented by an "|": > ============================================================================== 5. FUNCTIONS *delimitMateFunctions* +Functions should be used enclosed between = and , otherwise they +might not work as expected or at all. + ------------------------------------------------------------------------------ -delimitMate_WithinEmptyPair() *delimitMate_WithinEmptyPair* +delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair* Returns 1 if the cursor is inside an empty pair, 0 otherwise. ------------------------------------------------------------------------------ -DelimitMate_ExpandReturn() *DelimitMate_ExpandReturn()* +delimitMate#ExpandReturn() *delimitMate#ExpandReturn()* -Returns the expansion for . +Returns the expansion for if enabled and inside an empty pair, returns + otherwise. e.g.: This mapping could be used to select an item on a pop-up menu or expand inside an empty pair: > inoremap pumvisible() ? "\" : - \ DelimitMate_WithinEmptyPair ? - \ DelimitMate_ExpandReturn() : "\" + \ "\=delimitMate#ExpandReturn()\" < ------------------------------------------------------------------------------ -DelimitMate_ExpandSpace() *DelimitMate_ExpandSpace()* +delimitMate#ExpandSpace() *delimitMate#ExpandSpace()* -Returns the expansion for . +Returns the expansion for if enabled and inside an empty pair, returns + otherwise. e.g.: > - inoremap DelimitMate_WithinEmptyPair() ? - \ DelimitMate_ExpandSpace() : "\" + inoremap =delimitMate#ExpandSpace() < ------------------------------------------------------------------------------ -DelimitMate_ShouldJump() *DelimitMate_ShouldJump()* +delimitMate#ShouldJump() *delimitMate#ShouldJump()* Returns 1 if there is a closing delimiter or a quote to the right of the cursor, 0 otherwise. ------------------------------------------------------------------------------ -DelimitMate_JumpAny() *DelimitMate_JumpAny()* +delimitMate#JumpAny(key) *delimitMate#JumpAny()* -This function returns a mapping that will make the cursor jump to the right. +This function returns a mapping that will make the cursor jump to the right +when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise. e.g.: You can use this to create your own mapping to jump over any delimiter. > - inoremap DelimitMate_ShouldJump() ? - \ DelimitMate_JumpAny() : "\" + inoremap =delimitMate#JumpAny("\") < ============================================================================== @@ -452,7 +517,6 @@ e.g.: You can use this to create your own mapping to jump over any delimiter. - Automatic set-up by file type. - Make visual wrapping work on blockwise visual mode. -- Limit behaviour by region. ============================================================================== 7. MAINTAINER *delimitMateMaintainer* @@ -487,7 +551,29 @@ This script was inspired by the auto-completion of delimiters of TextMate. Version Date Release notes ~ |---------|------------|-----------------------------------------------------| - 2.0 2010-04-01 * New features: + 2.3.1 2010-06-06 * Current release: + - Fix: an extra is inserted after + expansion. +|---------|------------|-----------------------------------------------------| + 2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments + or other regions, customizable. + - Changed format of most mappings. + - Fix: expansion doesn't brake automatic + indentation adjustments anymore. + - Fix: Arrow keys would insert A, B, C or D instead + of moving the cursor when using Vim on a terminal. +|---------|------------|-----------------------------------------------------| + 2.2 2010-05-16 * - Added command to switch the plug-in on and off. + - Fix: some problems with , and . + - Fix: A small problem when inserting a delimiter at + the beginning of the line. +|---------|------------|-----------------------------------------------------| + 2.1 2010-05-10 * - Most of the functions have been moved to an + autoload script to avoid loading unnecessary ones. + - Fixed a problem with the redo command. + - Many small fixes. +|---------|------------|-----------------------------------------------------| + 2.0 2010-04-01 * New features: - All features are redo/undo-wise safe. - A single quote typed after an alphanumeric character is considered an apostrophe and one @@ -506,24 +592,24 @@ This script was inspired by the auto-completion of delimiters of TextMate. - s:vars were being used to store buffer options. |---------|------------|-----------------------------------------------------| - 1.6 2009-10-10 Now delimitMate tries to fix the balancing of single + 1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single quotes when used as apostrophes. You can read |delimitMate_apostrophes| for details. Fixed an error when |b:delimitMate_expand_space| wasn't set but |delimitMate_expand_space| wasn't. |---------|------------|-----------------------------------------------------| - 1.5 2009-10-05 Fix: delimitMate should work correctly for files + 1.5 2009-10-05 * Fix: delimitMate should work correctly for files passed as arguments to Vim. Thanks to Ben Beuchler for helping to nail this bug. |---------|------------|-----------------------------------------------------| - 1.4 2009-09-27 Fix: delimitMate is now enabled on new buffers even + 1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even if they don't have set the file type option or were opened directly from the terminal. |---------|------------|-----------------------------------------------------| - 1.3 2009-09-24 Now local options can be used along with autocmd + 1.3 2009-09-24 * Now local options can be used along with autocmd for specific file type configurations. Fixes: - Unnamed register content is not lost on visual @@ -532,7 +618,7 @@ This script was inspired by the auto-completion of delimiters of TextMate. - Wrapping a single empty line works as expected. |---------|------------|-----------------------------------------------------| - 1.2 2009-09-07 Fixes: + 1.2 2009-09-07 * Fixes: - When inside nested empty pairs, deleting the innermost left delimiter would delete all right contiguous delimiters. @@ -543,19 +629,21 @@ This script was inspired by the auto-completion of delimiters of TextMate. have the mappings set. |---------|------------|-----------------------------------------------------| - 1.1 2009-08-25 Fixed an error that ocurred when mapleader wasn't + 1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't set and added support for GetLatestScripts auto-detection. |---------|------------|-----------------------------------------------------| - 1.0 2009-08-23 Initial upload. + 1.0 2009-08-23 * Initial upload. |---------|------------|-----------------------------------------------------| - ... |"| _ _ . . ___ ~ - o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~ - 8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~ ----ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~ + `\|||/´ MMM \|/ www __^__ ~ + (o o) (o o) @ @ (O-O) /(o o)\\ ~ +ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~ +_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~ +__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~ +_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~ vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent: diff --git a/doc/tags b/doc/tags index 72c741b..f206a27 100644 --- a/doc/tags +++ b/doc/tags @@ -17,31 +17,6 @@ 'NERDTreeStatusline' NERD_tree.txt /*'NERDTreeStatusline'* 'NERDTreeWinPos' NERD_tree.txt /*'NERDTreeWinPos'* 'NERDTreeWinSize' NERD_tree.txt /*'NERDTreeWinSize'* -'Tlist_Auto_Highlight_Tag' taglist.txt /*'Tlist_Auto_Highlight_Tag'* -'Tlist_Auto_Open' taglist.txt /*'Tlist_Auto_Open'* -'Tlist_Auto_Update' taglist.txt /*'Tlist_Auto_Update'* -'Tlist_Close_On_Select' taglist.txt /*'Tlist_Close_On_Select'* -'Tlist_Compact_Format' taglist.txt /*'Tlist_Compact_Format'* -'Tlist_Ctags_Cmd' taglist.txt /*'Tlist_Ctags_Cmd'* -'Tlist_Display_Prototype' taglist.txt /*'Tlist_Display_Prototype'* -'Tlist_Display_Tag_Scope' taglist.txt /*'Tlist_Display_Tag_Scope'* -'Tlist_Enable_Fold_Column' taglist.txt /*'Tlist_Enable_Fold_Column'* -'Tlist_Exit_OnlyWindow' taglist.txt /*'Tlist_Exit_OnlyWindow'* -'Tlist_File_Fold_Auto_Close' taglist.txt /*'Tlist_File_Fold_Auto_Close'* -'Tlist_GainFocus_On_ToggleOpen' taglist.txt /*'Tlist_GainFocus_On_ToggleOpen'* -'Tlist_Highlight_Tag_On_BufEnter' taglist.txt /*'Tlist_Highlight_Tag_On_BufEnter'* -'Tlist_Inc_Winwidth' taglist.txt /*'Tlist_Inc_Winwidth'* -'Tlist_Max_Submenu_Items' taglist.txt /*'Tlist_Max_Submenu_Items'* -'Tlist_Max_Tag_Length' taglist.txt /*'Tlist_Max_Tag_Length'* -'Tlist_Process_File_Always' taglist.txt /*'Tlist_Process_File_Always'* -'Tlist_Show_Menu' taglist.txt /*'Tlist_Show_Menu'* -'Tlist_Show_One_File' taglist.txt /*'Tlist_Show_One_File'* -'Tlist_Sort_Type' taglist.txt /*'Tlist_Sort_Type'* -'Tlist_Use_Horiz_Window' taglist.txt /*'Tlist_Use_Horiz_Window'* -'Tlist_Use_Right_Window' taglist.txt /*'Tlist_Use_Right_Window'* -'Tlist_Use_SingleClick' taglist.txt /*'Tlist_Use_SingleClick'* -'Tlist_WinHeight' taglist.txt /*'Tlist_WinHeight'* -'Tlist_WinWidth' taglist.txt /*'Tlist_WinWidth'* 'b:delimitMate_autoclose' delimitMate.txt /*'b:delimitMate_autoclose'* 'b:delimitMate_expand_cr' delimitMate.txt /*'b:delimitMate_expand_cr'* 'b:delimitMate_expand_space' delimitMate.txt /*'b:delimitMate_expand_space'* @@ -52,6 +27,7 @@ 'delimitMate_apostrophes' delimitMate.txt /*'delimitMate_apostrophes'* 'delimitMate_autoclose' delimitMate.txt /*'delimitMate_autoclose'* 'delimitMate_excluded_ft' delimitMate.txt /*'delimitMate_excluded_ft'* +'delimitMate_excluded_regions' delimitMate.txt /*'delimitMate_excluded_regions'* 'delimitMate_expand_cr' delimitMate.txt /*'delimitMate_expand_cr'* 'delimitMate_expand_space' delimitMate.txt /*'delimitMate_expand_space'* 'delimitMate_matchpairs' delimitMate.txt /*'delimitMate_matchpairs'* @@ -81,6 +57,7 @@ :CVSWatchRemove vcscommand.txt /*:CVSWatchRemove* :CVSWatchers vcscommand.txt /*:CVSWatchers* :DelimitMateReload delimitMate.txt /*:DelimitMateReload* +:DelimitMateSwitch delimitMate.txt /*:DelimitMateSwitch* :DelimitMateTest delimitMate.txt /*:DelimitMateTest* :FufAddBookmark fuf.txt /*:FufAddBookmark* :FufAddBookmarkAsSelectedText fuf.txt /*:FufAddBookmarkAsSelectedText* @@ -113,22 +90,6 @@ :NERDTreeFromBookmark NERD_tree.txt /*:NERDTreeFromBookmark* :NERDTreeMirror NERD_tree.txt /*:NERDTreeMirror* :NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle* -:TlistAddFiles taglist.txt /*:TlistAddFiles* -:TlistAddFilesRecursive taglist.txt /*:TlistAddFilesRecursive* -:TlistClose taglist.txt /*:TlistClose* -:TlistDebug taglist.txt /*:TlistDebug* -:TlistHighlightTag taglist.txt /*:TlistHighlightTag* -:TlistLock taglist.txt /*:TlistLock* -:TlistMessages taglist.txt /*:TlistMessages* -:TlistOpen taglist.txt /*:TlistOpen* -:TlistSessionLoad taglist.txt /*:TlistSessionLoad* -:TlistSessionSave taglist.txt /*:TlistSessionSave* -:TlistShowPrototype taglist.txt /*:TlistShowPrototype* -:TlistShowTag taglist.txt /*:TlistShowTag* -:TlistToggle taglist.txt /*:TlistToggle* -:TlistUndebug taglist.txt /*:TlistUndebug* -:TlistUnlock taglist.txt /*:TlistUnlock* -:TlistUpdate taglist.txt /*:TlistUpdate* :VCSAdd vcscommand.txt /*:VCSAdd* :VCSAnnotate vcscommand.txt /*:VCSAnnotate* :VCSBlame vcscommand.txt /*:VCSBlame* @@ -151,6 +112,7 @@ :VimwikiAll2HTML vimwiki.txt /*:VimwikiAll2HTML* :VimwikiDeleteWord vimwiki.txt /*:VimwikiDeleteWord* :VimwikiFollowWord vimwiki.txt /*:VimwikiFollowWord* +:VimwikiGenerateLinks vimwiki.txt /*:VimwikiGenerateLinks* :VimwikiGoBackWord vimwiki.txt /*:VimwikiGoBackWord* :VimwikiGoHome vimwiki.txt /*:VimwikiGoHome* :VimwikiMakeDiaryNote vimwiki.txt /*:VimwikiMakeDiaryNote* @@ -162,13 +124,11 @@ :VimwikiTabGoHome vimwiki.txt /*:VimwikiTabGoHome* :VimwikiTabMakeDiaryNote vimwiki.txt /*:VimwikiTabMakeDiaryNote* :VimwikiTable vimwiki.txt /*:VimwikiTable* +:VimwikiTableMoveColumnLeft vimwiki.txt /*:VimwikiTableMoveColumnLeft* +:VimwikiTableMoveColumnRight vimwiki.txt /*:VimwikiTableMoveColumnRight* :VimwikiToggleListItem vimwiki.txt /*:VimwikiToggleListItem* :VimwikiUISelect vimwiki.txt /*:VimwikiUISelect* :VimwikiVSplitWord vimwiki.txt /*:VimwikiVSplitWord* -DelimitMate_ExpandReturn() delimitMate.txt /*DelimitMate_ExpandReturn()* -DelimitMate_ExpandSpace() delimitMate.txt /*DelimitMate_ExpandSpace()* -DelimitMate_JumpAny() delimitMate.txt /*DelimitMate_JumpAny()* -DelimitMate_ShouldJump() delimitMate.txt /*DelimitMate_ShouldJump()* ExtractSnips() snipMate.txt /*ExtractSnips()* ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()* Filename() snipMate.txt /*Filename()* @@ -240,10 +200,6 @@ ShowMarksClearMark showmarks.txt /*ShowMarksClearMark* ShowMarksOn showmarks.txt /*ShowMarksOn* ShowMarksPlaceMark showmarks.txt /*ShowMarksPlaceMark* ShowMarksToggle showmarks.txt /*ShowMarksToggle* -Tlist_Get_Tag_Prototype_By_Line() taglist.txt /*Tlist_Get_Tag_Prototype_By_Line()* -Tlist_Get_Tagname_By_Line() taglist.txt /*Tlist_Get_Tagname_By_Line()* -Tlist_Set_App() taglist.txt /*Tlist_Set_App()* -Tlist_Update_File_Tags() taglist.txt /*Tlist_Update_File_Tags()* VCSCommandCVSDiffOpt vcscommand.txt /*VCSCommandCVSDiffOpt* VCSCommandCVSExec vcscommand.txt /*VCSCommandCVSExec* VCSCommandCommitOnWrite vcscommand.txt /*VCSCommandCommitOnWrite* @@ -272,6 +228,10 @@ b:VCSCommandSourceFile vcscommand.txt /*b:VCSCommandSourceFile* b:VCSCommandVCSType vcscommand.txt /*b:VCSCommandVCSType* cvscommand-changes vcscommand.txt /*cvscommand-changes* delimitMate delimitMate.txt /*delimitMate* +delimitMate#ExpandReturn() delimitMate.txt /*delimitMate#ExpandReturn()* +delimitMate#ExpandSpace() delimitMate.txt /*delimitMate#ExpandSpace()* +delimitMate#JumpAny() delimitMate.txt /*delimitMate#JumpAny()* +delimitMate#ShouldJump() delimitMate.txt /*delimitMate#ShouldJump()* delimitMate-contents delimitMate.txt /*delimitMate-contents* delimitMate.txt delimitMate.txt /*delimitMate.txt* delimitMateAutoClose delimitMate.txt /*delimitMateAutoClose* @@ -279,6 +239,7 @@ delimitMateBackspace delimitMate.txt /*delimitMateBackspace* delimitMateCommands delimitMate.txt /*delimitMateCommands* delimitMateCredits delimitMate.txt /*delimitMateCredits* delimitMateExpansion delimitMate.txt /*delimitMateExpansion* +delimitMateFileType delimitMate.txt /*delimitMateFileType* delimitMateFunctionality delimitMate.txt /*delimitMateFunctionality* delimitMateFunctions delimitMate.txt /*delimitMateFunctions* delimitMateHistory delimitMate.txt /*delimitMateHistory* @@ -288,6 +249,7 @@ delimitMateOptionDetails delimitMate.txt /*delimitMateOptionDetails* delimitMateOptionSummary delimitMate.txt /*delimitMateOptionSummary* delimitMateOptions delimitMate.txt /*delimitMateOptions* delimitMateSmartQuotes delimitMate.txt /*delimitMateSmartQuotes* +delimitMateSyntax delimitMate.txt /*delimitMateSyntax* delimitMateTodo delimitMate.txt /*delimitMateTodo* delimitMateVisualWrapping delimitMate.txt /*delimitMateVisualWrapping* delimitMate_WithinEmptyPair delimitMate.txt /*delimitMate_WithinEmptyPair* @@ -414,16 +376,20 @@ g:fuf_timeFormat fuf.txt /*g:fuf_timeFormat* g:fuf_useMigemo fuf.txt /*g:fuf_useMigemo* g:snippets_dir snipMate.txt /*g:snippets_dir* g:snips_author snipMate.txt /*g:snips_author* +g:vimwiki_CJK_length vimwiki.txt /*g:vimwiki_CJK_length* g:vimwiki_auto_checkbox vimwiki.txt /*g:vimwiki_auto_checkbox* g:vimwiki_badsyms vimwiki.txt /*g:vimwiki_badsyms* g:vimwiki_browsers vimwiki.txt /*g:vimwiki_browsers* g:vimwiki_camel_case vimwiki.txt /*g:vimwiki_camel_case* +g:vimwiki_dir_link vimwiki.txt /*g:vimwiki_dir_link* g:vimwiki_fold_lists vimwiki.txt /*g:vimwiki_fold_lists* g:vimwiki_fold_trailing_empty_lines vimwiki.txt /*g:vimwiki_fold_trailing_empty_lines* g:vimwiki_folding vimwiki.txt /*g:vimwiki_folding* g:vimwiki_global_ext vimwiki.txt /*g:vimwiki_global_ext* g:vimwiki_hl_cb_checked vimwiki.txt /*g:vimwiki_hl_cb_checked* g:vimwiki_hl_headers vimwiki.txt /*g:vimwiki_hl_headers* +g:vimwiki_html_header_numbering vimwiki.txt /*g:vimwiki_html_header_numbering* +g:vimwiki_html_header_numbering_sym vimwiki.txt /*g:vimwiki_html_header_numbering_sym* g:vimwiki_list vimwiki.txt /*g:vimwiki_list* g:vimwiki_list_ignore_newline vimwiki.txt /*g:vimwiki_list_ignore_newline* g:vimwiki_listsyms vimwiki.txt /*g:vimwiki_listsyms* @@ -513,23 +479,6 @@ snipMate.txt snipMate.txt /*snipMate.txt* snippet snipMate.txt /*snippet* snippet-syntax snipMate.txt /*snippet-syntax* snippets snipMate.txt /*snippets* -taglist-commands taglist.txt /*taglist-commands* -taglist-debug taglist.txt /*taglist-debug* -taglist-extend taglist.txt /*taglist-extend* -taglist-faq taglist.txt /*taglist-faq* -taglist-functions taglist.txt /*taglist-functions* -taglist-install taglist.txt /*taglist-install* -taglist-internet taglist.txt /*taglist-internet* -taglist-intro taglist.txt /*taglist-intro* -taglist-keys taglist.txt /*taglist-keys* -taglist-license taglist.txt /*taglist-license* -taglist-menu taglist.txt /*taglist-menu* -taglist-options taglist.txt /*taglist-options* -taglist-requirements taglist.txt /*taglist-requirements* -taglist-session taglist.txt /*taglist-session* -taglist-todo taglist.txt /*taglist-todo* -taglist-using taglist.txt /*taglist-using* -taglist.txt taglist.txt /*taglist.txt* vcscommand vcscommand.txt /*vcscommand* vcscommand-buffer-management vcscommand.txt /*vcscommand-buffer-management* vcscommand-buffer-variables vcscommand.txt /*vcscommand-buffer-variables* @@ -554,11 +503,11 @@ vcscommand-ssh-wrapper vcscommand.txt /*vcscommand-ssh-wrapper* vcscommand-statusline vcscommand.txt /*vcscommand-statusline* vcscommand.txt vcscommand.txt /*vcscommand.txt* vimwiki vimwiki.txt /*vimwiki* -vimwiki-author vimwiki.txt /*vimwiki-author* vimwiki-calendar vimwiki.txt /*vimwiki-calendar* vimwiki-changelog vimwiki.txt /*vimwiki-changelog* vimwiki-commands vimwiki.txt /*vimwiki-commands* vimwiki-contents vimwiki.txt /*vimwiki-contents* +vimwiki-developers vimwiki.txt /*vimwiki-developers* vimwiki-diary vimwiki.txt /*vimwiki-diary* vimwiki-folding vimwiki.txt /*vimwiki-folding* vimwiki-global-commands vimwiki.txt /*vimwiki-global-commands* @@ -569,6 +518,7 @@ vimwiki-local-commands vimwiki.txt /*vimwiki-local-commands* vimwiki-local-mappings vimwiki.txt /*vimwiki-local-mappings* vimwiki-mappings vimwiki.txt /*vimwiki-mappings* vimwiki-multiple-wikies vimwiki.txt /*vimwiki-multiple-wikies* +vimwiki-nohtml vimwiki.txt /*vimwiki-nohtml* vimwiki-option-auto_export vimwiki.txt /*vimwiki-option-auto_export* vimwiki-option-css_name vimwiki.txt /*vimwiki-option-css_name* vimwiki-option-diary_header vimwiki.txt /*vimwiki-option-diary_header* @@ -607,6 +557,8 @@ vimwiki-toc vimwiki.txt /*vimwiki-toc* vimwiki-todo-lists vimwiki.txt /*vimwiki-todo-lists* vimwiki.txt vimwiki.txt /*vimwiki.txt* vimwiki_- vimwiki.txt /*vimwiki_-* +vimwiki_ vimwiki.txt /*vimwiki_* +vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* vimwiki_ vimwiki.txt /*vimwiki_* @@ -620,6 +572,7 @@ vimwiki_= vimwiki.txt /*vimwiki_=* vimwiki_gqq vimwiki.txt /*vimwiki_gqq* vimwiki_gww vimwiki.txt /*vimwiki_gww* vimwiki_i_ vimwiki.txt /*vimwiki_i_* +vimwiki_i_ vimwiki.txt /*vimwiki_i_* vimwiki_i_ vimwiki.txt /*vimwiki_i_* viwmiki-global-options vimwiki.txt /*viwmiki-global-options* viwmiki-local-options vimwiki.txt /*viwmiki-local-options* diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index b8836b9..6050c58 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1,14 +1,15 @@ *vimwiki.txt* A Personal Wiki for Vim - __ __ ______ __ __ ______ __ __ ______ ~ - /\ \/\ \/\__ _\ /'\_/`\/\ \ __/\ \/\__ _\ /\ \/\ \ /\__ _\ ~ - \ \ \ \ \/_/\ \/ /\ \ \ \/\ \ \ \/_/\ \/ \ \ \/'/'\/_/\ \/ ~ - \ \ \ \ \ \ \ \ \ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \ , < \ \ \ ~ - \ \ \_/ \ \_\ \__\ \ \_/\ \ \ \_/ \_\ \ \_\ \__\ \ \\`\ \_\ \__ ~ - \ `\___/ /\_____\\ \_\\ \_\ `\___x___/ /\_____\\ \_\ \_\ /\_____\~ - `\/__/ \/_____/ \/_/ \/_/'\/__//__/ \/_____/ \/_/\/_/ \/_____/~ + __ __ ___ __ __ _ _ ___ ___ _ ___ ~ + | | | || | | |_| || | _ | || | | | | || | ~ + | |_| || | | || || || || | | |_| || | ~ + | || | | || || | | _|| | ~ + | || | | || || | | |_ | | ~ + | | | | | ||_|| || _ || | | _ || | ~ + |___| |___| |_| |_||__| |__||___| |___| |_||___| ~ - Version: 0.9.9 + + Version: 1.0 ============================================================================== CONTENTS *vimwiki-contents* @@ -34,13 +35,12 @@ CONTENTS *vimwiki-contents* 5.9. Comments |vimwiki-syntax-comments| 6. Folding/Outline |vimwiki-folding| 7. Placeholders |vimwiki-placeholders| - 7.1 Table of Contents |vimwiki-table-of-contents| 8. Todo lists |vimwiki-todo-lists| 9. Tables |vimwiki-tables| 10. Diary |vimwiki-diary| 11. Options |vimwiki-options| 12. Help |vimwiki-help| - 13. Author |vimwiki-author| + 13. Developers |vimwiki-developers| 14. Changelog |vimwiki-changelog| 15. License |vimwiki-license| @@ -242,6 +242,13 @@ gqq Format table. If you did some changes to a table or without swapping insert/normal modes this command gww reformat it. + *vimwiki_* + Move current table column to the left. + See |:VimwikiTableMoveColumnLeft| + + *vimwiki_* + Move current table column to the right. + See |:VimwikiTableMoveColumnRight| @@ -267,6 +274,8 @@ INSERT MODE *vimwiki-table-mappings* Goto next table cell, create new row if on the last cell. + *vimwiki_i_* + Insert
    and a newline. ------------------------------------------------------------------------------ @@ -278,6 +287,10 @@ ih Inner Header without leading empty lines. You can 'vah' to select a header with its contents or 'dah' to delete it or 'yah' to yank it or 'cah' to change it. +a\ A cell in a table. +i\ Inner cell in a table. +ac A column in a table. +ic Inner column in a table. ============================================================================== 4. Commands *vimwiki-commands* @@ -362,6 +375,37 @@ You can 'vah' to select a header with its contents or 'dah' to delete it or :VimwikiTable cols Create a table with a given cols and 2 rows +*:VimwikiTableMoveColumnLeft* , *:VimwikiTableMoveColumnRight* + Move current column to the left or to the right: + Example: > + + | head1 | head2 | head3 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value1 | value2 | value3 | value4 | value5 | + + + Cursor is on 'head1'. + :VimwikiTableMoveColumnRight + + | head2 | head1 | head3 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value2 | value1 | value3 | value4 | value5 | + + Cursor is on 'head3'. + :VimwikiTableMoveColumnLeft + + | head2 | head3 | head1 | head4 | head5 | + |--------+--------+--------+--------+--------| + | value2 | value3 | value1 | value4 | value5 | +< + + Commands are mapped to and respectively. + + +*:VimwikiGenerateLinks* + Insert all available links into current buffer. + + ============================================================================== 5. Wiki syntax *vimwiki-syntax* @@ -370,13 +414,8 @@ There are a lot of different wikies out there. Most of them have their own syntax and vimwiki is not an exception here. Default vimwiki's syntax is a subset of google's wiki syntax markup. -As for MediaWiki's syntax -- it is not that convenient for non English -(Russian in my case :)) keyboard layouts to emphasize text as it uses a lot -of '''''' to do it. You have to switch layouts every time you want some bold -non English text. This is the answer to "Why not MediaWiki?" - -Nevertheless, there is MediaWiki syntax file included in the distribution (it -doesn't have all the fancy stuff original MediaWiki syntax has though). +There is MediaWiki syntax file included in the distribution (it doesn't have +all the fancy stuff original MediaWiki syntax has though). See |vimwiki-option-syntax|. @@ -500,18 +539,6 @@ You can center your headers in html by placing spaces before the first '=': -Note: before vimwiki 0.8.2, header's markup syntax used exclamation marks: -! Header level 1 -!! Header level 2 -etc... - -If you upgrade from pre 0.8.2 you might find the next commands useful. -To change headers from !Header to =Header= in your wiki files do: > - :args .wiki - :argdo %s/^\(!\+\)\([^!].*$\)/\=substitute(submatch(1),'!','=','g').submatch(2).substitute(submatch(1),'!','=','g') - -Note: BACKUP FIRST! - ------------------------------------------------------------------------------ 5.4. Paragraphs *vimwiki-syntax-paragraphs* @@ -619,6 +646,7 @@ In html the following part > > is higlighted as a table header. +If you indent table then it would be centered in html. See |vimwiki-tables| for more details on how to manage tables. @@ -723,7 +751,7 @@ To turn folding on/off check |g:vimwiki_folding|. 7. Placeholders *vimwiki-placeholders* ------------------------------------------------------------------------------ -7.1. Table of Contents *vimwiki-toc* *vimwiki-table-of-contents* +%toc Table of Contents *vimwiki-toc* *vimwiki-table-of-contents* You can add 'table of contents' to your html page generated from wiki one. Just place > @@ -740,6 +768,16 @@ or > %toc Whatever +------------------------------------------------------------------------------ +%nohtml *vimwiki-nohtml* + +If you do not want a wiki page to be converted to html, place: + +%nohtml + +into it. + + ============================================================================== 8. Todo lists *vimwiki-todo-lists* @@ -825,6 +863,8 @@ values: > | James | Esfandiary | 27 | Istanbul | esfandiary@tmail.com | < +To indent table indent the first row. Then format it with 'gqq'. + ============================================================================== @@ -870,6 +910,8 @@ be created in 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. + ============================================================================== @@ -907,6 +949,20 @@ Empty |Dictionary| in the g:vimwiki_list is the wiki with default options: > < +You can also create wikis as a separate |Dictionary|s. > + + let wiki_1 = {} + let wiki_1.path = '~/my_docs/' + let wiki_1.html_header = '~/public_html/header.tpl' + let wiki_1.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} + + let wiki_2 = {} + let wiki_2.path = '~/project_docs/' + let wiki_2.index = 'main' + + let g:vimwiki_list = [wiki_1, wiki_2] + +< PER WIKI OPTIONS *viwmiki-local-options* @@ -1079,11 +1135,11 @@ nested_syntaxes {} pairs of highlight keyword and vim filetype Description~ You can make preformatted text to be highlighted with a different syntaxes available for vim. -For example the following setup: > +For example the following setup in your vimrc: > let wiki = {} - let wiki.path = '~/my_site/' + let wiki.path = '~/my_wiki/' let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} - let vimwiki_list = [wiki] + let g:vimwiki_list = [wiki] would give you python and c++ highlighting in: > {{{class="brush: python" @@ -1152,8 +1208,8 @@ Description~ Number of maximum dated links placed on one line. Ex: = Diary = -|| [[2010-01-30]] || [[2010-01-29]] || [[2010-01-28]] || [[2010-01-27]] || -|| [[2010-01-26]] || [[2010-01-25]] || +| [[2010-01-30]] | [[2010-01-29]] | [[2010-01-28]] | [[2010-01-27]] | +| [[2010-01-26]] | [[2010-01-25]] | @@ -1399,7 +1455,7 @@ Default: 1 Convert directory name from current |encoding| into 'g:vimwiki_w32_dir_enc' before it is created. -If have 'enc=utf-8' and you set up > +If you have 'enc=utf-8' and set up > let g:vimwiki_w32_dir_enc = 'cp1251' < then following the next link with : > @@ -1407,40 +1463,184 @@ then following the next link with : > > would convert utf-8 'привет' to cp1251 and create directory with that name. -Default value: '' +Default: '' + + +------------------------------------------------------------------------------ +*g:vimwiki_CJK_length* + +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. +1 Use it. + +Default: 0 + + +------------------------------------------------------------------------------ +*g:vimwiki_dir_link* + +This option is about what to do with links to directories -- [[directory/]], +[[papers/]], etc. + +Value Description~ +'' Open 'directory/' using standard netrw plugin. +'index' Open 'directory/index.wiki', create if needed. +'main' Open 'directory/main.wiki', create if needed. +etc. + +Default: '' (empty string) + + +------------------------------------------------------------------------------ +*g:vimwiki_html_header_numbering* + +Set this option if you want headers to be auto numbered in html. + +ex: > + 1 Header1 + 1.1 Header2 + 1.2 Header2 + 1.2.1 Header3 + 1.2.2 Header3 + 1.3 Header2 + 2 Header1 + 3 Header1 +etc. + +Value Description~ +0 Header numbering is off. +1 Header numbering is on. Headers are numbered starting from + header level 1. +2 Header numbering is on. Headers are numbered starting from + header level 2. +etc. +Example when g:vimwiki_html_header_numbering = 2: > + Header1 + 1 Header2 + 2 Header2 + 2.1 Header3 + 2.1.1 Header4 + 2.1.2 Header4 + 2.2 Header3 + 3 Header2 + 4 Header2 +etc. + +Default: 0 + + +------------------------------------------------------------------------------ +*g:vimwiki_html_header_numbering_sym* + +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. +etc. + +With + let g:vimwiki_html_header_numbering = '.' +headers would look like: > + 1. Header1 + 1.1. Header2 + 1.2. Header2 + 1.2.1. Header3 + 1.2.2. Header3 + 1.3. Header2 + 2. Header1 + 3. Header1 + + +Default: '' (empty) ============================================================================== 12. Help *vimwiki-help* -As you could see I am not native English speaker (not a writer as well). -Please send me correct phrases instead of that incorrect stuff I have used -here. +Your help in making vimwiki better is really appreciated! +Any help. Would it be spell correction or code snippet to patch -- everything +is welcomed. + +Issues could be filled in at http://code.google.com/p/vimwiki/issues . -Any help is really appreciated! ============================================================================== -13. Author *vimwiki-author* +13. Developers *vimwiki-developers* -I live in Moscow and you may believe me -- there are no polar bears (no brown -too) here in the streets. + - Maxim Kim + Original author. + - Mikhail Trishchenkov + Joined in at Dec 2009. -I do not do programming for a living. So don't blame me for an ugly -ineffective code. Improvements are welcome. +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 . +Maxim Kim. -Vimwiki's website: http://code.google.com/p/vimwiki/ -Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 ============================================================================== 14. Changelog *vimwiki-changelog* +1.0~ + * NEW: Issue 41: Table cell and column text objects. See + |vimwiki-text-objects|. + * NEW: Issue 42: Commands to move table columns left and right. See + |: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. + * 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. + * FIX: Issue 48: With autochdir it is impossible to have path_html such as + 'd:\vimwiki\html\' + * FIX: Issue 49: Table is not HTMLized properly at the end of wiki page. + * FIX: Issue 50: Inline formatting is not performed in table cells. + * FIX: Issue 51: Cannot insert '-' (minus) into table cells of the first + column. + * FIX: Issue 52: Table cell width is incorrect when double wide characters + are used (ie. Chinese). Check |g:vimwiki_CJK_length|. + * NEW: Issue 53: Wiki markup can not nested. (Use links and inline markup + in Headers). + * NEW: Issue 54: Highlight for placeholders. + * NEW: Issue 56: Directory indexes. See |g:vimwiki_dir_link| option and + |:VimwikiGenerateLinks| command. + * NEW: Issue 58: Html new lines with
    . Could be inserted with + in insert mode. + * FIX: Issue 59: List item's text can't be started from *. + * 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 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 + 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 + skipped for navigation with . + * FIX: Issue 75: `code` syntax doesn't display correctly in toc. + * FIX: Issue 77: Diary index only showing link to today's diary entry + file for extensions other than '.wiki'. + * FIX: Issue 79: Further calendar.vim integration -- add sign to calendar + 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 + `let g:vimwiki_camel_case = 0` + 0.9.9~ * NEW: Diary. Help in making daily notes. See |vimwiki-diary|. Now you can really easy add information into vimwiki that should be sorted out @@ -1819,7 +2019,7 @@ Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 The MIT Licence http://www.opensource.org/licenses/mit-license.php -Copyright (c) 2010 Maxim Kim +Copyright (c) 2008-2010 Maxim Kim Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ftplugin/python/pyflakes/pyflakes/checker.py b/ftplugin/python/pyflakes/pyflakes/checker.py index 2d933a0..b3d6960 100644 --- a/ftplugin/python/pyflakes/pyflakes/checker.py +++ b/ftplugin/python/pyflakes/pyflakes/checker.py @@ -37,7 +37,7 @@ class Assignment(Binding): pass class FunctionDefinition(Binding): - pass + _property_decorator = False class Scope(dict): @@ -167,7 +167,16 @@ class Checker(ast.NodeVisitor): decorators = node.decorators self.visit_nodes(decorators) - self.add_binding(node, FunctionDefinition(node.name, node)) + + # Check for property decorator + func_def = FunctionDefinition(node.name, node) + + for decorator in decorators: + if getattr(decorator, 'attr', None) in ('setter', 'deleter'): + func_def._property_decorator = True + + self.add_binding(node, func_def) + self.visit_Lambda(node) def visit_Lambda(self, node): @@ -300,6 +309,14 @@ class Checker(ast.NodeVisitor): scope.globals.update(dict.fromkeys(node.names)) def visit_ClassDef(self, node): + try: + decorators = node.decorator_list + except AttributeError: + # Use .decorators for Python 2.5 compatibility + decorators = getattr(node, 'decorators', []) + + self.visit_nodes(decorators) + self.add_binding(node, Assignment(node.name, node)) self.visit_nodes(node.bases) @@ -344,7 +361,9 @@ class Checker(ast.NodeVisitor): # Check for a redefined function func = scope.get(name) if (isinstance(func, FunctionDefinition) and isinstance(value, FunctionDefinition)): - self.report(messages.RedefinedFunction, line, name, func.source.lineno) + # Property-decorated functions (@x.setter) should have duplicate names + if not value._property_decorator: + self.report(messages.RedefinedFunction, line, name, func.source.lineno) # Check for redefining an unused import if report_redef and not isinstance(scope, ClassScope): diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index edda29f..807d1f5 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -1,3 +1,4 @@ +" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 " Vimwiki filetype plugin file " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ @@ -41,6 +42,19 @@ inoremap vimwiki_lst#insertCR() nnoremap o :call vimwiki_lst#insertOo('o')a nnoremap O :call vimwiki_lst#insertOo('O')a +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#insertOo("o")a' + endif + + let l_O = matchstr(&langmap, '\C,\zs.\zeO,') + if l_O + exe 'nnoremap '.l_O.' :call vimwiki_lst#insertOo("O")a' + endif +endif + " COMMENTS }}} " FOLDING for headers and list items using expr fold method. {{{ @@ -205,6 +219,8 @@ command! -buffer VimwikiVSplitWord call vimwiki#WikiFollowWord('vsplit') command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(, ) +command! -buffer VimwikiGenerateLinks call vimwiki#generate_links() + exe 'command! -buffer -nargs=* VimwikiSearch vimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') @@ -215,6 +231,8 @@ exe 'command! -buffer -nargs=* VWS vimgrep '. 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() " COMMANDS }}} @@ -291,21 +309,39 @@ noremap