Version 0.3.3
* FIXED: `[[wiki word with dots at the end...]]` didn't work. * DONE: Added error handling for `delete wiki word` function. * DONE: Added keybindings `o` and `O` for list items when g:vimwiki_smartCR=1. * DONE: Added keybinding `<Leader>wh` to visit wiki home directory.
This commit is contained in:
parent
dfd2470208
commit
2cd2e35d0a
@ -3,8 +3,8 @@
|
|||||||
" Author: Maxim Kim (habamax at gmail dot com)
|
" Author: Maxim Kim (habamax at gmail dot com)
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
" Home: http://code.google.com/p/vimwiki/
|
||||||
" Filenames: *.wiki
|
" Filenames: *.wiki
|
||||||
" Last Change: (16.05.2008 14:28)
|
" Last Change: (20.05.2008 09:50)
|
||||||
" Version: 0.3.1
|
" Version: 0.3.3
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
if exists("b:did_ftplugin")
|
||||||
finish
|
finish
|
||||||
@ -60,6 +60,8 @@ noremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:call WikiFollowWord('split'
|
|||||||
noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:call WikiFollowWord('vsplit')<CR>
|
noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:call WikiFollowWord('vsplit')<CR>
|
||||||
|
|
||||||
nmap <silent><buffer> <BS> :call WikiGoBackWord()<CR>
|
nmap <silent><buffer> <BS> :call WikiGoBackWord()<CR>
|
||||||
|
"<BS> mapping doesn't work in vim console
|
||||||
|
nmap <silent><buffer> <C-h> :call WikiGoBackWord()<CR>
|
||||||
nmap <silent><buffer> <RightMouse><LeftMouse> :call WikiGoBackWord()<CR>
|
nmap <silent><buffer> <RightMouse><LeftMouse> :call WikiGoBackWord()<CR>
|
||||||
|
|
||||||
nmap <silent><buffer> <TAB> :call WikiNextWord()<CR>
|
nmap <silent><buffer> <TAB> :call WikiNextWord()<CR>
|
||||||
@ -69,6 +71,8 @@ nmap <silent><buffer> <Leader>wd :call WikiDeleteWord()<CR>
|
|||||||
nmap <silent><buffer> <Leader>wr :call WikiRenameWord()<CR>
|
nmap <silent><buffer> <Leader>wr :call WikiRenameWord()<CR>
|
||||||
|
|
||||||
if g:vimwiki_smartCR==1
|
if g:vimwiki_smartCR==1
|
||||||
inoremap <silent><buffer><CR> <CR><Space><C-O>:call WikiNewLine()<CR>
|
inoremap <silent><buffer><CR> <CR><Space><C-O>:call WikiNewLine('checkup')<CR>
|
||||||
|
noremap <silent><buffer>o o<Space><C-O>:call WikiNewLine('checkup')<CR>
|
||||||
|
noremap <silent><buffer>O O<Space><C-O>:call WikiNewLine('checkdown')<CR>
|
||||||
endif
|
endif
|
||||||
" Keybindings }}}
|
" Keybindings }}}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
" Author: Maxim Kim (habamax at gmail dot com)
|
" Author: Maxim Kim (habamax at gmail dot com)
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
" Home: http://code.google.com/p/vimwiki/
|
||||||
" Filenames: *.wiki
|
" Filenames: *.wiki
|
||||||
" Last Change: (16.05.2008 18:29)
|
" Last Change: (23.05.2008 16:38)
|
||||||
" Version: 0.3.2
|
" Version: 0.3.3
|
||||||
|
|
||||||
|
|
||||||
if exists("loaded_vimwiki") || &cp
|
if exists("loaded_vimwiki") || &cp
|
||||||
@ -32,6 +32,7 @@ call s:default('maxhi','1')
|
|||||||
call s:default('other','0-9_')
|
call s:default('other','0-9_')
|
||||||
call s:default('smartCR',1)
|
call s:default('smartCR',1)
|
||||||
call s:default('stripsym','_')
|
call s:default('stripsym','_')
|
||||||
|
" call s:default('addheading','1')
|
||||||
|
|
||||||
call s:default('history',[])
|
call s:default('history',[])
|
||||||
|
|
||||||
@ -59,8 +60,22 @@ function! s:msg(message)"{{{
|
|||||||
echohl None
|
echohl None
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! s:getfilename(filename)
|
||||||
|
let word = substitute(a:filename, '\'.g:vimwiki_ext, "", "g")
|
||||||
|
let word = substitute(word, '.*[/\\]', "", "g")
|
||||||
|
return word
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:editfile(command, filename)
|
function! s:editfile(command, filename)
|
||||||
execute a:command.' '.escape(a:filename, '% ')
|
let fname = escape(a:filename, '% ')
|
||||||
|
execute a:command.' '.fname
|
||||||
|
|
||||||
|
" if fname is new
|
||||||
|
" if g:vimwiki_addheading!=0 && glob(fname) == ''
|
||||||
|
" execute 'normal I! '.s:getfilename(fname)
|
||||||
|
" update
|
||||||
|
" endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SearchWord(wikiRx,cmd)"{{{
|
function! s:SearchWord(wikiRx,cmd)"{{{
|
||||||
@ -122,7 +137,7 @@ endfunction"}}}
|
|||||||
" Check if word is link to a non-wiki file.
|
" Check if word is link to a non-wiki file.
|
||||||
" The easiest way is to check if it has extension like .txt or .html
|
" The easiest way is to check if it has extension like .txt or .html
|
||||||
function! s:WikiIsLinkToNonWikiFile(word)"{{{
|
function! s:WikiIsLinkToNonWikiFile(word)"{{{
|
||||||
if a:word =~ '\..\{1,4}$'
|
if a:word =~ '\.\w\{1,4}$'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@ -139,7 +154,7 @@ function! s:GetHistoryColumn(historyItem)
|
|||||||
endfunction
|
endfunction
|
||||||
"2}}}
|
"2}}}
|
||||||
|
|
||||||
function! WikiFollowWord(split)"{{{
|
function! WikiFollowWord(split) "{{{
|
||||||
if a:split == "split"
|
if a:split == "split"
|
||||||
let cmd = ":split "
|
let cmd = ":split "
|
||||||
elseif a:split == "vsplit"
|
elseif a:split == "vsplit"
|
||||||
@ -154,12 +169,10 @@ function! WikiFollowWord(split)"{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if s:WikiIsLinkToNonWikiFile(word)
|
if s:WikiIsLinkToNonWikiFile(word)
|
||||||
" execute cmd.word
|
|
||||||
call s:editfile(cmd, word)
|
call s:editfile(cmd, word)
|
||||||
else
|
else
|
||||||
call insert(g:vimwiki_history, [expand('%:p'), col('.')])
|
call insert(g:vimwiki_history, [expand('%:p'), col('.')])
|
||||||
call s:editfile(cmd, g:vimwiki_home.word.g:vimwiki_ext)
|
call s:editfile(cmd, g:vimwiki_home.word.g:vimwiki_ext)
|
||||||
" execute cmd.g:vimwiki_home.word.g:vimwiki_ext
|
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
@ -172,10 +185,17 @@ function! WikiGoBackWord() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! WikiNewLine() "{{{
|
"" direction == checkup - use previous line for checking
|
||||||
function! s:WikiAutoListItemInsert(listSym)
|
"" direction == checkdown - use next line for checking
|
||||||
|
function! WikiNewLine(direction) "{{{
|
||||||
|
function! s:WikiAutoListItemInsert(listSym, dir)
|
||||||
let sym = escape(a:listSym, '*')
|
let sym = escape(a:listSym, '*')
|
||||||
let prevline = getline(line('.')-1)
|
if a:dir=='checkup'
|
||||||
|
let linenum = line('.')-1
|
||||||
|
else
|
||||||
|
let linenum = line('.')+1
|
||||||
|
end
|
||||||
|
let prevline = getline(linenum)
|
||||||
if prevline =~ '^\s\+'.sym
|
if prevline =~ '^\s\+'.sym
|
||||||
let curline = substitute(getline('.'),'^\s\+',"","g")
|
let curline = substitute(getline('.'),'^\s\+',"","g")
|
||||||
if prevline =~ '^\s*'.sym.'\s*$'
|
if prevline =~ '^\s*'.sym.'\s*$'
|
||||||
@ -183,7 +203,7 @@ function! WikiNewLine() "{{{
|
|||||||
execute 'normal kA '."\<ESC>".'"_dF'.a:listSym.'JX'
|
execute 'normal kA '."\<ESC>".'"_dF'.a:listSym.'JX'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
let ind = indent(line('.')-1)
|
let ind = indent(linenum)
|
||||||
call setline(line('.'), strpart(prevline, 0, ind).a:listSym.' '.curline)
|
call setline(line('.'), strpart(prevline, 0, ind).a:listSym.' '.curline)
|
||||||
call cursor(line('.'), ind+3)
|
call cursor(line('.'), ind+3)
|
||||||
return 1
|
return 1
|
||||||
@ -191,11 +211,11 @@ function! WikiNewLine() "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if s:WikiAutoListItemInsert('*')
|
if s:WikiAutoListItemInsert('*', a:direction)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if s:WikiAutoListItemInsert('#')
|
if s:WikiAutoListItemInsert('#', a:direction)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -216,8 +236,14 @@ function! WikiDeleteWord()"{{{
|
|||||||
endif
|
endif
|
||||||
let fname = expand('%:p')
|
let fname = expand('%:p')
|
||||||
" call WikiGoBackWord()
|
" call WikiGoBackWord()
|
||||||
|
try
|
||||||
call delete(fname)
|
call delete(fname)
|
||||||
execute "bwipeout ".escape(fname, " ")
|
catch /.*/
|
||||||
|
call s:msg('Cannot delete "'.expand('%:r').'"!')
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
execute "bdelete! ".escape(fname, " ")
|
||||||
|
|
||||||
" delete from g:vimwiki_history list
|
" delete from g:vimwiki_history list
|
||||||
call filter (g:vimwiki_history, 's:GetHistoryWord(v:val) != fname')
|
call filter (g:vimwiki_history, 's:GetHistoryWord(v:val) != fname')
|
||||||
" as we got back to previous WikiWord - delete it from history - as much
|
" as we got back to previous WikiWord - delete it from history - as much
|
||||||
@ -308,7 +334,7 @@ function! WikiRenameWord() "{{{
|
|||||||
while bcount<=bufnr("$")
|
while bcount<=bufnr("$")
|
||||||
if bufexists(bcount)
|
if bufexists(bcount)
|
||||||
if index(openbuffers, bufname(bcount)) == -1
|
if index(openbuffers, bufname(bcount)) == -1
|
||||||
execute 'silent bwipeout '.escape(bufname(bcount), " ")
|
execute 'silent bdelete '.escape(bufname(bcount), " ")
|
||||||
end
|
end
|
||||||
endif
|
endif
|
||||||
let bcount = bcount + 1
|
let bcount = bcount + 1
|
||||||
@ -320,7 +346,7 @@ function! WikiRenameWord() "{{{
|
|||||||
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! WikiHighlightWords()"{{{
|
function! WikiHighlightWords() "{{{
|
||||||
let wikies = glob(g:vimwiki_home.'*')
|
let wikies = glob(g:vimwiki_home.'*')
|
||||||
let wikies = substitute(wikies, '\'.g:vimwiki_ext, "", "g")
|
let wikies = substitute(wikies, '\'.g:vimwiki_ext, "", "g")
|
||||||
let g:vimwiki_wikiwords = split(wikies, '\n')
|
let g:vimwiki_wikiwords = split(wikies, '\n')
|
||||||
@ -353,3 +379,4 @@ command WikiPrevWord call WikiPrevWord()
|
|||||||
"" Commands }}}
|
"" Commands }}}
|
||||||
|
|
||||||
nmap <silent><unique> <Leader>ww :call WikiGoHome()<CR>
|
nmap <silent><unique> <Leader>ww :call WikiGoHome()<CR>
|
||||||
|
nmap <silent><unique> <Leader>wh :execute "edit ".g:vimwiki_home."."<CR>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
" Author: Maxim Kim (habamax at gmail dot com)
|
" Author: Maxim Kim (habamax at gmail dot com)
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
" Home: http://code.google.com/p/vimwiki/
|
||||||
" Filenames: *.wiki
|
" Filenames: *.wiki
|
||||||
" Last Change: (16.05.2008 17:14)
|
" Last Change: (22.05.2008 11:40)
|
||||||
" Version: 0.3.2
|
" Version: 0.3.3
|
||||||
|
|
||||||
" Quit if syntax file is already loaded
|
" Quit if syntax file is already loaded
|
||||||
if version < 600
|
if version < 600
|
||||||
@ -33,7 +33,9 @@ endif
|
|||||||
syntax match wikiLink `\("[^"(]\+\((\([^)]\+\))\)\?":\)\?\(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\(\(\(//\)\|\(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+-=.&\-\\\\]*\)`
|
syntax match wikiLink `\("[^"(]\+\((\([^)]\+\))\)\?":\)\?\(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\(\(\(//\)\|\(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+-=.&\-\\\\]*\)`
|
||||||
|
|
||||||
" text: *strong*
|
" text: *strong*
|
||||||
syntax match wikiBold /\(^\|\W\)\zs\*\([^ ].\{-}\)\*/
|
" syntax match wikiBold /\(^\|\W\)\zs\*\([^ ].\{-}\)\*/
|
||||||
|
" syntax match wikiBold /\(^\|\W\)\zs\*.\{-}\*/
|
||||||
|
syntax match wikiBold /\*.\{-}\*/
|
||||||
|
|
||||||
" text: _emphasis_
|
" text: _emphasis_
|
||||||
syntax match wikiItalic /_.\{-}_/
|
syntax match wikiItalic /_.\{-}_/
|
||||||
|
Loading…
Reference in New Issue
Block a user