Version 0.9.8
* NEW: Rename g:vimwiki_fold_empty_lines to g:vimwiki_fold_trailing_empty_lines.
* NEW: One can use - along with * to start unordered list item.
* NEW: List items could be started from the first column.  As a result some
  limitations appeared:
    * a space after *, - or # for a list item is mandatory.
    * g:vimwiki_fold_trailing_empty_lines if set to 0 folds one trailing
      empty line.
* NEW: Folding is off by default. Use g:vimwiki_folding to enable it.
* NEW: Speed up vimwiki's folding a bit. Should lag a bit less in a long todo lists.
* NEW: Centered headers. Start header with at least one space to make it html centered.
* NEW: Change in default css: header's colors.
* NEW: Vimwiki is aware of GetLatestVimScripts now.
* FIX: Use <del> tag instead of custom <span class="strike"> in html.
* FIX: There are no text styling in htmlized quoted text.
* FIX: set default value of g:vimwiki_fold_lists to 0 as written in this help.
* FIX: Issue 33: Folded list items have wrong indentation when 'tabs' are used.
* FIX: Issue 34: vimwiki#subdir got wrong dir when VimwikiGet('path') is a
  symbolic link. Thanks lilydjwg for the patch.
* FIX: Issue 28: todo-list auto-indent enhancement. New item should always be unchecked.
* FIX: Issue 36: Change the name of the :Search command to :VimwikiSearch
  as it conflicts with MultipleSearch. Alias :VWS is also available.
* NEW: You can generate 'Table of contents' of your wiki page. See :h vimwiki-toc for details.
			
			
This commit is contained in:
		
							
								
								
									
										299
									
								
								ftplugin/vimwiki.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										299
									
								
								ftplugin/vimwiki.vim
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,299 @@ | ||||
| " Vimwiki filetype plugin file | ||||
| " Author: Maxim Kim <habamax@gmail.com> | ||||
| " Home: http://code.google.com/p/vimwiki/ | ||||
|  | ||||
| if exists("b:did_ftplugin") | ||||
|   finish | ||||
| endif | ||||
| let b:did_ftplugin = 1  " Don't load another plugin for this buffer | ||||
|  | ||||
| " UNDO list {{{ | ||||
| " Reset the following options to undo this plugin. | ||||
| let b:undo_ftplugin = "setlocal wrap< linebreak< ". | ||||
|       \ "suffixesadd< isfname< comments< ". | ||||
|       \ "autowriteall< ". | ||||
|       \ "formatoptions< foldtext< ". | ||||
|       \ "foldmethod< foldexpr< commentstring< " | ||||
| " UNDO }}} | ||||
|  | ||||
| " MISC STUFF {{{ | ||||
|  | ||||
| setlocal wrap | ||||
| setlocal linebreak | ||||
| setlocal autowriteall | ||||
| setlocal commentstring=<!--%s--> | ||||
| " MISC }}} | ||||
|  | ||||
| " GOTO FILE: gf {{{ | ||||
| execute 'setlocal suffixesadd='.VimwikiGet('ext') | ||||
| setlocal isfname-=[,] | ||||
| " gf}}} | ||||
|  | ||||
| " Autocreate list items {{{ | ||||
| " for list items, and list items with checkboxes | ||||
| if VimwikiGet('syntax') == 'default' | ||||
|   setl comments=b:*,b:#,b:- | ||||
|   setl formatlistpat=^\\s*[*#-]\\s* | ||||
| else | ||||
|   setl comments=n:*,n:# | ||||
| endif | ||||
| setlocal formatoptions=tnro | ||||
|  | ||||
| inoremap <expr> <CR> vimwiki_lst#insertCR() | ||||
| nnoremap o :call vimwiki_lst#insertOo('o')<CR>a | ||||
| nnoremap O :call vimwiki_lst#insertOo('O')<CR>a | ||||
|  | ||||
| " COMMENTS }}} | ||||
|  | ||||
| " FOLDING for headers and list items using expr fold method. {{{ | ||||
| if g:vimwiki_folding == 1 | ||||
|   setlocal fdm=expr | ||||
|   setlocal foldexpr=VimwikiFoldLevel(v:lnum) | ||||
|   setlocal foldtext=VimwikiFoldText() | ||||
| endif | ||||
|  | ||||
| function! VimwikiFoldLevel(lnum) "{{{ | ||||
|   let line = getline(a:lnum) | ||||
|  | ||||
|   " Header folding... | ||||
|   if line =~ g:vimwiki_rxHeader | ||||
|     let n = vimwiki#count_first_sym(line) | ||||
|     return '>'.n | ||||
|   endif | ||||
|  | ||||
|   if g:vimwiki_fold_trailing_empty_lines == 0 | ||||
|     if line =~ '^\s*$' | ||||
|       let nnline = getline(nextnonblank(a:lnum + 1)) | ||||
|       if nnline =~ g:vimwiki_rxHeader | ||||
|         let n = vimwiki#count_first_sym(nnline) | ||||
|         return '<'.n | ||||
|       endif | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   " List item folding... | ||||
|   if g:vimwiki_fold_lists | ||||
|     let base_level = s:get_base_level(a:lnum) | ||||
|  | ||||
|     let rx_list_item = '\('. | ||||
|           \ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber. | ||||
|           \ '\)' | ||||
|  | ||||
|  | ||||
|     if line =~ rx_list_item | ||||
|       let [nnum, nline] = s:find_forward(rx_list_item, a:lnum) | ||||
|       let level = s:get_li_level(a:lnum) | ||||
|       let leveln = s:get_li_level(nnum) | ||||
|       let adj = s:get_li_level(s:get_start_list(rx_list_item, a:lnum)) | ||||
|  | ||||
|       if leveln > level | ||||
|         return ">".(base_level+leveln-adj) | ||||
|       else | ||||
|         return (base_level+level-adj) | ||||
|       endif | ||||
|     else | ||||
|       " process multilined list items | ||||
|       let [pnum, pline] = s:find_backward(rx_list_item, a:lnum) | ||||
|       if pline =~ rx_list_item | ||||
|         if indent(a:lnum) > indent(pnum) | ||||
|           let level = s:get_li_level(pnum) | ||||
|           let adj = s:get_li_level(s:get_start_list(rx_list_item, pnum)) | ||||
|  | ||||
|           let [nnum, nline] = s:find_forward(rx_list_item, a:lnum) | ||||
|           if nline =~ rx_list_item | ||||
|             let leveln = s:get_li_level(nnum) | ||||
|             if leveln > level | ||||
|               return (base_level+leveln-adj) | ||||
|             endif | ||||
|           endif | ||||
|  | ||||
|           return (base_level+level-adj) | ||||
|         endif | ||||
|       endif | ||||
|     endif | ||||
|  | ||||
|     return base_level | ||||
|   endif | ||||
|  | ||||
|   return -1 | ||||
| endfunction "}}} | ||||
|  | ||||
| function! s:get_base_level(lnum) "{{{ | ||||
|   let lnum = a:lnum - 1 | ||||
|   while lnum > 0 | ||||
|     if getline(lnum) =~ g:vimwiki_rxHeader | ||||
|       return vimwiki#count_first_sym(getline(lnum)) | ||||
|     endif | ||||
|     let lnum -= 1 | ||||
|   endwhile | ||||
|   return 0 | ||||
| endfunction "}}} | ||||
|  | ||||
| function! s:find_forward(rx_item, lnum) "{{{ | ||||
|   let lnum = a:lnum + 1 | ||||
|  | ||||
|   while lnum <= line('$') | ||||
|     let line = getline(lnum) | ||||
|     if line =~ a:rx_item | ||||
|           \ || line =~ '^\S' | ||||
|           \ || line =~ g:vimwiki_rxHeader | ||||
|       break | ||||
|     endif | ||||
|     let lnum += 1 | ||||
|   endwhile | ||||
|  | ||||
|   return [lnum, getline(lnum)] | ||||
| endfunction "}}} | ||||
|  | ||||
| function! s:find_backward(rx_item, lnum) "{{{ | ||||
|   let lnum = a:lnum - 1 | ||||
|  | ||||
|   while lnum > 1 | ||||
|     let line = getline(lnum) | ||||
|     if line =~ a:rx_item | ||||
|           \ || line =~ '^\S' | ||||
|       break | ||||
|     endif | ||||
|     let lnum -= 1 | ||||
|   endwhile | ||||
|  | ||||
|   return [lnum, getline(lnum)] | ||||
| endfunction "}}} | ||||
|  | ||||
| function! s:get_li_level(lnum) "{{{ | ||||
|   if VimwikiGet('syntax') == 'media' | ||||
|     let level = vimwiki#count_first_sym(getline(a:lnum)) | ||||
|   else | ||||
|     let level = (indent(a:lnum) / &sw) | ||||
|   endif | ||||
|   return level | ||||
| endfunction "}}} | ||||
|  | ||||
| function! s:get_start_list(rx_item, lnum) "{{{ | ||||
|   let lnum = a:lnum | ||||
|   while lnum >= 1 | ||||
|     let line = getline(lnum) | ||||
|     if line !~ a:rx_item && line =~ '^\S' | ||||
|       return nextnonblank(lnum + 1) | ||||
|     endif | ||||
|     let lnum -= 1 | ||||
|   endwhile | ||||
|   return 0 | ||||
| endfunction "}}} | ||||
|  | ||||
| function! VimwikiFoldText() "{{{ | ||||
|   let line = substitute(getline(v:foldstart), '\t', | ||||
|         \ repeat(' ', &tabstop), 'g') | ||||
|   return line.' ['.(v:foldend - v:foldstart).']' | ||||
| endfunction "}}} | ||||
|  | ||||
| " FOLDING }}} | ||||
|  | ||||
| " COMMANDS {{{ | ||||
| command! -buffer Vimwiki2HTML | ||||
|       \ call vimwiki_html#Wiki2HTML(expand(VimwikiGet('path_html')), | ||||
|       \                             expand('%')) | ||||
| command! -buffer VimwikiAll2HTML | ||||
|       \ call vimwiki_html#WikiAll2HTML(expand(VimwikiGet('path_html'))) | ||||
|  | ||||
| command! -buffer VimwikiNextWord call vimwiki#WikiNextWord() | ||||
| command! -buffer VimwikiPrevWord call vimwiki#WikiPrevWord() | ||||
| command! -buffer VimwikiDeleteWord call vimwiki#WikiDeleteWord() | ||||
| command! -buffer VimwikiRenameWord call vimwiki#WikiRenameWord() | ||||
| command! -buffer VimwikiFollowWord call vimwiki#WikiFollowWord('nosplit') | ||||
| command! -buffer VimwikiGoBackWord call vimwiki#WikiGoBackWord() | ||||
| command! -buffer VimwikiSplitWord call vimwiki#WikiFollowWord('split') | ||||
| command! -buffer VimwikiVSplitWord call vimwiki#WikiFollowWord('vsplit') | ||||
|  | ||||
| command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(<line1>, <line2>) | ||||
|  | ||||
| exe 'command! -buffer -nargs=* VimwikiSearch vimgrep <args> '. | ||||
|       \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') | ||||
|  | ||||
| exe 'command! -buffer -nargs=* VWS vimgrep <args> '. | ||||
|       \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') | ||||
|  | ||||
| " COMMANDS }}} | ||||
|  | ||||
| " KEYBINDINGS {{{ | ||||
| if g:vimwiki_use_mouse | ||||
|   nmap <buffer> <S-LeftMouse> <NOP> | ||||
|   nmap <buffer> <C-LeftMouse> <NOP> | ||||
|   noremap <silent><buffer> <2-LeftMouse> :VimwikiFollowWord<CR> | ||||
|   noremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitWord<CR> | ||||
|   noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitWord<CR> | ||||
|   noremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackWord<CR> | ||||
| endif | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiFollowWord') | ||||
|   nmap <silent><buffer> <CR> <Plug>VimwikiFollowWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiFollowWord :VimwikiFollowWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiSplitWord') | ||||
|   nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiSplitWord :VimwikiSplitWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiVSplitWord') | ||||
|   nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiVSplitWord :VimwikiVSplitWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiGoBackWord') | ||||
|   nmap <silent><buffer> <BS> <Plug>VimwikiGoBackWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiGoBackWord :VimwikiGoBackWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiNextWord') | ||||
|   nmap <silent><buffer> <TAB> <Plug>VimwikiNextWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiNextWord :VimwikiNextWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiPrevWord') | ||||
|   nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiPrevWord :VimwikiPrevWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiDeleteWord') | ||||
|   nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiDeleteWord :VimwikiDeleteWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiRenameWord') | ||||
|   nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameWord | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiRenameWord :VimwikiRenameWord<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiToggleListItem') | ||||
|   nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem | ||||
|   vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem | ||||
|   if has("unix") | ||||
|     nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem | ||||
|   endif | ||||
| endif | ||||
| noremap <silent><script><buffer> | ||||
|       \ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR> | ||||
|  | ||||
|  | ||||
| " Text objects {{{ | ||||
| omap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 0)<CR> | ||||
| vmap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 1)<CR> | ||||
|  | ||||
| omap <silent><buffer> ih :<C-U>call vimwiki#TO_header(1, 0)<CR> | ||||
| vmap <silent><buffer> ih :<C-U>call vimwiki#TO_header(1, 1)<CR> | ||||
|  | ||||
| nmap <silent><buffer> = :call vimwiki#AddHeaderLevel()<CR> | ||||
| nmap <silent><buffer> - :call vimwiki#RemoveHeaderLevel()<CR> | ||||
|  | ||||
| " }}} | ||||
|  | ||||
| " KEYBINDINGS }}} | ||||
		Reference in New Issue
	
	Block a user