From f88877376732804ad9ed3adcccfb83302c21bd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sat, 15 Jul 2017 23:35:48 +0200 Subject: [PATCH 01/22] New feature reject a item form todo-list Based on patches of davidlmontgomery. --- autoload/vimwiki/lst.vim | 56 +++++++++++++++++++++++++++++++++++-- ftplugin/vimwiki.vim | 1 + plugin/vimwiki.vim | 1 + syntax/vimwiki_default.vim | 2 +- syntax/vimwiki_markdown.vim | 2 +- syntax/vimwiki_media.vim | 2 +- 6 files changed, 59 insertions(+), 5 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index adaee22..a94373c 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -693,6 +693,9 @@ function! s:get_rate(item) "{{{ return -1 endif let state = a:item.cb + if state == g:vimwiki_listsym_rejected + return -1 + endif let n=len(g:vimwiki_listsyms_list) return index(g:vimwiki_listsyms_list, state) * 100/(n-1) endfunction "}}} @@ -735,6 +738,8 @@ function! s:rate_to_state(rate) "{{{ let state = g:vimwiki_listsyms_list[n-1] elseif a:rate == 0 let state = g:vimwiki_listsyms_list[0] + elseif a:rate == -1 + let state = g:vimwiki_listsym_rejected else let index = float2nr(ceil(a:rate/100.0*(n-2))) let state = g:vimwiki_listsyms_list[index] @@ -759,8 +764,11 @@ function! s:update_state(item) "{{{ break endif if child_item.cb != '' - let count_children_with_cb += 1 - let sum_children_rate += s:get_rate(child_item) + let rate = s:get_rate(child_item) + if rate != -1 + let count_children_with_cb += 1 + let sum_children_rate += rate + endif endif let child_item = s:get_next_child_item(a:item, child_item) endwhile @@ -909,6 +917,46 @@ function! vimwiki#lst#toggle_cb(from_line, to_line) "{{{ endfunction "}}} +"Toggles checkbox between [ ] and [-] or creates one +"in the lines of the given range +function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) "{{{ + let from_item = s:get_corresponding_item(a:from_line) + if from_item.type == 0 + return + endif + + if from_item.cb == '' + + "if from_line has no CB, make a CB in every selected line + let parent_items_of_lines = [] + for cur_ln in range(from_item.lnum, a:to_line) + let cur_item = s:get_item(cur_ln) + let success = s:create_cb(cur_item) + + if success + let cur_parent_item = s:get_parent(cur_item) + if index(parent_items_of_lines, cur_parent_item) == -1 + call insert(parent_items_of_lines, cur_parent_item) + endif + endif + endfor + + for parent_item in parent_items_of_lines + call s:update_state(parent_item) + endfor + + else + + "if from_line has CB, toggle it and set all siblings to the same new state + let rate_first_line = s:get_rate(from_item) + let new_rate = rate_first_line == -1 ? 0 : -1 + + call s:change_cb(a:from_line, a:to_line, new_rate) + + endif + +endfunction "}}} + function! vimwiki#lst#remove_cb(first_line, last_line) "{{{ let first_item = s:get_corresponding_item(a:first_line) let last_item = s:get_corresponding_item(a:last_line) @@ -1549,6 +1597,10 @@ function! vimwiki#lst#setup_marker_infos() "{{{ "the user can set the listsyms as string, but vimwiki needs a list let g:vimwiki_listsyms_list = split(g:vimwiki_listsyms, '\zs') + + if match(g:vimwiki_listsyms, g:vimwiki_listsym_rejected) != -1 + echomsg "Warning: g:vimwiki_listsyms and g:vimwiki_listsym_rejected overlap" + endif endfunction "}}} function! vimwiki#lst#TO_list_item(inner, visual) "{{{ diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index a2d6d3e..f2ad61f 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -295,6 +295,7 @@ command! -buffer -range -nargs=1 VimwikiChangeSymbolTo call vimwiki#lst#change_m command! -buffer -range -nargs=1 VimwikiListChangeSymbolI call vimwiki#lst#change_marker(, , , 'i') command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call vimwiki#lst#change_marker_in_list() command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(, ) +command! -buffer -range VimwikiToggleListItemRejected call vimwiki#lst#toggle_rejected_cb(, ) command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(, ) command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(, ) command! -buffer -range -nargs=+ VimwikiListChangeLvl call vimwiki#lst#change_level(, , ) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index e31c734..c7c90a4 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -373,6 +373,7 @@ call s:default('hl_cb_checked', 0) call s:default('list_ignore_newline', 1) call s:default('text_ignore_newline', 1) call s:default('listsyms', ' .oOX') +call s:default('listsym_rejected', '-') call s:default('use_calendar', 1) call s:default('table_mappings', 1) call s:default('table_auto_fmt', 1) diff --git a/syntax/vimwiki_default.vim b/syntax/vimwiki_default.vim index a90ea20..173c54a 100644 --- a/syntax/vimwiki_default.vim +++ b/syntax/vimwiki_default.vim @@ -79,7 +79,7 @@ let g:vimwiki_rxListDefine = '::\(\s\|$\)' call vimwiki#lst#setup_marker_infos() let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' -let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?' +let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.g:vimwiki_listsym_rejected.']\)\]\s\)\?' let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text diff --git a/syntax/vimwiki_markdown.vim b/syntax/vimwiki_markdown.vim index 3ae9da0..647cad9 100644 --- a/syntax/vimwiki_markdown.vim +++ b/syntax/vimwiki_markdown.vim @@ -76,7 +76,7 @@ let g:vimwiki_rxListDefine = '::\%(\s\|$\)' call vimwiki#lst#setup_marker_infos() let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' -let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?' +let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.g:vimwiki_listsym_rejected.']\)\]\s\)\?' let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text diff --git a/syntax/vimwiki_media.vim b/syntax/vimwiki_media.vim index a6f8e4a..814d934 100644 --- a/syntax/vimwiki_media.vim +++ b/syntax/vimwiki_media.vim @@ -57,7 +57,7 @@ let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' call vimwiki#lst#setup_marker_infos() let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' -let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?' +let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.g:vimwiki_listsym_rejected.']\)\]\s\)\?' let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*' " Preformatted text From 6b9df766bb9c677894172539f52010dbf4f98566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sat, 5 Aug 2017 14:50:58 +0200 Subject: [PATCH 02/22] Remove duplicated code --- autoload/vimwiki/lst.vim | 112 +++++++++++++++------------------------ 1 file changed, 42 insertions(+), 70 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index a94373c..f73fad3 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -843,6 +843,46 @@ function! s:change_cb(from_line, to_line, new_rate) "{{{ endfunction "}}} +"Toggles checkbox between two states in the lines of the given range, +"creates chceckboxes if there aren't any. +function! s:toggle_create_cb(from_line, to_line, state1, state2) "{{{ + let from_item = s:get_corresponding_item(a:from_line) + if from_item.type == 0 + return + endif + + if from_item.cb == '' + + "if from_line has no CB, make a CB in every selected line + let parent_items_of_lines = [] + for cur_ln in range(from_item.lnum, a:to_line) + let cur_item = s:get_item(cur_ln) + let success = s:create_cb(cur_item) + + if success + let cur_parent_item = s:get_parent(cur_item) + if index(parent_items_of_lines, cur_parent_item) == -1 + call insert(parent_items_of_lines, cur_parent_item) + endif + endif + endfor + + for parent_item in parent_items_of_lines + call s:update_state(parent_item) + endfor + + else + + "if from_line has CB, toggle it and set all siblings to the same new state + let rate_first_line = s:get_rate(from_item) + let new_rate = rate_first_line == a:state1 ? a:state2 : a:state1 + + call s:change_cb(a:from_line, a:to_line, new_rate) + + endif + +endfunction "}}} + "Decrement checkbox between [ ] and [X] "in the lines of the given range function! vimwiki#lst#decrement_cb(from_line, to_line) "{{{ @@ -880,81 +920,13 @@ endfunction "}}} "Toggles checkbox between [ ] and [X] or creates one "in the lines of the given range function! vimwiki#lst#toggle_cb(from_line, to_line) "{{{ - let from_item = s:get_corresponding_item(a:from_line) - if from_item.type == 0 - return - endif - - if from_item.cb == '' - - "if from_line has no CB, make a CB in every selected line - let parent_items_of_lines = [] - for cur_ln in range(from_item.lnum, a:to_line) - let cur_item = s:get_item(cur_ln) - let success = s:create_cb(cur_item) - - if success - let cur_parent_item = s:get_parent(cur_item) - if index(parent_items_of_lines, cur_parent_item) == -1 - call insert(parent_items_of_lines, cur_parent_item) - endif - endif - endfor - - for parent_item in parent_items_of_lines - call s:update_state(parent_item) - endfor - - else - - "if from_line has CB, toggle it and set all siblings to the same new state - let rate_first_line = s:get_rate(from_item) - let new_rate = rate_first_line == 100 ? 0 : 100 - - call s:change_cb(a:from_line, a:to_line, new_rate) - - endif - + return s:toggle_create_cb(a:from_line, a:to_line, 100, 0) endfunction "}}} "Toggles checkbox between [ ] and [-] or creates one "in the lines of the given range function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) "{{{ - let from_item = s:get_corresponding_item(a:from_line) - if from_item.type == 0 - return - endif - - if from_item.cb == '' - - "if from_line has no CB, make a CB in every selected line - let parent_items_of_lines = [] - for cur_ln in range(from_item.lnum, a:to_line) - let cur_item = s:get_item(cur_ln) - let success = s:create_cb(cur_item) - - if success - let cur_parent_item = s:get_parent(cur_item) - if index(parent_items_of_lines, cur_parent_item) == -1 - call insert(parent_items_of_lines, cur_parent_item) - endif - endif - endfor - - for parent_item in parent_items_of_lines - call s:update_state(parent_item) - endfor - - else - - "if from_line has CB, toggle it and set all siblings to the same new state - let rate_first_line = s:get_rate(from_item) - let new_rate = rate_first_line == -1 ? 0 : -1 - - call s:change_cb(a:from_line, a:to_line, new_rate) - - endif - + return s:toggle_create_cb(a:from_line, a:to_line, -1, 0) endfunction "}}} function! vimwiki#lst#remove_cb(first_line, last_line) "{{{ From f917b01998d59e7b168e193a9fdb9a1b7dafebc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sat, 5 Aug 2017 00:20:37 +0200 Subject: [PATCH 03/22] Html-export: Add support of rejected Todo-listentry --- autoload/vimwiki/html.vim | 2 ++ autoload/vimwiki/style.css | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 0d52271..88f186b 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -876,6 +876,8 @@ function! s:process_tag_list(line, lists) "{{{ let n = len(g:vimwiki_listsyms_list) if completion == 0 let st_tag = '
  • ' + elseif completion == -1 && chk[1] == g:vimwiki_listsym_rejected + let st_tag = '
  • ' elseif completion > 0 && completion < n let completion = float2nr(round(completion / (n-1.0) * 3.0 + 0.5 )) let st_tag = '
  • ' diff --git a/autoload/vimwiki/style.css b/autoload/vimwiki/style.css index da2518c..431d15b 100644 --- a/autoload/vimwiki/style.css +++ b/autoload/vimwiki/style.css @@ -27,6 +27,13 @@ del {text-decoration: line-through; color: #777777;} .tag {background-color: #eeeeee; font-family: monospace; padding: 2px;} /* classes for items of todo lists */ +.rejected { + /* list-style: none; */ + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAAACXBIWXMAAADFAAAAxQEdzbqoAAAAB3RJTUUH4QgEFhAtuWgv9wAAAPZQTFRFmpqam5iYnJaWnJeXnpSUn5OTopCQpoqKpouLp4iIqIiIrYCAt3V1vW1tv2xsmZmZmpeXnpKS/x4e/x8f/yAg/yIi/yQk/yUl/yYm/ygo/ykp/yws/zAw/zIy/zMz/zQ0/zU1/zY2/zw8/0BA/0ZG/0pK/1FR/1JS/1NT/1RU/1VV/1ZW/1dX/1pa/15e/19f/2Zm/2lp/21t/25u/3R0/3p6/4CA/4GB/4SE/4iI/46O/4+P/52d/6am/6ur/66u/7Oz/7S0/7e3/87O/9fX/9zc/93d/+Dg/+vr/+3t/+/v//Dw//Ly//X1//f3//n5//z8////gzaKowAAAA90Uk5T/Pz8/Pz8/Pz8/Pz8/f39ppQKWQAAAAFiS0dEEnu8bAAAAACuSURBVAhbPY9ZF4FQFEZPSKbIMmWep4gMGTKLkIv6/3/GPbfF97b3w17rA0kQOPgvAeHW6uJ6+5h7HqLdwowgOzejXRXBdx6UdSru216xuOMBHHNU0clTzeSUA6EhF8V8kqroluMiU6HKcuf4phGPr1o2q9kYZWwNq1qfRRmTaXpqsyjj17KkWCxKBUBgXWueHIyiAIg18gsse4KHkLF5IKIY10WQgv7fOy4ST34BRiopZ8WLNrgAAAAASUVORK5CYII=); + background-repeat: no-repeat; + background-position: 0 .2em; + padding-left: 1.5em; +} .done0 { /* list-style: none; */ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==); From 013603930679ec801249371e7a55db2a9abbb995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sat, 5 Aug 2017 02:12:41 +0200 Subject: [PATCH 04/22] Documented VimwikiToggleListItemRejected --- doc/vimwiki.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index bc8db38..883c06c 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -656,6 +656,10 @@ Vimwiki file. Toggle checkbox of a list item on/off. See |vimwiki-todo-lists|. +*:VimwikiToggleListItemRejected* + Toggle checkbox of a list item disabled/off. + See |vimwiki-todo-lists|. + *:VimwikiListChangeLevel* CMD Change the nesting level, or symbol, for a single-line list item. CMD may be ">>" or "<<" to change the indentation of the item, or @@ -1621,6 +1625,10 @@ Use gl (see |vimwiki_gl|) to remove a single checkbox and gL (see |vimwiki_gL|) to remove all checkboxes of the list the cursor is in. +You can mark an item as rejected ("won't do") with +|:VimwikiToggleListItemRejected.| It will not influence the status of it's +parents. + ============================================================================== 9. Tables *vimwiki-tables* @@ -2345,6 +2353,19 @@ You can set it to some more fancy symbols like this: let g:vimwiki_listsyms = '✗○◐●✓' +------------------------------------------------------------------------------ +*g:vimwiki_listsym_rejected* + +Character that is used to show that an item of a todo list will not be done. +Default value is '-'. + +The character used here may not be part of g:vimwiki_listsyms. + +You can set it to some more fancy symbols like this: +> + let g:vimwiki_listsym_rejected = '✗' + + ------------------------------------------------------------------------------ *g:vimwiki_use_mouse* From 413b9ca04fe079a0eb3e93173755e2b020fff92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sat, 5 Aug 2017 17:32:15 +0200 Subject: [PATCH 05/22] Add default keybinding glx for toggling disabled --- doc/vimwiki.txt | 9 ++++++++- ftplugin/vimwiki.vim | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 883c06c..80ef89e 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -455,6 +455,13 @@ gLI Change the symbol of the current list to To remap: > noremap glo :VimwikiChangeSymbolTo I) noremap glO :VimwikiChangeSymbolInListTo I) +< + *vimwiki_glx* +glx Toggle checkbox of a list item disabled/off. + Maps to |:VimwikiToggleListItemRejected|. + See |vimwiki-todo-lists|. + To remap: > + :map tx VimwikiToggleListItemRejected < *vimwiki_gqq* *vimwiki_gww* gqq Format table. If you made some changes to a table @@ -1626,7 +1633,7 @@ gL (see |vimwiki_gL|) to remove all checkboxes of the list the cursor is in. You can mark an item as rejected ("won't do") with -|:VimwikiToggleListItemRejected.| It will not influence the status of it's +|vimwiki_glx|. A rejected item will not influence the status of it's parents. diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index f2ad61f..e8a18e4 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -443,6 +443,10 @@ if !hasmapto('VimwikiToggleListItem') vmap VimwikiToggleListItem endif endif +if !hasmapto('VimwikiToggleListItemRejected') + nmap glx VimwikiToggleListItemRejected + vmap glx VimwikiToggleListItemRejected +endif nnoremap - -2. installing MathJax locally (faster, no internet required). Choose a -folder on your hard drive and save MathJax in it. Then add to your HTML -template the following line: +1. installing MathJax locally (Recommended: faster, no internet required). +Choose a folder on your hard drive and save MathJax in it. Then add to your +HTML template the following line: @@ -1255,6 +1250,11 @@ template folder. For instance, a sensible folder structure could be: In this case, would be "../mathjax" (without quotes). +2. Loading MathJax from a CDN-server (needs internet connection). +Add to your HTML template the following line: + + + ------------------------------------------------------------------------------ 5.9. Blockquotes *vimwiki-syntax-blockquotes* From 37e4dfc2883c0dec5862df128e7f421e0795ce03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sun, 17 Sep 2017 01:10:14 +0100 Subject: [PATCH 09/22] Add License-File Vimwiki currently has not License-File, and the license is only mentioned in the help-file. We should change this. --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..be93eec --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 742fc996928e6aa2f2053848aa151fdcccd0dfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Wed, 25 Oct 2017 02:11:01 +0200 Subject: [PATCH 10/22] Add Copyright-attribution to Daniel Schemala --- LICENSE | 1 + doc/vimwiki.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/LICENSE b/LICENSE index be93eec..cdf8546 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2008-2010 Maxim Kim + 2013-2017 Daniel Schemala 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/doc/vimwiki.txt b/doc/vimwiki.txt index 6b89238..c5b227b 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -3105,6 +3105,7 @@ The MIT Licence http://www.opensource.org/licenses/mit-license.php Copyright (c) 2008-2010 Maxim Kim + 2013-2017 Daniel Schemala Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From ec3d554c0b824f0e10f455b17645d6a722520c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Wed, 25 Oct 2017 13:10:23 +0200 Subject: [PATCH 11/22] Update list of contributers --- doc/vimwiki.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index c5b227b..06f95b8 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2854,6 +2854,19 @@ Contributors and their Github usernames in roughly chronological order: - @wangzq - Jinzhou Zhang (@lotabout) - Michael Riley (@optik-aper) + - Irfan Sharif (@irfansharif) + - John Conroy (@jconroy77) + - Christian Rondeau (@christianrondeau) + - Alex Thorne (@thornecc) + - Shafqat Bhuiyan (@priomsrb) + - Bradley Cicenas (@bcicen) + - Michael Thessel (@MichaelThessel) + - Michael F. Schönitzer (@nudin) + - @sqlwwx + - Guilherme Salazar (@salazar) + - Daniel Trnka (@trnila) + - Yuchen Pei (@ycpei) + - @maqiv ============================================================================== From cf8e3e731929b872d154d631d5b067e4c100cc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Wed, 25 Oct 2017 13:45:00 +0200 Subject: [PATCH 12/22] Unified spelling Licence -> License --- doc/vimwiki.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 06f95b8..323ccfe 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -3114,7 +3114,7 @@ http://code.google.com/p/vimwiki/issues/list ============================================================================== 16. License *vimwiki-license* -The MIT Licence +The MIT License http://www.opensource.org/licenses/mit-license.php Copyright (c) 2008-2010 Maxim Kim From d9a73b71173b418bc1ae64217aa4e2c65272541f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ci=C4=99=C5=BCarkiewicz?= Date: Sat, 14 Oct 2017 23:12:47 -0700 Subject: [PATCH 13/22] Fix diary index generation with custom file extensions Fix #302 --- autoload/vimwiki/diary.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index fcd176a..d6cd9e9 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -65,7 +65,7 @@ fun! s:read_captions(files) "{{{ let result = {} for fl in a:files " remove paths and extensions - let fl_key = fnamemodify(fl, ':t:r') + let fl_key = substitute(fnamemodify(fl, ':t'), VimwikiGet('ext').'$', '', '') if filereadable(fl) for line in readfile(fl, '', s:vimwiki_max_scan_for_caption) From eed4ceff1af6ae11f33ee589f7bf099fdc62fdd5 Mon Sep 17 00:00:00 2001 From: Drew Hays Date: Thu, 17 Aug 2017 23:53:40 -0700 Subject: [PATCH 14/22] Escape the 'dot' in extension substitution This escapes the `.` preceding an extension (e.g. `.wiki`) so that it doesn't accidentally match any character. For example: `[vimwiki](vimwiki)` was opening the `vi.wiki` page, because of this rule. --- autoload/vimwiki/base.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 0cd537a..4e3cde5 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1273,7 +1273,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{ " remove the extension from the filename if exists, because non-vimwiki " markdown files usually include the extension in links - let lnk = substitute(lnk, VimwikiGet('ext').'$', '', '') + let lnk = substitute(lnk, '\'.VimwikiGet('ext').'$', '', '') endif let current_tab_page = tabpagenr() From 293e1f51eecfe93b9e519a5b10e059edf835ac35 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 18 Dec 2016 13:02:51 -0600 Subject: [PATCH 15/22] Added the option to open vimwiki in a pane. 1 tabedit 2 split 3 vsplit Similar to opening a tab,:: vimwiki#base#goto_index(v:count1, 1) we can now open a split with:: vimwiki#base#goto_index(v:count1, 2) and a vertical split with:: vimwiki#base#goto_index(v:count1, 3) --- autoload/vimwiki/base.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 4e3cde5..a246081 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1325,8 +1325,12 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{ let idx = 0 endif - if a:0 + if a:0 == 1 let cmd = 'tabedit' + elseif a:0 == 2 + let cmd = 'sp' + elseif a:0 == 3 + let cmd = 'vsp' else let cmd = 'edit' endif From 734d0143675e64966881ee62f89391d3c2b4c06d Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 18 Dec 2016 13:02:51 -0600 Subject: [PATCH 16/22] Added the option to open vimwiki in a pane. 1 tabedit 2 split 3 vsplit Similar to opening a tab,:: vimwiki#base#goto_index(1, 1) we can now open a split with:: vimwiki#base#goto_index(1, 2) and a vertical split with:: vimwiki#base#goto_index(1, 3) --- autoload/vimwiki/base.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index a246081..07e3e72 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1325,16 +1325,18 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{ let idx = 0 endif - if a:0 == 1 + if a:1 == 1 let cmd = 'tabedit' - elseif a:0 == 2 - let cmd = 'sp' - elseif a:0 == 3 - let cmd = 'vsp' + elseif a:1 == 2 + let cmd = 'split' + elseif a:1 == 3 + let cmd = 'vsplit' else let cmd = 'edit' endif + echomsg 'Passed argument '.a:0.'. Using cmd '.cmd + call Validate_wiki_options(idx) call vimwiki#base#edit_file(cmd, \ VimwikiGet('path', idx).VimwikiGet('index', idx). From 95d4c095d0a615c9586df49d3bc0eedec8e4ea4d Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 18 Dec 2016 13:02:51 -0600 Subject: [PATCH 17/22] Added the option to open vimwiki in a pane. 1 tabedit 2 split 3 vsplit Similar to opening a tab,:: vimwiki#base#goto_index(v:count1, 1) we can now open a split with:: vimwiki#base#goto_index(v:count1, 2) and a vertical split with:: vimwiki#base#goto_index(v:count1, 3) --- autoload/vimwiki/base.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 07e3e72..ecc322b 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1335,8 +1335,6 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{ let cmd = 'edit' endif - echomsg 'Passed argument '.a:0.'. Using cmd '.cmd - call Validate_wiki_options(idx) call vimwiki#base#edit_file(cmd, \ VimwikiGet('path', idx).VimwikiGet('index', idx). From 02e32489d7652189026c1d4b48bf88b6da98a739 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 18 Dec 2016 13:02:51 -0600 Subject: [PATCH 18/22] Added the option to open vimwiki in a pane. 1 tabedit 2 split 3 vsplit Similar to opening a tab,:: vimwiki#base#goto_index(v:count1, 1) we can now open a split with:: vimwiki#base#goto_index(v:count1, 2) and a vertical split with:: vimwiki#base#goto_index(v:count1, 3) --- autoload/vimwiki/base.vim | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index ecc322b..6f81453 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1325,12 +1325,14 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{ let idx = 0 endif - if a:1 == 1 - let cmd = 'tabedit' - elseif a:1 == 2 - let cmd = 'split' - elseif a:1 == 3 - let cmd = 'vsplit' + if a:0 + if a:1 == 1 + let cmd = 'tabedit' + elseif a:1 == 2 + let cmd = 'split' + elseif a:1 == 3 + let cmd = 'vsplit' + endif else let cmd = 'edit' endif From b6d47e894d78bc9589a11cde501093fa04da1941 Mon Sep 17 00:00:00 2001 From: Daniel Etrata Date: Mon, 6 Nov 2017 21:08:52 -0600 Subject: [PATCH 19/22] Give vimwiki#diary#make_note similar functionality --- autoload/vimwiki/diary.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index d6cd9e9..2bc702b 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -174,8 +174,14 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{ call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)) - if a:0 && a:1 == 1 - let cmd = 'tabedit' + if a:0 + if a:1 == 1 + let cmd = 'tabedit' + elseif a:2 == 2 + let cmd = 'split' + elseif a:3 == 3 + let cmd = 'vsplit' + endif else let cmd = 'edit' endif From 91c382a034062e23571058f6b4cc9976016906af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Fri, 10 Nov 2017 22:28:33 +0100 Subject: [PATCH 20/22] Use a safe substitution-function everywhere --- autoload/vimwiki/base.vim | 47 +++++++++++++++++------------- autoload/vimwiki/markdown_base.vim | 11 +++++-- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 6f81453..62140ab 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -8,6 +8,13 @@ if exists("g:loaded_vimwiki_auto") || &cp endif let g:loaded_vimwiki_auto = 1 +" s:safesubstitute +function! s:safesubstitute(text, search, replace, mode) "{{{ + " Substitute regexp but do not interpret replace + let escaped = escape(a:replace, '\&') + return substitute(a:text, a:search, escaped, a:mode) +endfunction " }}} + " s:vimwiki_get_known_syntaxes function! s:vimwiki_get_known_syntaxes() " {{{ " Getting all syntaxes that different wikis could have @@ -465,7 +472,7 @@ function! vimwiki#base#generate_links() "{{{ let abs_filepath = vimwiki#path#abs_path_of_link(link) if !s:is_diary_file(abs_filepath) call add(lines, bullet. - \ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".link."'", '')) + \ s:safesubstitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', link, '')) endif endfor @@ -677,13 +684,13 @@ function! s:jump_to_anchor(anchor) "{{{ let segments = split(anchor, '#', 0) for segment in segments - let anchor_header = substitute( + let anchor_header = s:safesubstitute( \ g:vimwiki_{VimwikiGet('syntax')}_header_match, - \ '__Header__', "\\='".segment."'", '') - let anchor_bold = substitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match, - \ '__Text__', "\\='".segment."'", '') - let anchor_tag = substitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match, - \ '__Tag__', "\\='".segment."'", '') + \ '__Header__', segment, '') + let anchor_bold = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match, + \ '__Text__', segment, '') + let anchor_tag = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match, + \ '__Tag__', segment, '') if !search(anchor_tag, 'Wc') \ && !search(anchor_header, 'Wc') @@ -1176,8 +1183,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header, " write new listing let new_header = whitespaces_in_first_line - \ . substitute(g:vimwiki_rxH1_Template, - \ '__Header__', '\='."'".a:start_header."'", '') + \ . s:safesubstitute(g:vimwiki_rxH1_Template, + \ '__Header__', a:start_header, '') call append(start_lnum - 1, new_header) let start_lnum += 1 let lines_diff += 1 + len(a:strings) @@ -1832,9 +1839,9 @@ function! vimwiki#base#table_of_contents(create) for [lvl, link, desc] in headers let esc_link = substitute(link, "'", "''", 'g') let esc_desc = substitute(desc, "'", "''", 'g') - let link = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', - \ '\='."'".'#'.esc_link."'", '') - let link = substitute(link, '__LinkDescription__', '\='."'".esc_desc."'", '') + let link = s:safesubstitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', + \ '#'.esc_link, '') + let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '') call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link) endfor @@ -1855,13 +1862,13 @@ endfunction function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{ let lnk = a:template if a:rxUrl != "" - let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", 'g') + let lnk = s:safesubstitute(lnk, '__LinkUrl__', a:rxUrl, 'g') endif if a:rxDesc != "" - let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", 'g') + let lnk = s:safesubstitute(lnk, '__LinkDescription__', a:rxDesc, 'g') endif if a:rxStyle != "" - let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", 'g') + let lnk = s:safesubstitute(lnk, '__LinkStyle__', a:rxStyle, 'g') endif return lnk endfunction " }}} @@ -1900,8 +1907,8 @@ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{ if descr == "" let descr = s:clean_url(url) endif - let lnk = substitute(template, '__LinkDescription__', '\="'.descr.'"', '') - let lnk = substitute(lnk, '__LinkUrl__', '\="'.url.'"', '') + let lnk = s:safesubstitute(template, '__LinkDescription__', descr, '') + let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '') return lnk endfunction " }}} @@ -1909,7 +1916,7 @@ endfunction " }}} function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template) "{{{ let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template) let style = matchstr(a:str, a:rxStyle) - let lnk = substitute(lnk, '__LinkStyle__', '\="'.style.'"', '') + let lnk = s:safesubstitute(lnk, '__LinkStyle__', style, '') return lnk endfunction " }}} @@ -2001,8 +2008,8 @@ function! s:normalize_link_syntax_v() " {{{ if s:is_diary_file(expand("%:p")) let sub = s:normalize_link_in_diary(@") else - let sub = substitute(g:vimwiki_WikiLinkTemplate1, - \ '__LinkUrl__', '\=' . "'" . @" . "'", '') + let sub = s:safesubstitute(g:vimwiki_WikiLinkTemplate1, + \ '__LinkUrl__', @", '') endif " Put substitution in register " and change text diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim index 06477d8..01f2c96 100644 --- a/autoload/vimwiki/markdown_base.vim +++ b/autoload/vimwiki/markdown_base.vim @@ -6,6 +6,13 @@ " MISC helper functions {{{ +" s:safesubstitute +function! s:safesubstitute(text, search, replace, mode) "{{{ + " Substitute regexp but do not interpret replace + let escaped = escape(a:replace, '\&') + return substitute(a:text, a:search, escaped, a:mode) +endfunction " }}} + " vimwiki#markdown_base#reset_mkd_refs function! vimwiki#markdown_base#reset_mkd_refs() "{{{ call VimwikiClear('markdown_refs') @@ -139,8 +146,8 @@ function! s:normalize_link_syntax_v() " {{{ try norm! gvy let visual_selection = @" - let link = substitute(g:vimwiki_Weblink1Template, '__LinkUrl__', '\='."'".visual_selection."'", '') - let link = substitute(link, '__LinkDescription__', '\='."'".visual_selection."'", '') + let link = Safesubstitute(g:vimwiki_Weblink1Template, '__LinkUrl__', visual_selection, '') + let link = Safesubstitute(link, '__LinkDescription__', visual_selection, '') call setreg('"', link, 'v') From 074d8827620c0d1d0535f21808862659c611ceb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sat, 4 Nov 2017 03:26:33 +0100 Subject: [PATCH 21/22] Allow Backtick in Link --- autoload/vimwiki/base.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 6f81453..9fdfaf5 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -840,7 +840,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{ " then " [[test*file]]... " you'll have E77: Too many file names - let fname = escape(a:filename, '% *|#') + let fname = escape(a:filename, '% *|#`') let dir = fnamemodify(a:filename, ":p:h") let ok = vimwiki#path#mkdir(dir, 1) From c94af4b3f17711b068fa67814bcdeeda5a785181 Mon Sep 17 00:00:00 2001 From: Keith Haber Date: Tue, 14 Nov 2017 22:57:52 -0800 Subject: [PATCH 22/22] Update argument handling in diary#make_note Fix an "Undefined variable: a:3" error that occurs when attempting to open a diary page with Calendar.vim. --- autoload/vimwiki/diary.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 2bc702b..109ae07 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -174,16 +174,15 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{ call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)) + let cmd = 'edit' if a:0 if a:1 == 1 let cmd = 'tabedit' - elseif a:2 == 2 + elseif a:1 == 2 let cmd = 'split' - elseif a:3 == 3 + elseif a:1 == 3 let cmd = 'vsplit' endif - else - let cmd = 'edit' endif if a:0>1 let link = 'diary:'.a:2