Cherry-pick the changes from dev -- part3

This commit is contained in:
EinfachToll 2018-02-16 18:11:49 +01:00
parent 7d4254a75d
commit 73bda6b9ab
9 changed files with 85 additions and 27 deletions

View File

@ -2,7 +2,7 @@ A Personal Wiki For Vim
============================================================================== ==============================================================================
![screenshot1](doc/screenshot_1.png) ![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) ![screenshot2](doc/screenshot_2.png) *
Intro Intro
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -122,6 +122,11 @@ Make sure you have these settings in your vimrc file:
Without them Vimwiki will not work properly. 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) 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/` 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. 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)

View File

@ -42,7 +42,7 @@ function! s:get_position_links(link) "{{{
let idx = -1 let idx = -1
let links = [] let links = []
if a:link =~# '^\d\{4}-\d\d-\d\d' 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 " include 'today' into links
if index(links, vimwiki#diary#diary_date_link()) == -1 if index(links, vimwiki#diary#diary_date_link()) == -1
call add(links, vimwiki#diary#diary_date_link()) call add(links, vimwiki#diary#diary_date_link())
@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{
return result return result
endfun "}}} endfun "}}}
fun! s:get_diary_links() "{{{ fun! s:get_diary_files() "{{{
let rx = '^\d\{4}-\d\d-\d\d' 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 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') let files = split(s_files, '\n')
@ -92,9 +92,7 @@ fun! s:get_diary_links() "{{{
" remove backup files (.wiki~) " remove backup files (.wiki~)
call filter(files, 'v:val !~# ''.*\~$''') call filter(files, 'v:val !~# ''.*\~$''')
let links_with_captions = s:read_captions(files) return files
return links_with_captions
endfun "}}} endfun "}}}
fun! s:group_links(links) "{{{ fun! s:group_links(links) "{{{
@ -129,7 +127,9 @@ endfunction "}}}
function! s:format_diary() "{{{ function! s:format_diary() "{{{
let result = [] 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)) for year in s:sort(keys(g_files))
call add(result, '') call add(result, '')

View File

@ -209,6 +209,19 @@ function! s:save_vimwiki_buffer() "{{{
endif endif
endfunction "}}} 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. " get title.
function! s:process_title(placeholders, default_title) "{{{ function! s:process_title(placeholders, default_title) "{{{
if !empty(a:placeholders) if !empty(a:placeholders)
@ -1190,7 +1203,7 @@ function! s:parse_line(line, state) " {{{
" nohtml -- placeholder " nohtml -- placeholder
if !processed if !processed
if line =~# '^\s*%nohtml' if line =~# '\m^\s*%nohtml\s*$'
let processed = 1 let processed = 1
let state.placeholder = ['nohtml'] let state.placeholder = ['nohtml']
endif endif
@ -1198,18 +1211,27 @@ function! s:parse_line(line, state) " {{{
" title -- placeholder " title -- placeholder
if !processed if !processed
if line =~# '^\s*%title' if line =~# '\m^\s*%title\%(\s.*\)\?$'
let processed = 1 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] let state.placeholder = ['title', param]
endif endif
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 "{{{ " html template -- placeholder "{{{
if !processed if !processed
if line =~# '^\s*%template' if line =~# '\m^\s*%template\%(\s.*\)\?$'
let processed = 1 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] let state.placeholder = ['template', param]
endif endif
endif endif
@ -1483,11 +1505,13 @@ function! s:convert_file(path_html, wikifile) "{{{
call extend(ldest, lines) call extend(ldest, lines)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) 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) let html_lines = s:get_html_template(template_name)
" processing template variables (refactor to a function) " processing template variables (refactor to a function)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")') 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%", "'. call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")') \ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')

View File

@ -123,7 +123,7 @@ function! s:normalize_link_syntax_v() " {{{
call setreg('"', link, 'v') call setreg('"', link, 'v')
" paste result " paste result
norm! `>pgvd norm! `>""pgvd
finally finally
call setreg('"', rv, rt) call setreg('"', rv, rt)

View File

@ -77,7 +77,7 @@ function! s:populate_global_variables()
let g:vimwiki_global_vars.schemes = 'wiki\d\+,diary,local' 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'. 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' \ ',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 = '\%('. let rx_schemes = '\%('.
\ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'. \ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'.

View File

@ -742,8 +742,9 @@ Vimwiki file.
*:VimwikiGenerateTags* tagname1 tagname2 ... *:VimwikiGenerateTags* tagname1 tagname2 ...
Creates or updates an overview on all tags of the wiki with links to all Creates or updates an overview on all tags of the wiki with links to all
their instances. Supports |cmdline-completion|. If their instances. Supports |cmdline-completion|. If no arguments (tags)
no arguments (tags) are specified, outputs all 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* 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 > To map them to a key, use >
nnoremap <C-K> :call vimwiki#base#function_name(arg1, arg2)<CR> nnoremap <C-K> :call vimwiki#base#function_name(arg1, arg2)<CR>
<
*vimwiki-follow_link*
vimwiki#base#follow_link({split}, {reuse}, {move_cursor}) *follow_link* vimwiki#base#follow_link({split}, {reuse}, {move_cursor})
Open the link under the cursor. {split} can have the following values: Open the link under the cursor. {split} can have the following values:
'nosplit' open the link in the current window 'nosplit' open the link in the current window
'vsplit' open in a vertically split 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. such as Google's syntax highlighter.
You can setup Vimwiki to highlight code snippets in preformatted text. 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). Tags are also treated as |vimwiki-anchors| (similar to bold text).
Note that tag search/jump/completion commands need certain metadata saved in *vimwiki-build-tags*
the wiki folder. This metadata file can be manually updated by running 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, |:VimwikiRebuildTags|. When the option |vimwiki-option-auto_tags| is enabled,
the tags metadata will be auto-updated on each page save. the tags metadata will be auto-updated on each page save.
@ -1391,6 +1395,18 @@ into it.
See |vimwiki-option-template_path| for details. 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* 8. Lists *vimwiki-lists*
@ -1942,11 +1958,13 @@ Each template could look like: >
<div class="content"> <div class="content">
%content% %content%
</div> </div>
<p><small>Page created on %date%</small></p>
</body> </body>
</html> </html>
where where
%title% is replaced by a wiki page name or by a |vimwiki-title| %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: %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 if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
%root_path% is replaced by '../../../'. %root_path% is replaced by '../../../'.
@ -2067,7 +2085,9 @@ Just write your preformatted text in your file like this >
my preformatted text 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. 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) 'expr' Folding based on expression (folds sections and code blocks)
'syntax' Folding based on syntax (folds sections; slower than 'expr') 'syntax' Folding based on syntax (folds sections; slower than 'expr')
'list' Folding based on expression (folds list subitems; much slower) '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: '' Default: ''

View File

@ -473,8 +473,8 @@ if !hasmapto('<Plug>VimwikiListToggle', 'i')
endif endif
inoremap <silent><script><buffer> <Plug>VimwikiListToggle <Esc>:VimwikiListToggle<CR> inoremap <silent><script><buffer> <Plug>VimwikiListToggle <Esc>:VimwikiListToggle<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 :call vimwiki#lst#kbd_O()<CR> nnoremap <silent> <buffer> O :<C-U>call vimwiki#lst#kbd_O()<CR>
if !hasmapto('<Plug>VimwikiRenumberList') if !hasmapto('<Plug>VimwikiRenumberList')
nmap <silent><buffer> glr <Plug>VimwikiRenumberList nmap <silent><buffer> glr <Plug>VimwikiRenumberList

View File

@ -155,6 +155,8 @@ function! s:set_windowlocal_options()
elseif foldmethod ==? 'syntax' elseif foldmethod ==? 'syntax'
setlocal foldmethod=syntax setlocal foldmethod=syntax
setlocal foldtext=VimwikiFoldText() setlocal foldtext=VimwikiFoldText()
elseif foldmethod ==? 'custom'
" do nothing
else else
setlocal foldmethod=manual setlocal foldmethod=manual
normal! zE normal! zE

View File

@ -282,9 +282,10 @@ execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMath
" placeholders " placeholders
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/ syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam syntax match VimwikiPlaceholder /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam syntax match VimwikiPlaceholder /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholderParam /\s.*/ contained syntax match VimwikiPlaceholder /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholderParam /.*/ contained
" html tags " html tags
if vimwiki#vars#get_global('valid_html_tags') != '' if vimwiki#vars#get_global('valid_html_tags') != ''