Cherry-pick the changes from dev -- part3
This commit is contained in:
		
							
								
								
									
										11
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								README.md
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ A Personal Wiki For Vim | ||||
| ============================================================================== | ||||
|  | ||||
|  | ||||
|  | ||||
|  * | ||||
|  | ||||
| Intro | ||||
| ------------------------------------------------------------------------------ | ||||
| @@ -122,6 +122,11 @@ Make sure you have these settings in your vimrc file: | ||||
| Without them Vimwiki will not work properly. | ||||
|  | ||||
|  | ||||
| Installation using [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528) | ||||
| ------------------------------------------------------------------------------ | ||||
|  | ||||
|     git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki | ||||
|  | ||||
| Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) | ||||
| ------------------------------------------------------------------------------ | ||||
|  | ||||
| @@ -140,3 +145,7 @@ Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run | ||||
| Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it in `~/.vim/bundle/` | ||||
|  | ||||
| Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed. | ||||
|  | ||||
| ---- | ||||
| \* Screenshots made with the [solarized colorscheme](https://github.com/altercation/vim-colors-solarized) | ||||
| and [lightline](https://github.com/itchyny/lightline.vim) | ||||
|   | ||||
| @@ -42,7 +42,7 @@ function! s:get_position_links(link) "{{{ | ||||
|   let idx = -1 | ||||
|   let links = [] | ||||
|   if a:link =~# '^\d\{4}-\d\d-\d\d' | ||||
|     let links = keys(s:get_diary_links()) | ||||
|     let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")') | ||||
|     " include 'today' into links | ||||
|     if index(links, vimwiki#diary#diary_date_link()) == -1 | ||||
|       call add(links, vimwiki#diary#diary_date_link()) | ||||
| @@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{ | ||||
|   return result | ||||
| endfun "}}} | ||||
|  | ||||
| fun! s:get_diary_links() "{{{ | ||||
| fun! s:get_diary_files() "{{{ | ||||
|   let rx = '^\d\{4}-\d\d-\d\d' | ||||
|   let s_files = glob(vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext')) | ||||
|   let files = split(s_files, '\n') | ||||
| @@ -92,9 +92,7 @@ fun! s:get_diary_links() "{{{ | ||||
|   " remove backup files (.wiki~) | ||||
|   call filter(files, 'v:val !~# ''.*\~$''') | ||||
|  | ||||
|   let links_with_captions = s:read_captions(files) | ||||
|  | ||||
|   return links_with_captions | ||||
|   return files | ||||
| endfun "}}} | ||||
|  | ||||
| fun! s:group_links(links) "{{{ | ||||
| @@ -129,7 +127,9 @@ endfunction "}}} | ||||
| function! s:format_diary() "{{{ | ||||
|   let result = [] | ||||
|  | ||||
|   let g_files = s:group_links(s:get_diary_links()) | ||||
|  | ||||
|   let links_with_captions = s:read_captions(s:get_diary_files()) | ||||
|   let g_files = s:group_links(links_with_captions) | ||||
|  | ||||
|   for year in s:sort(keys(g_files)) | ||||
|     call add(result, '') | ||||
|   | ||||
| @@ -209,6 +209,19 @@ function! s:save_vimwiki_buffer() "{{{ | ||||
|   endif | ||||
| endfunction "}}} | ||||
|  | ||||
| " get date. | ||||
| function! s:process_date(placeholders, default_date) "{{{ | ||||
|   if !empty(a:placeholders) | ||||
|     for [placeholder, row, idx] in a:placeholders | ||||
|       let [type, param] = placeholder | ||||
|       if type ==# 'date' && !empty(param) | ||||
|         return param | ||||
|       endif | ||||
|     endfor | ||||
|   endif | ||||
|   return a:default_date | ||||
| endfunction "}}} | ||||
|  | ||||
| " get title. | ||||
| function! s:process_title(placeholders, default_title) "{{{ | ||||
|   if !empty(a:placeholders) | ||||
| @@ -1190,7 +1203,7 @@ function! s:parse_line(line, state) " {{{ | ||||
|  | ||||
|   " nohtml -- placeholder | ||||
|   if !processed | ||||
|     if line =~# '^\s*%nohtml' | ||||
|     if line =~# '\m^\s*%nohtml\s*$' | ||||
|       let processed = 1 | ||||
|       let state.placeholder = ['nohtml'] | ||||
|     endif | ||||
| @@ -1198,18 +1211,27 @@ function! s:parse_line(line, state) " {{{ | ||||
|  | ||||
|   " title -- placeholder | ||||
|   if !processed | ||||
|     if line =~# '^\s*%title' | ||||
|     if line =~# '\m^\s*%title\%(\s.*\)\?$' | ||||
|       let processed = 1 | ||||
|       let param = matchstr(line, '^\s*%title\s\zs.*') | ||||
|       let param = matchstr(line, '\m^\s*%title\s\+\zs.*') | ||||
|       let state.placeholder = ['title', param] | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   " date -- placeholder | ||||
|   if !processed | ||||
|     if line =~# '\m^\s*%date\%(\s.*\)\?$' | ||||
|       let processed = 1 | ||||
|       let param = matchstr(line, '\m^\s*%date\s\+\zs.*') | ||||
|       let state.placeholder = ['date', param] | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   " html template -- placeholder "{{{ | ||||
|   if !processed | ||||
|     if line =~# '^\s*%template' | ||||
|     if line =~# '\m^\s*%template\%(\s.*\)\?$' | ||||
|       let processed = 1 | ||||
|       let param = matchstr(line, '^\s*%template\s\zs.*') | ||||
|       let param = matchstr(line, '\m^\s*%template\s\+\zs.*') | ||||
|       let state.placeholder = ['template', param] | ||||
|     endif | ||||
|   endif | ||||
| @@ -1483,11 +1505,13 @@ function! s:convert_file(path_html, wikifile) "{{{ | ||||
|     call extend(ldest, lines) | ||||
|  | ||||
|     let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) | ||||
|     let date = s:process_date(placeholders, strftime('%Y-%m-%d')) | ||||
|  | ||||
|     let html_lines = s:get_html_template(template_name) | ||||
|  | ||||
|     " processing template variables (refactor to a function) | ||||
|     call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")') | ||||
|     call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")') | ||||
|     call map(html_lines, 'substitute(v:val, "%root_path%", "'. | ||||
|           \ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")') | ||||
|  | ||||
|   | ||||
| @@ -123,7 +123,7 @@ function! s:normalize_link_syntax_v() " {{{ | ||||
|     call setreg('"', link, 'v') | ||||
|  | ||||
|     " paste result | ||||
|     norm! `>pgvd | ||||
|     norm! `>""pgvd | ||||
|  | ||||
|   finally | ||||
|     call setreg('"', rv, rt) | ||||
|   | ||||
| @@ -77,7 +77,7 @@ function! s:populate_global_variables() | ||||
|   let g:vimwiki_global_vars.schemes = 'wiki\d\+,diary,local' | ||||
|   let g:vimwiki_global_vars.web_schemes1 = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'. | ||||
|         \ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp' | ||||
|   let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel' | ||||
|   let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel,data' | ||||
|  | ||||
|   let rx_schemes = '\%('. | ||||
|         \ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'. | ||||
|   | ||||
| @@ -742,8 +742,9 @@ Vimwiki file. | ||||
|  | ||||
| *:VimwikiGenerateTags* tagname1 tagname2 ... | ||||
|     Creates or updates an overview on all tags of the wiki with links to all | ||||
|     their instances.  Supports |cmdline-completion|.  If | ||||
|     no arguments (tags) are specified, outputs all tags. | ||||
|     their instances.  Supports |cmdline-completion|.  If no arguments (tags) | ||||
|     are specified, outputs all tags.  To make this command work properly, make | ||||
|     sure the tags have been built (see |vimwiki-build-tags|). | ||||
|  | ||||
| ------------------------------------------------------------------------------ | ||||
| 4.3. Functions                                              *vimwiki-functions* | ||||
| @@ -755,9 +756,10 @@ Warning: this is currently unstable and likely to change. | ||||
|  | ||||
| To map them to a key, use > | ||||
|  nnoremap <C-K> :call vimwiki#base#function_name(arg1, arg2)<CR> | ||||
| < | ||||
|  | ||||
|  | ||||
| vimwiki#base#follow_link({split}, {reuse}, {move_cursor})         *follow_link* | ||||
|                                                           *vimwiki-follow_link* | ||||
| vimwiki#base#follow_link({split}, {reuse}, {move_cursor}) | ||||
|     Open the link under the cursor. {split} can have the following values: | ||||
|         'nosplit'       open the link in the current window | ||||
|         'vsplit'        open in a vertically split window | ||||
| @@ -1171,7 +1173,8 @@ This might be useful for coloring program code with external JS tools | ||||
| such as Google's syntax highlighter. | ||||
|  | ||||
| You can setup Vimwiki to highlight code snippets in preformatted text. | ||||
| See |vimwiki-option-nested_syntaxes| | ||||
| See |vimwiki-option-nested_syntaxes| and | ||||
| |vimwiki-option-automatic_nested_syntaxes|. | ||||
|  | ||||
|  | ||||
| ------------------------------------------------------------------------------ | ||||
| @@ -1291,8 +1294,9 @@ which opens up a popup menu with all tags defined in the wiki starting with | ||||
|  | ||||
| Tags are also treated as |vimwiki-anchors| (similar to bold text). | ||||
|  | ||||
| Note that tag search/jump/completion commands need certain metadata saved in | ||||
| the wiki folder.  This metadata file can be manually updated by running | ||||
|                                                           *vimwiki-build-tags* | ||||
| Note that the tag search/jump/completion commands need certain metadata saved | ||||
| in the wiki folder.  This metadata file can be manually updated by running | ||||
| |:VimwikiRebuildTags|.  When the option |vimwiki-option-auto_tags| is enabled, | ||||
| the tags metadata will be auto-updated on each page save. | ||||
|  | ||||
| @@ -1391,6 +1395,18 @@ into it. | ||||
|  | ||||
| See |vimwiki-option-template_path| for details. | ||||
|  | ||||
| ------------------------------------------------------------------------------ | ||||
| %date                                                           *vimwiki-date* | ||||
|  | ||||
| The date of the wiki page. The value can be used in the HTML template, see | ||||
| |vimwiki-option-template_path| for details. | ||||
|  | ||||
| %date 2017-07-08 | ||||
| %date | ||||
|  | ||||
| If you omit the date after the placeholder, the date of the HTML conversion is | ||||
| used. | ||||
|  | ||||
|  | ||||
| ============================================================================== | ||||
| 8. Lists                                                       *vimwiki-lists* | ||||
| @@ -1942,11 +1958,13 @@ Each template could look like: > | ||||
|         <div class="content"> | ||||
|         %content% | ||||
|         </div> | ||||
|         <p><small>Page created on %date%</small></p> | ||||
|     </body> | ||||
|     </html> | ||||
|  | ||||
| where | ||||
|   %title% is replaced by a wiki page name or by a |vimwiki-title| | ||||
|   %date% is replaced with the current date or by |vimwiki-date| | ||||
|   %root_path% is replaced by a count of ../ for pages buried in subdirs: | ||||
|     if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then | ||||
|     %root_path% is replaced by '../../../'. | ||||
| @@ -2067,7 +2085,9 @@ Just write your preformatted text in your file like this > | ||||
|  my preformatted text | ||||
|  }}} | ||||
|  | ||||
| where xxx is a Vim filetype. | ||||
| where xxx is a filetype which is known to Vim. For example, for C++ | ||||
| highlighting, use "cpp" (not "c++"). For a list of known filetypes, type | ||||
| ":setf " and hit Ctrl+d. | ||||
|  | ||||
| Note that you may have to reload the file (|:edit|) to see the highlight. | ||||
|  | ||||
| @@ -2316,6 +2336,8 @@ Value           Description~ | ||||
| 'expr'          Folding based on expression (folds sections and code blocks) | ||||
| 'syntax'        Folding based on syntax (folds sections; slower than 'expr') | ||||
| 'list'          Folding based on expression (folds list subitems; much slower) | ||||
| 'custom'        Leave the folding settings as they are (e.g. set by another | ||||
|                 plugin) | ||||
|  | ||||
| Default: '' | ||||
|  | ||||
|   | ||||
| @@ -473,8 +473,8 @@ if !hasmapto('<Plug>VimwikiListToggle', 'i') | ||||
| endif | ||||
| inoremap <silent><script><buffer> <Plug>VimwikiListToggle <Esc>:VimwikiListToggle<CR> | ||||
|  | ||||
| nnoremap <silent> <buffer> o :call vimwiki#lst#kbd_o()<CR> | ||||
| nnoremap <silent> <buffer> O :call vimwiki#lst#kbd_O()<CR> | ||||
| nnoremap <silent> <buffer> o :<C-U>call vimwiki#lst#kbd_o()<CR> | ||||
| nnoremap <silent> <buffer> O :<C-U>call vimwiki#lst#kbd_O()<CR> | ||||
|  | ||||
| if !hasmapto('<Plug>VimwikiRenumberList') | ||||
|   nmap <silent><buffer> glr <Plug>VimwikiRenumberList | ||||
|   | ||||
| @@ -155,6 +155,8 @@ function! s:set_windowlocal_options() | ||||
|   elseif foldmethod ==? 'syntax' | ||||
|     setlocal foldmethod=syntax | ||||
|     setlocal foldtext=VimwikiFoldText() | ||||
|   elseif foldmethod ==? 'custom' | ||||
|     " do nothing | ||||
|   else | ||||
|     setlocal foldmethod=manual | ||||
|     normal! zE | ||||
|   | ||||
| @@ -282,9 +282,10 @@ execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMath | ||||
|  | ||||
| " placeholders | ||||
| syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/ | ||||
| syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam | ||||
| syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam | ||||
| syntax match VimwikiPlaceholderParam /\s.*/ contained | ||||
| syntax match VimwikiPlaceholder /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite | ||||
| syntax match VimwikiPlaceholder /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite | ||||
| syntax match VimwikiPlaceholder /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite | ||||
| syntax match VimwikiPlaceholderParam /.*/ contained | ||||
|  | ||||
| " html tags | ||||
| if vimwiki#vars#get_global('valid_html_tags') != '' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user