1 Commits

Author SHA1 Message Date
Brennen Bearnes 5fdf73f61d WIP: document link resolution behavior and design decisions
This commit is starting as attempt to add useful context for link functions
in the comments / docstrings, and clean up a few things for better
readability.  This is preliminary work for a solution to:

https://github.com/vimwiki/vimwiki/issues/1271

...which is gradually becoming a description of everything that's wrong
with how VimWiki links to files, more or less.

It includes a decision document, which should become a full description
of the problem and steps taken.

This commit _will_ be rewritten.

Bug: #1271
2023-03-27 10:57:28 -06:00
32 changed files with 391 additions and 1057 deletions
+6 -10
View File
@@ -64,24 +64,20 @@ jobs:
opt: [ opt: [
# "vint", # "vint",
"-n vim_7.4.2367", "-n vim_7.3.429",
"-n vim_8.2.5172", "-n vim_8.1.0519",
"-n vim_9.0.2190",
"-n vim_9.1.0786",
# TODO add me when test works on Vim, 9.0 # TODO add me when test works on Vim, 9.0
# -- Currently I experienced some surprised due to defaults # -- Currently I experienced some surprised due to defaults
# -- tinmarino 2023-03-10 # -- tinmarino 2023-03-10
# "-n v9.0.1396", # "-n v9.0.1396",
# This build isn't currently working with vim-testbed: "-n nvim_0.3.8",
# "-n nvim_0.10.2",
# Cannot quote as it is expanded from $OPT after quote removal # Cannot quote as it is expanded from $OPT after quote removal
# So I decided to escape the * # So I decided to escape the *
# "-n vim_7.4.1099 -f '[a-k]*.vader'", "-n vim_7.4.1099 -f '[a-k]*.vader'",
# "-n vim_7.4.1546 -f 'l*.vader'", "-n vim_7.4.1546 -f 'l*.vader'",
# "-n vim_8.0.0027 -f '[m-z]*.vader'", "-n vim_8.0.0027 -f '[m-z]*.vader'",
] ]
steps: steps:
# This action is required to fetch the code to test # This action is required to fetch the code to test
+7 -8
View File
@@ -17,11 +17,10 @@ RUN git checkout de8a976f1eae2c2b680604205c3e8b5c8882493c
# Build vim and neovim versions we want to test # Build vim and neovim versions we want to test
WORKDIR / WORKDIR /
RUN install_vim -tag v7.4.2367 -name vim_7.4.2367 -build RUN install_vim -tag v7.3.429 -name vim_7.3.429 -build
RUN install_vim -tag v8.2.5172 -name vim_8.2.5172 -build RUN install_vim -tag v7.4.1099 -name vim_7.4.1099 -build
RUN install_vim -tag v9.0.2190 -name v9.0.2190 -build RUN install_vim -tag v7.4.1546 -name vim_7.4.1546 -build
RUN install_vim -tag v9.1.0786 -name v9.1.0786 -build RUN install_vim -tag v8.0.0027 -name vim_8.0.0027 -build
RUN install_vim -tag v8.1.0519 -name vim_8.1.0519 -build
# TODO: This one doesn't build - vim-testbed seems way out of date: RUN install_vim -tag v9.0.1396 -name v9.0.1396 -build
# TODO: tag neovim:v0.10.2, name nvim_0.10.2 RUN install_vim -tag neovim:v0.3.8 -name nvim_0.3.8 -build
# (Format as install_vim instances above.)
+17 -45
View File
@@ -28,6 +28,7 @@ VimWiki is a personal wiki for Vim -- a number of linked text files that have
their own syntax highlighting. See the [VimWiki Wiki](https://vimwiki.github.io/vimwikiwiki/) their own syntax highlighting. See the [VimWiki Wiki](https://vimwiki.github.io/vimwikiwiki/)
for an example website built with VimWiki! for an example website built with VimWiki!
For the latest features and fixes checkout the [dev branch](https://github.com/vimwiki/vimwiki/tree/dev).
If you are interested in contributing see [this section](#helping-vimwiki). If you are interested in contributing see [this section](#helping-vimwiki).
With VimWiki, you can: With VimWiki, you can:
@@ -39,8 +40,8 @@ With VimWiki, you can:
- Export everything to HTML - Export everything to HTML
To do a quick start, press `<Leader>ww` (default is `\ww`) to go to your index To do a quick start, press `<Leader>ww` (default is `\ww`) to go to your index
wiki file. By default, it is located in `~/vimwiki/index.wiki`. See wiki file. By default, it is located in `~/vimwiki/index.wiki`. See `:h vimwiki_list`
`:h vimwiki_list` for registering a different path/wiki. for registering a different path/wiki.
Feed it with the following example: Feed it with the following example:
@@ -76,10 +77,8 @@ The result should look something like:
## Installation ## Installation
VimWiki has been tested on **Vim >= 7.3**. It may work on older versions but VimWiki has been tested on **Vim >= 7.3**. It will likely work on older
will not be officially supported. It is known to work on NeoVim, although versions but will not be officially supported.
it is likely to have
[NeoVim-specific bugs](https://github.com/vimwiki/vimwiki/labels/neovim).
### Prerequisites ### Prerequisites
@@ -144,7 +143,7 @@ vim +PluginInstall +qall
#### Manual Install #### Manual Install
Download the [zip archive](https://github.com/vimwiki/vimwiki/archive/dev.zip) Download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip)
and extract it in `~/.vim/bundle/` and extract it in `~/.vim/bundle/`
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was
@@ -186,16 +185,6 @@ _italic_ -- italic text
For other syntax elements, see `:h vimwiki-syntax` For other syntax elements, see `:h vimwiki-syntax`
### Todo lists
```text
- [.] Partially completed item with sub-tasks
- [X] Completed sub-task
- [ ] Incomplete sub-task
- [ ] Other incomplete sub-task
- [ ] Incomplete item
```
## Key bindings ## Key bindings
### Normal mode ### Normal mode
@@ -233,13 +222,11 @@ more bindings.
## Changing Wiki Syntax ## Changing Wiki Syntax
VimWiki currently ships with 3 syntaxes: VimWiki (default), Markdown VimWiki currently ships with 3 syntaxes: VimWiki (default), Markdown
(markdown), and MediaWiki (media). Of these, the native VimWiki syntax is (markdown), and MediaWiki (media).
best supported, followed by Markdown. No promises are made for MediaWiki.
**NOTE:** Only the default syntax ships with a built-in HTML converter. For **NOTE:** Only the default syntax ships with a built-in HTML converter. For
Markdown or MediaWiki see `:h vimwiki-option-custom_wiki2html`. Some examples Markdown or MediaWiki see `:h vimwiki-option-custom_wiki2html`. Some examples
and 3rd party tools are available and 3rd party tools are available [here](https://vimwiki.github.io/vimwikiwiki/Related%20Tools.html#Related%20Tools-External%20Tools).
[here](https://vimwiki.github.io/vimwikiwiki/Related%20Tools.html#Related%20Tools-External%20Tools).
If you would prefer to use either Markdown or MediaWiki syntaxes, set the If you would prefer to use either Markdown or MediaWiki syntaxes, set the
following option in your `.vimrc`: following option in your `.vimrc`:
@@ -247,31 +234,18 @@ following option in your `.vimrc`:
```vim ```vim
let g:vimwiki_list = [{'path': '~/vimwiki/', let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': 'md'}] \ 'syntax': 'markdown', 'ext': '.md'}]
``` ```
This option will treat all markdown files in your system as part of vimwiki This option will treat all markdown files in your system as part of vimwiki (check `set filetype?`). Add
(check `set filetype?`). Add
```vim ```vim
let g:vimwiki_global_ext = 0 let g:vimwiki_global_ext = 0
``` ```
to your `.vimrc` to restrict Vimwiki's operation to only those paths listed in `g:vimwiki_list`.
to your `.vimrc` to restrict Vimwiki's operation to only those paths listed in Other markdown files wouldn't be treated as wiki pages.
`g:vimwiki_list`. Other markdown files wouldn't be treated as wiki pages.
See [g:vimwiki_global_ext](https://github.com/vimwiki/vimwiki/blob/619f04f89861c58e5a6415a4f83847752928252d/doc/vimwiki.txt#L2631). See [g:vimwiki_global_ext](https://github.com/vimwiki/vimwiki/blob/619f04f89861c58e5a6415a4f83847752928252d/doc/vimwiki.txt#L2631).
if you want to turn off support for other extension(for example, disabling
accidently creating new wiki and link for normal markdown files), set the
following option in your `.vimrc` before packadd vimwiki:
```vim
let g:vimwiki_ext2syntax = {}
```
See [g:vimiki_ext2syntax](https://github.com/vimwiki/vimwiki/blob/619f04f89861c58e5a6415a4f83847752928252d/doc/vimwiki.txt#L2652)
## Getting help ## Getting help
[GitHub issues](https://github.com/vimwiki/vimwiki/issues) are the primary [GitHub issues](https://github.com/vimwiki/vimwiki/issues) are the primary
@@ -279,20 +253,18 @@ method for raising bug reports or feature requests.
Additional resources: Additional resources:
- The IRC channel [#vimwiki](ircs://irc.libera.chat:6697/vimwiki) on - The IRC channel [#vimwiki](ircs://irc.libera.chat:6697/vimwiki) on irc.libera.chat
irc.libera.chat is the "official" discussion and support channel
- [Connect via webchat](https://web.libera.chat/?channels=#vimwiki) - [Connect via webchat](https://web.libera.chat/?channels=#vimwiki)
- [@vimwiki@wikis.world](https://wikis.world/@vimwiki) on the Fediverse - Connect via Matrix/Element: [#vimwiki:libera.chat](https://matrix.to/#/#vimwiki:libera.chat)
- Post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki).
## Helping VimWiki ## Helping VimWiki
VimWiki has a lot of users but only very few recurring developers or people VimWiki has a lot of users but only very few recurring developers or people
helping the community. Your help is therefore appreciated. Everyone can help! helping the community. Your help is therefore appreciated. Everyone can help!
See [#625](https://github.com/vimwiki/vimwiki/issues/625) for information on how See [#625](https://github.com/vimwiki/vimwiki/issues/625) for information on how you can help.
you can help.
Also, take a look at [CONTRIBUTING.md](https://github.com/vimwiki/vimwiki/blob/master/CONTRIBUTING.md) Also, take a look at [CONTRIBUTING.md](https://github.com/vimwiki/vimwiki/blob/master/CONTRIBUTING.md) and [design_notes.md](doc/design_notes.md)
and [design_notes.md](doc/design_notes.md)
---- ----
+53 -90
View File
@@ -125,10 +125,21 @@ endfunction
function! vimwiki#base#resolve_link(link_text, ...) abort function! vimwiki#base#resolve_link(link_text, ...) abort
" Extract infos about the target from a link. " Extract infos about the target from a link.
" THE central function of Vimwiki. "
" If the second parameter is present, which should be an absolute file path, it " THE central function of Vimwiki. Here be dragons!
" is assumed that the link appears in that file. Without it, the current file "
" is used. " This has become confusing and extremely brittle. Don't change it unless
" you know exactly what you're doing and test every code path. It is safe
" to assume that at least one user relies on everything this does, whether
" it was intentional or not. Do not make breaking changes here, or you will
" hear about it. If you want to add extra link syntax or behavior, please
" consult with other maintainers first!
"
" See doc/specification.wiki for a draft spec that covers link syntax.
" a:0 is set to the number of extra arguments. If the second parameter is
" present, which should be an absolute file path, it is assumed that the
" link appears in that file. Without it, the current file is used.
if a:0 if a:0
let source_wiki = vimwiki#base#find_wiki(a:1) let source_wiki = vimwiki#base#find_wiki(a:1)
let source_file = a:1 let source_file = a:1
@@ -262,20 +273,11 @@ function! vimwiki#base#resolve_link(link_text, ...) abort
\ vimwiki#vars#get_wikilocal('ext', link_infos.index) \ vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif endif
else else
" append extension if one not already present or it's not the targeted " append extension iff one not already present or it's not the targeted
" wiki extension - https://github.com/vimwiki/vimwiki/issues/950 " wiki extension - https://github.com/vimwiki/vimwiki/issues/950
let ext = fnamemodify(link_text, ':e') let ext = fnamemodify(link_text, ':e')
let ext_with_dot = '.' . ext let ext_with_dot = '.' . ext
if ext ==? '' || ext_with_dot !=? vimwiki#vars#get_wikilocal('ext', link_infos.index)
" Check if a .md must be added
" See #1271 to modify files with a "."
let do_add_ext = ext ==? ''
if vimwiki#vars#get_syntaxlocal('open_link_add_ext')
let do_add_ext = do_add_ext || ext_with_dot !=? vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif
" Add the dot
if do_add_ext
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index) let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif endif
endif endif
@@ -307,8 +309,20 @@ endfunction
function! vimwiki#base#system_open_link(url) abort function! vimwiki#base#system_open_link(url) abort
" Open Link with OS handler (like gx) " Open Link with OS handler (like gx).
" handlers "
" This handles all supported URI-like links, including http:, file:, etc.,
" unless a custom VimwikiLinkHandler() does something with them first.
"
" It can be a source of OS-specific bugs, since behavior differs across
" operating systems and this makes some fairly basic assumptions about
" what's available.
"
" TODO: The easiest way for a user to change this behavior at present is to
" write a VimwikiLinkHandler(). This is probably fine, but there might be a
" use case for being able to explicitly set a handler just for system links.
" Handlers
function! s:win32_handler(url) abort function! s:win32_handler(url) abort
"Disable shellslash for cmd and command.com, but enable for all other shells "Disable shellslash for cmd and command.com, but enable for all other shells
"See Issue #560 "See Issue #560
@@ -338,12 +352,15 @@ function! vimwiki#base#system_open_link(url) abort
endif endif
endfunction endfunction
function! s:macunix_handler(url) abort function! s:macunix_handler(url) abort
call system('open ' . shellescape(a:url).' &') call system('open ' . shellescape(a:url).' &')
endfunction endfunction
function! s:linux_handler(url) abort function! s:linux_handler(url) abort
call system('xdg-open ' . shellescape(a:url).' >/dev/null 2>&1 &') call system('xdg-open ' . shellescape(a:url).' >/dev/null 2>&1 &')
endfunction endfunction
try try
if vimwiki#u#is_windows() if vimwiki#u#is_windows()
call s:win32_handler(a:url) call s:win32_handler(a:url)
@@ -403,33 +420,9 @@ function! vimwiki#base#open_link(cmd, link, ...) abort
endfunction endfunction
function! vimwiki#base#nop1(stg) abort
" Nop with one arg, used if callback is required
return a:stg
endfunction
function! vimwiki#base#get_globlinks_escaped(...) abort function! vimwiki#base#get_globlinks_escaped(...) abort
" Proxy: Called by command completion
let args = copy(a:000)
call insert(args, 'fnameescape')
return call('vimwiki#base#get_globlinks_callback', args)
endfunction
function! vimwiki#base#get_globlinks_raw(...) abort
" Proxy: Called by command completion
let args = copy(a:000)
call insert(args, 'vimwiki#base#nop1')
return call('vimwiki#base#get_globlinks_callback', args)
endfunction
function! vimwiki#base#get_globlinks_callback(callback, ...) abort
" Escape global link " Escape global link
" Called by command completion " Called by command completion
" [1] callback <string> of a function converting file <string> => escaped file <string>
" -- ex: fnameescape
let s_arg_lead = a:0 > 0 ? a:1 : '' let s_arg_lead = a:0 > 0 ? a:1 : ''
" only get links from the current dir " only get links from the current dir
" change to the directory of the current file " change to the directory of the current file
@@ -447,8 +440,8 @@ function! vimwiki#base#get_globlinks_callback(callback, ...) abort
" " use smart case matching " " use smart case matching
let r_arg = substitute(s_arg_lead, '\u', '[\0\l\0]', 'g') let r_arg = substitute(s_arg_lead, '\u', '[\0\l\0]', 'g')
call filter(lst, '-1 != match(v:val, r_arg)') call filter(lst, '-1 != match(v:val, r_arg)')
" Apply callback to each item " Apply fnameescape() to each item
call map(lst, a:callback . '(v:val)') call map(lst, 'fnameescape(v:val)')
" Return list (for customlist completion) " Return list (for customlist completion)
return lst return lst
endfunction endfunction
@@ -482,7 +475,7 @@ function! vimwiki#base#generate_links(create, ...) abort
let use_caption = vimwiki#vars#get_wikilocal('generated_links_caption', wiki_nr) let use_caption = vimwiki#vars#get_wikilocal('generated_links_caption', wiki_nr)
for link in links for link in links
let link_infos = vimwiki#base#resolve_link(link) let link_infos = vimwiki#base#resolve_link(link)
if !vimwiki#base#is_among_diary_files(link_infos.filename, copy(l:diary_file_paths)) if !vimwiki#base#is_diary_file(link_infos.filename, copy(l:diary_file_paths))
let link_tpl = vimwiki#vars#get_syntaxlocal('Link1') let link_tpl = vimwiki#vars#get_syntaxlocal('Link1')
let link_caption = vimwiki#base#read_caption(link_infos.filename) let link_caption = vimwiki#base#read_caption(link_infos.filename)
@@ -526,12 +519,7 @@ function! vimwiki#base#goto(...) abort
" Jump: to other wikifile, specified on command mode " Jump: to other wikifile, specified on command mode
" Called: by command VimwikiGoto (Exported) " Called: by command VimwikiGoto (Exported)
let key = a:0 > 0 && a:1 !=# '' ? a:1 : input('Enter name: ', '', let key = a:0 > 0 && a:1 !=# '' ? a:1 : input('Enter name: ', '',
\ 'customlist,vimwiki#base#complete_links_raw') \ 'customlist,vimwiki#base#complete_links_escaped')
if key ==# ''
" Input cancelled
return
endif
let anchor = a:0 > 1 ? a:2 : '' let anchor = a:0 > 1 ? a:2 : ''
@@ -891,9 +879,6 @@ function! s:jump_to_anchor(anchor) abort
let anchor = vimwiki#u#escape(a:anchor) let anchor = vimwiki#u#escape(a:anchor)
let segments = split(anchor, '#', 0) let segments = split(anchor, '#', 0)
" Start at beginning => Independent of link position
call cursor(1, 1)
" For markdown: there is only one segment " For markdown: there is only one segment
for segment in segments for segment in segments
" Craft segment pattern so that it is case insensitive and also matches dashes " Craft segment pattern so that it is case insensitive and also matches dashes
@@ -914,6 +899,7 @@ function! s:jump_to_segment(segment, segment_norm_re, segment_nb) abort
" Called: jump_to_anchor with suffix and withtou suffix " Called: jump_to_anchor with suffix and withtou suffix
" Save cursor %% Initialize at top of line " Save cursor %% Initialize at top of line
let oldpos = getpos('.') let oldpos = getpos('.')
call cursor(1, 1)
" Get anchor regex " Get anchor regex
let anchor_header = s:safesubstitute( let anchor_header = s:safesubstitute(
@@ -971,6 +957,9 @@ function! s:jump_to_segment(segment, segment_norm_re, segment_nb) abort
return 0 return 0
endif endif
" Or keep on (i.e more than once segment)
let oldpos = getpos('.')
" Said 'fail' to caller " Said 'fail' to caller
return 1 return 1
endfunction endfunction
@@ -1143,7 +1132,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort
" :param: anchor " :param: anchor
" :param: (1) vimwiki_prev_link " :param: (1) vimwiki_prev_link
" :param: (2) vimwiki#u#ft_is_vw() " :param: (2) vimwiki#u#ft_is_vw()
let fname = fnameescape(a:filename) let fname = escape(a:filename, '% *|#`')
let dir = fnamemodify(a:filename, ':p:h') let dir = fnamemodify(a:filename, ':p:h')
let ok = vimwiki#path#mkdir(dir, 1) let ok = vimwiki#path#mkdir(dir, 1)
@@ -1676,16 +1665,19 @@ function! vimwiki#base#follow_link(split, ...) abort
" Try WikiLink " Try WikiLink
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')),
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl')) \ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
" Try WikiIncl " Try WikiIncl
if lnk ==? '' if lnk ==? ''
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')),
\ vimwiki#vars#get_global('rxWikiInclMatchUrl')) \ vimwiki#vars#get_global('rxWikiInclMatchUrl'))
endif endif
" Try Weblink " Try Weblink
if lnk ==? '' if lnk ==? ''
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')),
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl')) \ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
endif endif
" Try markdown image ![]() " Try markdown image ![]()
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' && lnk ==# '' if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' && lnk ==# ''
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxImage')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxImage')),
@@ -2676,10 +2668,13 @@ function! s:clean_url(url) abort
endfunction endfunction
function! vimwiki#base#is_among_diary_files(filename, diary_file_paths) abort function! vimwiki#base#is_diary_file(filename, ...) abort
" Check if filename is in a list of diary files " Check if 1.filename is a diary file
" An optional second argument allows you to pass in a list of diary files rather
" than generating a list on each call to the function.
let l:diary_file_paths = a:0 > 0 ? a:1 : vimwiki#diary#get_diary_files()
let l:normalised_file_paths = let l:normalised_file_paths =
\ map(a:diary_file_paths, 'vimwiki#path#normalize(v:val)') \ map(l:diary_file_paths, 'vimwiki#path#normalize(v:val)')
" Escape single quote (Issue #886) " Escape single quote (Issue #886)
let filename = substitute(a:filename, "'", "''", 'g') let filename = substitute(a:filename, "'", "''", 'g')
let l:matching_files = let l:matching_files =
@@ -2688,32 +2683,6 @@ function! vimwiki#base#is_among_diary_files(filename, diary_file_paths) abort
endfunction endfunction
function! vimwiki#base#is_diary_file(filename, ...) abort
" Check if filename is a diary file.
"
" For our purposes, a diary file is any readable file with the current wiki
" extension in diary_rel_path.
"
" An optional second argument allows you to pass in a list of diary files
" rather than generating a list on each call to the function. This is
" handled by passing off to is_among_diary_files(). This behavior is
" retained just in case anyone has scripted against is_diary_file(), but
" shouldn't be used internally by VimWiki code. Call is_among_diary_files()
" directly instead.
" Handle the case with diary file paths passed in:
if a:0 > 0
return vimwiki#base#is_among_diary_files(a:filename, a:1)
endif
let l:readable = filereadable(a:filename)
let l:diary_path = vimwiki#vars#get_wikilocal('path') .
\ vimwiki#vars#get_wikilocal('diary_rel_path')
let l:in_diary_path = (0 == stridx(a:filename, l:diary_path))
return l:readable && l:in_diary_path
endfunction
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) abort function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) abort
" Treat link string towards normalization " Treat link string towards normalization
" [__LinkDescription__](__LinkUrl__.__FileExtension__) " [__LinkDescription__](__LinkUrl__.__FileExtension__)
@@ -2900,17 +2869,11 @@ endfunction
function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort
" Complete globlinks escaping " Complete escaping globlinks
return vimwiki#base#get_globlinks_escaped(a:ArgLead) return vimwiki#base#get_globlinks_escaped(a:ArgLead)
endfunction endfunction
function! vimwiki#base#complete_links_raw(ArgLead, CmdLine, CursorPos) abort
" Complete globlinks as raw string (unescaped)
return vimwiki#base#get_globlinks_raw(a:ArgLead)
endfunction
function! vimwiki#base#complete_file(ArgLead, CmdLine, CursorPos) abort function! vimwiki#base#complete_file(ArgLead, CmdLine, CursorPos) abort
" Complete filename relative to current file " Complete filename relative to current file
" Called: rename_file " Called: rename_file
+2 -6
View File
@@ -37,12 +37,8 @@ endfunction
function! vimwiki#diary#diary_date_link(...) abort function! vimwiki#diary#diary_date_link(...) abort
" Return: <String> date " Return: <String> date
if a:0 > 2
" user supply wiki number as 1 indexed, not 0 indexed
let wiki_nr = a:3 - 1
else
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr') let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
endif
if wiki_nr < 0 " this happens when called outside a wiki buffer if wiki_nr < 0 " this happens when called outside a wiki buffer
let wiki_nr = 0 let wiki_nr = 0
endif endif
@@ -527,7 +523,7 @@ endfunction
function! vimwiki#diary#calendar_sign(day, month, year) abort function! vimwiki#diary#calendar_sign(day, month, year) abort
" Callback function for Calendar.vim " Callback function for Calendar.vim
" Clause: no wiki no sign #290 " Clause: no wiki no sign #290
if exists('g:vimwiki_list') && len(g:vimwiki_list) <= 0 if len(g:vimwiki_list) <= 0
return return
endif endif
let day = s:prefix_zero(a:day) let day = s:prefix_zero(a:day)
+2 -2
View File
@@ -1898,12 +1898,12 @@ function! s:convert_file(path_html, wikifile) abort
endwhile endwhile
let tmp = ('tmp'. split(system('mktemp -p . --suffix=.' . type, 'silent'), 'tmp')[-1])[:-2] let tmp = ('tmp'. split(system('mktemp -p . --suffix=.' . type, 'silent'), 'tmp')[-1])[:-2]
call system('echo ' . shellescape(join(html_lines[start : cur - 1], "\n")) . ' > ' . tmp) call system('echo ' . shellescape(join(html_lines[start : cur - 1], '\n')) . ' > ' . tmp)
call system(g:vimwiki_global_vars['listing_hl_command'] . ' ' . tmp . ' > ' . tmp . '.html') call system(g:vimwiki_global_vars['listing_hl_command'] . ' ' . tmp . ' > ' . tmp . '.html')
let html_out = system('cat ' . tmp . '.html') let html_out = system('cat ' . tmp . '.html')
call system('rm ' . tmp . ' ' . tmp . '.html') call system('rm ' . tmp . ' ' . tmp . '.html')
let i = cur let i = cur
let html_lines = html_lines[0 : start - 1] + split(html_out, "\n") + html_lines[cur : ] let html_lines = html_lines[0 : start - 1] + split(html_out, '\n') + html_lines[cur : ]
endif endif
let i += 1 let i += 1
endwhile endwhile
+1 -2
View File
@@ -100,8 +100,7 @@ function! s:normalize_link_syntax_n() abort
let sub = vimwiki#base#normalize_link_in_diary(lnk) let sub = vimwiki#base#normalize_link_in_diary(lnk)
else else
let sub = vimwiki#base#normalize_link_helper(lnk, let sub = vimwiki#base#normalize_link_helper(lnk,
\ vimwiki#vars#get_global('rxWord'), \ vimwiki#vars#get_global('rxWord'), '',
\ vimwiki#vars#get_global('rxWord'),
\ vimwiki#vars#get_syntaxlocal('Link1')) \ vimwiki#vars#get_syntaxlocal('Link1'))
endif endif
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub) call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
+8 -9
View File
@@ -123,12 +123,15 @@ function! s:scan_tags(lines, page_name) abort
" Scan line for tags. There can be many of them. " Scan line for tags. There can be many of them.
let str = line let str = line
while 1
" Get all matches " Get all matches
let tag_groups = [] let tag_groups = []
call substitute(str, tag_search_rx, '\=add(tag_groups, submatch(0))', 'g') call substitute(str, tag_search_rx, '\=add(tag_groups, submatch(0))', 'g')
if tag_groups == [] if tag_groups == []
continue break
endif endif
let tagend = matchend(str, tag_search_rx)
let str = str[(tagend):]
for tag_group in tag_groups for tag_group in tag_groups
for tag in split(tag_group, tag_format.sep) for tag in split(tag_group, tag_format.sep)
" Create metadata entry " Create metadata entry
@@ -151,6 +154,7 @@ function! s:scan_tags(lines, page_name) abort
call add(entries, entry) call add(entries, entry)
endfor endfor
endfor endfor
endwhile
endfor " loop over lines endfor " loop over lines
return entries return entries
@@ -360,28 +364,22 @@ function! vimwiki#tags#generate_tags(create, ...) abort
" make a dictionary { tag_name: [tag_links, ...] } " make a dictionary { tag_name: [tag_links, ...] }
let tags_entries = {} let tags_entries = {}
for tagname in self.specific_tags
let tags_entries[tagname] = []
endfor
for entries in values(metadata) for entries in values(metadata)
for entry in entries for entry in entries
if has_key(tags_entries, entry.tagname) if has_key(tags_entries, entry.tagname)
call add(tags_entries[entry.tagname], [entry.link, entry.description]) call add(tags_entries[entry.tagname], [entry.link, entry.description])
else else
if need_all_tags
let tags_entries[entry.tagname] = [[entry.link, entry.description]] let tags_entries[entry.tagname] = [[entry.link, entry.description]]
endif endif
endif
endfor endfor
unlet entry " needed for older vims with sticky type checking since name is reused unlet entry " needed for older vims with sticky type checking since name is reused
endfor endfor
let tagnames = need_all_tags ? sort(keys(tags_entries)) : self.specific_tags
let lines = [] let lines = []
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' ' let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' '
let current_dir = vimwiki#base#current_subdir() let current_dir = vimwiki#base#current_subdir()
for tagname in tagnames for tagname in sort(keys(tags_entries))
if need_all_tags || index(self.specific_tags, tagname) != -1
if len(lines) > 0 if len(lines) > 0
call add(lines, '') call add(lines, '')
endif endif
@@ -424,6 +422,7 @@ function! vimwiki#tags#generate_tags(create, ...) abort
call add(lines, bullet . substitute(link_tpl, '__LinkUrl__', taglink, '')) call add(lines, bullet . substitute(link_tpl, '__LinkUrl__', taglink, ''))
endif endif
endfor endfor
endif
endfor endfor
return lines return lines
+6 -7
View File
@@ -149,9 +149,7 @@ function! vimwiki#tbl#get_cells(line, ...) abort
let state = 'NONE' let state = 'NONE'
let cell_start = 0 let cell_start = 0
let quote_start = 0 let quote_start = 0
" Split byte string into list of character to properly handle multibyte chars let len = strlen(a:line) - 1
let chars = split(a:line, '\zs')
let len = len(chars) - 1
" 'Simple' FSM " 'Simple' FSM
while state !=# 'CELL' while state !=# 'CELL'
@@ -159,9 +157,10 @@ function! vimwiki#tbl#get_cells(line, ...) abort
let state = 'CELL' let state = 'CELL'
endif endif
for idx in range(quote_start, len) for idx in range(quote_start, len)
let ch = chars[idx] " The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state ==# 'NONE' if state ==# 'NONE'
if ch ==# s:s_sep() && (idx < 1 || chars[idx-1] !=# '\') if ch ==# s:s_sep() && (idx < 1 || a:line[idx-1] !=# '\')
let cell_start = idx + 1 let cell_start = idx + 1
let state = 'CELL' let state = 'CELL'
endif endif
@@ -169,8 +168,8 @@ function! vimwiki#tbl#get_cells(line, ...) abort
if ch ==# '[' || ch ==# '{' if ch ==# '[' || ch ==# '{'
let state = 'BEFORE_QUOTE_START' let state = 'BEFORE_QUOTE_START'
let quote_start = idx let quote_start = idx
elseif ch ==# s:s_sep() && (idx < 1 || chars[idx-1] !=# '\') elseif ch ==# s:s_sep() && (idx < 1 || a:line[idx-1] !=# '\')
let cell = join(chars[cell_start : idx-1], '') let cell = strpart(a:line, cell_start, idx - cell_start)
if a:0 && a:1 if a:0 && a:1
let cell = substitute(cell, '^ \(.*\) $', '\1', '') let cell = substitute(cell, '^ \(.*\) $', '\1', '')
else else
+6 -6
View File
@@ -303,11 +303,11 @@ endfunction
function! vimwiki#u#hi_expand_regex(lst) abort function! vimwiki#u#hi_expand_regex(lst) abort
" Helper: Expand regex from reduced typeface delimiters " Helper: Expand regex from reduced typeface delimiters
" :param: list<list<delimiters>> with reduced regex " :param: list<list,delimiters>> with reduced regex
" 1: Left delimiter (regex) " 1: Left delimiter
" 2: Right delimiter (regex) " 2: right delimiter
" 3: Possible characters to ignore (regex: default '$^' => never match) " 3: possible characters to ignore (default '$^' => never match)
" 4: Can multiply delimiter (boolean: default 0 => do not repeat) " 4: can multiply delimiter (boolean) (default 0 => do not repeat)
" Return: list with extended regex delimiters (not inside a word) " Return: list with extended regex delimiters (not inside a word)
" -- [['\*_', '_\*']] -> [['\*_\S\@=', '\S\@<=_\*\%(\s\|$\)\@=']] " -- [['\*_', '_\*']] -> [['\*_\S\@=', '\S\@<=_\*\%(\s\|$\)\@=']]
" Note: For purposes of this definition, the beginning and the end of the line count as Unicode whitespace. " Note: For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.
@@ -354,7 +354,7 @@ function! vimwiki#u#hi_expand_regex(lst) abort
" Right Case2: preceded by a punctuation character and followed by Unicode whitespace or end of line or a punctuation character " Right Case2: preceded by a punctuation character and followed by Unicode whitespace or end of line or a punctuation character
let r_right_prefix2 = '\%([' . punctuation . ']\@<=\)' let r_right_prefix2 = '\%([' . punctuation . ']\@<=\)'
let r_right_suffix2 = '\%(\%($\|[[:space:]\n' . punctuation . ']\)\@=\)' let r_right_suffix2 = '\%(\%($\|[[:space:]' . punctuation . ']\)\@<=\)'
" Right Concatenate " Right Concatenate
let r_end = '\%(' . r_right_prefix1 . r_right_repeat . r_right_suffix1 let r_end = '\%(' . r_right_prefix1 . r_right_repeat . r_right_suffix1
+13 -40
View File
@@ -177,7 +177,7 @@ function! s:get_default_global() abort
\ [ \ [
\ 'http', 'https', 'file', 'ftp', 'gopher', 'telnet', 'nntp', 'ldap', \ 'http', 'https', 'file', 'ftp', 'gopher', 'telnet', 'nntp', 'ldap',
\ 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh', \ 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh',
\ 'git', 'ssh', 'fish', 'sftp', 'thunderlink', 'message' \ 'git', 'ssh', 'fish', 'sftp', 'thunderlink'
\ ]}, \ ]},
\ 'schemes_any': {'type': type([]), 'default': ['mailto', 'matrix', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data']}, \ 'schemes_any': {'type': type([]), 'default': ['mailto', 'matrix', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data']},
\ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
@@ -476,7 +476,6 @@ function! s:get_default_wikilocal() abort
\ 'auto_toc': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'auto_toc': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'automatic_nested_syntaxes': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'automatic_nested_syntaxes': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'base_url': {'type': type(''), 'default': '', 'min_length': 1}, \ 'base_url': {'type': type(''), 'default': '', 'min_length': 1},
\ 'bullet_types': {'type': type([]), 'default': []},
\ 'color_dic': {'type': type({}), 'default': { \ 'color_dic': {'type': type({}), 'default': {
\ 'default': ['', '#d79921'], \ 'default': ['', '#d79921'],
\ 'red': ['#cc241d', ''], \ 'red': ['#cc241d', ''],
@@ -498,7 +497,6 @@ function! s:get_default_wikilocal() abort
\ 'css_name': {'type': type(''), 'default': 'style.css', 'min_length': 1}, \ 'css_name': {'type': type(''), 'default': 'style.css', 'min_length': 1},
\ 'custom_wiki2html': {'type': type(''), 'default': ''}, \ 'custom_wiki2html': {'type': type(''), 'default': ''},
\ 'custom_wiki2html_args': {'type': type(''), 'default': ''}, \ 'custom_wiki2html_args': {'type': type(''), 'default': ''},
\ 'cycle_bullets': {'type': type(0), 'default': 0},
\ 'diary_frequency': {'type': type(''), 'default': 'daily', 'possible_values': ['daily', 'weekly', 'monthly', 'yearly']}, \ 'diary_frequency': {'type': type(''), 'default': 'daily', 'possible_values': ['daily', 'weekly', 'monthly', 'yearly']},
\ 'diary_start_week_day': {'type': type(''), 'default': 'monday', 'possible_values': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']}, \ 'diary_start_week_day': {'type': type(''), 'default': 'monday', 'possible_values': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']},
\ 'diary_header': {'type': type(''), 'default': 'Diary', 'min_length': 1}, \ 'diary_header': {'type': type(''), 'default': 'Diary', 'min_length': 1},
@@ -508,6 +506,8 @@ function! s:get_default_wikilocal() abort
\ 'diary_sort': {'type': type(''), 'default': 'desc', 'possible_values': ['asc', 'desc']}, \ 'diary_sort': {'type': type(''), 'default': 'desc', 'possible_values': ['asc', 'desc']},
\ 'exclude_files': {'type': type([]), 'default': []}, \ 'exclude_files': {'type': type([]), 'default': []},
\ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1}, \ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1},
\ 'bullet_types': {'type': type([]), 'default': []},
\ 'cycle_bullets': {'type': type(0), 'default': 0},
\ 'html_filename_parameterization': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'html_filename_parameterization': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'generated_links_caption': {'type': type(0), 'default': 0 }, \ 'generated_links_caption': {'type': type(0), 'default': 0 },
\ 'index': {'type': type(''), 'default': 'index', 'min_length': 1}, \ 'index': {'type': type(''), 'default': 'index', 'min_length': 1},
@@ -676,7 +676,6 @@ function! s:get_default_syntaxlocal() abort
" type, default, min, max, possible_values, min_length " type, default, min, max, possible_values, min_length
return extend(s:get_common_syntaxlocal(), { return extend(s:get_common_syntaxlocal(), {
\ 'blockquote_markers': {'type': type([]), 'default': ['>', '::']},
\ 'bold_match': {'type': type(''), 'default': '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='}, \ 'bold_match': {'type': type(''), 'default': '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='},
\ 'bold_search': {'type': type(''), 'default': '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='}, \ 'bold_search': {'type': type(''), 'default': '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='},
\ 'bullet_types': {'type': type([]), 'default': ['-', '*', '#']}, \ 'bullet_types': {'type': type([]), 'default': ['-', '*', '#']},
@@ -685,6 +684,7 @@ function! s:get_default_syntaxlocal() abort
\ 'list_markers': {'type': type([]), 'default': ['-', '1.', '*', 'I)', 'a)']}, \ 'list_markers': {'type': type([]), 'default': ['-', '1.', '*', 'I)', 'a)']},
\ 'number_types': {'type': type([]), 'default': ['1)', '1.', 'i)', 'I)', 'a)', 'A)']}, \ 'number_types': {'type': type([]), 'default': ['1)', '1.', 'i)', 'I)', 'a)', 'A)']},
\ 'recurring_bullets': {'type': type(0), 'default': 0}, \ 'recurring_bullets': {'type': type(0), 'default': 0},
\ 'comment_regex': {'type': type(''), 'default': '^\s*%%.*$'},
\ 'header_symbol': {'type': type(''), 'default': '='}, \ 'header_symbol': {'type': type(''), 'default': '='},
\ 'rxHR': {'type': type(''), 'default': '^-----*$'}, \ 'rxHR': {'type': type(''), 'default': '^-----*$'},
\ 'rxListDefine': {'type': type(''), 'default': '::\(\s\|$\)'}, \ 'rxListDefine': {'type': type(''), 'default': '::\(\s\|$\)'},
@@ -699,10 +699,10 @@ function! s:get_default_syntaxlocal() abort
\ 'post_mark': '}}}'}}, \ 'post_mark': '}}}'}},
\ 'symH': {'type': type(1), 'default': 1}, \ 'symH': {'type': type(1), 'default': 1},
\ 'typeface': {'type': type({}), 'default': { \ 'typeface': {'type': type({}), 'default': {
\ 'bold': vimwiki#u#hi_expand_regex([['\*', '\*', '[*]', 0]]), \ 'bold': vimwiki#u#hi_expand_regex([['\*', '\*']]),
\ 'italic': vimwiki#u#hi_expand_regex([['_', '_', '[_]', 0]]), \ 'italic': vimwiki#u#hi_expand_regex([['_', '_']]),
\ 'underline': vimwiki#u#hi_expand_regex([]), \ 'underline': vimwiki#u#hi_expand_regex([]),
\ 'bold_italic': vimwiki#u#hi_expand_regex([['\*_', '_\*', '[*_]', 1], ['_\*', '\*_', '[*_]', 1]]), \ 'bold_italic': vimwiki#u#hi_expand_regex([['\*_', '_\*'], ['_\*', '\*_']]),
\ 'code': [ \ 'code': [
\ ['\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@=', \ ['\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@=',
\ '\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@='], \ '\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@='],
@@ -737,6 +737,7 @@ function! s:get_markdown_syntaxlocal() abort
\ 'list_markers': {'type': type([]), 'default': ['-', '*', '+', '1.']}, \ 'list_markers': {'type': type([]), 'default': ['-', '*', '+', '1.']},
\ 'number_types': {'type': type([]), 'default': ['1.']}, \ 'number_types': {'type': type([]), 'default': ['1.']},
\ 'recurring_bullets': {'type': type(0), 'default': 0}, \ 'recurring_bullets': {'type': type(0), 'default': 0},
\ 'comment_regex': {'type': type(''), 'default': '^\s*%%.*$\|<!--[^>]*-->'},
\ 'header_symbol': {'type': type(''), 'default': '#'}, \ 'header_symbol': {'type': type(''), 'default': '#'},
\ 'rxHR': {'type': type(''), 'default': '\(^---*$\|^___*$\|^\*\*\**$\)'}, \ 'rxHR': {'type': type(''), 'default': '\(^---*$\|^___*$\|^\*\*\**$\)'},
\ 'rxListDefine': {'type': type(''), 'default': '::\%(\s\|$\)'}, \ 'rxListDefine': {'type': type(''), 'default': '::\%(\s\|$\)'},
@@ -791,6 +792,7 @@ function! s:get_media_syntaxlocal() abort
\ 'list_markers': {'type': type([]), 'default': ['*', '#']}, \ 'list_markers': {'type': type([]), 'default': ['*', '#']},
\ 'number_types': {'type': type([]), 'default': []}, \ 'number_types': {'type': type([]), 'default': []},
\ 'recurring_bullets': {'type': type(1), 'default': 1}, \ 'recurring_bullets': {'type': type(1), 'default': 1},
\ 'comment_regex': {'type': type(''), 'default': '^\s*%%.*$'},
\ 'header_symbol': {'type': type(''), 'default': '='}, \ 'header_symbol': {'type': type(''), 'default': '='},
\ 'rxHR': {'type': type(''), 'default': '^-----*$'}, \ 'rxHR': {'type': type(''), 'default': '^-----*$'},
\ 'rxListDefine': {'type': type(''), 'default': '^\%(;\|:\)\s'}, \ 'rxListDefine': {'type': type(''), 'default': '^\%(;\|:\)\s'},
@@ -831,14 +833,14 @@ function! s:get_common_syntaxlocal() abort
let rx_yaml_start_pre = '\%(^\%(\%1l\|^$\n\)\@<=\)' let rx_yaml_start_pre = '\%(^\%(\%1l\|^$\n\)\@<=\)'
let rx_yaml_start_post = '\%(\%(\n^$\)\@!$\)' let rx_yaml_start_post = '\%(\%(\n^$\)\@!$\)'
let rx_yaml_start = rx_yaml_start_pre . '---' . rx_yaml_start_post let rx_yaml_start = rx_yaml_start_pre . '---' . rx_yaml_start_post
let rx_yaml_end = '^\%(---\|\.\.\.\)\s*$' let rx_yaml_stop = '^' . '\%(---\|\.\.\.\)' . '$'
let res.nested_extended = {'type': type(''), 'default': 'VimwikiError,VimwikiPre,VimwikiCode,VimwikiEqIn,VimwikiSuperScript,VimwikiSubScript,textSnipTEX'} let res.nested_extended = {'type': type(''), 'default': 'VimwikiError,VimwikiPre,VimwikiCode,VimwikiEqIn,VimwikiSuperScript,VimwikiSubScript,textSnipTEX'}
let res.nested_typeface = {'type': type(''), 'default': 'VimwikiBold,VimwikiItalic,VimwikiUnderline,VimwikiDelText'} let res.nested_typeface = {'type': type(''), 'default': 'VimwikiBold,VimwikiItalic,VimwikiUnderline,VimwikiDelText'}
let res.nested = {'type': type(''), 'default': res.nested_extended.default . ',' . res.nested_typeface.default} let res.nested = {'type': type(''), 'default': res.nested_extended.default . ',' . res.nested_typeface.default}
let res.rxTableSep = {'type': type(''), 'default': '|'} let res.rxTableSep = {'type': type(''), 'default': '|'}
" See issue #1287 " See issue #1287
let res.yaml_metadata_block = {'type': type([]), 'default': [[rx_yaml_start, rx_yaml_end]]} let res.yaml_metadata_block = {'type': type([]), 'default': [[rx_yaml_start, rx_yaml_stop]]}
" Declare helper for inline math nested variable " Declare helper for inline math nested variable
let s:rx_inline_math_start = '\%(^\|[^$\\]\)\@<=\$\%($\|[^$[:space:]]\)\@=' let s:rx_inline_math_start = '\%(^\|[^$\\]\)\@<=\$\%($\|[^$[:space:]]\)\@='
@@ -848,13 +850,6 @@ function! s:get_common_syntaxlocal() abort
" -- it should not be changed but let's avoid hardcoding " -- it should not be changed but let's avoid hardcoding
let res.blockquote_markers = {'type': type([]), 'default': ['>']} let res.blockquote_markers = {'type': type([]), 'default': ['>']}
" HTML comment
let res.comment_regex = {'type': type(''), 'default': '\%(^\s*%%.*$\|<!--\%([^>]\|\n\)*-->\)'}
" Opening link with dot in the ref, see #1271 and ref and Brennen comment:
" -- https://github.com/vimwiki/vimwiki/issues/1271#issuecomment-1482207680
let res.open_link_add_ext = {'type': type(1), 'default': 1}
return res return res
endfunction endfunction
@@ -1234,7 +1229,7 @@ function! s:populate_extra_markdown_vars() abort
let mkd_syntax.rxWeblink1Prefix = '[' let mkd_syntax.rxWeblink1Prefix = '['
let mkd_syntax.rxWeblink1Suffix = ')' let mkd_syntax.rxWeblink1Suffix = ')'
let mkd_syntax.rxWeblink1EscapeCharsSuffix = '\(\\\)\@<!\(>\=)\)' let mkd_syntax.rxWeblink1EscapeCharsSuffix = '\(\\\)\@<!\()\)'
let mkd_syntax.rxWeblink1Separator = '](' let mkd_syntax.rxWeblink1Separator = ']('
let rxWeblink1Ext = '' let rxWeblink1Ext = ''
@@ -1259,7 +1254,7 @@ function! s:populate_extra_markdown_vars() abort
let valid_chars_url = '[^[:cntrl:]]' let valid_chars_url = '[^[:cntrl:]]'
let mkd_syntax.rxWeblink1Prefix = vimwiki#u#escape(mkd_syntax.rxWeblink1Prefix) let mkd_syntax.rxWeblink1Prefix = vimwiki#u#escape(mkd_syntax.rxWeblink1Prefix)
let mkd_syntax.rxWeblink1Separator = '\](<\=' let mkd_syntax.rxWeblink1Separator = vimwiki#u#escape(mkd_syntax.rxWeblink1Separator)
let mkd_syntax.rxWeblink1Url = valid_chars_url.'\{-}' let mkd_syntax.rxWeblink1Url = valid_chars_url.'\{-}'
let mkd_syntax.rxWeblink1Descr = valid_chars.'\{-}' let mkd_syntax.rxWeblink1Descr = valid_chars.'\{-}'
let mkd_syntax.WikiLinkMatchUrlTemplate = let mkd_syntax.WikiLinkMatchUrlTemplate =
@@ -1611,28 +1606,6 @@ function! vimwiki#vars#get_syntaxlocal(key, ...) abort
endfunction endfunction
function! vimwiki#vars#set_syntaxlocal(key, value, ...) abort
" Set syntax variable
" Param: 1: key (<string>)
" Param: 2: value (<any type>)
" Param: (3): syntax name (<string> ex:'markdown')
" Set desired syntax variable to value
if a:0
let syntax = a:1
else
let syntax = vimwiki#vars#get_wikilocal('syntax')
endif
" Create syntax variable dict if not exists (lazy)
if !exists('g:vimwiki_syntaxlocal_vars') || !has_key(g:vimwiki_syntaxlocal_vars, syntax)
call vimwiki#vars#populate_syntax_vars(syntax)
endif
" Set d_syntax[a:key]
let g:vimwiki_syntaxlocal_vars[syntax][a:key] = a:value
endfunction
function! vimwiki#vars#get_bufferlocal(key, ...) abort function! vimwiki#vars#get_bufferlocal(key, ...) abort
" Return: buffer local variable " Return: buffer local variable
" for the buffer we are currently in or for the given buffer (number or name). " for the buffer we are currently in or for the given buffer (number or name).
+171
View File
@@ -0,0 +1,171 @@
= Contents =
- [[#VimWiki file link resolution]]
- [[#context]]
- [[#possible solutions]]
- [[#revert to original behavior]]
- [[#check if a file exists on disk when following link]]
- [[#add a link scheme that means "open in vim"]]
- [[#add a configuration toggle for opening file: links in vim]]
- [[#add configuration for a set of filetypes to open in vim]]
- [[#open questions]]
= VimWiki file link resolution =
A decision document started by Brennen Bearnes on 2023-03-23.
== context ==
https://github.com/vimwiki/vimwiki/issues/950
https://github.com/vimwiki/vimwiki/commit/d7ec12645a0460a7d200279c52915e6e080e9869
Commit d7ec126 applies the wiki extension to files containing a `.`, thus
allowing page names to contain a literal period. This is correct behavior,
insofar as pages like `Franklin D. Roosevelt` should be able to exist and get
mapped to e.g. `Franklin D. Roosevelt.wiki`.
Unfortunately, this broke behavior that a number of users rely on:
https://github.com/vimwiki/vimwiki/issues/1271
I have some latex files stored and linked to in my wiki.
Before d7ec126 I could omit the file: part of a link to have vim open the file
directly.
After d7ec126 vimwiki adds a `md` extension when opening any file which
results in a `filename.tex.md` being created alongside the original tex
file. Using `file:` is not a solution since this can only be configured to
open a second instance of vim.
It makes sense that this is useful.
Sidebar: `file:` _can_ be configured to do just about anything with a custom
handler, but that doesn't mean it's a very good user experience.
= possible solutions =
== revert to original behavior ==
As a default, I personally think this is a non-starter. Not being able to use
`.` in page names is broken. I also suspect other things break if you treat
those files as wiki pages.
We could make it configurable, though.
*Pro:*
- People can go back to their expected behavior by setting one config
variable.
*Con:*
- Adds an extra branch to link handling code.
- I haven't thought through the implications of treating it as fully
supported behavior. What else will people expect to work right?
== check if a file exists on disk when following link ==
The idea is that if a link is `[[foo.txt]]` and `foo.txt` already exists, we
should edit the existing file instead of creating a `foo.txt.md`.
*Pro:*
- Might be the closest to expectations of people who rely on the old
behavior.
- Doesn't expand the language itself.
*Con:*
- Complicates link handling code.
- Parsing a page requires knowing about external files.
- Might be surprising / confusing. You can write `foo.txt` and wind up with
two different outcomes depending on whether `foo.txt` already exists.
- It's very Do What I Mean, which isn't necessarily bad. But if I write a
link to `foo.txt` and wind up at `foo.txt.md`, it's not obvious that's
what I meant.
== add a link scheme that means "open in vim" ==
Something like `[[edit:foo.txt]]`.
I vaguely think there's prior art for this in some older browsers? I could
swear Lynx had something like it, although I couldn't find anything under:
- [[https://en.wikipedia.org/wiki/List_of_URI_schemes|wp:List of URI schemes]]
- [[https://lynx.invisible-island.net/lynx_help/lynx_url_support.html|list of Lynx URL schemes]].
I may just be thinking of `lynxexec:`.
*Pro:*
- People want this anyway, and a `VimwikiLinkHandler()` for using `file:` or
some custom prefix to handle it is a common tweak to configurations which
we already document.
- It doesn't need a file existence check.
*Con:*
- Expands the language.
- How is this converted to HTML?
- What will Markdown parsers do with it?
- Right now there are at least 3 high-level paths for opening a link:
- Open in VimWiki
- Hand off to custom link handler
- Open with `vimwiki#base#system_open_link()`
- ...this would introduce a 4th.
- Unless there is prior art, this would be something that _looks_ like a
URL/URI, but isn't recognized outside the wiki. That seems fine for
custom prefixes, but is it ok to introduce here?
== add a configuration toggle for opening file: links in vim ==
Add a boolean that says "just open `file:` and `local:` links in the editor".
*Pro:*
- Probably a relatively simple change.
- Might meet some users' needs.
*Con:*
- Loses the utility in linking to binary filetypes which are best opened via
the system handler (images, PDFs, etc.).
- Users are explicitly already relying on `file:` links to be distinct from
`[[file.foo]]` links.
== add configuration for a set of filetypes to open in vim ==
A variation on the toggle for `file:` links would be to allow configuring a
_list_ of file extensions which should be opened with Vim rather than passed on
to the system handler.
Something like:
{{{vim
let wiki.file_link_edit_ext = ['txt', 'csv']
}}}
*Pro:*
- Doesn't expand the language.
- Doesn't have any implications for HTML rendering.
- A lot of `VimwikiLinkHandler()` boilerplate that is just used for making
links open in Vim could go away.
- I have this in my own config, so it's an appealing feature.
*Con:*
- Does require people to rewrite existing link collections, but that's
true of other solutions as well.
*Unanswered:*
- Would there be any sensible default for this besides an empty list?
My guess is not.
= open questions =
- What is the actual current behavior with Markdown?
- Does it differ meaningfully from vimwiki syntax?
- If so, why?
+4 -16
View File
@@ -4,6 +4,9 @@ This file is meant to document design decisions and algorithms inside Vimwiki
which are too large for code comments, and not necessarily interesting to which are too large for code comments, and not necessarily interesting to
users. Please create a new section to document each behavior. users. Please create a new section to document each behavior.
## Link resolution
See [VimWiki file link resolution](./2023-03-23-file-link-resolution.wiki).
## Formatting tables ## Formatting tables
@@ -245,24 +248,9 @@ reasons for such a complex system is:
TODO currently the typeface delimiters are customized that way: TODO currently the typeface delimiters are customized that way:
```vim ```vim
" Typeface: -> u.vim
" 1/ Redraw: Typeface: -> u.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let s:typeface_dic = vimwiki#vars#get_syntaxlocal('typeface') let s:typeface_dic = vimwiki#vars#get_syntaxlocal('typeface')
call vimwiki#u#hi_typeface(s:typeface_dic) call vimwiki#u#hi_typeface(s:typeface_dic)
" 2/ Clear typeface highlighting (see #1346)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Create a dic with no highlight but yes with all keys
" -- So that they are effectivemly overwritten
let typeface_dic = {'bold': [], 'italic': [], 'underline': [], 'bold_italic': [], 'code': [], 'del': [], 'sup': [], 'sub': [], 'eq': []}
" Just for consistency, this is an internal variable
echo vimwiki#vars#set_syntaxlocal('typeface', typeface_dic)
" Here is a Vim aware syntax highlighting big command
verbose call vimwiki#u#hi_typeface(typeface_dic)
``` ```
+5 -74
View File
@@ -479,13 +479,13 @@ glp Decrease the "done" status.
gll n Increase the level of a list item. gll n Increase the level of a list item.
Remap command: `<Plug>VimwikiIncreaseLvlSingleItem` Remap command: `<Plug>VimwikiIncreaseLvlSingleItem`
gLl Increase the level of a list item and all child items. gLl Increase the level of a list item and all child items.
or gLL Remap command: `<Plug>VimwikiIncreaseLvlWholeItem` Remap command: `<Plug>VimwikiIncreaseLvlWholeItem`
*vimwiki_glh* *vimwiki_gLh* *vimwiki_glh* *vimwiki_gLh*
glh n Decrease the level of a list item. glh n Decrease the level of a list item.
Remap command: `<Plug>VimwikiDecreaseLvlSingleItem` Remap command: `<Plug>VimwikiDecreaseLvlSingleItem`
gLh Decrease the level of a list item and all child items. gLh Decrease the level of a list item and all child items.
or gLH Remap command: `<Plug>VimwikiDecreaseLvlWholeItem` Remap command: `<Plug>VimwikiDecreaseLvlWholeItem`
*vimwiki_glr* *vimwiki_gLr* *vimwiki_glr* *vimwiki_gLr*
glr n Renumber list items if the cursor is on a numbered glr n Renumber list items if the cursor is on a numbered
@@ -516,13 +516,6 @@ gl- n Make a list item out of a normal line or change the
gL- Change the symbol of the current list to -. gL- Change the symbol of the current list to -.
Remap command: `:VimwikiChangeSymbolInListTo -<CR>` Remap command: `:VimwikiChangeSymbolInListTo -<CR>`
*vimwiki_gl+* *vimwiki_gL+*
gl+ n Make a list item out of a normal line or change the
symbol of the current item to +.
Remap command: `:VimwikiChangeSymbolTo +<CR>`
gL+ Change the symbol of the current list to +.
Remap command: `:VimwikiChangeSymbolInListTo +<CR>`
*vimwiki_gl1* *vimwiki_gL1* *vimwiki_gl1* *vimwiki_gL1*
gl1 n Make a list item out of a normal line or change the gl1 n Make a list item out of a normal line or change the
symbol of the current item to 1., the numbering is symbol of the current item to 1., the numbering is
@@ -1521,7 +1514,7 @@ In this case, <mathjax_folder> would be "../mathjax" (without quotes).
2. Loading MathJax from a CDN-server (needs internet connection). 2. Loading MathJax from a CDN-server (needs internet connection).
Add to your HTML template the following lines: Add to your HTML template the following lines:
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script> <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
@@ -2731,7 +2724,7 @@ The last is for 100% done items.
You can set it to some more fancy symbols like this: You can set it to some more fancy symbols like this:
> >
let g:vimwiki_list = [{'path': '~/path/', 'listsyms': '✗○◐●✓'}] let g:vimwiki_list = [{'path': '~/path/', 'listsyms' = '✗○◐●✓'}]
*vimwiki-option-listsym_rejected* *vimwiki-option-listsym_rejected*
@@ -3282,7 +3275,7 @@ cannot otherwise convert the link. A customized handler might look like this: >
let str = a:value let str = a:value
" complete URL " complete URL
let url_0 = matchstr(str, g:vimwiki_global_vars.rxWikiInclMatchUrl) let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl)
" URL parts " URL parts
let link_infos = vimwiki#base#resolve_link(url_0) let link_infos = vimwiki#base#resolve_link(url_0)
let arg1 = matchstr(str, VimwikiWikiInclMatchArg(1)) let arg1 = matchstr(str, VimwikiWikiInclMatchArg(1))
@@ -4007,19 +4000,8 @@ Contributors and their Github usernames in roughly chronological order:
- Jean-Luc Bastarache (@jlbas) - Jean-Luc Bastarache (@jlbas)
- Youssof Taha (@ysftaha) - Youssof Taha (@ysftaha)
- Thomas Leyh (@leyhline) - Thomas Leyh (@leyhline)
- Charles Schimmelpfennig (@charlesschimmel)
- nebulaeandstars (@nebulaeandstars) - nebulaeandstars (@nebulaeandstars)
- dmitry kim (@jsn) - dmitry kim (@jsn)
- Julian Prein (@druckdev)
- Luke Atkinson (@LukeDAtkinson)
- Joe Planisky (@jplanisky)
- Bence Ferdinandy (@ferdinandyb)
- R. David Dunphy (@rdunphy)
- Aarón Fas (@aaronfc)
- @jiamingc
- Alex Claman (@claman)
- @qadzek
============================================================================== ==============================================================================
16. Changelog *vimwiki-changelog* 16. Changelog *vimwiki-changelog*
@@ -4037,54 +4019,6 @@ master is retained as a legacy mirror of the dev branch.
This is somewhat experimental, and will probably be refined over time. This is somewhat experimental, and will probably be refined over time.
2024.01.24~
New:~
* PR #1389: Document gLH, gl+, and gL+ mappings
* Tidy some aspects of README.md, remove pointers to defunct Matrix
channel and Google Group, add wikis.world Mastodon account.
2024.01.22~
New:~
* Issue #1279: Fix/Improvement: When re-wrap a long line in a definition
by 'gq' it should insert ':: ' at the new line
* Issue #1211: Support angle bracket escaped markdown urls
* Make auto_tags preserve existing tag section structure
* Issue #1315: GTD-style token highlighting
* Issue #1279: gqq autowrap leading :: definition as &l:comments
* Issue #1332: message URLs on Mac
* Util: add vimwiki#vars#set_syntaxlocal function for consistency
Fixed:~
* Issue #1365: Fix: count ignored when looking up diary frequency Issue
* Issue #1323: Folding code blocks using markdown syntax folds the entire rest of
the file
* Issue #1365: Jumping to nested anchor with markdown
* Issue #1297: Handle multibyte chars properly in table separators
* Issue #1311: Newlines in HTML conversion of codeblocks
* Issue #1326: Duplicate tag generation
* Issue #1324: File name prompt fixes
* Fix vimwiki#diary#calendar_sign when g:vimwiki_list is not set
* Use fnameescape() instead of escape() in edit_file()
* Admit trailing spaces for YAML delimiters
* Minor documentation fixes and CI improvements
2023.04.04~
Fixed:~
* Issue #1229: VimwikiGoto completion with file with space
Must complete file unescaped as argument is then quoted
* PR #1324: Fix pressing escape in VimwikiGoto prompt (rddunphy)
* Issue #1336: vimwiki#diary#calendar_sign throws an error
when g:vimwiki_list is not set
2023.04.04~
New:~ New:~
* Issue #1261: Feature: Support for <mark> in Markdown * Issue #1261: Feature: Support for <mark> in Markdown
highlighting with yellow background and back foreground highlighting with yellow background and back foreground
@@ -4093,8 +4027,6 @@ New:~
Also add the |blockquote_markers| variable Also add the |blockquote_markers| variable
Fixed:~ Fixed:~
* Issue #1267: Improve performance on link creation by speeding up
is_diary_file()
* Issue #1229: Bug: VimwikiGoto without argument creates empty page * Issue #1229: Bug: VimwikiGoto without argument creates empty page
* Issue #1316: Permit tags in heading * Issue #1316: Permit tags in heading
and improve |VimwikiSearchTags| and |VimwikiRebuildTags| and improve |VimwikiSearchTags| and |VimwikiRebuildTags|
@@ -4166,7 +4098,6 @@ New:~
current file current file
* Feature: Add |VimwikiBaddLink| to add links to the buffer list, without * Feature: Add |VimwikiBaddLink| to add links to the buffer list, without
loading, if they weren't listed yet loading, if they weren't listed yet
* PR 1211: Enable parsing Markdown links escaped with angle brackets
Changed:~ Changed:~
* PR #1047: Allow to replace default mapping of VimwikiToggleListItem * PR #1047: Allow to replace default mapping of VimwikiToggleListItem
+5 -17
View File
@@ -149,10 +149,6 @@ for bullet in vimwiki#vars#get_syntaxlocal('bullet_types')
" list " list
let comments .= ',fb:' . bullet let comments .= ',fb:' . bullet
endfor endfor
" Add :: for vimwiki default syntax (#1279)
if 'default' ==# vimwiki#vars#get_wikilocal('syntax')
let comments .= ',b:::'
endif
let &l:comments = comments let &l:comments = comments
" Set Format Options: (:h fo-table) " Set Format Options: (:h fo-table)
@@ -193,22 +189,14 @@ function! VimwikiFoldLevel(lnum) abort
" Header/section folding... " Header/section folding...
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader') && !vimwiki#u#is_codeblock(a:lnum) if line =~# vimwiki#vars#get_syntaxlocal('rxHeader') && !vimwiki#u#is_codeblock(a:lnum)
return '>'.vimwiki#u#count_first_sym(line) return '>'.vimwiki#u#count_first_sym(line)
endif
" Code block folding... " Code block folding...
" -- previously it would always increment when it saw a ```, so we never left the code block. (See #1323) elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
let prevline = getline(v:lnum - 1)
let nextline = getline(v:lnum + 1)
" -- Start: assumes empty line before
if line =~# vimwiki#vars#get_syntaxlocal('rxPreStart') && prevline =~# '^\s*$'
return 'a1' return 'a1'
" -- End: assumes empty line after elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') && nextline =~# '^\s*$'
return 's1' return 's1'
endif else
return '=' return '='
endif
endfunction endfunction
@@ -334,7 +322,7 @@ command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
command! -buffer -nargs=* VimwikiSearch call vimwiki#base#search(<q-args>) command! -buffer -nargs=* VimwikiSearch call vimwiki#base#search(<q-args>)
command! -buffer -nargs=* VWS call vimwiki#base#search(<q-args>) command! -buffer -nargs=* VWS call vimwiki#base#search(<q-args>)
command! -buffer -nargs=* -complete=customlist,vimwiki#base#complete_links_raw command! -buffer -nargs=* -complete=customlist,vimwiki#base#complete_links_escaped
\ VimwikiGoto call vimwiki#base#goto(<q-args>) \ VimwikiGoto call vimwiki#base#goto(<q-args>)
command! -buffer -range VimwikiCheckLinks call vimwiki#base#check_links(<range>, <line1>, <line2>) command! -buffer -range VimwikiCheckLinks call vimwiki#base#check_links(<range>, <line1>, <line2>)
+5 -5
View File
@@ -11,7 +11,7 @@ endif
let g:loaded_vimwiki = 1 let g:loaded_vimwiki = 1
" Set to version number for release: " Set to version number for release:
let g:vimwiki_version = '2024.01.24' let g:vimwiki_version = '2022.12.02'
" Get the directory the script is installed in " Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h') let s:plugin_dir = expand('<sfile>:p:h:h')
@@ -366,11 +366,11 @@ command! -count=0 VimwikiTabMakeDiaryNote
command! -count=0 VimwikiMakeYesterdayDiaryNote command! -count=0 VimwikiMakeYesterdayDiaryNote
\ call vimwiki#diary#make_note(<count>, 0, \ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime(), -1, <count>)) \ vimwiki#diary#diary_date_link(localtime(), -1))
command! -count=0 VimwikiMakeTomorrowDiaryNote command! -count=0 VimwikiMakeTomorrowDiaryNote
\ call vimwiki#diary#make_note(<count>, 0, \ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime(), 1, <count>)) \ vimwiki#diary#diary_date_link(localtime(), 1))
command! VimwikiDiaryGenerateLinks command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section() \ call vimwiki#diary#generate_diary_section()
@@ -399,10 +399,10 @@ nnoremap <silent><script> <Plug>VimwikiTabMakeDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 1)<CR> \ :<C-U>call vimwiki#diary#make_note(v:count, 1)<CR>
nnoremap <silent><script> <Plug>VimwikiMakeYesterdayDiaryNote nnoremap <silent><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0, \ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime(), -1, v:count))<CR> \ vimwiki#diary#diary_date_link(localtime(), -1))<CR>
nnoremap <silent><script> <Plug>VimwikiMakeTomorrowDiaryNote nnoremap <silent><script> <Plug>VimwikiMakeTomorrowDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0, \ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime(), 1, v:count))<CR> \ vimwiki#diary#diary_date_link(localtime(), 1))<CR>
" Set default global key mappings " Set default global key mappings
-12
View File
@@ -168,12 +168,6 @@ elseif vimwiki#vars#get_global('hl_cb_checked') == 2
\ .'/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell' \ .'/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endif endif
" GTD-style token highlighting
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=VimwikiTodo
syntax match TodoDueDate 'due:\d\{2,4\}-\d\{2\}-\d\{2\}' contains=VimwikiTodo
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=VimwikiTodo
syntax match TodoContext '\(^\|\W\)@[^[:blank:]]\+' contains=VimwikiTodo
" Header Level: 1..6 " Header Level: 1..6
for s:i in range(1,6) for s:i in range(1,6)
@@ -501,12 +495,6 @@ hi def link VimwikiHeaderCharT VimwikiMarkers
hi def link VimwikiLinkCharT VimwikiLinkT hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
" GTD-style token highlighting
hi def link TodoDate PreProc
hi def link TodoDueDate VimWikiBold
hi def link TodoProject Constant
hi def link TodoContext Statement
" Load syntax-specific functionality " Load syntax-specific functionality
call vimwiki#u#reload_regexes_custom() call vimwiki#u#reload_regexes_custom()
-25
View File
@@ -1,25 +0,0 @@
# Test vimwiki#base#is_diary_file() for various inputs.
Execute (Check known good diary file):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('diary:2020-07-22')
Assert vimwiki#base#is_diary_file(link_infos.filename)
Execute (Check known good diary file using is_diary_file, with list of all diary files - legacy interface):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('diary:2020-07-22')
let diary_file_paths = vimwiki#diary#get_diary_files()
Assert vimwiki#base#is_diary_file(link_infos.filename, diary_file_paths)
Execute (Check known good diary file use is_among_diary_files, with list of all diary files):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('diary:2020-07-22')
let diary_file_paths = vimwiki#diary#get_diary_files()
Assert vimwiki#base#is_among_diary_files(link_infos.filename, diary_file_paths)
Execute (Check for nonexistent diary file):
VimwikiIndex 1
Assert !vimwiki#base#is_diary_file('not-a-diary-file')
Execute (Clean):
call ReloadVimwiki()
+6 -6
View File
@@ -40,7 +40,7 @@ Do (,wn buzz_bo + Completion(input()) && Assert):
Execute (:VimwikiGoto + Completion (API)): Execute (:VimwikiGoto + Completion (API)):
VimwikiIndex 2 VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%') AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
let s_complete=string(vimwiki#base#get_globlinks_raw()) let s_complete=string(vimwiki#base#get_globlinks_escaped())
Assert -1 != stridx(s_complete, 'buzz_bozz') Assert -1 != stridx(s_complete, 'buzz_bozz')
Execute (Create dir1/dir2/test_goto_file.md): Execute (Create dir1/dir2/test_goto_file.md):
@@ -55,23 +55,23 @@ Execute (:VimwikiGoto + Completion in directory):
AssertEqual $HOME . '/testmarkdown/index.md', expand('%') AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
" Complete without argment " Complete without argment
let s_complete1=string(vimwiki#base#get_globlinks_raw()) let s_complete1=string(vimwiki#base#get_globlinks_escaped())
Assert -1 != stridx(s_complete1, 'test_goto_file') Assert -1 != stridx(s_complete1, 'test_goto_file')
" Complete with file argument " Complete with file argument
let s_complete2=string(vimwiki#base#get_globlinks_raw('test_goto_file')) let s_complete2=string(vimwiki#base#get_globlinks_escaped('test_goto_file'))
Assert -1 != stridx(s_complete2, 'test_goto_file') Assert -1 != stridx(s_complete2, 'test_goto_file')
" Complete with start of file argument " Complete with start of file argument
let s_complete3=string(vimwiki#base#get_globlinks_raw('test_got')) let s_complete3=string(vimwiki#base#get_globlinks_escaped('test_got'))
Assert -1 != stridx(s_complete3, 'test_goto_file') Assert -1 != stridx(s_complete3, 'test_goto_file')
" Complete with (nested) dir2 argument " Complete with (nested) dir2 argument
let s_complete4=string(vimwiki#base#get_globlinks_raw('dir2')) let s_complete4=string(vimwiki#base#get_globlinks_escaped('dir2'))
Assert -1 != stridx(s_complete4, 'test_goto_file') Assert -1 != stridx(s_complete4, 'test_goto_file')
" Complete with bad argument " Complete with bad argument
let l_complete5=vimwiki#base#get_globlinks_raw('this_string_is_nowhere') let l_complete5=vimwiki#base#get_globlinks_escaped('this_string_is_nowhere')
let s_complete5=string(l_complete5) let s_complete5=string(l_complete5)
Assert -1 == stridx(s_complete5, 'test_goto_file') Assert -1 == stridx(s_complete5, 'test_goto_file')
AssertEqual 0, len(l_complete5) AssertEqual 0, len(l_complete5)
-32
View File
@@ -1,32 +0,0 @@
# Non regression tests for issue: #1279
# Fix/Improvement: When re-wrap a long line in a definition by 'gq' it should insert ':: ' at the new line
Given vimwiki (Dummy heading):
:: aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
Do (gqq):
gqq
Expect (Wrapped with the :: prefix prepended):
:: aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
:: aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
:: aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
:: aaa aaa aaa
Given vimwiki (Small heading):
:: aaa
Execute (Log):
call SetSyntax("default")
Log 'Comments: ' . &comments
Log 'Formatoptions: ' . &formatoptions
Log 'Blockquote_markers: ' . string(vimwiki#vars#get_syntaxlocal('blockquote_markers'))
Log 'Syntax: ' . vimwiki#vars#get_wikilocal('syntax')
Do (A <CR>):
A\<CR>
Expect (Bloquote prefix :: inserted):
:: aaa
::
-45
View File
@@ -1,45 +0,0 @@
# Non regression tests for issue TODO
# -- TODO copy-paste issue description
#
# Syntax: https://github.com/junegunn/vader.vim#syntax-of-vader-file
# Run: bash run_tests.sh -v -t vader -n vim_7.3.429 -f issue_example.vader
Given vimwiki (Empty file):
Execute (Set vimwiki property rxTableSep):
call SetSyntax('markdown')
call vimwiki#vars#set_syntaxlocal('rxTableSep', '│' )
AssertEqual '│', vimwiki#vars#get_syntaxlocal('rxTableSep'), "Conf has been changed"
Execute(VimwikiTable):
VimwikiTable
Expect (Unicode table created):
│ │ │ │ │ │
│---│---│---│---│---│
│ │ │ │ │ │
Given vimwiki (Unicode table):
│ bla bla bla │ │ │ │ │
│---│---│---│---│---│
│ │ │ │ │ │
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
call SetSyntax('markdown')
call vimwiki#vars#set_syntaxlocal('rxTableSep', '│' )
Do (Expand table):
:AssertEqual '│', vimwiki#vars#get_syntaxlocal('rxTableSep'), "Conf has been changed"\<Cr>
A
Expect (Unicode table expanded):
│ bla bla bla │ │ │ │ │
│-------------│---│---│---│---│
│ │ │ │ │ │
@@ -1,36 +0,0 @@
# Non regression tests for issue #1311
# -- Can't enable syntax highlighting for codes in HTML files when converting wiki to HTML
#
# Syntax: https://github.com/junegunn/vader.vim#syntax-of-vader-file
# Run: bash run_tests.sh -v -t vader -n vim_7.3.429 -f issue_example.vader
Given vimwiki (Input file with python code):
{{{type=py
if (a == 2):
print("2")
else:
print("other")
}}}
Execute (Convert to HTML):
Log "HTML path: " . vimwiki#vars#get_wikilocal('path_html')
let g:bck_command = g:vimwiki_global_vars['listing_hl_command']
let g:vimwiki_global_vars['listing_hl_command'] = 'cat'
call ConvertWiki2Body()
g/^\s*$/d
Expect (Output with good newlines):
<pre type=py>
if (a == 2):
print("2")
else:
print("other")
</pre>
Execute (restore):
let g:vimwiki_global_vars['listing_hl_command'] = g:bck_command
-36
View File
@@ -1,36 +0,0 @@
# Non regression tests for issue:
# -- How to turn off inline math highlights?
Given vimwiki (All math inline possible):
12345678901234567890123456789
2023-06-22
23-06-22
due:2023-06-22
+ProjectName project description
@ContextName context description
Other +ProjectName and desc
Other @ContectName and desc
Execute (Assert all lines):
# Math
AssertEqual 'normal', GetSyntaxVimwiki(1, 1)
AssertEqual 'TodoDate', GetSyntaxVimwiki(2, 1)
AssertEqual 'TodoDate', GetSyntaxVimwiki(3, 1)
AssertEqual 'TodoDueDate', GetSyntaxVimwiki(4, 1)
AssertEqual 'TodoProject', GetSyntaxVimwiki(6, 1)
AssertEqual 'normal', GetSyntaxVimwiki(6, 15)
AssertEqual 'TodoContext', GetSyntaxVimwiki(7, 1)
AssertEqual 'normal', GetSyntaxVimwiki(7, 15)
AssertEqual 'normal', GetSyntaxVimwiki(9, 1)
AssertEqual 'TodoProject', GetSyntaxVimwiki(9, 10)
AssertEqual 'normal', GetSyntaxVimwiki(9, 20)
AssertEqual 'normal', GetSyntaxVimwiki(10, 1)
AssertEqual 'TodoContext', GetSyntaxVimwiki(10, 10)
AssertEqual 'normal', GetSyntaxVimwiki(10, 20)
-46
View File
@@ -1,46 +0,0 @@
# Non regression tests for issue 1323
# -- Folding code blocks using markdown syntax folds the entire rest of the file #1323
#
# Syntax: https://github.com/junegunn/vader.vim#syntax-of-vader-file
# Run: bash run_tests.sh -v -t vader -n vim_7.3.429 -f issue_example.vader
Given vimwiki (Input file):
# Header
```sql
SELECT blah FROM bleh;
```
More text in session one
# Header two
More text in session two
Execute (Cheat vars):
call SetSyntax('markdown')
let old_foldexpr = &foldexpr
let old_foldmethod = &foldmethod
set foldexpr=VimwikiFoldLevel(v:lnum)
set foldmethod=expr
Execute (Call function to verify):
AssertEqual 'line 1 => 1', 'line 1 => ' . foldlevel(1)
AssertEqual 'line 2 => 1', 'line 2 => ' . foldlevel(2)
AssertEqual 'line 3 => 2', 'line 3 => ' . foldlevel(3)
AssertEqual 'line 4 => 2', 'line 4 => ' . foldlevel(4)
AssertEqual 'line 5 => 2', 'line 5 => ' . foldlevel(5)
AssertEqual 'line 6 => 1', 'line 6 => ' . foldlevel(6)
AssertEqual 'line 7 => 1', 'line 7 => ' . foldlevel(7)
AssertEqual 'line 8 => 1', 'line 8 => ' . foldlevel(8)
AssertEqual 'line 9 => 0', 'line 9 => ' . foldlevel(9)
# AssertEqual 'line 10 => 1', 'line 10 => ' . foldlevel(10)
# AssertEqual 'line 11 => 1', 'line 11 => ' . foldlevel(11)
Execute (Restore vars):
# call SetSyntax('default')
let &foldexpr = old_foldexpr
let &foldmethod = old_foldmethod
-29
View File
@@ -1,29 +0,0 @@
# Non regression tests for issue: #1325
# -- Bold syntax highlighting broken for default syntax since 72d0220 (tk Brennen)
Given vimwiki (All math inline possible):
*foo:* bar #1: Bold
<!-- exec-raw zsh -c 'grep --exclude-dir="*logscratch" -rino -- "- \[ \].*$" ~/notes/vimwiki' | perl -pe 's{^/home/brennen/notes/vimwiki/(.*?)\.wiki:(\d+):- \[ \] (.*?)$}{ - [[$1|$1]] - ($2) $3}' -->
# 2: Online comment # 3
<!--
multiple line # 5
comment # 6
-->
123456789
Execute (Set syntax wiki):
call SetSyntax('default')
Log &foldexpr
Log &foldmethod
Execute (Assert syntax):
# Bold
# AssertEqual 'VimwikiBold1', GetSyntaxStack(1, 2)[0] . 1
AssertEqual '02', len(GetSyntaxStack(1, 8)) . 2
# HTML Comment
AssertEqual 'VimwikiComment3', GetSyntaxStack(2, 6)[0] . 3
# Multiline HTML Comment
AssertEqual 'VimwikiComment4', GetSyntaxStack(5, 2)[0] . 4
@@ -1,65 +0,0 @@
# Tests for issue: 1326
# Multiple discrete tags on one line
# cause duplicate entries in .vimwiki_tags
# For example, this line:
# :tag1:tag2:
# gives correct results in .vimwiki_tags when VimwikiRebuildTags is called.
# This line
# :tag3: :tag4:
# gives duplicate entries for tag4.
Execute (Start with no content or .vimwiki_tags files - Start issue 1326 test):
call system("rm $HOME/testwiki/.vimwiki_tags")
call system("rm $HOME/testwiki/Test-Tag-issue-1326.wiki")
Do (Create file with tags and rebuild all tags):
:edit! $HOME/testwiki/Test-Tag-issue-1326.wiki\<CR>
I
:discrete1: :discrete2:\<CR>
:concat1:concat2:\<CR>
:mixed1:mixed2: :mixed3: :mixed4:\<CR>
\<Esc>
:write\<CR>
:VimwikiRebuildTags!\<CR>
Execute (Examine .vimwiki_tags file for generated tag entries.):
edit $HOME/testwiki/.vimwiki_tags
AssertEqual $HOME . '/testwiki/.vimwiki_tags', expand('%')
AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 0, vimwiki#vars#get_bufferlocal('wiki_nr')
# For each tag, make sure it is found # once and ONLY once in
# the .vimwiki_tags file.
# The "AssertNotEqual" tests that the tag is present at least once.
# The "AssertEqual" searches for the tag 2 times and checks that the
# line number where it was found is the same both times.
# The 'w' flag tells search to wrap around at the end of the file.
# The 'e' flag makes search position the cursor at the end of the match.
AssertNotEqual 0, search('concat1', 'we'), 'Expected tag "concat1" was not found.'
AssertEqual search('concat1', 'we'), search('concat1', 'we'), 'More than 1 instance of tag "concat1" found'
AssertNotEqual 0, search('concat2', 'we'), 'Expected tag "concat2" was not found.'
AssertEqual search('concat2', 'we'), search('concat2', 'we'), 'More than 1 instance of tag "concat2" found'
AssertNotEqual 0, search('discrete1', 'we'), 'Expected tag "discrete1" was not found.'
AssertEqual search('discrete1', 'we'), search('discrete1', 'we'), 'More than 1 instance of tag "discrete1" found'
AssertNotEqual 0, search('discrete2', 'we'), 'Expected tag "discrete2" was not found.'
AssertEqual search('discrete2', 'we'), search('discrete2', 'we'), 'More than 1 instance of tag "discrete2" found'
AssertNotEqual 0, search('mixed1', 'we'), 'Expected tag "mixed1" was not found.'
AssertEqual search('mixed1', 'we'), search('mixed1', 'we'), 'More than 1 instance of tag "mixed1" found'
AssertNotEqual 0, search('mixed2', 'we'), 'Expected tag "mixed2" was not found.'
AssertEqual search('mixed2', 'we'), search('mixed2', 'we'), 'More than 1 instance of tag "mixed2" found'
AssertNotEqual 0, search('mixed3', 'we'), 'Expected tag "mixed3" was not found.'
AssertEqual search('mixed3', 'we'), search('mixed3', 'we'), 'More than 1 instance of tag "mixed3" found'
AssertNotEqual 0, search('mixed4', 'we'), 'Expected tag "mixed4" was not found.'
AssertEqual search('mixed4', 'we'), search('mixed4', 'we'), 'More than 1 instance of tag "mixed4" found'
Execute (Remove content and tags files - End issue 1326 test):
call system("rm $HOME/testwiki/.vimwiki_tags")
call system("rm $HOME/testwiki/Test-Tag-issue-1326.wiki")
-148
View File
@@ -1,148 +0,0 @@
# Non regression tests for issue TODO
# -- TODO copy-paste issue description
#
# Syntax: https://github.com/junegunn/vader.vim#syntax-of-vader-file
# Run: bash run_tests.sh -v -t vader -n vim_7.3.429 -f issue_example.vader
Given vimwiki (Input file):
[this](#TopCategoryOne)
[that](#TopCategoryTwo)
[Here, we correctly jump to T1-S2](#TopCategoryOne#SubCategoryTwo)
[Here, however, we incorrectly land at T1-S2](#TopCategoryTwo#SubCategoryTwo)
[T2-S3 works, likely because T1-S3 doesn't exist](#TopCategoryTwo#SubCategoryThree)
# TopCategoryOne
## SubCategoryOne
## SubCategoryTwo
# TopCategoryTwo
## SubCategoryOne
## SubCategoryTwo
## SubCategoryThree
Execute (Set syntax markdown):
call SetSyntax('markdown')
file issue1356.md
Log 'Initial file:' . resolve(expand('%:p'))
Do (Jump1):
1G
\<Cr>
A--Link1\<Esc>
Expect(Link1):
[this](#TopCategoryOne)
[that](#TopCategoryTwo)
[Here, we correctly jump to T1-S2](#TopCategoryOne#SubCategoryTwo)
[Here, however, we incorrectly land at T1-S2](#TopCategoryTwo#SubCategoryTwo)
[T2-S3 works, likely because T1-S3 doesn't exist](#TopCategoryTwo#SubCategoryThree)
# TopCategoryOne--Link1
## SubCategoryOne
## SubCategoryTwo
# TopCategoryTwo
## SubCategoryOne
## SubCategoryTwo
## SubCategoryThree
Do (Jump2):
2G
\<Cr>
A--Link2\<Esc>
Expect (Link2):
[this](#TopCategoryOne)
[that](#TopCategoryTwo)
[Here, we correctly jump to T1-S2](#TopCategoryOne#SubCategoryTwo)
[Here, however, we incorrectly land at T1-S2](#TopCategoryTwo#SubCategoryTwo)
[T2-S3 works, likely because T1-S3 doesn't exist](#TopCategoryTwo#SubCategoryThree)
# TopCategoryOne
## SubCategoryOne
## SubCategoryTwo
# TopCategoryTwo--Link2
## SubCategoryOne
## SubCategoryTwo
## SubCategoryThree
Do (Jump3):
3G
\<Cr>
A--Link3\<Esc>
Expect (Link3):
[this](#TopCategoryOne)
[that](#TopCategoryTwo)
[Here, we correctly jump to T1-S2](#TopCategoryOne#SubCategoryTwo)
[Here, however, we incorrectly land at T1-S2](#TopCategoryTwo#SubCategoryTwo)
[T2-S3 works, likely because T1-S3 doesn't exist](#TopCategoryTwo#SubCategoryThree)
# TopCategoryOne
## SubCategoryOne
## SubCategoryTwo--Link3
# TopCategoryTwo
## SubCategoryOne
## SubCategoryTwo
## SubCategoryThree
Do (Jump4):
4G
\<Cr>
A--Link4\<Esc>
Expect (Link4):
[this](#TopCategoryOne)
[that](#TopCategoryTwo)
[Here, we correctly jump to T1-S2](#TopCategoryOne#SubCategoryTwo)
[Here, however, we incorrectly land at T1-S2](#TopCategoryTwo#SubCategoryTwo)
[T2-S3 works, likely because T1-S3 doesn't exist](#TopCategoryTwo#SubCategoryThree)
# TopCategoryOne
## SubCategoryOne
## SubCategoryTwo
# TopCategoryTwo
## SubCategoryOne
## SubCategoryTwo--Link4
## SubCategoryThree
Do (Jump5):
5G
\<Cr>
A--Link5\<Esc>
Expect (Link5):
[this](#TopCategoryOne)
[that](#TopCategoryTwo)
[Here, we correctly jump to T1-S2](#TopCategoryOne#SubCategoryTwo)
[Here, however, we incorrectly land at T1-S2](#TopCategoryTwo#SubCategoryTwo)
[T2-S3 works, likely because T1-S3 doesn't exist](#TopCategoryTwo#SubCategoryThree)
# TopCategoryOne
## SubCategoryOne
## SubCategoryTwo
# TopCategoryTwo
## SubCategoryOne
## SubCategoryTwo
## SubCategoryThree--Link5
-16
View File
@@ -1,16 +0,0 @@
# Non regression tests for issue TODO
# -- TODO copy-paste issue description
#
# Syntax: https://github.com/junegunn/vader.vim#syntax-of-vader-file
# Run: bash run_tests.sh -v -t vader -n vim_7.3.429 -f issue_example.vader
Given vimwiki (Input file):
test
Execute (Call function to verify):
echo 'Dummy command, not displayed'
Log 'Debug message displayed in Vader output'
AssertEqual 'test', getline(1), 'Dummy assertion'
Expect (Output file):
test
+4 -5
View File
@@ -29,9 +29,9 @@ Given vimwiki (Markdown typeface with escape sequence #1044: _ __ * ** {{{2):
This is 14 | 1 This is 14 | 1
__bold from begining__ 2 __bold from begining__ 2
\__not bold even from begin \__ 3 \__not bold even from begin \__ 3
and __t __isss still bold__ Bold 4 and __t \__ is still bold__ Bold 4
and _itaaa_licccontinues and end_ Italic 5 and _ita\_ alic continues and end_ Italic 5
*this aa is italic also* Italic 6 *this\* \* is italic also* Italic 6
a ^taa is supperscrit^ Sup 7 a ^taa is supperscrit^ Sup 7
,,subaaa subscript end,, Sub 8 ,,subaaa subscript end,, Sub 8
a ~~staaill deleted~~ Del 9 a ~~staaill deleted~~ Del 9
@@ -47,8 +47,7 @@ Execute (Assert Syntax of escape typeface):
AssertEqual 'VimwikiBold2' , SyntaxAt(2, 14) . 2 AssertEqual 'VimwikiBold2' , SyntaxAt(2, 14) . 2
AssertEqual '3' , SyntaxAt(3, 14) . 3 AssertEqual '3' , SyntaxAt(3, 14) . 3
AssertEqual 'VimwikiBold4' , SyntaxAt(4, 14) . 4 AssertEqual 'VimwikiBold4' , SyntaxAt(4, 14) . 4
" TODO AssertEqual 'VimwikiItalic5' , SyntaxAt(5, 14) . 5
" AssertEqual 'VimwikiItalic5' , SyntaxAt(5, 14) . 5
" See: #1303 where an escape start can close the region " See: #1303 where an escape start can close the region
" Fixed removing vars.vim::expand_delimiter " Fixed removing vars.vim::expand_delimiter
AssertEqual 'VimwikiItalic6' , SyntaxAt(6, 14) . 6 AssertEqual 'VimwikiItalic6' , SyntaxAt(6, 14) . 6
+1 -79
View File
@@ -257,7 +257,7 @@ Expect (Correctly formatted tags file):
!_TAG_PROGRAM_AUTHOR Vimwiki !_TAG_PROGRAM_AUTHOR Vimwiki
!_TAG_PROGRAM_NAME Vimwiki Tags !_TAG_PROGRAM_NAME Vimwiki Tags
!_TAG_PROGRAM_URL https://github.com/vimwiki/vimwiki !_TAG_PROGRAM_URL https://github.com/vimwiki/vimwiki
!_TAG_PROGRAM_VERSION 2024.01.24 !_TAG_PROGRAM_VERSION 2022.12.02
second-tag Test-Tag.md 13;" vimwiki:Test-Tag\tTest-Tag#second-tag\tTest-Tag#second-tag second-tag Test-Tag.md 13;" vimwiki:Test-Tag\tTest-Tag#second-tag\tTest-Tag#second-tag
test-tag Test-Tag.md 5;" vimwiki:Test-Tag\tTest-Tag#a-header\tA header test-tag Test-Tag.md 5;" vimwiki:Test-Tag\tTest-Tag#a-header\tA header
top-tag Test-Tag.md 1;" vimwiki:Test-Tag\tTest-Tag\tTest-Tag top-tag Test-Tag.md 1;" vimwiki:Test-Tag\tTest-Tag\tTest-Tag
@@ -553,81 +553,3 @@ Expect (Content appended at tags):
Execute (Clean file for tag #1316): Execute (Clean file for tag #1316):
call system("rm $HOME/testmarkdown/.vimwiki_tags") call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag-issue-1316-bis.md") call system("rm $HOME/testmarkdown/Test-Tag-issue-1316-bis.md")
Execute (Clean):
call system("rm $HOME/testmarkdown/.vimwiki_tags")
unlet g:vimwiki_tag_format
unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init()
Do (Md: #1034: Create File with tag in code for issue #1034):
:edit $HOME/testmarkdown/Test-Tag-issue-1034.md\<CR>
I
# Line1: Heading
Some line\<Cr>
# Line2: Tag not in header
```bash\<Cr>
# Line3: Tag in header
this is bash code with :tag1:\<Cr>
# Line4: empty
```\<Cr>
# Line5: tag2
and :tag2:\<Cr>
\<Esc>
:write\<CR>
:VimwikiRebuildTags!\<CR>
Do (Md: #1034: Append something at mono tag):
:edit $HOME/testmarkdown/Test-Tag-issue-1034.md\<CR>
ggdG
:read $HOME/testmarkdown/.vimwiki_tags\<CR>
G
:g/^!/d\<CR>
oContent\<Esc>
Expect (Md: #1034: Can see tag2 but not tag1 as in code):
tag2 Test-Tag-issue-1034.md 5;" vimwiki:Test-Tag-issue-1034\tTest-Tag-issue-1034#tag2\tTest-Tag-issue-1034#tag2
Content
Do (Wiki: #1034: Create File with tag in code for issue #1034):
:edit $HOME/testwiki/Test-Tag-issue-1034.wiki\<CR>
I
# Line1: Heading
Some line\<Cr>
# Line2: Tag not in header
{{{bash\<Cr>
# Line3: Tag in header
this is bash code with :tag1:\<Cr>
# Line4: empty
}}}\<Cr>
# Line5: tag2
and :tag2:\<Cr>
\<Esc>
:write\<CR>
:VimwikiRebuildTags!\<CR>
Do (Wiki: #1034: Append something at mono tag):
:edit $HOME/testwiki/Test-Tag-issue-1034.wiki\<CR>
ggdG
:read $HOME/testwiki/.vimwiki_tags\<CR>
G
:g/^!/d\<CR>
oContent\<Esc>
Expect (Wiki: #1034: Can see tag2 but not tag1 as in code):
tag2 Test-Tag-issue-1034.wiki 5;" vimwiki:Test-Tag-issue-1034\tTest-Tag-issue-1034#tag2\tTest-Tag-issue-1034#tag2
Content
Execute (#1034: Clean file for tag #1034):
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testwiki/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag-issue-1013.md")
call system("rm $HOME/testwiki/Test-Tag-issue-1013.wiki")
-63
View File
@@ -1,63 +0,0 @@
# Test how vimwiki#tags#generate_tags behaves when updating existing tag link sections
Before (Setup test wiki files):
call writefile([":usedtag:", ":othertag:"], expand("~/testmarkdown/Test-Tag-tagged.md"))
edit ~/testmarkdown/Test-Tag-links.md
After (Cleanup files):
%delete
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag-tagged.md")
call system("rm $HOME/testmarkdown/Test-Tag-links.md")
Do (Create preexisting tag links with unused tag):
I
# Generated Tags\<CR>
\<CR>
## unusedtag\<CR>
\<CR>
## usedtag\<CR>
\<ESC>
:VimwikiRebuildTags!\<CR>
:call vimwiki#tags#generate_tags(0)\<CR>
Expect (Keeps unused tag header):
# Generated Tags
## unusedtag
## usedtag
- [Test-Tag-tagged](Test-Tag-tagged)
Do (Create preexisting tag subheadings out of alphabetical order):
I
# Generated Tags\<CR>
\<CR>
## z\<CR>
\<CR>
## usedtag\<CR>
\<CR>
## a\<CR>
\<CR>
# Other Stuff
\<ESC>
:VimwikiRebuildTags!\<CR>
:call vimwiki#tags#generate_tags(0)\<CR>
Expect (Existing tag subheading order is preserved):
# Generated Tags
## z
## usedtag
- [Test-Tag-tagged](Test-Tag-tagged)
## a
# Other Stuff
-8
View File
@@ -343,14 +343,6 @@
0d 0d
endfunction endfunction
function! GetSyntaxVimwiki(line, col)
let res = GetSyntaxStack(a:line, a:col)
if empty(res)
return 'normal'
endif
return res[0]
endfunction
function! GetSyntaxGroup(...) function! GetSyntaxGroup(...)
" Get normalized syntax group: usefull for boldItalic Vs italicBold " Get normalized syntax group: usefull for boldItalic Vs italicBold
" Arg1: line " Arg1: line