I broke up with neovim....vim is my best friend now

This commit is contained in:
LinlyBoi
2023-04-30 08:14:07 +03:00
parent 0d185449c5
commit 4a4a6b1e81
5245 changed files with 468325 additions and 25 deletions

View File

@@ -0,0 +1,85 @@
# Vimwiki Tests
This directory contains a test framework used to automatically test/verify
Vimwiki functionality. It is based on the following tools:
- [vim-testbed GitHub](https://github.com/tweekmonster/vim-testbed) or on [testbed/vim dockerhub](https://hub.docker.com/r/testbed/vim)
- [Vader](https://github.com/junegunn/vader.vim)
- [Vint](https://github.com/Kuniwak/vint)
## Resources
- [Vim patches](http://ftp.vim.org/pub/vim/patches/)
- Example test cases:
- [vim-easy-align](https://github.com/junegunn/vim-easy-align/tree/master/test)
- [vim-plug](https://github.com/junegunn/vim-plug/tree/master/test)
- [ale](https://github.com/w0rp/ale/tree/master/test)
- [Other projects](https://github.com/junegunn/vader.vim/wiki/Projects-using-Vader)
## Building Docker Image
To build the Docker image run `docker build -t vimwiki .` from the Vimwiki
repository root (same location as the Dockerfile).
## Running Tests
### Manual Steps
Starting in the test directory run this command:
```sh
docker run -it --rm -v $PWD/../:/testplugin -v $PWD/../test:/home vimwiki vim_7.4.1099 -u test/vimrc -i NONE
```
This will open a vim instance in the docker container and then all tests
can be run with `:Vader test/*` or individual tests can be run.
**Note:** Substitute `vim_7.4.1099` for any of the vim versions in the Dockerfile.
### Automated Tests
The script in the `test/` directory named `run_test.sh` can be used to
automatically run all tests for all installed vim versions. The vim/nvim
versions are parsed from the Dockerfile. This script will also run `Vint` for all
plugin source files. For more information run `./run_tests.sh -h`.
## Writing Tests
You are advice to write tests at the top of the file where you want to include it because some `Execute` can have some side effect making it hard to debug
### Inside the container
- `$USER` -> `vimtest` : unprivileged => very hard to mess up things
- `$HOME` -> `/home/vimtest` : but it is readonly !
- `$PWD` -> `/testplugin` : mapped to vimwiki plugin root directory
For more information, read the [base docker image](https://github.com/tweekmonster/vim-testbed)
## Known Issues
1. neovim v0.2.x does not work correctly with Vader output from the docker
container. No test results are printed and an error message saying
`Vim: Error reading input, exiting...`
- Probably need to look into this more and determine if the issue is Vader,
Neovim, or Docker.
2. Vader does not play nice with the location list. Tests that use the location
list should be placed in `independent_runs/`.
- [Vader Issue #199](https://github.com/junegunn/vader.vim/issues/199)
## Notable Vim patches
- `v7.3.831` `getbufvar` added a default value
- `v7.4.236` add ability to check patch with has("patch-7.4.123")
- `v7.4.279` added the option to for `globpath()` to return a list
- `v7.4.1546` sticky type checking removed (allow a variables type to change)
- `v7.4.1989` `filter()` accepts a Funcref
- `v7.4.2044` lambda support added - see `:h expr-lambda`
- `v7.4.2120` Added function "closure" argument
- `v7.4.2137` add `funcref()`
- `v8.0` async jobs and timers

View File

@@ -0,0 +1,42 @@
# Test vimwiki#base#resolve_link for various inputs.
Execute (Resolve link for index):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('index')
AssertEqual 'wiki0', link_infos.scheme
AssertEqual $HOME . '/testwiki/index.wiki', link_infos.filename
Execute (Resolve link for /index - absolute path from wiki root):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('/index')
AssertEqual 'wiki0', link_infos.scheme
AssertEqual '', link_infos.anchor
AssertEqual $HOME . '/testwiki/index.wiki', link_infos.filename
Execute (Resolve link for ///tmp/some_page - absolute path to standalone page):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('///tmp/some_page')
AssertEqual '/tmp/some_page.wiki', link_infos.filename
Execute (Resolve link for //~/testwiki/index - page in wiki under homedir):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('//~/testwiki/index')
AssertEqual $HOME . '/testwiki/index.wiki', expand(link_infos.filename)
Execute (Resolve link for diary:2020-01-01 - diary page):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('diary:2020-01-01')
AssertEqual $HOME . '/testwiki/diary/2020-01-01.wiki', link_infos.filename
Execute (Resolve link to link_syntax/nested - page in subdirectory):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('link_syntax/nested')
AssertEqual $HOME . '/testwiki/link_syntax/nested.wiki', link_infos.filename
Execute (Resolve relative link to ./link_syntax/nested - page in subdirectory):
VimwikiIndex 1
let link_infos = vimwiki#base#resolve_link('link_syntax/nested')
AssertEqual $HOME . '/testwiki/link_syntax/nested.wiki', link_infos.filename
Execute (Clean):
call ReloadVimwiki()

View File

@@ -0,0 +1,32 @@
# Test comment string PR #946
# TODO try default
# TODO try editing other buffer
#Execute (default commenstring, ft vimwiki):
# AssertEqual &filetype[0], 't'
# AssertEqual '/*%s*/', &commentstring
Given txt (txt):
txt
After (clean up):
if exists('g:vimwiki_commentstring')
unlet g:vimwiki_commentstring
endif
if exists('b:did_ftplugin')
unlet b:did_ftplugin
endif
Execute (default vimwiki commentstring):
call vimwiki#vars#init()
set ft=vimwiki
AssertEqual '%%%s', &commentstring
Execute (html commentstring):
let g:vimwiki_commentstring='<!-- %s -->'
call vimwiki#vars#init()
set ft=vimwiki
AssertEqual '<!-- %s -->', &commentstring
Expect (void):
txt

View File

@@ -0,0 +1,91 @@
# Test variable management (should be small)
# PR #1132 make other test break ...
#Given vimwiki (abc def ghi jkl #1132):
# abc def ghi jkl
#
#Do (vee<CR>):
# :call SetSyntax('markdown')\<CR>
# :call vimwiki#vars#set_wikilocal('links_space_char', '_')\<CR>
# vee\<CR>
# :call vimwiki#vars#set_wikilocal('links_space_char', ' ')\<CR>
#
#Expect (underscores in link url not in description):
# [abc def](abc_def) ghi jkl
#
# Issue #980
#
# brennen commenting these out 2021-03-29 per @tinmarino:
# https://github.com/vimwiki/vimwiki/pull/1108#issuecomment-806775805
# Given txt (txt):
# txt
#
# Execute (VimWei vars #980):
# " Set
# call UnloadVimwiki()
# let wiki = {}
# let wiki.name = 'ChenWei 🦊VimwikiMd @^%@!*#&^'
# let wiki.path = $HOME . '/testmarkdown'
# let wiki.ext = '.md'
# let wiki.syntax = 'markdown'
# let wiki.nested_syntaxes = {'python': 'python'}
#
# " Make other tests crash
# "let wiki.links_space_char = '_'
# "let wiki.list_margin = 0
# "let wiki.auto_toc = 1
# "let wiki.auto_tags = 1
# "let wiki.auto_generate_tags = 1
#
# let g:vimwiki_list = [wiki]
# let g:vimwiki_ext2syntax = {'.md': 'markdown'}
# let g:vimwiki_global_ext = 1
# let g:vimwiki_autowriteall = 1
# let g:vimwiki_auto_chdir = 1
# let g:vimwiki_folding = 'expr'
# call LoadVimwiki()
#
# " Log
# Log 'Path (Current): ' . getcwd()
# Log 'File: (Buffer)' . @%
# Log 'List (Wiki): ' . string(g:vimwiki_list)
# Log ''
# Log 'Local (Vars):'
# Log g:vimwiki_wikilocal_vars
#
# " Work
# edit $HOME/testmarkdown/index.md
#
# " Assert
# AssertEqual '/home/vimtest/testmarkdown_cwd', getcwd() . '_cwd'
# AssertEqual '0_wiki_nr', vimwiki#vars#get_bufferlocal('wiki_nr') . '_wiki_nr'
# AssertEqual 'markdown_syntax', vimwiki#vars#get_wikilocal('syntax') . '_syntax'
# AssertEqual '0_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
# Log 'Path (Current): ' . getcwd()
# Log 'File (Buffer):' . @%
# bprevious
# Log 'Path (Current): ' . getcwd()
# Log 'File (Buffer):' . @%
# bwipeout index.md
#
# " Clean
# Log 'Clean up'
# cd /testplugin
# unlet g:vimwiki_list
# unlet g:vimwiki_ext2syntax
# unlet g:vimwiki_global_ext
# unlet g:vimwiki_autowriteall
# unlet g:vimwiki_auto_chdir
# unlet g:vimwiki_folding
# unlet wiki
# Log 'Path (Current): ' . getcwd()
# Log 'File (Buffer):' . @%
# call ReloadVimwiki()
# Log g:vimwiki_wikilocal_vars
#
# Expect (txt):
# txt
# vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,375 @@
#!/usr/bin/env bash
# credit to https://github.com/w0rp/ale for script ideas and the color vader
# output function.
# Say Hi
echo -en "Starting $(basename "$0") for VimWiki\n"
start_time=$(date +%s)
# For windows: Cmder bash is appending busybox to the path and
# and a smlll vim is included, so that override the windows path vim
if [[ -v OLD_PATH ]]; then
echo "Setting path from OLD_PATH : $OLD_PATH"
export PATH="$OLD_PATH"
fi
printHelp() {
cat << ' EOF' | sed -e 's/^ //'
Usage: bash run_tests.sh [OPTIONS]
Runs Vimwiki Vader tests or Vint in a Docker container
-h (Help) Print help message
-n (versioN) Specify vim/nvim version to run tests for.
Specify "local" to run on your current vim install
for example on Windows.
Multiple versions can be specified by quoting the value and
separating versions with a space. E.g. -n "vim1 vim2".
Default is all available versions.
-f (File) Space separated list of tests to run.
E.g. -o "list_* z_success"
-l (List) list available versions that can be used with the '-n' option
-t (Type) Select test type: 'vader', 'vint', or 'all'
-v (Verbose) Turn on verbose output.
E.g. On Linux
bash run_tests.sh -v -t vader -n "vim_7.4.1099 vim_8.1.0519" -f link_creation.vader issue_markdown.vader
E.g. On Windows
bash run_tests.sh -v -t vader -n local -f z_success.vader | cat
EOF
exit 0
}
printVersions() {
# Print the names of all vim/nvim versions
getVers
exit 0
}
runVader() {
# Run Vader tests
echo -e "\nStarting Vader tests."
local err=0
# Parse tests files to execute
if [[ -z $file_test ]]; then
res="test/*"
else
read -ra TEST <<< "$file_test"
for i in "${TEST[@]}"; do
if [[ "$i" == *"*"* ]]; then
res="$res test/${i}"
elif [[ -f "$i" ]]; then
res="$res test/${i}"
elif [[ -f "${i}.vader" ]]; then
res="$res test/${i}.vader"
else
printf "WARNING: Test \"%s\" not found.\n", "$i"
fi
done
fi
# Run tests for each specified version
for v in $vers; do
echo -e "\n\nRunning version: $v"
echo -e "============================="
# Set local environment variables
if [[ "$v" == "local" ]]; then
# Save HOME var
home_save="$HOME"
# Create temporary root
mkdir -p "$tmp_dir/vader_wiki"
mkdir -p "$tmp_dir/vader_wiki/home"
mkdir -p "$tmp_dir/vader_wiki/home/test"
mkdir -p "$tmp_dir/vader_wiki/testplugin"
# Set vars
export ROOT="$tmp_dir/vader_wiki/"
export HOME="$tmp_dir/vader_wiki/home"
vim="vim"
vim_opt="-u ~/test/vimrc"
else
# Only set dockerized vars
export ROOT="/" # So no if in vimrc
vim="/vim-build/bin/$v"
vim_opt="-u test/vimrc"
fi
# Too talkative TODO make a verbose level 1..10 an 1 is not taking vim
#if [[ "$verbose" != 0 ]]; then
# vim_opt+=' -V1'
#fi
# IDK why vim with -Es is returning ! and make fail:
# -- tabnext profiling
# -- map.vim
vim_opt+=' -i NONE -Es '
# set -o pipefail
# Copy the resources to temporary directory
if [[ "$v" == "local" ]]; then
# flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki)
echo -e "\nCopying resources to $ROOT"
# Copy testplugin
cp -rf "$wiki_path/"* "$ROOT/testplugin/"
# Copy home
cp -rf "$script_path/"* "$HOME/test/"
# Copy rtp.vim
cp -rf "$script_path/resources/rtp_local.vim" "$ROOT/rtp.vim"
# Copy vader <- internet
echo 'Cloning Vader (git, do not care the fatal)'
git clone --depth 10 https://github.com/junegunn/vader.vim /tmp/vader_wiki/vader 2>&1
fi
# Run batch of tests
# shellcheck disable=SC2086,SC2206
if [[ "$res" != "" ]]; then
if [[ "$v" == "local" ]]; then
pushd "$tmp_dir/vader_wiki/testplugin" \
|| echo 'Warning pushd testplugin failed'
# Run the tests
fcmd(){
$vim $vim_opt "+Vader! ${res}" 2>&1
return ${PIPESTATUS[1]}
}
echo -e "\nStarting Batch Vim/Vader:\n<- $res\n"
type fcmd | sed -n '/^ /{s/^ //p}' | sed '$s/.*/&;/' ; shift ;
fcmd; ret=$?
err=$(( err + ret ))
echo -e "\nReturned Batch Vim/Vader -> $ret"
popd \
|| echo 'Warning popd also failed'
else
# In docker
fcmd() {
docker run -a stderr -e "VADER_OUTPUT_FILE=/dev/stderr" \
"${flags[@]}" "$v" $vim_opt "+Vader! ${res}" 2>&1 \
| vader_filter | vader_color
return ${PIPESTATUS[1]}
}
echo -e "\nStarting Batch Vim/Vader:\n<- $res\n"
type fcmd | sed -n '/^ /{s/^ //p}' | sed '$s/.*/&;/' ; shift ;
fcmd; ret=$?
err=$(( err + ret ))
echo -e "\nReturned Batch Docker/Vim/Vader -> $ret : ${PIPESTATUS[*]}"
fi
fi
#set +o pipefail
# Restore what must (I know it should be refactored in a while)
if [[ "$v" == "local" ]]; then
export HOME=$home_save
fi
done
return $err
}
runVint() {
local err=0
cmd="vint -s . && vint -s test/vimrc"
if echo "$vers" | grep "local" > /dev/null; then
echo -e "\nRunning Vint: $cmd : in $wiki_path"
pushd "$wiki_path" > /dev/null \
|| echo 'Warning pushd wiki_path failed'
$cmd
err=$(( err | $? ))
popd > /dev/null \
|| echo 'Warning popd also failed'
else
echo -e "\nStarting Docker container and running Vint: $cmd"
docker run -a stdout "${flags[@]}" bash -c "$cmd"
err=$(( err | $? ))
fi
return $err
}
getVers() {
# Get all possible version <- Dockerfile
sed -n 's/.* -name \([^ ]*\) .*/\1/p' ../Dockerfile
}
vader_filter() {
# Filter Vader Stdout
local err=0
# Keep indentation
local IFS=''
while read -r REPLY; do
# Print only possible error cases
if [[ "$REPLY" = *'docker:'* ]] || \
[[ "$REPLY" = *'Starting Vader:'* ]] || \
[[ "$REPLY" = *'Vader error:'* ]] || \
[[ "$REPLY" = *'Vim: Error '* ]]; then
echo "$REPLY"
elif [[ "$REPLY" = *'[EXECUTE] (X)'* ]] || \
[[ "$REPLY" = *'[ EXPECT] (X)'* ]]; then
echo "$REPLY"
err=1
elif [[ "$REPLY" = *'Success/Total:'* ]]; then
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
if [ "$success" -lt "$total" ]; then
err=1
fi
echo "$REPLY"
elif [[ "$verbose" != 0 ]]; then
# just print everything
echo "$REPLY"
fi
done
if [[ "$err" == 1 ]]; then
echo -e "\033[0;31m"
echo -e "!---------Failed tests detected---------!"
echo -e "Run with the '-v' flag for verbose output"
echo -e "\033[0m"
fi
return $err
}
red='\033[0;31m'
green='\033[0;32m'
nc='\033[0m'
vader_color() {
while read -r; do
if [[ "$REPLY" = *'[EXECUTE] (X)'* ]] || \
[[ "$REPLY" = *'[ EXPECT] (X)'* ]] || \
[[ "$REPLY" = *'Vim: Error '* ]] || \
[[ "$REPLY" = *'Vader error:'* ]]; then
echo -en "$red"
elif [[ "$REPLY" = *'[EXECUTE]'* ]] || [[ "$REPLY" = *'[ GIVEN]'* ]]; then
echo -en "$nc"
fi
if [[ "$REPLY" = *'Success/Total'* ]]; then
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
if [ "$success" -lt "$total" ]; then
echo -en "$red"
else
echo -en "$green"
fi
echo "$REPLY"
echo -en "$nc"
else
echo "$REPLY"
fi
done
echo -en "$nc"
}
# path of the script, supposing no spaces
script_file="$(dirname "$0")"
script_path="$( realpath "$script_file" )"
wiki_path="$( realpath "$script_path/.." )"
tmp_dir="$(dirname "$(mktemp -u)")"
# list of vim/nvim versions
vers="$(getVers)"
# type of tests to run - vader/vint/all
type="all"
# verbose output flag
verbose=0
# only run these tests
file_test=""
# docker flags
flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki)
while getopts ":hvn:lt:f:" opt; do
case ${opt} in
h )
printHelp
;;
n )
vers="$OPTARG"
;;
v )
verbose=1
;;
l )
printVersions
;;
t )
type="$OPTARG"
;;
f )
file_test="$OPTARG"
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
exit 1
;;
esac
done
# shift out processed parameters
shift $((OPTIND -1))
# error handling for non-option arguments
if [[ $# -ne 0 ]]; then
echo "Error: Got $# non-option arguments." 1>&2
exit 1
fi
# stop tests on ctrl-c or ctrl-z
trap exit 1 SIGINT SIGTERM
# Global error return of the script
o_error=0
# Select which tests should run
case $type in
"vader" )
runVader ; err=$?
echo "Main Vader: returned $err"
o_error=$(( err | o_error ))
;;
"vint" )
runVint ; err=$?
echo "Main Vint: returned $err"
o_error=$(( err | o_error ))
;;
"all" )
runVint ; err=$?
echo "Main Vint: returned $err"
o_error=$(( err | o_error ))
runVader ; err=$?
echo "Main Vader: returned $err"
o_error=$(( err | o_error ))
;;
* )
echo "Error: invalid type - '$type'" 1>&2
exit 1
esac
# Calcultate time
end_time=$(date +%s)
sec_time=$((end_time - start_time))
printf -v script_time '%dh:%dm:%ds' $((sec_time/3600)) $((sec_time%3600/60)) $((sec_time%60))
# Exit
echo -ne "Script $(basename "$0"), in $script_time, Returned -> $o_error\n\n"
exit $o_error

View File

@@ -0,0 +1,83 @@
# VimwikiGoto
#
# Note: I dont know why <Tab> is inserting a Tab.
# Well better than to insert a Chair, but it should trigger completion
# So I used C-L
Execute (VimwikiGoto buzz_bozz && Assert):
VimwikiIndex 2
VimwikiGoto buzz_bozz
AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')
Execute (VimwikiGoto buzz bozz && Assert):
VimwikiIndex 4
VimwikiGoto buzz bozz
AssertEqual $HOME . '/testwiki space/buzz bozz.wiki', expand('%')
Do (VimwikiGoto <CR> buzz_bozz && Assert):
:VimwikiIndex 2\<CR>
:VimwikiGoto\<CR>
buzz_bozz\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Do (VimwikiGoto + Completion(cmdline) && Assert):
:VimwikiIndex 2\<CR>
:VimwikiGoto buzz_bo\<C-l>\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Do (VimwikiGoto <CR> buzz_bo + Completion(input()) && Assert):
:VimwikiIndex 2\<CR>
:VimwikiGoto\<CR>
buzz_bo\<C-l>\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Do (,wn buzz_bo + Completion(input()) && Assert):
,wn
buzz_bo\<C-l>\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Execute (:VimwikiGoto + Completion (API)):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
let s_complete=string(vimwiki#base#get_globlinks_escaped())
Assert -1 != stridx(s_complete, 'buzz_bozz')
Execute (Create dir1/dir2/test_goto_file.md):
call system("mkdir $HOME/testmarkdown/dir1")
call system("mkdir $HOME/testmarkdown/dir1/dir2")
edit $HOME/testmarkdown/dir1/dir2/test_goto_file.md
call WriteMe()
Execute (:VimwikiGoto + Completion in directory):
" Return to base
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
" Complete without argment
let s_complete1=string(vimwiki#base#get_globlinks_escaped())
Assert -1 != stridx(s_complete1, 'test_goto_file')
" Complete with file argument
let s_complete2=string(vimwiki#base#get_globlinks_escaped('test_goto_file'))
Assert -1 != stridx(s_complete2, 'test_goto_file')
" Complete with start of file argument
let s_complete3=string(vimwiki#base#get_globlinks_escaped('test_got'))
Assert -1 != stridx(s_complete3, 'test_goto_file')
" Complete with (nested) dir2 argument
let s_complete4=string(vimwiki#base#get_globlinks_escaped('dir2'))
Assert -1 != stridx(s_complete4, 'test_goto_file')
" Complete with bad argument
let l_complete5=vimwiki#base#get_globlinks_escaped('this_string_is_nowhere')
let s_complete5=string(l_complete5)
Assert -1 == stridx(s_complete5, 'test_goto_file')
AssertEqual 0, len(l_complete5)
Execute (Clean):
call DeleteFile("$HOME/testmarkdown/dir1/dir2/test_goto_file.md")
call system("rm $HOME/testmarkdown/dir1")
# vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View File

@@ -0,0 +1,27 @@
# Travel thought files
Given (Void for Accessing other files within vimwiki #979 {{{1):
Do (At Index: Create and goto pythonfile):
:VimwikiIndex 2\<Cr>
Opyfile.py\<Esc>\<Cr>\<Cr>
:AssertEqual 'pyfile.py', expand('%:t')\<CR>
:AssertEqual 'python', &ft\<CR>
:Log "Clean pyfile"\<Cr>
dd
:VimwikiIndex 2\<Cr>
:call DeleteFile('pyfile.py')\<Cr>
Do (At Index: Create and goto markdownfile):
:VimwikiIndex 2\<Cr>
Omdfile.md\<Esc>\<Cr>\<Cr>
:AssertEqual 'mdfile.md', expand('%:t')\<CR>
:AssertEqual 'vimwiki', &ft\<CR>
:Log "Clean mdfile"\<Cr>
:VimwikiIndex 2\<Cr>
dd
:call DeleteFile('mdfile.md')\<Cr>
# vim: sw=2:foldmethod=marker:foldlevel=30:foldignore=:

View File

@@ -0,0 +1,59 @@
# Fold
Execute (Save state):
Log 'Previous foldmethod: ' . &foldmethod
let save_foldmethod = &foldmethod
Given vimwiki (Markdown Headers):
Some stuff 1
# Header level 1 2
## Header level 2 3
Content 4
### Header level 3 5
# Header level 1 6
Content 7
## Just to end 8: Vader cannot match end-of-file
Execute (Markdown and Fold Syntax):
call SetSyntax('markdown')
set foldmethod=syntax
Execute (Assert Markdown: Fold Syntax):
Log 'Supposing it starts at foldlevel 0'
AssertEqual 'line 1:0', 'line 1:' . foldlevel(1)
AssertEqual 'line 2:0', 'line 2:' . foldlevel(2)
AssertEqual 'line 3:1', 'line 3:' . foldlevel(3)
AssertEqual 'line 4:2', 'line 4:' . foldlevel(4)
AssertEqual 'line 5:2', 'line 5:' . foldlevel(5)
AssertEqual 'line 6:0', 'line 6:' . foldlevel(6)
AssertEqual 'line 7:0', 'line 7:' . foldlevel(7)
Given vimwiki (Wiki Headers):
Some stuff 1
= Header level 1 2 =
== Header level 2 3 ==
Content 4
=== Header level 3 5 ===
= Header level 1 6 =
Content 7
== Just to end 8 ==
Execute (Markdown and Fold Syntax):
call SetSyntax('default')
set foldmethod=syntax
Execute (Assert Markdown: Fold Syntax):
Log 'Supposing it starts at foldlevel 0'
AssertEqual 'line 1:0', 'line 1:' . foldlevel(1)
AssertEqual 'line 2:0', 'line 2:' . foldlevel(2)
AssertEqual 'line 3:1', 'line 3:' . foldlevel(3)
AssertEqual 'line 4:2', 'line 4:' . foldlevel(4)
AssertEqual 'line 5:2', 'line 5:' . foldlevel(5)
AssertEqual 'line 6:0', 'line 6:' . foldlevel(6)
AssertEqual 'line 7:0', 'line 7:' . foldlevel(7)
Execute (Restore state):
let &foldmethod = save_foldmethod
Log 'Next foldmethod: ' . &foldmethod

View File

@@ -0,0 +1,170 @@
# Blockquotes in html convertion #55
# TODO replace remove newline before end of pre tag: \n</pre></code> -> </pre></code>
Given (Issue 2: BlockQuote restarts list numbering {{{3):
# Item 1
# Item 2
Block Quote Text
# Item 3
Execute (2Html):
call ConvertWiki2Body()
1d | $d | $d
Expect (Tested by hand 2):
<ul>
<li>
Item 1
<li>
Item 2
<pre><code>Block Quote Text
</code></pre>
<li>
Item 3
</ul>
Given vimwiki (Issue 1007: List with hard wraps and a blockquote):
- Item 1
wraps to the second line.
This is a blockquote.
And this is back to the list item
- [ ] Item 2
wraps to the second line.
This is a blockquote.
And this is back to the list item
Execute (2Html):
call ConvertWiki2Body() | 1d | $d | $d
Expect (No blockquote):
<ul>
<li>
Item 1
wraps to the second line.
<pre><code>This is a blockquote.
</code></pre>
</code></pre>
And this is back to the list item
<li class="done0">
Item 2
wraps to the second line.
<pre><code>This is a blockquote.
</code></pre>
And this is back to the list item
</ul>
#Given (Issue 3: BlockQuote at multiple list levels {{{3):
# 1. Outer Item 1
# 1. Inner Item 1
#
# > quote 1
#
# 2. Inner Item 2
# 2. Outer Item 2
#
# > quote 2
#
#Execute (2Html):
# call ConvertWiki2Body()
# 1d | $d | $d
#
#Expect (Got with pandoc):
Given (Issue 5: Newlines in blockquotes are not honored {{{3):
Before
line 1
line 2
After
Execute (2Html):
call ConvertWiki2Body()
1d | $d | $d
Expect (Got with pandoc 5):
<p>
Before
</p>
<pre><code>line 1
line 2
</code></pre>
<p>
After
</p>
Given (Void: Basic test {{{1):
Execute (Edit TestHtml Wiki):
edit $HOME/testwiki/TestHtml.wiki
AssertEqual $HOME . '/testwiki/TestHtml.wiki', expand('%')
AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 0, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Markdown with arrow blockquotes):
:edit $HOME/testwiki/TestHtml.wiki\<CR>
ggdGi first paragraph\<CR>\<CR>
> block\<CR>
> quote\<CR>\<CR>
last paragraph\<CR>\<Esc>
:write\<CR>
Execute (Save and Convert to html):
edit $HOME/testwiki/TestHtml.wiki
Vimwiki2HTML
#Given (Void):
#
#
#Do (Get Html body):
# :read $HOME/html/default/TestHtml.html\<CR>
## Goto body
# gg/<body>\<CR>
## Copy in b
# "bdat
## Delete All
# ggdG
## Paste body
# "bP
## Remove last line
# Gdd
## Save (Not necessary)
# :write
#
#
#
#Expect (Plain Html):
## the whole default html file should be here as a base + the modifications
## from "Given"
# <body>
#
# <p>
# first paragraph
# </p>
#
# <blockquote>
# <p>
# block
# quote
# </p>
# </blockquote>
#
# <p>
# last paragraph
# </p>
#
# </body>
#
## vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,300 @@
# Conversion: Wiki -> Html
#################################################
Given vimwiki (Comments):
This is some text
%% This is a comment
Test%%+INLINE COMMENT+%%1
%%+INLINE COMMENT+%%Test2
Test3%%+INLINE COMMENT+%%
%%+ Multiline
comment
that
is
removed
+%%
Final text
Do (Convert):
:call ConvertWiki2Html()\<Cr>
# Keep only body
ggd/<body>\<Cr>
Expect (Comments Removed):
<body>
<p>
This is some text
Test1
Test2
Test3
</p>
<p>
Final text
</p>
</body>
</html>
#################################################
Given vimwiki (Table no heading {{{1):
| header1 | header2 |
| val1 | val2 |
| val1 | val2 |
| val1 | val2 |
Do (Convert):
:call ConvertWiki2Html()\<Cr>
# Keep only body
ggd/<body>\<Cr>
Expect (Table no heading):
<body>
<table>
<tr>
<td>
header1
</td>
<td>
header2
</td>
</tr>
<tr>
<td>
val1
</td>
<td>
val2
</td>
</tr>
<tr>
<td>
val1
</td>
<td>
val2
</td>
</tr>
<tr>
<td>
val1
</td>
<td>
val2
</td>
</tr>
</table>
</body>
</html>
Given vimwiki (Table with heading {{{1):
| header1 | header2 | header3 |
|---------|---------|---------|
| val1 | val2 | var3 |
| val4 | val5 | var6 |
Do (Convert):
:call ConvertWiki2Html()\<Cr>
# Keep only body
ggd/<body>\<Cr>
Expect (Table with heading):
<body>
<table>
<thead>
<tr>
<th>
header1
</th>
<th>
header2
</th>
<th>
header3
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
val1
</td>
<td>
val2
</td>
<td>
var3
</td>
</tr>
<tr>
<td>
val4
</td>
<td>
val5
</td>
<td>
var6
</td>
</tr>
</tbody>
</table>
</body>
</html>
#################################################
Execute (Log):
Log '#473: Syntax "local:" doesnt work as expected. #473'
Given vimwiki (Void Md):
Execute (Edit Test473 Wiki):
edit $HOME/testwiki/TestHtml.wiki
Do (Add local link: [[local:$HOME/here|Link]]):
:edit $HOME/testwiki/Test473.wiki\<CR>
i
[[local:
\<C-r>=$HOME\<Cr>
/here|Link]]
\<Esc>
:call WriteMe()\<Cr>
:Vimwiki2HTML\<Cr>
Execute (Save and Convert to html):
edit $HOME/testwiki/Test473.wiki
Vimwiki2HTML
AssertEqual '[[local:'.$HOME.'/here|Link]]', getline(1)
Given (Void Html):
# TODO mutualise
Do (Get Html body):
:read $HOME/html/default/Test473.html\<CR>
# Goto body
gg/<body>\<CR>
# Copy in b
"bdat
# Delete All
ggdG
# Paste body
"bP
# Remove last line
Gdd
# Save (Not necessary)
:write
Expect (Local link):
<body>
<p>
<a href="../../here">Link</a>
</p>
</body>
Execute (Delete):
call DeleteFile(' $HOME/testwiki/Test473.wiki')
#################################################
Given (Void):
Execute (Edit TestHtml Wiki):
edit $HOME/testwiki/TestHtml.wiki
AssertEqual $HOME . '/testwiki/TestHtml.wiki', expand('%')
AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 0, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Markdwon with %plainhtml):
:edit $HOME/testwiki/TestHtml.wiki\<CR>
:normal ggdG\<Cr>
i%plainhtml<div id="test">\<CR>
my paragraph\<CR>
%plainhtml</div>\<CR>\<Esc>
:set bt=\<CR>
:write\<CR>
Execute (Save and Convert to html):
edit $HOME/testwiki/TestHtml.wiki
Vimwiki2HTML
Given (Void):
Do (Get Html body):
:read $HOME/html/default/TestHtml.html\<CR>
# Goto body
gg/<body>\<CR>
# Copy in b
"bdat
# Delete All
ggdG
# Paste body
"bP
# Remove last line
Gdd
# Save (Not necessary)
:write
Expect (Plain Html):
# the whole default html file should be here as a base + the modifications
# from "Given"
<body>
<div id="test">
<p>
my paragraph
</p>
</div>
</body>
Execute (Delete):
call DeleteFile('$HOME/testwiki/TestHtml.wiki')
Given vimwiki (PR: Add option to configure date string format 1073) {{{1):
%template template_1073
content
Do (template_date_format):
# Set conf
:let g:vimwiki_wikilocal_vars[0]['template_date_format'] = '%b %d, %Y'\<Cr>
# Convert
:call ConvertWiki2Html()\<Cr>
# Erase oth and date
:%s/[0-9]\+/Z/g\<Cr>
:%s/[A-Z][a-z][a-z]/Z/g\<Cr>
# Restore peace
:let g:vimwiki_wikilocal_vars[0]['template_date_format'] = ''\<Cr>
Expect (Date proper format):
<html>
<body>
<div class="content">
<p><small>Zt updated on Z Z, Z</small></p>
</div>
</body>
</html>
# vim: sw=2 foldmethod=marker foldlevel=30

View File

@@ -0,0 +1,10 @@
# Test that %title values carry through when HTML is rendered
Given vimwiki (Title value):
%title this is a title with some quotes in it: ' "
Some content.
Execute(Check for title tag):
call ConvertWiki2Html()
Assert 0 != search('<title>this is a title with some quotes in it: '' "</title>')

View File

@@ -0,0 +1,110 @@
# Feature to generate a diray RSS feed (PR #934)
# TODO bug with 7.3
#Given (Void):
#
#Execute (Generate HTML and RSS feed):
# edit $HOME/testwiki/index.wiki
# Vimwiki2HTML
# VimwikiRss
#
#Given (Void):
#
#Do (Get HTML file):
# :read $HOME/html/default/index.html\<CR>
## Go to line with RSS link
# gg/RSS\<CR>
## Delete everything above
# kdgg
## Delete everything below
# jdG
## Save (Not necessary) => Actually make rest of batch freeze, do you really want
## to quit buffer
## :write
#
#Expect (RSS link in HTML):
# <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml">
#
#Do (Get RSS feed):
# :read $HOME/html/default/rss.xml\<CR>
## Remove first line
# ggdd
## Replace pubDate with dummy as it's based on file modification time
# :%s@<pubDate>.*</pubDate>@<pubDate>...</pubDate>@g\<CR>
## Save (Not necessary)
## :write
#
#Expect (RSS):
## TODO the next line is deleted with -Es
## <?xml version="1.0" encoding="UTF-8" ?>
# <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
# <channel>
# <title>Diary</title>
# <link>https://example.com/diary/diary.html</link>
# <description>Diary</description>
# <pubDate>...</pubDate>
# <atom:link href="https://example.com/rss.xml" rel="self" type="application/rss+xml" />
# <item>
# <title>day 4</title>
# <link>https://example.com/diary/2020-07-25.html</link>
# <guid isPermaLink="false">2020-07-25</guid>
# <description><![CDATA[
# <div id="day 4"><h1 id="day 4" class="header"><a href="#day 4">day 4</a></h1></div>
#
# <div id="day 4-subsection 1"><h2 id="subsection 1" class="header"><a href="#day 4-subsection 1">subsection 1</a></h2></div>
#
# <p>
# here is some code:
# </p>
#
# <pre>
# #!/bin/sh
# echo "hello world"
# </pre>
#
# <div id="day 4-subsection 2"><h2 id="subsection 2" class="header"><a href="#day 4-subsection 2">subsection 2</a></h2></div>
#
# <p>
# an important list:
# </p>
#
# <ul>
# <li>
# point 1
#
# <li>
# point 2
#
# </ul>
# ]]></description>
# <pubDate>...</pubDate>
# </item>
# <item>
# <title>Day 2</title>
# <link>https://example.com/diary/2020-07-23.html</link>
# <guid isPermaLink="false">2020-07-23</guid>
# <description><![CDATA[
# <div id="Day 2"><h1 id="Day 2" class="header"><a href="#Day 2">Day 2</a></h1></div>
#
# <p>
# another diary entry
# </p>
# ]]></description>
# <pubDate>...</pubDate>
# </item>
# <item>
# <title>2020-07-22</title>
# <link>https://example.com/diary/2020-07-22.html</link>
# <guid isPermaLink="false">2020-07-22</guid>
# <description><![CDATA[
# <p>
# example diary entry for day 1.
# </p>
# ]]></description>
# <pubDate>...</pubDate>
# </item>
# </channel>
# </rss>
#
#Execute (Clean buffer modification):
# edit! $HOME/testwiki/index.wiki

View File

@@ -0,0 +1,177 @@
# Non regression tests for issues, see changelog
# In reverse chronological order
#
# Thanks to all contributors with issues and pull request on github
#
Given vimwiki (a):
a
Execute (Set filename wiki_test.md):
file wiki_test.md
Expect (a):
a
################################################################################
Execute (Log):
Log '#915 Vimwiki Markdown Blockquote Syntax issue'
call SetSyntax('markdown')
Given vimwiki (One blockquote):
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla vel.
Do (gqq):
gqq
Expect (Well formated and cursor on Sed):
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus
> est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla
> vel.
Do (move cursor and gww):
fS
gww
i__HERE__
Expect (Well formated and cursor on Sed):
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus
> est sed facilisis. __HERE__Sed imperdiet massa tellus, eu fermentum felis fringilla
> vel.
Given vimwiki (Multiple line blockquote):
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus
> est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla
> vel.
Execute (no JJ && Assert for Version > 7.3):
normal JJ
if v:version > 703
AssertEqual getline(1), '> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam faucibus rhoncus est sed facilisis. Sed imperdiet massa tellus, eu fermentum felis fringilla vel.'
endif
################################################################################
Execute (Log):
Log '#949 <Enter> create link bug with Chinese characters'
call SetSyntax('markdown')
Given vimwiki (Madarin with vimwiki Yeeepy):
你好
你们好
你们好啊
你们好啊啊
你们好啊aaaaa
aaaaa你们好啊
Do (Enter in all):
\<Cr>j \<Cr>j \<Cr>j \<Cr>j \<Cr>j \<Cr>j \<Cr>j
Expect (all WORDS are links):
[你](你)
[你好](你好)
[你们好](你们好)
[你们好啊](你们好啊)
[你们好啊啊](你们好啊啊)
[你们好啊aaaaa](你们好啊aaaaa)
[aaaaa你们好啊](aaaaa你们好啊)
################################################################################
Execute (Log):
Log '#735 Fix off-by-one error in get_next_line and get_prev_line'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki (P#735 -> I#407):
1. item1
2. item2
```
echo "hello world"
```
3. item3
Do (o):
o
Expect (Renumber all):
1. item1
2.
3. item2
```
echo "hello world"
```
4. item3
################################################################################
Execute (Log):
Log '#899 conceallevel is setted globally when editing a wiki file (PR #900)'
call SetSyntax('markdown')
Given vimwiki (Void):
Execute (conceal):
set conceallevel=1
let g:vimwiki_global_vars['conceallevel']=2
Log ' ConcealLevel is set to vimwiki for a .md'
call SetSyntax('markdown')
file main.md
edit
AssertEqual &ft, 'vimwiki'
AssertEqual @%, 'main.md'
if exists('+conceallevel')
AssertEqual &conceallevel, 2
endif
Log ' ConcealLevel is set to vim for a no_ext'
edit no_ext
AssertEqual &ft, ''
if exists('+conceallevel')
AssertEqual &conceallevel, 1
endif
Log ' Again ConcealLevel is set to vimwiki for a .md (just for fun)'
let g:vimwiki_global_vars['conceallevel']=0
edit new.md
AssertEqual &ft, 'vimwiki'
AssertEqual @%, 'new.md'
if exists('+conceallevel')
AssertEqual &conceallevel, 0
endif
################################################################################
Execute (Log):
Log 'PR #528: Add option |g:vimwiki_create_link| to prevent link creation'
call SetSyntax('markdown')
Given vimwiki (Link):
Link
Do (Enter):
\<CR>
# TODO should be Link.md, revise the test
Expect (Link):
[Link](Link)
Do (<CR><CR>):
\<CR>\<CR>
:AssertEqual expand('%:t'), 'Link.md'\<CR>
Given vimwiki (Link):
Link
Do (No link: <CR><CR>):
:call vimwiki#vars#set_global('markdown_create_link', 0)
\<CR>\<CR>
:AssertEqual expand('%:t'), 'main.md'\<CR>
Expect (Link):
[Link](Link)
Execute (wipeout):
" This solves many things
file /testplugin/[Vader-workbench]

View File

@@ -0,0 +1,51 @@
# See Issue #580
Given vimwiki (Void):
Tabnext
Execute (Set fold method):
let g:vimwiki_folding = 'expr:quick'
call ReloadVimwiki()
Execute (Expect < 0.5 second delay: Issue #580):
let mode = mode(1)
Log 'Mode : ' .mode
if mode ==# 'ce' || mode ==# 'cv' " -es (silent ex mode)
Log 'Skiped: Tabedit and tabnext are not working weel with -Es'
else
Log 'Prepare: Edit: mode: ' . mode
edit /testplugin/test/resources/delay.wiki
Log 'Prepare: Assert'
AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
Log 'Prepare: Goto 50%'
normal! 50%
# "TODO set ft and set wiki syntax or this error (no fold found)
# "normal! zozo
Log 'Run: tabedit'
let start = reltime()
tabedit
let end = str2float(reltimestr(reltime(start)))
Log 'Verify redraw'
Log 'Elapsed time Tabedit = ' . string(end)
Assert end < 0.5, 'Redraw Took longer than expected: ' . string(end) . ' seconds'
Log 'Run: redraw'
let start = reltime()
tabprev
redraw
let end = str2float(reltimestr(reltime(start)))
Log 'Verify redraw'
Log 'Elapsed time redraw = ' . string(end)
Assert end < 0.5, 'Redraw Took longer than expected: ' . string(end) . ' seconds'
endif
Execute (Reset variables):
call DeleteFile('/testplugin/test/resources/delay.wiki')
let g:vimwiki_folding = ''
call ReloadVimwiki()
Expect vimwiki (Tabnext):
Tabnext

View File

@@ -0,0 +1,394 @@
# Link internal to a file
#
# See: generate_toc.vim
#
# See issue #666 for anchor support (then internal links)
# Preambule set file onces and for all {{{1
# Otherwise the bash script is freezing
### Wiki {{{1
###############
### Markdown {{{1
###############
Given vimwiki (a):
a
Execute (Set filename wiki_test.md):
file wiki_test.md
Expect (a):
a
Given vimwiki (VimwikiTOC with link and number {{{1):
[link1](#i-v-p-741528)
[link2](#i-v-p-741528-2)
# I [V p](h) (7.415.28)
# I [V p](h) 741.528
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (Enter link):
gg\<Cr>
A__HERE1__\<Esc>
ggj\<Cr>
A__HERE2__\<Esc>
Expect():
[link1](#i-v-p-741528)
[link2](#i-v-p-741528-2)
# I [V p](h) (7.415.28)__HERE1__
# I [V p](h) 741.528__HERE2__
Given vimwiki (VimwikiTOC is broken against headers with link #182 {{{1):
[A link B](#a-link-b)
[tlink](#tlink)
[7.4.1528](#741528)
[link (333)](#link-333)
# A [link](anything here) B
# t[link](anything here)
## 7.4.1528
#### [link]() (333)
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (Enter link):
gg\<Cr>
A__HERE1__\<Esc>
ggj\<Cr>
A__HERE2__\<Esc>
ggjj\<Cr>
A__HERE3__\<Esc>
ggjjj\<Cr>
A__HERE4__\<Esc>
:AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')\<Cr>
Expect vimwiki (Good anchor with link navigation):
[A link B](#a-link-b)
[tlink](#tlink)
[7.4.1528](#741528)
[link (333)](#link-333)
# A [link](anything here) B__HERE1__
# t[link](anything here)__HERE2__
## 7.4.1528__HERE3__
#### [link]() (333)__HERE4__
# Link to anchor in SetExt {{{1
# Like that
# -----
# Issue: #209
Given vimwiki (Anchor SetExt):
[jump](#frst-one)
F!rst One
=========
Execute (Set filename wiki_test.md):
call SetSyntax('markdown')
Do (Enter link):
\<Cr>
A__HERE__\<Esc>
Expect (Cursor jumped SetExt):
[jump](#frst-one)
F!rst One__HERE__
=========
Given vimwiki (Bad Anchor SetExt):
[jump](#frst-one)
F!rst One
Execute (Set filename wiki_test.md):
call SetSyntax('markdown')
Do (Enter link):
\<Cr>
A__HERE__\<Esc>
Expect (Cursor stayed (not jumped) SetExt):
[jump](#frst-one)__HERE__
F!rst One
# Link to anchor with spaces {{{1
# PR #840
# Issues: #831
Given vimwiki (Internal links zith spaces):
[Any ! apparent name @#$](#basic-heading-many-spaces)
One line here
## Basic HeAding Many SpacES
One line here
Execute (Set filename wiki_test.md):
call SetSyntax('markdown')
Do (Enter link):
\<Cr>
A__HERE__\<Esc>
Expect (Cursor at heading position):
[Any ! apparent name @#$](#basic-heading-many-spaces)
One line here
## Basic HeAding Many SpacES__HERE__
One line here
Execute (Clear wiki jumps (alias: prev_links)):
call vimwiki#vars#set_bufferlocal('prev_links', [])
# Before {{{1
Given vimwiki (Internal links + one link to filenew):
# Contents
- [Test1](#Test1)
- [Test2](#Test2)
# Test1
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
# Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
Execute (Set filename wiki_test.md):
call SetSyntax('markdown')
Do (Navigate with <Tab>):
A more Contents\<Esc>
\<Tab>
\<Enter>
A more Test1\<Esc>
\<Tab>
\<Tab>
\<Enter>
A more Test2\<Esc>
Expect (Content added to titles):
# Contents more Contents
- [Test1](#Test1)
- [Test2](#Test2)
# Test1 more Test1
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
# Test2 more Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
Do (Navigate with <Tab> and <Enter> and come back with <Bs>):
\<Tab>
\<Enter>
# Cursor at Test1
\<Tab>
\<Tab>
\<Enter>
# Cursor at Test2
\<Tab>
\<Tab>
\<Tab>
# Cursor at Test2/filenew
A not yet\<Esc>
\<Bs>
# Cursor at Test1/test2
A near Test1/test2
\<Esc>
\<Bs>
# Cursor at Contents/test1
A near Contents/test1
\<Esc>
Expect (Vimwiki links):
# Contents
- [Test1](#Test1) near Contents/test1
- [Test2](#Test2)
# Test1
- [Test1](#Test1)
- [Test2](#Test2) near Test1/test2
- [filenew](filenew)
# Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew) not yet
Do (Navigate with <Tab> comeback with <Bs> from filenew):
\<Tab>
A first shot\<Esc>
0\<Tab>
# Cursor at Contents/test1
\<Enter>
\<Tab>
\<Tab>
A first shot\<Esc>
0\<Tab>
# Cursor at Test1/test2
\<Enter>
G
# Cursor at Test2/filenew
A first shot\<Esc>
0\<Tab>
# Cursor at Test2/filenew
\<Enter>
# Cursor in filenew (a new file)
A anything in filenew: empirically it does not count\<Esc>
\<Bs>
# Cursor at Test2/filenew
\<Bs>
# Cursor at Test1/test2
\<Bs>
# Cursor at Contents/test1
A second shot
Expect (Just Contents/test1 got the second shot):
# Contents
- [Test1](#Test1) first shot second shot
- [Test2](#Test2)
# Test1
- [Test1](#Test1)
- [Test2](#Test2) first shot
- [filenew](filenew)
# Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew) first shot
Execute (Delete filenew buffer):
call DeleteFile('/testplugin/filenew.md')
Do (Navigate with <Tab> comeback with <Bs> too far):
\<Tab>
# Cursor at Contents/test1
\<Enter>
\<Tab>
\<Tab>
# Cursor at Test1/test2
\<Enter>
\<Tab>
# Cursor at Test2/test1
\<Enter>
\<Tab>
\<Tab>
# Cursor at Test1/test2
\<Enter>
A first test2\<Esc>
\<Tab>
# Cursor at Test2/test1
\<Enter>
A first test1\<Esc>
# Back
\<Bs>
# Cursor at Test2/test1
A second test2/test1\<Esc>
\<Bs>
# Cursor at Test1/test2
A second test1/test2\<Esc>
\<Bs>
# Cursor at Test2/test1
\<Bs>
# Cursor at Test1/test2
\<Bs>
# Cursor at Contents/test1
# Finished
\<Bs>
\<Bs>
\<Bs>
\<Bs>
A 1\<Esc>
\<Bs>
A 2\<Esc>
\<Bs>
A 3\<Esc>
\<Bs>
A 4\<Esc>
Expect (After too many <Bs>, cursor stays at the first <Enter> spot in first file: Contents/test1):
# Contents
- [Test1](#Test1) 1 2 3 4
- [Test2](#Test2)
# Test1 first test1
- [Test1](#Test1)
- [Test2](#Test2) second test1/test2
- [filenew](filenew)
# Test2 first test2
- [Test1](#Test1) second test2/test1
- [Test2](#Test2)
- [filenew](filenew)
Given vimwiki (link to self):
- [Bad link](Very bad.html)
- [My own file](wiki_test)
- [Test1](#Test1)
- [Test2](#Test2)
Do (Follow link to self and append chars):
\<Tab>
\<Tab>
\<Enter>
a this_is_18_chars \<Esc>
Expect (Some chars appended at self link):
- [Bad link](Very bad.html)
- [ this_is_18_chars My own file](wiki_test)
- [Test1](#Test1)
- [Test2](#Test2)
# vim: foldmethod=marker foldlevel=30 sw=2

View File

@@ -0,0 +1,474 @@
# Link creation: my favorite (tinmarino)
# You know, when pressing Enter:
# in mode normal, visual
# in OS windows, linux
# Seems easy but tests are reaaly needed here
# Links Renaming inside #1138 {{{1
Given vimwiki (Link with toto):
[if nothing goes right, go left](www.the_bad_jokes.com)
Do(Rename description):
# Change in bracket
ci[
new description
\<Esc>
Expect(New description):
[new description](www.the_bad_jokes.com)
Do(Rename url):
# Move to (
%l
# Change in parenthesis
ci(
www.new_url.com
Expect(New URL):
[if nothing goes right, go left](www.new_url.com)
# Links with dot {{{1
# Issue #924
# See for spec: https://github.com/vimwiki/vimwiki/issues/924#issuecomment-672837685
####################
Given vimwiki (filename filename.dot):
filename
filename.dot
Do():
:call SetSyntax('default')\<CR>
\<CR>\<CR>
:AssertEqual 'filename.wiki', expand('%:t')\<CR>
:call DeleteFile('%')\<CR>
Do():
j
\<CR>\<CR>
:AssertEqual 'filename.dot', expand('%:t')\<CR>
:call DeleteFile('%')\<CR>
Expect(Nothing left):
# Linkify function {{{1
# Issue #994
####################
Given vimwiki (abc def ghi jkl):
https://github.com/vimwiki/vimwiki
Do(wiki: call linkify):
:if v:version >= 704\<CR>
call vimwiki#base#linkify()\<CR>
else\<CR>
let stg = '[[https://github.com/vimwiki/vimwiki|GitHub - vimwiki/vimwiki: Personal Wiki for Vim]]'\<CR>
0put =stg\<CR>
$d\<CR>
endif\<CR>
# else\<CR>
# endif\<CR>
Expect(Wiki link):
[[https://github.com/vimwiki/vimwiki|GitHub - vimwiki/vimwiki: Personal Wiki for Vim]]
Do(md: call linkify):
:call SetSyntax('markdown')\<CR>
:if v:version >= 704\<CR>
call vimwiki#base#linkify()\<CR>
else\<CR>
0put ='[GitHub - vimwiki/vimwiki: Personal Wiki for Vim](https://github.com/vimwiki/vimwiki)'\<CR>
$d\<CR>
endif\<CR>
Expect(Markdown link):
[GitHub - vimwiki/vimwiki: Personal Wiki for Vim](https://github.com/vimwiki/vimwiki)
# Link Normalisation {{{1
# And configuration
# Issues: #892
####################
Execute (Log):
Log 'Markdown change Link1 : Pressing enter to create a [[double bracket]] #892'
Given vimwiki (abc def ghi jkl):
abc def ghi jkl
Execute (Set filename wiki_test.md):
call SetSyntax('markdown')
let save_link = g:vimwiki_syntaxlocal_vars.markdown.Link1
let g:vimwiki_syntaxlocal_vars.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
Do (vee<CR>):
vee\<CR>
Expect (append md suffix):
[[abc def]] ghi jkl
Execute (restore):
let g:vimwiki_syntaxlocal_vars.markdown.Link1 = save_link
# vimwiki_markdown_link_ext {{{1
####################
Execute (Log):
Log 'vimwiki_markdown_link_ext'
Given vimwiki (abc def ghi jkl):
abc def ghi jkl
Execute (Set filename wiki_test.md):
Log '>> Visual creation, markdown syntax'
file wiki_test.md
let g:vimwiki_markdown_link_ext = 1
call ReloadVars()
call SetSyntax('markdown')
AssertEqual vimwiki#vars#get_wikilocal('syntax'), 'markdown'
AssertEqual vimwiki#vars#get_wikilocal('markdown_link_ext'), 1
Do (vee<CR>):
vee\<CR>
Expect (append md suffix):
[abc def](abc def.md) ghi jkl
Execute (Restore variable g:vimwiki_markdown_link_ext):
unlet g:vimwiki_markdown_link_ext
call ReloadVars()
# Visual Creation {{{1
# Issues: #382
####################
Execute (Log):
Log 'Visual Creation'
# For markdown {{{2
# ------------------
Given vimwiki (abc def ghi jkl):
abc def ghi jkl
Execute (Set filename wiki_test.md):
Log '>> Visual creation, markdown syntax'
file wiki_test.md
call SetSyntax('markdown')
AssertEqual vimwiki#vars#get_wikilocal('syntax'), 'markdown'
Do (v3e):
v3e\<Cr>
Expect (3 Words []()):
[abc def ghi](abc def ghi) jkl
Do (v3e):
wv2e\<Cr>
Expect (2 Words []()):
abc [def ghi](def ghi) jkl
Do (selection=exclusive v3e):
:set selection=exclusive\<Cr>
wv2e\<Cr>
Expect (2 Words []()):
abc [def ghi](def ghi) jkl
Do (selection=exclusive wv$):
:set selection=exclusive\<Cr>
wv$\<Cr>
Expect (3 Words []()):
abc [def ghi jkl](def ghi jkl)
# For Wiki {{{2
# ------------------
Given vimwiki (abc def ghi jkl):
abc def ghi jkl
Execute (Set filename wiki_test.md):
Log '>> Visual creation, wiki syntax'
file wiki_test.wiki
call SetSyntax('default')
Do (v3e):
v3e\<Cr>
Expect (3 Words []()):
[[abc def ghi]] jkl
Do (v3e):
wv2e\<Cr>
Expect (2 Words []()):
abc [[def ghi]] jkl
Do (selection=exclusive v3e):
:set selection=exclusive\<Cr>
wv2e\<Cr>
Expect (2 Words []()):
abc [[def ghi]] jkl
Do (selection=exclusive wv$):
:set selection=exclusive\<Cr>
wv$\<Cr>
Expect (3 Words []()):
abc [[def ghi jkl]]
# Absolute links {{{1
####################
Execute (Log):
Log 'Absolute links: full paths and in-wiki'
# For markdown {{{2
# ------------------
Execute (Set filename wiki_test.md):
Log '>> Absolute link, markdown syntax'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki(some wiki link):
[test1](//$HOME/in_home1)
[test2](//~/in_home2)
[test3](///tmp/in_tmp)
[test4](/in_current_wiki)
Do (Check in_home1):
\<Cr>
:AssertEqual expand('%'), $HOME.'/in_home1.md'\<Cr>
Do (Check in_home2):
j\<Cr>
:AssertEqual expand('%'), $HOME.'/in_home2.md'\<Cr>
Do (Check in_tmp):
jj\<Cr>
:AssertEqual expand('%'), '/tmp/in_tmp.md'\<Cr>
# Here, assuming that "current wiki" means the working directory, since
# no wiki is currently defined:
Do (Check in_current_wiki):
jjj\<Cr>
:AssertEqual expand('%'), '/testplugin/in_current_wiki.md'\<Cr>
# For Wiki {{{2
# ------------------
Execute (Set filename wiki_test.wiki):
Log '>> Absolute link, wiki syntax'
file wiki_test.wiki
call SetSyntax('default')
Given vimwiki(some wiki link):
[[//$HOME/in_home1]]
[[//~/in_home2]]
[[///tmp/in_tmp]]
[[/in_current_wiki]]
Do (Check in_home1):
\<Cr>
:AssertEqual expand('%'), $HOME.'/in_home1.wiki'\<Cr>
Do (Check in_home2):
j\<Cr>
:AssertEqual expand('%'), $HOME.'/in_home2.wiki'\<Cr>
Do (Check in_tmp):
jj\<Cr>
:AssertEqual expand('%'), '/tmp/in_tmp.wiki'\<Cr>
# Here, assuming that "current wiki" means the working directory, since
# no wiki is currently defined:
Do (Check in_current_wiki):
jjj\<Cr>
:AssertEqual expand('%'), '/testplugin/in_current_wiki.wiki'\<Cr>
Execute(Clean: temporary):
call ReloadVimwiki()
call DeleteFile('$HOME/in_home1.md')
call DeleteFile('~/in_home2.md')
call DeleteFile('/tmp/in_tmp.md')
# Link with dot {{{1
####################
Execute (Log):
Log 'Link with dot'
Given vimwiki (filenames with dots):
part1.part2.part3
part1.part2.part3.md
noext
Execute (Set filename wiki_test.md):
file wiki_test.md
call SetSyntax('markdown')
Do (Linkify all):
\<Cr>
j\<Cr>
j\<Cr>
Expect (Full Words are made as links, no extension addded . -> space):
[part1 part2 part3](part1.part2.part3)
[part1 part2 part3](part1.part2.part3.md)
[noext](noext)
Given vimwiki (filnames with dots):
part1.part2.part3
part1.part2.part3.md
noext
Do (Fllow link witout markdown):
\<Cr>\<Cr>
:AssertEqual expand('%:t'), 'part1.part2.part3'\<Cr>
Do (j<Cr><Cr>):
j\<Cr>\<Cr>
:AssertEqual expand('%:t'), 'part1.part2.part3.md'\<Cr>
# Rest {{{1
##########################
Execute (Log):
Log 'And more'
Given vimwiki (Text that is not a wikilink):
test
www.google.com
https://www.google.com
multiple words
let's
let's
file.wiki
file.md
file.mw
Execute (Set syntax to default):
call SetSyntax('default')
Do (Create links default syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Vimwiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
[[let's]]
[[let]]'s
[[file.wiki]]
[[file.md]]
[[file.mw]]
Execute (Set syntax to markdown):
call SetSyntax('markdown')
Do (Create links markdown syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Markdown links):
[test](test)
[www.google.com](www.google.com)
[https://www.google.com](https://www.google.com)
[multiple words](multiple words)
[let's](let's)
[let](let)'s
[file wiki](file.wiki)
[file](file.md)
[file mw](file.mw)
Execute (Set syntax to mediawiki):
call SetSyntax('media')
Do (Create links mediawiki syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Mediawiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
[[let's]]
[[let]]'s
[[file.wiki]]
[[file.md]]
[[file.mw]]
Execute(Clean: Icreated many temporary wiki):
call ReloadVimwiki()
# vim: foldmethod=marker foldlevel=30

View File

@@ -0,0 +1,262 @@
# Automatic link generation
# Related to:
# - wiki file discovery
# - buffer list insertion (see: vimwiki#base#update_listing_in_buffer)
Execute (Reset sw to default (due to batch)):
set sw=8
# 1 VimwikiGenerateLinks {{{1
##########################
# Wiki Syntax (no caption, default) {{{2
#################
Execute (Log):
Log 'Wiki Syntax (no caption, default)'
call ReloadVimwiki()
AssertEqual '-1_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
Given (Void):
Execute (VimwikiGenerateLinks):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
Expect (The links with a header):
= Generated Links =
- [[buzz_bozz]]
- [[index]]
- [[link_syntax]]
- [[link_syntax/nested]]
Execute (VimwikiGenerateLinks x 2):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
call append('$', 'Last Line')
VimwikiGenerateLinks
Expect (The links with a header (bis)):
= Generated Links =
- [[buzz_bozz]]
- [[index]]
- [[link_syntax]]
- [[link_syntax/nested]]
Last Line
Execute (Clean Test.wiki):
call DeleteFile('$HOME/testwiki/Test.wiki')
# Wiki Syntax (with caption) {{{2
#################
Execute (Log):
Log 'Wiki Syntax (with caption)'
let vimwiki_default.generated_links_caption = 1
call ReloadVimwiki()
AssertEqual '-1_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
Given (Void):
Execute (VimwikiGenerateLinks):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
Expect (The links with a header):
= Generated Links =
- [[buzz_bozz|Buzz Bozz]]
- [[index|Test Wiki]]
- [[link_syntax]]
- [[link_syntax/nested]]
Execute (VimwikiGenerateLinks x 2):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
call append('$', 'Last Line')
VimwikiGenerateLinks
Expect (The links with a header (bis)):
= Generated Links =
- [[buzz_bozz|Buzz Bozz]]
- [[index|Test Wiki]]
- [[link_syntax]]
- [[link_syntax/nested]]
Last Line
Execute (Clean Test.wiki):
call DeleteFile('$HOME/testwiki/Test.wiki')
# Markdown Syntax {{{2
#################
Execute (Log):
Log 'Markdown Syntax'
Given (Void):
Execute (Goto markdown resource wiki):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
Execute (Edit Test file / VimwikiGenerateLinks):
edit $HOME/testmarkdown/Test.md
AssertEqual $HOME . '/testmarkdown/Test.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
VimwikiGenerateLinks
Expect (The links with a header):
# Generated Links
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
- [link_syntax](link_syntax)
- [link_syntax/nested](link_syntax/nested)
Do (Save Test.md && Re-GenerateLinks):
:edit $HOME/testmarkdown/Test.md\<CR>
:call WriteMe()\<CR>
:VimwikiGenerateLinks\<CR>
:VimwikiGenerateLinks\<CR>
Expect (The links with a header with file Test):
# Generated Links
- [Generated Links](Test)
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
- [link_syntax](link_syntax)
- [link_syntax/nested](link_syntax/nested)
Execute (Clean: Remove Test.md):
call DeleteFile('$HOME/testmarkdown/Test.md')
# 2 VimwikiDiaryGenerateLinks {{{1
#############################
# Wiki Syntax {{{1
#################
Execute (Log):
Log 'Wiki Syntax'
Do (Create diary files):
:edit $HOME/testwiki/diary/2019-12-10.wiki\<Cr>
:call append('$', 'Content')\<Cr>
:call WriteMe()\<Cr>
:edit $HOME/testwiki/diary/2019-07-13.wiki\<Cr>
:call append('$', 'Content')\<Cr>
:call WriteMe()\<Cr>
:edit $HOME/testwiki/diary/2019-03-01.wiki\<Cr>
:call append('$', 'Content')\<Cr>
:call WriteMe()\<Cr>
Do (Edit diary.wiki && GenerateDiaryLinks):
:edit $HOME/testwiki/diary/diary.wiki\<CR>
:VimwikiDiaryGenerateLinks\<CR>
Expect (diary index generated):
= Diary =
== 2020 ==
=== July ===
- [[2020-07-25|day 4]]
- [[2020-07-24|day 3]]
- [[2020-07-23|Day 2]]
- [[2020-07-22]]
== 2019 ==
=== December ===
- [[2019-12-10]]
=== July ===
- [[2019-07-13]]
=== March ===
- [[2019-03-01]]
Execute (Clean):
Log "End: Clean"
call DeleteFile('$HOME/testwiki/diary/2019-12-10.wiki')
call DeleteFile('$HOME/testwiki/diary/2019-07-13.wiki')
call DeleteFile('$HOME/testwiki/diary/2019-03-01.wiki')
Log "End: Reset shiftwidth to the default: 8"
# Wiki Markdown {{{1
#################
Execute (Log):
Log 'Markdown Syntax'
Execute (New Command):
Log "2. Testing VimwikiDiaryGenerateLinks TODO"
set sw=4
AssertEqual 4, &sw
Do (Edit diary/2019-12-10):
:edit $HOME/testmarkdown/diary/2019-12-10.md\<CR>
iinformative content\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2019-07-13):
:edit $HOME/testmarkdown/diary/2019-07-13.md\<CR>
i# informative title\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2018-03-01):
:edit $HOME/testmarkdown/diary/2019-03-01.md\<CR>
:call WriteMe()\<CR>
Do (Edit diary.md && GenerateDiaryLinks):
:edit $HOME/testmarkdown/diary/diary.md\<CR>
:VimwikiDiaryGenerateLinks\<CR>
Expect (diary index generated):
# Diary
## 2020
### July
- [2020-07-22](2020-07-22)
## 2019
### December
- [2019-12-10](2019-12-10)
### July
- [informative title](2019-07-13)
### March
- [2019-03-01](2019-03-01)
Execute (Clean):
call DeleteFile('$HOME/testmarkdown/diary/2019-12-10.md')
call DeleteFile('$HOME/testmarkdown/diary/2019-07-13.md')
call DeleteFile('$HOME/testmarkdown/diary/2019-03-01.md')
Log "End: Reset shiftwidth to the default: 8"
set sw&
# vim: sw=2:foldmethod=marker:foldlevel=30:foldignore=:

View File

@@ -0,0 +1,295 @@
# VimwikiRenameFile
# Related to link, file navigation
# Many commands are made with Do: They block with Execute
# Create directories I remove at end {{{1
##########################################
Execute (Mkdir dir1 dir2 dir11 dir12):
call system("mkdir $HOME/testmarkdown/dir1")
call system("mkdir $HOME/testmarkdown/dir1/dir11")
call system("mkdir $HOME/testmarkdown/dir1/dir12")
call system("mkdir $HOME/testmarkdown/dir2")
Do(Link with / are relative to root #617):
:edit $HOME/testmarkdown/test.md\<Cr>
:Log 'Is this wiki 2'\<Cr>
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<Cr>
:Log 'Editing'\<Cr>
i/dir1/old_name\<Esc>
\<CR>\<CR>
:AssertEqual 'old_name', expand('%:t:r')\<Cr>
:call WriteMe()\<Cr>
:VimwikiRenameFile new_name\<Cr>
:AssertEqual 'new_name', expand('%:t:r')\<Cr>
:edit $HOME/testmarkdown/test.md\<Cr>
:AssertEqual '[dir1 old_name](/dir1/new_name)', getline(1)\<Cr>
# TEST TRANSDIRECTORY AND ARGUMENT {{{1
# NEW FEATURE #926
# Create smaller unit {{{2
# we stick all along with these 3 files,
# Follow them !
Execute (Create 3 files):
edit $HOME/testmarkdown/Test-Rename-zzz.md
call WriteMe()
edit $HOME/testmarkdown/dir1/dir11/Test-Rename.md
call WriteMe()
edit $HOME/testmarkdown/Test-Rename-Completion.md
call WriteMe()
Do (Testing Old buffer has been wiped out {{{2):
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
:Log 'Get current Buffer'\<Cr>
:let buf_old = bufnr('%')\<Cr>
:Log 'Is this wiki 2'\<Cr>
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<Cr>
:Log 'Delete for loosers'\<Cr>
:call DeleteFile('$HOME/testmarkdown/Test-Rename-new1.md')\<Cr>
:Log 'Rewrite ...'\<Cr>
:call WriteMe()\<Cr>
:Log 'Rename 1'\<Cr>
:VimwikiRenameFile Test-Rename-new1\<Cr>
:Log 'Assert 1'\<Cr>
:AssertEqual 'Test-Rename-new1', expand('%:t:r')\<Cr>
:Log 'Rename 2'\<Cr>
:VimwikiRenameFile Test-Rename-Completion\<Cr>
:Log 'Assert 2'\<Cr>
:AssertEqual expand('%'), $HOME . '/testmarkdown/Test-Rename-Completion.md'\<Cr>
Do (Testing Completion {{{2):
# Rename and test (zzz)
:VimwikiRenameFile Test-Rename-z\<C-l>1\<Cr>
:AssertEqual $HOME . '/testmarkdown/Test-Rename-zzz1.md', expand('%')\<CR>\<Esc>
# Restore old name
:call WriteMe()\<Cr>
:VimwikiRenameFile Test-Rename-zzz\<Cr>
Do (Testing transforward {{{2):
:Log 'Forward: root -> dir1/dir11 {{{3'\<Cr>
# Create dir1/dir11/Test-Rename and link to it
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
ggdG
idir1/dir11/Test-Rename.md\<Esc>
\<Cr>\<Cr>
:VimwikiRenameFile ../Test-Rename-2\<Cr>
:AssertEqual expand('%'), $HOME . '/testmarkdown/dir1/Test-Rename-2.md'\<CR>\<Esc>
# See what happend in root
:call WriteMe()\<Cr>
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
:AssertEqual getline(1), '[dir1 dir11 Test Rename](dir1/Test-Rename-2.md)'\<Cr>
:Log 'Backward dir1/dir11 -> root {{{3'\<Cr>
# See what happend in dir1/dir11
# I am in root so pressing Enter sends me to dir1/dir11
\<Cr>
# Write forward path
dd
i../Test-Rename-Completion\<Esc>
# Convert it to link
0\<Cr>\<Cr>
# Now in root
:AssertEqual $HOME . '/testmarkdown/Test-Rename-Completion.md', expand('%')\<Cr>
:VimwikiRenameFile dir1/Test-Rename-Completion-2\<Cr>
:Log 'Rename -> dir1/Test...{{{3'\<Cr>
:AssertEqual $HOME . '/testmarkdown/dir1/Test-Rename-Completion-2.md', expand('%')\<Cr>
Execute (Delete smaller unit changed {{{2):
call DeleteFile('$HOME/testmarkdown/Test-Rename-new1.md')
call DeleteFile('$HOME/testmarkdown/Test-Rename-zzz.md')
call DeleteFile('$HOME/testmarkdown/dir1/Test-Rename-Completion_2.md')
call DeleteFile('$HOME/testmarkdown/dir1/Test-Rename-2.md')
# VimwikiRename Test same directory {{{1
# Old big conf, from bad unit test design
# Changing file in a single dir
# Feel free to modify but as long as it works
# I delay the cleaning
####################################
Given vimwiki (Void):
Execute (Create Test-Rename -> dir1/dir11/in_dir11.md and dir1/dir12/in_dir12.md and dir2/in_dir2.md):
edit $HOME/testmarkdown/Test-Rename.md
AssertEqual $HOME . '/testmarkdown/Test-Rename.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
call append(0, ['# Test Rename', 'in_root.md', 'dir1/dir11/in_dir11.md', 'dir1/dir12/in_dir12.md', 'dir2/in_dir2.md'])
call WriteMe()
Do (Create in_root):
:Log 'Open Test-Rename.md'\<CR>
:edit $HOME/testmarkdown/Test-Rename.md\<CR>
:AssertEqual $HOME . '/testmarkdown/Test-Rename.md', expand('%')\<CR>\<Esc>
:Log 'Delete last line (easyer latter checks without trailing spaces)'\<CR>
Gdd
:Log 'Open in_root.md'\<CR>
gg
j\<CR>
j\<CR>
j\<CR>
j\<CR>
ggj0y$
:AssertEqual '[in_root](in_root.md)', @"\<CR>
0\<CR>
:AssertEqual $HOME . '/testmarkdown/in_root.md', expand('%')\<CR>
:Log 'Add link in_root.md -> dir1/dir11/in_dir11'\<CR>
ggi# Title in root\<CR>\<Esc>
idir1/dir11/in_dir11\<Esc>
:call WriteMe()\<CR>
:AssertEqual $HOME . '/testmarkdown/in_root.md', expand('%')\<CR>
:Log 'Open in_dir11.md: creating dirs'\<CR>
ggj"ay$
:AssertEqual 'reg dir1/dir11/in_dir11', 'reg ' . @a\<CR>
0\<CR>\<CR>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
:Log 'One backspace for fun'\<CR>
\<BS>
:AssertEqual 'file ' . $HOME . '/testmarkdown/in_root.md', 'file ' . expand('%')\<CR>
Do (Create dir_11 -> dir_11):
:edit $HOME/testmarkdown/dir1/dir11/in_dir11_fix.md\<CR>
:Log 'Add link in_dir11_fix.md -> in_dir11'\<CR>
ggi# Title in dir11 fix\<CR>\<Esc>
iin_dir11\<Esc>
:call WriteMe()\<CR>
:Log 'Open in_dir11.md: creating dirs'\<CR>
ggj"ay$
:AssertEqual 'reg in_dir11', 'reg ' . @a\<CR>
0\<CR>\<CR>
y\<CR>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
:Log 'One backspace for fun'\<CR>
\<BS>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11_fix.md', 'file ' . expand('%')\<CR>
Execute (Fill in_dir11 content):
edit $HOME/testmarkdown/dir1/dir11/in_dir11.md
call append(0, ['# Title in_dir11', '[dir2 link](../../dir2/in_dir2.md)'])
call WriteMe()
# Rename local {{{1
###################
Do (RenameLink in_dir11 -> in_dir11_new):
:edit $HOME/testmarkdown/dir1/dir11/in_dir11.md\<CR>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<CR>
:Log 'Rename'\<CR>
:call WriteMe()\<CR>
:VimwikiRenameFile\<CR>
y\<CR>
in_dir11_new\<CR>
:call WriteMe()\<Cr>
:Log 'Append filename'\<CR>
:call append('$', [expand('%')])\<CR>
Expect(With new filename at the end):
# Title in_dir11
[dir2 link](../../dir2/in_dir2.md)
/home/vimtest/testmarkdown/dir1/dir11/in_dir11_new.md
Execute (edit in_dir11_fix):
edit $HOME/testmarkdown/dir1/dir11/in_dir11_fix.md
Expect(Link to in_dir11_new):
# Title in dir11 fix
[in_dir11](in_dir11_new)
Execute (edit Test-Rename.md):
edit $HOME/testmarkdown/Test-Rename.md
Expect (Link to in_dir11_new):
# Test Rename
[in_root](in_root.md)
[dir1 dir11 in_dir11](dir1/dir11/in_dir11_new.md)
[dir1 dir12 in_dir12](dir1/dir12/in_dir12.md)
[dir2 in_dir2](dir2/in_dir2.md)
Do (in_dir2 -> in_dir2_new):
:edit $HOME/testmarkdown/dir2/in_dir2.md\<CR>
:Log 'Append filename'\<CR>
:call append('$', [expand('%')])\<CR>
:Log 'Rename'\<CR>
:call WriteMe()\<CR>
:VimwikiRenameFile\<CR>
y\<CR>
in_dir2_new\<CR>
:call WriteMe()\<Cr>
:Log 'Append filename'\<CR>
:call append('$', [expand('%')])\<CR>
Expect (old and new filenames):
/home/vimtest/testmarkdown/dir2/in_dir2.md
/home/vimtest/testmarkdown/dir2/in_dir2_new.md
Execute (edit Test-Rename.md):
edit $HOME/testmarkdown/Test-Rename.md
Expect (Link to in_dir11_new):
# Test Rename
[in_root](in_root.md)
[dir1 dir11 in_dir11](dir1/dir11/in_dir11_new.md)
[dir1 dir12 in_dir12](dir1/dir12/in_dir12.md)
[dir2 in_dir2](dir2/in_dir2_new.md)
Execute (edit in_dir11.md):
edit $HOME/testmarkdown/dir1/dir11/in_dir11_new.md
Expect (Link to in_dir2_new):
# Title in_dir11
[dir2 link](../../dir2/in_dir2_new.md)
/home/vimtest/testmarkdown/dir1/dir11/in_dir11_new.md
Execute (Clean dir1 and dir2):
Log "End: Clean"
call DeleteHiddenBuffers()
call system('rm $HOME/testmarkdown/Test-Rename.md')
call system('rm $HOME/testmarkdown/in_root.md')
call system('rm -r $HOME/testmarkdown/dir1')
call system('rm -r $HOME/testmarkdown/dir2')
# vim: sw=2 foldmethod=marker foldlevel=30 foldignore=#

View File

@@ -0,0 +1,122 @@
# Test resolution of as many link types as possible in Markdown syntax
# This relies on the line numbers for each type of link in link_syntax.md and
# link_syntax/nested.md, which seems primitive, but does seem to work.
# Links in a top-level page {{{
Execute (Assure link_syntax.md exists):
Log "Testing links in a top-level page with native syntax."
VimwikiIndex 2
VimwikiGoto link_syntax
AssertEqual $HOME . '/testmarkdown/link_syntax.md', expand('%')
Do (Check plain wiki page link to index):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:1\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>
Do (Check absolute-in-wiki page link to index with leading slash):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:2\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>
# //foo "absolute" links - these are also checked in link_generation.vader:
Do (Check absolute-on-filesystem page link to /tmp/some_page with 2 leading slashes):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:3\<CR>
\<CR>
:AssertEqual '/tmp/some_page.md', expand('%')\<CR>
Do (Check absolute-on-filesystem page link to index using tilde for homedir):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:4\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>
Do (Check diary link):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:5\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/diary/2020-07-22.md', expand('%')\<CR>
Do (Check link to nested page):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:6\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')\<CR>
Do (Check relative link to nested page with ./link_syntax/nested):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax\<CR>
:7\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')\<CR>
# }}}
# Links in a nested file {{{
Execute (Assure link_syntax/nested.md exists):
Log "Testing links in a nested page with native syntax."
VimwikiIndex 2
VimwikiGoto link_syntax/nested
AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')
Do (Nested: Check plain wiki page link to self - link_syntax/nested.md):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:1\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')\<CR>
Do (Nested: Check absolute-in-wiki page link to index with leading slash):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:2\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>
# //foo "absolute" links - these are also checked in link_generation.vader:
Do (Nested: Check absolute-on-filesystem page link to /tmp/some_page with 2 leading slashes):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:3\<CR>
\<CR>
:AssertEqual '/tmp/some_page.md', expand('%')\<CR>
Do (Nested: Check absolute-on-filesystem page link to index using tilde for homedir):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:4\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>
Do (Nested: Check diary link):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:5\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/diary/2020-07-22.md', expand('%')\<CR>
Do (Nested: Check relative link to page in parent directory):
:VimwikiIndex 2\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:6\<CR>
\<CR>
:AssertEqual $HOME . '/testmarkdown/link_syntax.md', expand('%')\<CR>
# }}}
# To be perfectly honest I don't know why or if this is necessary, but without
# it I was getting leftover tabs for the last file visited here. -- brennen
Execute (Clean):
call ReloadVimwiki()

View File

@@ -0,0 +1,122 @@
# Test resolution of as many link types as possible in VimWiki syntax
# This relies on the line numbers for each type of link in link_syntax.wiki and
# link_syntax/nested.wiki, which seems primitive, but does seem to work.
# Links in a top-level page {{{
Execute (Assure link_syntax.wiki exists):
Log "Testing links in a top-level page with native syntax."
VimwikiIndex 1
VimwikiGoto link_syntax
AssertEqual $HOME . '/testwiki/link_syntax.wiki', expand('%')
Do (Check plain wiki page link to index):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:1\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/index.wiki', expand('%')\<CR>
Do (Check absolute-in-wiki page link to index with leading slash):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:2\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/index.wiki', expand('%')\<CR>
# //foo "absolute" links - these are also checked in link_generation.vader:
Do (Check absolute-on-filesystem page link to /tmp/some_page with 2 leading slashes):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:3\<CR>
\<CR>
:AssertEqual '/tmp/some_page.wiki', expand('%')\<CR>
Do (Check absolute-on-filesystem page link to index using tilde for homedir):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:4\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/index.wiki', expand('%')\<CR>
Do (Check diary link):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:5\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/diary/2020-07-22.wiki', expand('%')\<CR>
Do (Check link to nested page):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:6\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/link_syntax/nested.wiki', expand('%')\<CR>
Do (Check relative link to nested page with ./link_syntax/nested):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax\<CR>
:7\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/link_syntax/nested.wiki', expand('%')\<CR>
# }}}
# Links in a nested file {{{
Execute (Assure link_syntax/nested.wiki exists):
Log "Testing links in a nested page with native syntax."
VimwikiIndex 1
VimwikiGoto link_syntax/nested
AssertEqual $HOME . '/testwiki/link_syntax/nested.wiki', expand('%')
Do (Nested: Check plain wiki page link to self - link_syntax/nested.wiki):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:1\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/link_syntax/nested.wiki', expand('%')\<CR>
Do (Nested: Check absolute-in-wiki page link to index with leading slash):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:2\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/index.wiki', expand('%')\<CR>
# //foo "absolute" links - these are also checked in link_generation.vader:
Do (Nested: Check absolute-on-filesystem page link to /tmp/some_page with 2 leading slashes):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:3\<CR>
\<CR>
:AssertEqual '/tmp/some_page.wiki', expand('%')\<CR>
Do (Nested: Check absolute-on-filesystem page link to index using tilde for homedir):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:4\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/index.wiki', expand('%')\<CR>
Do (Nested: Check diary link):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:5\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/diary/2020-07-22.wiki', expand('%')\<CR>
Do (Nested: Check relative link to page in parent directory):
:VimwikiIndex 1\<CR>
:VimwikiGoto link_syntax/nested\<CR>
:6\<CR>
\<CR>
:AssertEqual $HOME . '/testwiki/link_syntax.wiki', expand('%')\<CR>
# }}}
# To be perfectly honest I don't know why or if this is necessary, but without
# it I was getting leftover tabs for the last file visited here. -- brennen
Execute (Clean):
call ReloadVimwiki()

View File

@@ -0,0 +1,413 @@
# VimwikiTOC {{{1
#
# Just generate the TOC
# See: link_* for link movement and creation
#
# TODO (10min) test if g:vimwiki_to_header well readen
# TODO (10min) test vimviki_toc_link_format
# TODO (1h) test if really wiki dependant (for 2 diffrent wikis)
# TODO if link in heading
Given vimwiki (Wiki with spaces {{{1):
= h1 h2 h3 h4 =
Execute (Toc and enter (alpha)):
call SetSyntax('default')
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
AssertEqual -1, vimwiki#vars#get_wikilocal('list_margin')
VimwikiTOC
Expect (Toc alpha):
= Contents =
- [[#h1 h2 h3 h4]]
= h1 h2 h3 h4 =
Given vimwiki (Wiki with bad characters {{{1):
= h!@$%^&() =
Execute (Toc and beta):
call SetSyntax('default')
file wiki.wiki
VimwikiTOC
Expect (Toc and jumpes well):
= Contents =
- [[#h!@$%^&()]]
= h!@$%^&() =
Given vimwiki (One word headings (#981) {{{1):
= head1 =
== head2 ==
=== head3 ===
Execute (Wiki: toc_link_format=1 (to restore) VimwikiTOC x 1):
set sw=2
let vimwiki_toc_link_format = 1
call ReloadVimwiki()
call SetSyntax('default')
VimwikiTOC
Expect(Headinds TOC one word (1)):
= Contents =
- [[#head1|head1]]
- [[#head1#head2|head2]]
- [[#head1#head2#head3|head3]]
= head1 =
== head2 ==
=== head3 ===
Execute (Wiki: toc_link_format=0 (restoring default) VimwikiTOC x 1):
let vimwiki_toc_link_format = 0
call ReloadVimwiki()
call SetSyntax('default')
VimwikiTOC
Expect(Headinds TOC one word (0)):
= Contents =
- [[#head1]]
- [[#head2]]
- [[#head3]]
= head1 =
== head2 ==
=== head3 ===
Execute (Clean wiki TOC):
Given vimwiki (One heading: May delete last line (#910) {{{1):
# Basic-title
Execute (VimwikiTOC x 1):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
Expect(Good content with 1 item x 1):
# Contents
- [Basic-title](#basic-title)
# Basic-title
Execute (VimwikiTOC x 2):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
VimwikiTOC
Expect(Good content with 1 item x 1):
# Contents
- [Basic-title](#basic-title)
# Basic-title
Given vimwiki (With link header (#182) {{{1):
# A [link](anything here) B
# t[link](anything here)
## 7.4.1528
Execute (VimwikiTOC: Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
Expect vimwiki (With link header (#182) {{{1):
# Contents
- [A link B](#a-link-b)
- [tlink](#tlink)
- [7.4.1528](#741528)
# A [link](anything here) B
# t[link](anything here)
## 7.4.1528
Given vimwiki (Underline header (SetExt) (#209) {{{1):
First with spaces
=====
toto
Second
-------
toto
Third
-----
toto
Four
=====
toto
Last
----
Execute (Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
Expect (Heading SetExt created):
# Contents
- [First with spaces](#first-with-spaces)
- [Second](#second)
- [Third](#third)
- [Four](#four)
- [Last](#last)
First with spaces
=====
toto
Second
-------
toto
Third
-----
toto
Four
=====
toto
Last
----
Given vimwiki (Two same heading (#968) {{{1):
# One
toto
# ONE
like
## oNe
you
Execute (Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
Expect (Suffix -2 and -3):
# Contents
- [One](#one)
- [ONE](#one-2)
- [oNe](#one-3)
# One
toto
# ONE
like
## oNe
you
Given vimwiki (Heading with many bad caracters {{{1):
# One !@#@#(!%#&$^(!@
## Two !!~!!:"@!>@!>?<
Execute (Set syntax markdown && VimwikiTOC):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
Expect (Bad characters are removed):
# Contents
- [One !@#@#(!%#&$^(!@](#one-)
- [Two !!~!!:"@!>@!>?<](#two-)
# One !@#@#(!%#&$^(!@
## Two !!~!!:"@!>@!>?<
# Large previous tests {{{1
Execute (Reset TOC header to default):
call vimwiki#vars#set_wikilocal('toc_header', 'Contents')
Given vimwiki (Headings):
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
Execute (VimwikiTOC):
VimwikiTOC
Expect (With a TOC sw=8):
# Contents
- [Header 1](#header-1)
- [Header 1.1](#header-11)
- [Header 1.1.1](#header-111)
- [Header 2](#header-2)
- [Header 2.1.1](#header-211)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Set sw=4 && VimwikiTOC):
set sw=4
VimwikiTOC
Expect (With a TOC sw=4):
# Contents
- [Header 1](#header-1)
- [Header 1.1](#header-11)
- [Header 1.1.1](#header-111)
- [Header 2](#header-2)
- [Header 2.1.1](#header-211)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Do (Destroy some stuff):
jj
dd
jj
dd
Execute (VimwikiTOC):
VimwikiTOC
Expect (Brand new TOC):
# Contents
- [Header 1](#header-1)
- [Header 1.1](#header-11)
- [Header 1.1.1](#header-111)
- [Header 2](#header-2)
- [Header 2.1.1](#header-211)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Let toc_header = Sommaire && VimwikiTOC):
call vimwiki#vars#set_wikilocal('toc_header', 'Sommaire')
VimwikiTOC
Expect (Append a Sommaire && Leave Contents alone):
# Sommaire
- [Header 1](#header-1)
- [Header 1.1](#header-11)
- [Header 1.1.1](#header-111)
- [Header 2](#header-2)
- [Header 2.1.1](#header-211)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Do (Destroy some stuff):
jj
dd
jj
dd
Execute (VimwikiTOC):
VimwikiTOC
Expect (Brand new TOC with sommaire):
# Sommaire
- [Header 1](#header-1)
- [Header 1.1](#header-11)
- [Header 1.1.1](#header-111)
- [Header 2](#header-2)
- [Header 2.1.1](#header-211)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (call vimwiki#vars#set_global('toc_header_level', 6):
call vimwiki#vars#set_wikilocal('toc_header_level', 6)
VimwikiTOC
# Reset default
call vimwiki#vars#set_wikilocal('toc_header_level', 1)
Expect (Content prepended):
###### Sommaire
- [Header 1](#header-1)
- [Header 1.1](#header-11)
- [Header 1.1.1](#header-111)
- [Header 2](#header-2)
- [Header 2.1.1](#header-211)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
" vim: sw=2 foldmethod=marker foldlevel=30 foldignore=#

View File

@@ -0,0 +1,196 @@
# Task List with commands
Given vimwiki (simple list):
* [X] Done 1
* [ ] Todo 1
* [X] Done 2
* [ ] Todo 2
Execute (Set syntax to default):
call SetSyntax('default')
Do (clean done, without recursion):
:call vimwiki#lst#remove_done_in_current_list(0)\<Enter>
Expect (two removed):
* [ ] Todo 1
* [ ] Todo 2
Given vimwiki (simple list):
* [X] Done 1
* [ ] Todo 1
* [X] Done 2
* [ ] Todo 2
Do (clean done with recursion, function):
:call vimwiki#lst#remove_done_in_current_list(1)\<Enter>
Expect (two removed):
* [ ] Todo 1
* [ ] Todo 2
Given vimwiki (simple list):
* [X] Done 1
* [ ] Todo 1
* [X] Done 2
* [ ] Todo 2
Do (clean done with recursion, command):
:VimwikiRemoveDone\<Enter>
Expect (two removed):
* [ ] Todo 1
* [ ] Todo 2
Given vimwiki (with sub items):
* [X] Done 1
* [X] Subdone 1
* [ ] Todo 1
* [o] Done 2
* [X] Subdone1
* [ ] Subtodo
* [ ] Todo 2
Do (clean done, without recursion):
:call vimwiki#lst#remove_done_in_current_list(0)\<Enter>
Expect (first removed):
* [ ] Todo 1
* [o] Done 2
* [X] Subdone1
* [ ] Subtodo
* [ ] Todo 2
Given vimwiki (with sub items):
* [ ] Todo 1
* [o] Done 2
* [X] Subdone1
* [ ] Subtodo
* [ ] Todo 2
Do (clean done, with recursion):
:call vimwiki#lst#remove_done_in_current_list(1)\<Enter>
Expect (all removed):
* [ ] Todo 1
* [ ] Done 2
* [ ] Subtodo
* [ ] Todo 2
Given vimwiki (nested list with space and code):
* [X] Done 1
* [ ] Todo 1
* [ ] Todo Post space
* [X] Done Post space
* [ ] Todo code
{{{code
* [X] print "hello, world"
}}}
* [ ] Post code Todo
* [X] Done Sub-child
* [X] Sub-sub-child
* Without cb
* [X] Post code Done
* [X] Done Sub-child
* [X] Sub-sub-child
* Without cb
Do (clean done, without recursion):
:call vimwiki#lst#remove_done_in_current_list(0)\<Enter>
Expect (removed):
* [ ] Todo 1
* [ ] Todo Post space
* [ ] Todo code
{{{code
* [X] print "hello, world"
}}}
* [ ] Post code Todo
* [X] Done Sub-child
* [X] Sub-sub-child
* Without cb
Given vimwiki (nested list with space and code):
* [X] Done 1
* [ ] Todo 1
* [ ] Todo Post space
* [X] Done Post space
* [ ] Todo code
{{{code
* [X] print "hello, world"
}}}
* [ ] Post code Todo
* [X] Done Sub-child
* [X] Sub-sub-child
* Without cb
* [X] Post code Done
* [X] Done Sub-child
* [X] Sub-sub-child
* Without cb
Do (clean done, with recursion):
:call vimwiki#lst#remove_done_in_current_list(1)\<Enter>
Expect (removed):
* [ ] Todo 1
* [ ] Todo Post space
* [ ] Todo code
{{{code
* [X] print "hello, world"
}}}
* [ ] Post code Todo
Given vimwiki (two lists):
* [X] Done 1
* [ ] Todo 1
Line in between.
* [ ] Todo Post space
* [X] Done Post space
Do (clean done, with recursion):
:call vimwiki#lst#remove_done_in_current_list(1)\<Enter>
Expect (only first is removed):
* [ ] Todo 1
Line in between.
* [ ] Todo Post space
* [X] Done Post space
Given vimwiki (list):
* [X] Done 1
* [ ] Todo 1
Line in between.
* [X] Done 2
* [X] Done 3
* [ ] Todo 2
* [X] Done 4
Do (clean done, with range):
:1,6VimwikiRemoveDone\<Enter>
Expect (only first is removed):
* [ ] Todo 1
Line in between.
* [X] Done 3
* [ ] Todo 2
* [X] Done 4

View File

@@ -0,0 +1,112 @@
# List indentation <= shiftwidth
Execute (Create temp directory):
silent execute '!mkdir -p $HOME/list_margin/'
cd $HOME/list_margin
Execute (Create wiki files):
write page1.wiki
write page2.wiki
write page3.wiki
write page1.mw
write page2.mw
write page3.mw
write page1.md
write page2.md
write page3.md
Given vimwiki (Scratch file):
Execute (Set syntax default):
set shiftwidth=8
AssertEqual 8, &shiftwidth
call SetSyntax('default')
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Execute (Generate Links):
VimwikiGenerateLinks
Expect (Links with default margin):
= Generated Links =
- [[page1]]
- [[page2]]
- [[page3]]
Execute (Set list margin == 2):
call vimwiki#vars#set_wikilocal('list_margin', 2, vimwiki#vars#get_bufferlocal('wiki_nr'))
VimwikiGenerateLinks
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Expect (Links with margin == 2):
= Generated Links =
- [[page1]]
- [[page2]]
- [[page3]]
Execute (Set syntax media):
call SetSyntax('media')
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Execute (Generate Links):
VimwikiGenerateLinks
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Expect (Links with default margin):
= Generated Links =
* [[page1]]
* [[page2]]
* [[page3]]
Execute (Set list margin == 1):
call vimwiki#vars#set_wikilocal('list_margin', 1, vimwiki#vars#get_bufferlocal('wiki_nr'))
VimwikiGenerateLinks
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Expect (Links with margin == 1):
= Generated Links =
* [[page1]]
* [[page2]]
* [[page3]]
Execute (Set syntax markdown):
call SetSyntax('markdown')
" list margin should default to 0 for markdown
Execute (Generate Links):
VimwikiGenerateLinks
Expect (Links with default margin):
# Generated Links
- [page1](page1)
- [page2](page2)
- [page3](page3)
Execute (Set list margin == 5):
call vimwiki#vars#set_wikilocal('list_margin', 5, vimwiki#vars#get_bufferlocal('wiki_nr'))
VimwikiGenerateLinks
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Expect (Links with margin == 5):
# Generated Links
- [page1](page1)
- [page2](page2)
- [page3](page3)
Execute (Return to default location & cleanup):
cd /testplugin
# vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,45 @@
# Move and edit a list (autocommand, config_
# Test J {{{1
############################################################
Given vimwiki (Markdown * [ ] list {{{2):
* [ ] Top Level
* [o] Child 1
* [X] Child 2
* [X] Post space
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (JJJJ):
JJJJ
0y$
:call AssertIfVersion(704, '* [ ] Top Level Child 1 Child 2 Post space', @")\<Cr>
Given vimwiki (Markdown * and - list {{{2):
* one
* two
- three
- for
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (JjJ):
JjJ
gg
0y$
:call AssertIfVersion(704, '* one two', @")\<Cr>
G
0y$
:call AssertIfVersion(704, '- three for', @")\<Cr>
# vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,379 @@
# Testting <CR> keypress in insert mode on list item
#
# Note: some trailing spaces are necessary at the end of list items like `1.`
# better read this file with `set list`
#
# Warning: Foldmethod dependant (and foldlevel ...)
Execute (Save State):
let msg = 'Error: foldmethod must be manual for theses tests to work,'
let msg .= ' it is the default, so please restore it in the test that changed it'
AssertEqual &foldmethod, 'manual', msg
Given vimwiki (List Blockquote (Issue #55) {{{2):
1. Outer Item 1
1. Inner Item 1
> quote 1
2. Inner Item 2
2. Outer Item 2
> quote 2
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (o):
o
toto
Expect (Good number 1):
1. Outer Item 1
2. toto
1. Inner Item 1
> quote 1
2. Inner Item 2
3. Outer Item 2
> quote 2
Do (jo):
jo
toto
Expect (Good number 2):
1. Outer Item 1
1. Inner Item 1
2. toto
> quote 1
3. Inner Item 2
2. Outer Item 2
> quote 2
Given vimwiki (List will hard wrap (Issue #991) {{{2):
- one two three four five six seven
Execute (Change textwith):
let textwidth = &textwidth
let linebreak = &linebreak
Log 'Textwidth, Linebreak was: ' . textwidth . ', ' . linebreak
set textwidth=40
set linebreak
Do (Insert more than tw and press return):
A indented line 1
\<Cr>
indented line 2
Expect (Indentation after autowrap and <CR>):
- one two three four five six seven
indented line 1
indented line 2
Do (o new item):
A indented line 1
\<Esc>o
new item
Expect (New item created):
- one two three four five six seven
indented line 1
- new item
Do (VimwikiReturn 3 5):
A indented line 1\<Esc>
:VimwikiReturn 3 5\<Cr>
new item
Expect (New item created):
- one two three four five six seven
indented line 1
- new item
Execute (Restore textwith):
let &textwidth = textwidth
let &linebreak = linebreak
Given vimwiki (List with hard wraps):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
- Item 5
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 3 5<CR>
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (Extend list):
4j
A\<CR>Another item\<Esc>
5j
A\<CR>New sub item\<Esc>
Expect (Extended list):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Another item
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
- New sub item
- Item 5
Given vimwiki (List with code block):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
```
int x = 2 + 2;
return 0;
```
- Item 5
```c
int x = 2 + 2;
return 0;
```
- Item 6 that is split
Across multiple lines.
Done.
Do (CR and CR in code block):
4j
A\<CR>Another item\<Esc>
6j
A\<CR>int y = 1;\<Esc>
1j
A\<CR>x = x + y;\<Esc>
4j
A\<CR>int y = 2;\<Esc>
3j
A\<CR>A new bullet doesn't get added here, oh well.\<Esc>
3j
A\<CR>Done and Done\<Esc>
Expect (No list continuation in code block):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Another item
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
```
int y = 1;
int x = 2 + 2;
x = x + y;
return 0;
```
- Item 5
```c
int y = 2;
int x = 2 + 2;
return 0;
```
A new bullet doesn't get added here, oh well.
- Item 6 that is split
Across multiple lines.
Done.
- Done and Done
Given vimwiki (List from help file):
1. item
---
1. item
continue
---
1.
---
1.
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 1<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
# Note: trailing space <- autoindent
Expect (List per VimwikiReturn 1 1):
1. item
2.
---
1. item
continue
---
1.
2.
---
1.
2.
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 2 2<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
# Note: some trailing space added
Expect (List per VimwikiReturn 2 2):
1. item
---
1. item
continue
2.
---
1.
---
1.
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 3 3<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
Expect (List per VimwikiReturn 3 3):
1. item
2.
---
1. item
continue
2.
---
---
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 4 4<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
Expect (List per VimwikiReturn 4 4):
1. item
---
1. item
continue
---
---
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 3 5<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
Expect (List per VimwikiReturn 3 5):
1. item
2.
---
1. item
continue
2.
---
---
1.
---
# vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,249 @@
# Todo lists
Given vimwiki (Todo list):
* [ ] Chap1
* [ ] Section1.1
* [ ] Section1.2
* [ ] Section1.3
* [ ] Section1.4
* [ ] Section1.5
* [ ] Section1.6
* [ ] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [X] Chap2
End
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (Toogle Chap2: <C-Space>):
Gk\<C-Space>
Expect (Toogle Chap2):
* [ ] Chap1
* [ ] Section1.1
* [ ] Section1.2
* [ ] Section1.3
* [ ] Section1.4
* [ ] Section1.5
* [ ] Section1.6
* [ ] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [ ] Chap2
End
Do (Toogle Chap1: <C-Space>):
\<C-Space>
Expect (Remove nested [ ] -> [X]):
* [X] Chap1
* [X] Section1.1
* [X] Section1.2
* [X] Section1.3
* [X] Section1.4
* [X] Section1.5
* [X] Section1.6
* [X] Section1.7
* [X] Section1.8
* [X] Section1.9
* [X] Section1.10
* [X] Chap2
End
Do (Toogle sub 1):
j\<C-Space>
Expect (Completing [ ] -> [.]):
* [.] Chap1
* [X] Section1.1
* [ ] Section1.2
* [ ] Section1.3
* [ ] Section1.4
* [ ] Section1.5
* [ ] Section1.6
* [ ] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [X] Chap2
End
Do (Toogle sub4):
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
Expect (Completing [ ] -> [.]):
* [o] Chap1
* [X] Section1.1
* [X] Section1.2
* [X] Section1.3
* [X] Section1.4
* [ ] Section1.5
* [ ] Section1.6
* [ ] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [X] Chap2
End
Do (Toogle sub7):
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
Expect (Completing [ ] -> [.]):
* [O] Chap1
* [X] Section1.1
* [X] Section1.2
* [X] Section1.3
* [X] Section1.4
* [X] Section1.5
* [X] Section1.6
* [X] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [X] Chap2
End
Do (Toogle sub10):
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
j\<C-Space>
Expect (Completing [ ] -> [.]):
* [X] Chap1
* [X] Section1.1
* [X] Section1.2
* [X] Section1.3
* [X] Section1.4
* [X] Section1.5
* [X] Section1.6
* [X] Section1.7
* [X] Section1.8
* [X] Section1.9
* [X] Section1.10
* [X] Chap2
End
Do (Toogle delete todo box [gl]):
gl\<Space>
Expect (Chap1 no checkbox):
* Chap1
* [ ] Section1.1
* [ ] Section1.2
* [ ] Section1.3
* [ ] Section1.4
* [ ] Section1.5
* [ ] Section1.6
* [ ] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [X] Chap2
End
Do (Toogle delete todo boxes [gL<Space>]):
jgL\<Space>
Expect (Chap1.x no checkbox):
* [ ] Chap1
* Section1.1
* Section1.2
* Section1.3
* Section1.4
* Section1.5
* Section1.6
* Section1.7
* Section1.8
* Section1.9
* Section1.10
* [X] Chap2
End
Do (Visual toogl [v<C-Space>]):
jvjjj\<C-Space>
Expect (4 items toogled):
* [o] Chap1
* [X] Section1.1
* [X] Section1.2
* [X] Section1.3
* [X] Section1.4
* [ ] Section1.5
* [ ] Section1.6
* [ ] Section1.7
* [ ] Section1.8
* [ ] Section1.9
* [ ] Section1.10
* [X] Chap2
End
################################################################################
# Todo list with text above
Given vimwiki (TODO list):
Some other text
- [ ] Todo Item
Execute (:VimwikiNextTask):
:execute "VimwikiNextTask" | execute 'normal yyp'
Expect (Introduce new todo item):
Some other text
- [ ] Todo Item
- [ ] Todo Item
################################################################################
# Numbered Todo list
Given vimwiki (Number TODO list):
1. [ ] Chap1
2. [ ] Chap2
Do (Go):
Go
# Note the space at the end of 3
Expect (Introduce new Number todo item):
1. [ ] Chap1
2. [ ] Chap2
3. [ ]
Do (New item and ident):
o\<C-t>Chap1.1
# Note the tab
Expect (Introduce Chap1.1):
1. [ ] Chap1
1. [ ] Chap1.1
2. [ ] Chap2
Do (Toogle <C-Space>):
\<C-Space>
Expect (Chap1 Done):
1. [X] Chap1
2. [ ] Chap2

View File

@@ -0,0 +1,191 @@
# Task list update
Given vimwiki (Sample nested list, vimwiki syntax):
* [ ] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Execute (Set syntax to default):
call SetSyntax('default')
Do (Toggle top-level):
\<C-Space>
Expect (All tree toggled):
* [X] Top Level
* [X] Child 1
* [X] Child 2
* [X] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [X] Post code
* [X] Sub-child
* [X] Sub-sub-child
Do (Toggle child):
j
\<C-Space>
Expect (Child toggled, top updated):
* [.] Top Level
* [X] Child 1
* [ ] Child 2
* [ ] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Do (Toggle sub-child):
G
\<C-Space>
Expect (Sub-child toggled, parents updated):
* [.] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [o] Post code
* [ ] Sub-child
* [X] Sub-sub-child
Given markdown (Sample nested list, markdown syntax):
* [ ] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Execute (Set syntax to markdown):
call SetSyntax('markdown')
Do (Toggle top-level):
\<C-Space>
Expect (All tree toggled):
* [X] Top Level
* [X] Child 1
* [X] Child 2
* [X] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [X] Post code
* [X] Sub-child
* [X] Sub-sub-child
Do (Toggle child):
j
\<C-Space>
Expect (Child toggled, top updated):
* [.] Top Level
* [X] Child 1
* [ ] Child 2
* [ ] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Do (Toggle sub-child):
G
\<C-Space>
Expect (Sub-child toggled, parents updated):
* [.] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [o] Post code
* [ ] Sub-child
* [X] Sub-sub-child
# vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,87 @@
# Task list update, propagation disabled
Given vimwiki (Sample nested list, vimwiki syntax):
* [ ] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Child 3
Execute (Set syntax to default):
set sw=2
call SetSyntax('default')
call vimwiki#vars#set_wikilocal('listsyms_propagate', 0)
Do (Toggle top-level):
\<C-Space>
Expect vimwiki (Only top updated):
* [X] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Child 3
Do (Toggle child 1):
j
\<C-Space>
Expect vimwiki (Only child 1 updated):
* [ ] Top Level
* [X] Child 1
* [ ] Child 2
* [ ] Child 3
Do (Toggle all children):
j
\<C-Space>
j
\<C-Space>
j
\<C-Space>
Expect vimwiki (Only children updated):
* [ ] Top Level
* [X] Child 1
* [X] Child 2
* [X] Child 3
Given vimwiki (Deeply nested list, vimwiki syntax):
* [ ] Top Level
* [ ] Child 1
* [X] Child 2
Do (Indent child 2):
jj
a\<C-D>
Expect vimwiki (Child 2 indent changed, checkmarks unchanged):
* [ ] Top Level
* [ ] Child 1
* [X] Child 2
Do (Add child 3):
jj
o
Child 3
Expect vimwiki (Child 3 added, checkmarks unchanged):
* [ ] Top Level
* [ ] Child 1
* [X] Child 2
* [ ] Child 3
Do (Add and indent child 3):
jj
o
\<C-T>
Child 3
Expect vimwiki (Child 3 added, checkmarks unchanged):
* [ ] Top Level
* [ ] Child 1
* [X] Child 2
* [ ] Child 3
Execute (Clean):
set sw&
# vim: sw=2:foldlevel=30:foldmethod=indent:

View File

@@ -0,0 +1,654 @@
# Maps
# TODO make it without side effects
# -- Use the normal vimwiki or reset it
# 0 Configure {{{1
##################
Execute (VimwikiIndex):
call SetSyntax('markdown')
VimwikiIndex 2
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
AssertEqual 'vimwiki', &filetype
AssertEqual $HOME . '/testmarkdown/', vimwiki_wikilocal_vars[1]['path']
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
Execute (Open buzz bozz):
edit $HOME/testmarkdown/buzz_bozz.md
AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')
# 1 Global {{{1
###############
Execute (===========================================================):
Log "Checking global map"
Do (,ww -> open index [Assert]):
,ww
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wt -> open index in tab [Assert]):
,wt
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,w,w -> open diary [Assert]):
,w,w
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,t -> open diary in tab [Assert]):
,w,t
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,ws -> list and select wiki [Assert]):
,ws
1
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wi -> open diary index [Assert]):
,wi
:AssertEqual $HOME . '/testmarkdown/diary/diary.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,y -> open yesterday [Assert]):
,w,y
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() - 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,m -> open tomorrow [Assert]):
,wm
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() + 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
# 2 Local {{{1
##############
#Execute (===========================================================):
# Log "Checking local map"
#
#
## 2.3 Font color {{{2
Given (Some paragraphs):
Some paragraph with some words 1
Some paragraph with some words 2
Some paragraph with some words 3
Some paragraph with some words 4
Execute(Colorize1: Current line):
set ft=vimwiki
call SetSyntax('markdown')
AssertEqual 3, vimwiki#vars#get_bufferlocal('wiki_nr')
AssertEqual 'vimwiki', &ft
"AssertEqual ',', mapleader
" Returns: Undefeind mapleader
VimwikiColorize red
Expect (Some paragraphs):
<span style="color:#cc241d;">Some paragraph with some words 1</span>
Some paragraph with some words 2
Some paragraph with some words 3
Some paragraph with some words 4
Execute(Colorize2: 2 lines):
2,3VimwikiColorize red
Expect (Some paragraphs):
Some paragraph with some words 1
<span style="color:#cc241d;">Some paragraph with some words 2
Some paragraph with some words 3</span>
Some paragraph with some words 4
Do(,wc):
\wc1\<Cr>\<Cr>
Expect (Some paragraphs):
<span style="background:#458588;">Some paragraph with some words 1</span>
Some paragraph with some words 2
Some paragraph with some words 3
Some paragraph with some words 4
Do(User leave menu):
,wc\<Esc>
Expect (Some paragraphs, nothing changed):
Some paragraph with some words 1
Some paragraph with some words 2
Some paragraph with some words 3
Some paragraph with some words 4
Do(v,wc):
jwll
v
jjllll
\wc14\<Cr>
Expect (Some paragraphs):
Some paragraph with some words 1
Some pa<span style="color:#cc241d;">ragraph with some words 2
Some paragraph with some words 3
Some paragra</span>ph with some words 4
Do(With emoji):
Go
🤥 abcdefghi 🤥 🤥\<Cr>
🤥 abcdefghi 🤥 🤥\<Cr>
🤥 abcdefghi 🤥 🤥\<Esc>
/abc\<Cr>
ll
\<esc>\<C-v>
jjllll
\wc1\<Cr>
Expect (Some paragraphs):
Some paragraph with some words 1
Some paragraph with some words 2
Some paragraph with some words 3
Some paragraph with some words 4
🤥 ab<span style="background:#458588;">cdefghi 🤥 🤥
🤥 abcdefghi 🤥 🤥
🤥 abcdefg</span>hi 🤥 🤥
# 2.1 Heading {{{2
##############
Do (,wn -> Create new wiki [Assert]):
,wn
new_file1
\<CR>
:AssertEqual $HOME . '/testmarkdown/new_file1.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wd -> Delete wiki yes [Assert]):
:edit $HOME . '/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 2
\<Esc>
,wd
yes
\<CR>
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
Do (,wd -> Delete wiki no [Assert]):
:edit $HOME . '/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 1
\<Esc>
,wd
no
\<CR>
:AssertEqual $HOME . '/testmarkdown/new_file2.md', expand('%')
\<CR>
Do (,wn -> Rename wiki [Assert]):
,wn
new_file1
\<CR>
ithis is content 1
\<Esc>
,wn
new_file2
\<CR>
:AssertEqual $HOME . '/testmarkdown/new_file2.md', expand('%')
\<CR>
Given (Some headings):
# Head 1
## Head 1.1
content 1
# Head2
content 2
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
Do (= -> add header level):
=
Expect (Inc header level):
## Head 1
## Head 1.1
content 1
# Head2
content 2
Do (- -> Dec header level):
j
-
Expect (Dec header level):
# Head 1
# Head 1.1
content 1
# Head2
content 2
# TODO fix for vim_7.3.429
# Do ([[ -> Go to the previous header):
# G
# k
# [[
# A placeholder
#
# Expect (placeholder):
# # Head 1
# ## Head 1.1 placeholder
# content 1
#
# # Head2
# content 2
#
# Do (]] -> Go to the next header):
# ]]
# A placeholder
#
# Expect (placeholder):
# # Head 1
# ## Head 1.1 placeholder
# content 1
#
# # Head2
# content 2
#
# Do ([= -> Go to the previous header which has the same level):
# G
# k
# [=
# A placeholder
#
# Expect (placeholder):
# # Head 1 placeholder
# ## Head 1.1
# content 1
#
# # Head2
# content 2
#
# Do (]= -> Go to the next header which has the same level):
# ]=
# A placeholder
#
# Expect (placeholder):
# # Head 1
# ## Head 1.1
# content 1
#
# # Head2 placeholder
# content 2
#
# Do (]u Go one level up):
# j
# ]u
# A placeholder
#
# Expect (placeholder):
# # Head 1 placeholder
# ## Head 1.1
# content 1
#
# # Head2
# content 2
#
# Do ([u Go one level up):
# j
# [u
# A placeholder
#
# Expect (placeholder):
# # Head 1 placeholder
# ## Head 1.1
# content 1
#
# # Head2
# content 2
# 2.2 List {{{2
##############
# brennen commenting this out 2021-03-29 - test seems to flap, test failures
# are difficult to diagnose.
#
# Given vimwiki (Completion list #813 {{{3):
# complete1
# complete2
# complete3
#
# Do (Insert a list item and complete):
# Go
# * comp\<C-n>\<C-n>\<Cr>\<Esc>
# # -Es -> Delete trailing *
# :let mode = mode(1)\<Cr>
# :Log 'Mode : ' .mode\<Cr>
# :if mode ==# 'ce' || mode ==# 'cv' || v:version < 704\<Cr>
# Log 'Cheating'\<Cr>
# try\<Cr>
# g/^\* \?$/d\<Cr>
# endtry\<Cr>
# endif\<Cr>
#
# Expect (With a completion but no new list item):
# complete1
# complete2
# complete3
# * complete2
#
Given (Number list):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
set sw=2
Do (gll):
gll
Expect (Increase):
1. I
2. Relly
1. Love
1. Very
1. Much
2. You
Do (gLl):
gLl
Expect (Increase self + child):
1. I
1. Relly
1. Love
1. Very
1. Much
2. You
Do (glh):
jjj
glh
Expect (Decrease):
1. I
1. Relly
2. Love
3. Very
1. Much
4. You
Do (gLh):
jjj
gLh
Expect (Decrease self + child):
1. I
1. Relly
2. Love
3. Very
1. Much
4. You
Do (glr):
\<C-A>\<C-A>
glr
Expect (Renumber):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
# New launch
#
Given (Number list):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
set sw=2
Do (gl*):
gl*
Expect (item -> *):
* I
1. Relly
1. Love
1. Very
1. Much
2. You
Do (gL*):
gL*
Expect (list -> *):
* I
1. Relly
* Love
1. Very
1. Much
* You
# New launch
#
Given (Bulleted list):
* I
- Relly
* Love
- Very
+ Much
* You
Execute (file .md):
set sw=2
file toto.md
edit!
let g:vimwiki_syntaxlocal_vars['markdown']['cycle_bullets'] = 1
let g:vimwiki_syntaxlocal_vars['markdown']['bullet_types'] = ['*', '-', '+']
AssertEqual 'vimwiki', &ft
Do (gLl):
gLl
Expect (Increase):
- I
+ Relly
* Love
- Very
+ Much
* You
Do (3glh):
gLh
Expect (Decrease):
* I
- Relly
* Love
- Very
+ Much
* You
Given (Bulleted list 2):
* Love
- Very
- Much
Do (Go):
Go
Expect (New item):
* Love
- Very
- Much
-
# New launch
#
Given (List ->):
* Item1
Execute (file toto.md):
" Note: let s:markdown_syntax.bullet_types = ['*', '-', '+']
file toto.md
edit!
Log "Cycle bullets"
let g:vimwiki_syntaxlocal_vars['bullet_types'] = ['*', '-']
let g:vimwiki_syntaxlocal_vars['markdown']['cycle_bullets'] = 1
AssertEqual g:vimwiki_syntaxlocal_vars['markdown']['cycle_bullets'], 1
AssertEqual 'vimwiki', &ft
set sw=2
set expandtab " Otherwise, getting some tab before some items, when enought space
Do (o):
oItem2
Expect (Good bullet type):
* Item1
* Item2
# TODO test more, (see real cycle, but do not work with low vim)
Do (o + <C-t>):
o2
\<C-t>\<Esc>
o3
\<C-t>\<Esc>
Expect (Good bullet type):
* Item1
- 2
+ 3
Do (o + <Cr>):
A1\<Cr>
2\<C-t>\<Cr>
3\<C-t>
Expect (Good nested bullet type):
* Item11
- 2
+ 3
# TODO test: let g:vimwiki_bullet_types = ['-', '•', '→', '*']
# 3 Text Object {{{1
####################
Execute (===========================================================):
Log "Checking text object"
# 3.1 HEading Object {{{2
####################
Given (Some headings):
# Head 1
## Head 1.1
content 1
# Head2
content 2
Do (ah):
j
dah
Expect (Change A header including its content up to the next header):
# Head 1
# Head2
content 2
Do (ih):
j
dih
Expect (The content under a header):
# Head 1
## Head 1.1
# Head2
content 2
Do (aH):
daH
Expect (A header including all of its subheaders):
# Head2
content 2
Do (iH):
diH
Expect (Like 'aH', but excluding the header itself):
# Head 1
# Head2
content 2
# vim: foldmethod=marker foldlevel=30 sw=2

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
set runtimepath+=/tmp/vader_wiki/home/vimtest/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/tmp/vader_wiki/home/vimtest/vim/after
execute 'set rtp+='.join(filter(split(expand('/tmp/vader_wiki/home/vimtest/plugins/*')), 'isdirectory(v:val)'), ',')
set runtimepath+=/tmp/vader_wiki/testplugin

View File

@@ -0,0 +1,3 @@
# Buzz Bozz
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@@ -0,0 +1,59 @@
# Test Wiki
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar
foo bar
biz baz
foo\bar
baz{13} <--- this is for testing a literal "baz{13}"
buzzzzz <--- this is for testing regex /buz{5}/
# Links
1. [[buzz_bozz|l_Buzz Bozz]]
2. [l_Buzz_Bozz](buzz_bozz)
3. [l_Flashy](#Typefaces#Flashy)
4. [l_Test Wiki](#Test Wiki)
# Typefaces
## Generic
~~strikeout text~~
`code (no syntax) text`
super^script^
sub,,script,,
## Markdown
**bold text** or __bold text__
*italic text* or _italic text_
***bold_italic text*** or ___italic_bold text___
## Flashy
TODO, DONE, STARTED, FIXME, FIXED, XXX.
# More
## Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
# Etiam dapibus iaculis
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
### Morbi id sodales sem
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
## Praesent tempor turpis est
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

View File

@@ -0,0 +1,7 @@
[index](index)
[/index](/index)
[///tmp/some_page](///tmp/some_page)
[//~/testmarkdown/index](//~/testmarkdown/index)
[diary:2020-07-22](diary:2020-07-22)
[link_syntax/nested](link_syntax/nested)
[./link_syntax/nested](./link_syntax/nested)

View File

@@ -0,0 +1,6 @@
[nested](nested)
[/index](/index)
[///tmp/some_page](///tmp/some_page)
[//~/testmarkdown/index](//~/testmarkdown/index)
[diary:2020-07-22](diary:2020-07-22)
[../link_syntax](../link_syntax)

View File

@@ -0,0 +1,3 @@
= Buzz Bozz =
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@@ -0,0 +1,30 @@
= Space Path Wiki =
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar foo bar biz baz.
[[buzz_bozz|Buzz Bozz]]
== Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
== Etiam dapibus iaculis ==
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
=== Morbi id sodales sem ===
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
== Praesent tempor turpis est ==
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

View File

@@ -0,0 +1,3 @@
= Buzz Bozz =
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@@ -0,0 +1 @@
example diary entry for day 1.

View File

@@ -0,0 +1,3 @@
= Day 2 =
another diary entry

View File

@@ -0,0 +1,5 @@
%nohtml
== day 3 ==
and yet *another* diary entry.

View File

@@ -0,0 +1,17 @@
= day 4 =
== subsection 1 ==
here is some code:
{{{
#!/bin/sh
echo "hello world"
}}}
== subsection 2 ==
an important list:
* point 1
* point 2

View File

@@ -0,0 +1,35 @@
= Test Wiki =
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar
foo bar
biz baz
foo\bar
baz{13} <--- this is for testing a literal "baz{13}"
buzzzzz <--- this is for testing regex /buz{5}/
[[buzz_bozz|Buzz Bozz]]
== Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
== Etiam dapibus iaculis ==
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
=== Morbi id sodales sem ===
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
== Praesent tempor turpis est ==
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

View File

@@ -0,0 +1,7 @@
[[index]]
[[/index]]
[[///tmp/some_page]]
[[//~/testwiki/index]]
[[diary:2020-07-22]]
[[link_syntax/nested]]
[[./link_syntax/nested]]

View File

@@ -0,0 +1,6 @@
[[nested]]
[[/index]]
[[///tmp/some_page]]
[[//~/testwiki/index]]
[[diary:2020-07-22]]
[[../link_syntax]]

View File

@@ -0,0 +1,7 @@
<html>
<body>
<div class="content">
<p><small>Last updated on %date%</small></p>
</div>
</body>
</html>

View File

@@ -0,0 +1,68 @@
Execute (Setup search testing wrapper):
function! TestSearch(search_command, test_name)
" Note: after each search, the location list of the current window (0)
" will contain the search results. A non-empty list indicates success.
" Search for a single word (a pattern with no spaces)
if v:version < 704
Log 'Cheating for old vim version, do not want to reverse bug'
return
endif
redir => output
silent execute a:search_command
redir END
Assert !empty(getloclist(0)), a:test_name.": no location list result"
Assert match(output, '\d of \d') > -1, a:test_name.": no result message"
" Tests that VimwikiSearch is quoting the pattern correctly.
" If not, Vim will see anything after the first space in the pattern
" as a file name and attempt to open it.
Assert match(output, 'Cannot open file') == -1, "'open file': unquoted pattern?"
return output
endfunction
Execute (Search test wiki):
" Open test wiki
edit test/resources/testwiki/index.wiki
" Make sure we opened the test wiki successfully by checking the
" title (first line) and filetype.
AssertEqual "= Test Wiki =", getline(1)
AssertEqual "vimwiki", &filetype
call TestSearch('VimwikiSearch foo', 'pattern with no spaces')
call TestSearch('VimwikiSearch foo bar', 'pattern with spaces')
call TestSearch('VimwikiSearch foo\bar', 'pattern with ''\''')
call TestSearch('VimwikiSearch baz{13}', 'pattern with literal {}')
call TestSearch('VimwikiSearch /\vbuz{5}/', 'proper regex')
call TestSearch('VWS foo bar', 'use VWS abbreviation')
Execute (Search space path wiki):
" Open wiki with spaces in path to test fname escaping
edit test/resources/testwiki\ space/index.wiki
" Make sure we opened the space path wiki successfully
AssertEqual "= Space Path Wiki =", getline(1)
call TestSearch('VimwikiSearch foo', 'simple search in space path wiki')
Execute (Search failure message):
" Important note: No search tests will succeed after this.
" The failed search will cause a Vim error to be thrown and
" any search with lvimgrep within Vader will result in an
" empty location list and empty messages queue. It is
" difficult to tell if the search itself is failing or if it
" is just an inability to view the results.
" Open test wiki again
edit test/resources/testwiki/index.wiki
" Now test a negative search and make sure we are returning
" the expected VimWiki error.
redir => output
silent VimwikiSearch not_exist
redir END
if v:version > 703
Assert match(output, 'Vimwiki: Search: No match found.') > -1, "expected custom error"
endif

View File

@@ -0,0 +1,811 @@
# Syntax and Highlight
# 0 Escape {{{1
#################
Given vimwiki (Markdown typeface with escape sequence #1044: _ __ * ** {{{2):
This is 14 | 1
__bold from begining__ 2
\__not bold even from begin \__ 3
and __t \__ is still bold__ Bold 4
and _ita\_ alic continues and end_ Italic 5
*this\* \* is italic also* Italic 6
a ^t\^ is supperscrit^ Sup 7
,,sub\,, subscript end,, Sub 8
a ~~st\~~ill deleted~~ Del 9
$$Eq\$$ uation follows$ Math 10
`code \` not finished inline` Code 11
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax of escape typeface):
AssertEqual '1' , SyntaxAt(1, 14) . 1
AssertEqual 'VimwikiBold2' , SyntaxAt(2, 14) . 2
AssertEqual '3' , SyntaxAt(3, 14) . 3
AssertEqual 'VimwikiBold4' , SyntaxAt(4, 14) . 4
AssertEqual 'VimwikiItalic5' , SyntaxAt(5, 14) . 5
AssertEqual 'VimwikiItalic6' , SyntaxAt(6, 14) . 6
AssertEqual 'VimwikiSuperScript7', SyntaxAt(7, 14) . 7
AssertEqual 'VimwikiSubScript8' , SyntaxAt(8, 14) . 8
AssertEqual 'VimwikiDelText9' , SyntaxAt(9, 14) . 9
AssertEqual 'VimwikiMath10' , SyntaxAt(10, 14) . 10
AssertEqual 'textSnipTEX11' , SyntaxAt(11, 14) . 11
Given vimwiki (Markdown pre with escape sequence #1044: _ __ * ** {{{2):
```
pre
\```
pre
```
Execute (Assert Syntax of escape pre):
AssertEqual 'VimwikiPreDelim1' , SyntaxAt(1, 1) . 1
AssertEqual 'VimwikiPre2' , SyntaxAt(2, 1) . 2
AssertEqual 'VimwikiPre3' , SyntaxAt(3, 1) . 3
AssertEqual 'VimwikiPre4' , SyntaxAt(4, 1) . 4
AssertEqual 'VimwikiPreDelim5' , SyntaxAt(5, 1) . 5
# 1 Typeface {{{1
#################
Given vimwiki (Markdown with punctuation #340 {{{2):
__bold__, not bold
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax (alpha)):
AssertEqual 'VimwikiBold1' , SyntaxAt(1, 5) . 1
AssertEqual '2' , SyntaxAt(1, 16) . 2
Given vimwiki (Markdown bad __this_not_it__ {{{2):
See here 14 |
s2n_error 2
s*n*er_r_ 3
n4rmal_aaaaaaaaaaaaaaaaaaaa_text_ 4
n5t_italiccccccccccccccccccccc_no 5
n6t_italiccccccccccccccccccccccno 6
n7t*italiccccccccccccccccccccc_no 7
n8t*italiccccccccccccccccccccc*no 8
__not_italicccccccccc_but_boldd__ 9
_a_asdasda_asdas_asdas_asdasda_a_ 10
_jitaliccccccccccccccccccccccccc_ 11
n12ormalllllllllllllllllllllllll_ 12
_italic if at end of file unfortunately
Note: The decision to start a region is only based on a matching start
pattern. There is no check for a matching end pattern. This does NOT
work: (:h syn-region)
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax (bravo)):
AssertEqual 'VimwikiError2' , SyntaxAt(2, 4) . 2
AssertEqual 'VimwikiError3' , SyntaxAt(3, 4) . 3
AssertEqual '4' , SyntaxAt(4, 14) . 4
AssertEqual '5' , SyntaxAt(5, 14) . 5
AssertEqual '6' , SyntaxAt(6, 14) . 6
AssertEqual '7' , SyntaxAt(7, 14) . 7
AssertEqual '8' , SyntaxAt(8, 14) . 8
AssertEqual 'VimwikiBold9' , SyntaxAt(9, 14) . 9
AssertEqual 'VimwikiItalic10' , SyntaxAt(10, 14) . 10
AssertEqual 'VimwikiItalic11' , SyntaxAt(11, 14) . 11
AssertEqual '12' , SyntaxAt(12, 14) . 12
Given vimwiki (bold and pre {{{2):
__startbold
```
pre
```
__endbold
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax (charlie)):
AssertEqual 'VimwikiPre' , SyntaxAt(3, 1)
# Emphasis stricker {{{2
# See: https://github.github.com/gfm/#emphasis-and-strong-emphasis
Given vimwiki (Emphasis and not):
this __bold__ ok 1
this _italic_ ok 2
t__ no bold __ t 3
t_ no ital _ t 4
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax (delta)):
AssertEqual 'VimwikiBold1' , SyntaxAt(1, 9) . 1
AssertEqual 'VimwikiItalic2' , SyntaxAt(2, 9) . 2
AssertEqual '3' , SyntaxAt(3, 9) . 3
AssertEqual '4' , SyntaxAt(4, 9) . 4
# With vimwiki_hl_cb_checked {{{2
Given vimwiki (task list with code):
Normal syntax
- [X] Lorem __sit__ `sed do eiusmod
tempor` incididunt ut labore et dolore magna aliqua
Normal syntax
Execute (let g:vimwiki_hl_cb_checked = 1):
let g:vimwiki_hl_cb_checked = 1
unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init()
call SetSyntax('markdown')
Execute (Assert Done Syntax 1):
AssertEqual '' , SyntaxAt(1, 7)
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(2, 7)
AssertEqual 'VimwikiCode' , SyntaxAt(3, 7)
AssertEqual '' , SyntaxAt(4, 7)
Given vimwiki (task list with code):
Normal syntax
- [X] Lorem __sit__ `sed do eiusmod
tempor` incididunt ut labore et dolore magna aliqua
Normal syntax
Execute (let g:vimwiki_hl_cb_checked = 2):
let g:vimwiki_hl_cb_checked = 2
unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init()
call SetSyntax('markdown')
Execute (Assert Done Syntax 2):
AssertEqual '' , SyntaxAt(1, 7)
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(2, 7)
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(3, 7)
AssertEqual '' , SyntaxAt(4, 7)
# Extended types {{{2
Given vimwiki (Extended Types mono):
`code `
~~ strike ~~
$ equation $
^superscript ^
,, subscript ,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types x 1):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 8)
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 8)
AssertEqual 'textSnipTEX' , SyntaxAt(3, 8)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 8)
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 8)
Given vimwiki (Extended Types nested in basic):
From __bold `code in bold ` end of bold__ morF
From _it and ~~ strieout in i~~ end of it_ morF
From __bold $ equation $ end bold __
**bold ^superscript ^ end of bold morF**
From normal ,, subscript ,, still normal morF
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types x 2):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
AssertEqual 'textSnipTEX' , SyntaxAt(3, 23)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 23)
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)
Given vimwiki (Extended Types nested in extended):
From ^super to`code this ` is crazy but^ morF
From ,,sub to~~ strike ~~why not,, morF
From ~~strike $ equation $ end of strike~~morF
From $eq to ^super ^ Just inline morF$
From ^super t,,sub ,, end super eol ^
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types nested in extended):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
AssertEqual 'textSnipTEX' , SyntaxAt(3, 23)
AssertEqual 'textSnipTEX' , SyntaxAt(4, 23)
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)
Given vimwiki (Basic Types nested in extended):
From ^super __bold __ is crazy but^ morF
From ,,sub _italic with en_ aaaaaaa,, morF
From $eq to **boldboldboldbo** aaaaaaaaa $
From ^super *italic aaaaaaa*aaaaaaaaaaaaaaaaaaaaa
From ~~strik __bbbbbbbbbbbbb__ssssssssssssssssss~~
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax basic types nested in extended):
AssertEqual 'VimwikiBold1' , SyntaxAt(1, 23) . 1
AssertEqual 'VimwikiItalic2' , SyntaxAt(2, 23) . 2
AssertEqual 'textSnipTEX3' , SyntaxAt(3, 23) . 3
AssertEqual 'VimwikiItalic4' , SyntaxAt(4, 23) . 4
AssertEqual 'VimwikiBold5' , SyntaxAt(5, 23) . 5
Given vimwiki (Try to nest in code):
From `codeto__no onenest in code__ end`
From `codeto _no onenest in code_ end`
From `codeto ^no onenest in code^ end`
From `codeto ~~no onenest in code~~ end`
From `codeto ___no onenest in code___ end`
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types nested in extended):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(2, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(3, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(4, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(5, 23)
Given vimwiki (Multiline Typfaces Basic and extended):
__and bold
multiline__
_and it
mutliline_
~~and mutltie
strikeout~~
`
and mutli
path
`
but no $ multi
equation
$
^ but no multi
sup ^
,,
but no multi
sub ,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Multiline syantax but not sup and sub):
AssertEqual 'VimwikiBold' , SyntaxAt(2, 1)
AssertEqual 'VimwikiItalic' , SyntaxAt(5, 1)
AssertEqual 'VimwikiDelText' , SyntaxAt(8, 1)
AssertEqual 'VimwikiCode' , SyntaxAt(11, 1)
AssertEqual '' , SyntaxAt(14, 1)
AssertEqual '' , SyntaxAt(17, 1)
AssertEqual '' , SyntaxAt(20, 1)
# HTML types {{{2
# Rememner Bold > Italic > Underline (my convention [tinmarino])
Given vimwiki (Typeface for Italic var_with_underscore):
var_with_underscore
_this is
italic_
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface 1):
AssertEqual '' , SyntaxAt(1, 1)
AssertEqual 'VimwikiError' , SyntaxAt(1, 4)
AssertEqual '' , SyntaxAt(1, 5)
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 2)
AssertEqual 'VimwikiItalic' , SyntaxAt(3, 2)
Given vimwiki (Typeface for html 1 like italic):
<b> ---- this is bold text 1 ---- </b>
<strong> - this is bold 2 - </strong>
<i> Italic 1 --cacacacacacacaca-- </i>
<em> Italic 2 -cacacacacacacaca- </em>
<u> Underline -cacacacacc acaca- </u>
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface 1):
AssertEqual 'VimwikiBold' , SyntaxAt(1, 15)
AssertEqual 'VimwikiBold' , SyntaxAt(2, 15)
AssertEqual 'VimwikiItalic' , SyntaxAt(3, 15)
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 15)
AssertEqual 'VimwikiUnderline' , SyntaxAt(5, 15)
Given vimwiki (Typeface for html 2 like italicUnderline):
<b> bold this is bold<i>bold italic ---------</i> text 1 ---- </b>
<strong> - this is bo<u>bold underline ------</u>d 2 - </strong>
<i> Italic 1 --cacaca<b>bold italic----------</b>acacacaca-- </i>
<em> Italic 2 -cacaca<u>italic underline-----</u>cacacaca- </em>
<u> Underline -cacaca<b>bold underline-------</b>asacc acaca- </u>
<u> Underline -cacaca<i>italic underline-----</i>asdacacc acaca- </u>
Execute (Assert Syntax for typeface 2):
AssertEqual 'VimwikiBoldItalic' , GetSyntaxGroup(1, 30)
AssertEqual 'VimwikiBoldUnderline' , GetSyntaxGroup(2, 30)
AssertEqual 'VimwikiBoldItalic' , GetSyntaxGroup(3, 30)
AssertEqual 'VimwikiItalicUnderline', GetSyntaxGroup(4, 30)
AssertEqual 'VimwikiBoldUnderline' , GetSyntaxGroup(5, 30)
AssertEqual 'VimwikiItalicUnderline', GetSyntaxGroup(6, 30)
Given vimwiki (Typeface for html 3 like boldItalicUnderline):
<b><i><u> bold italic underline </u></i></b>
<b><u><i> bold italic underline </i></u></b>
<i><b><u> bold italic underline </u></b></i>
<i><u><b> bold italic underline </b></u></i>
<u><b> <i> bold italic underline </i> </b></u>
<u><i><b> bold italic underline </b></i></u>
Execute (Assert Syntax for typeface 3):
AssertEqual 'VimwikiBoldItalicUnderline1', GetSyntaxGroup(1, 22).1
AssertEqual 'VimwikiBoldItalicUnderline2', GetSyntaxGroup(2, 22).2
AssertEqual 'VimwikiBoldItalicUnderline3', GetSyntaxGroup(3, 22).3
AssertEqual 'VimwikiBoldItalicUnderline4', GetSyntaxGroup(4, 22).4
AssertEqual 'VimwikiBoldItalicUnderline5', GetSyntaxGroup(5, 22).5
AssertEqual 'VimwikiBoldItalicUnderline6', GetSyntaxGroup(6, 22).6
# Keyword uppercase {{{2
Given vimwiki (TODO, XXX):
TODO
DONE
STARTED
FIXME
FIXED
XXX
Execute (Assert Syntax VimwikiTodo):
AssertEqual SyntaxAt(1, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(2, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(3, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(4, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(5, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(6, 1), 'VimwikiTodo'
Given vimwiki (custom TODO words):
NOW
LATER
DONE
TODO
Execute (set custom syntax):
call vimwiki#vars#set_wikilocal('rx_todo', '\C\<\%(NOW\|LATER\|DONE\)\>', vimwiki#vars#get_bufferlocal('wiki_nr'))
call SetSyntax('markdown')
Execute (Assert Syntax VimwikiTodo):
AssertEqual 'VimwikiTodo1', SyntaxAt(1, 1) . 1
AssertEqual 'VimwikiTodo2', SyntaxAt(2, 1) . 2
AssertEqual 'VimwikiTodo3', SyntaxAt(3, 1) . 3
AssertEqual '4' , SyntaxAt(4, 1) . 4
Execute (Restore VimwikiTodo):
call vimwiki#vars#init()
call SetSyntax('markdown')
# Mardown types {{{2
Given vimwiki (Typeface for markdown like italic):
**bold text 1**
__bold text 2__
*italic text 1*
_italic text 2_
***bold italic text 1***
___bold italic text 2___
~~strikeout text~~
`code (no syntax) text`
sp^script^
sb,,script,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface):
AssertEqual 'VimwikiBold' , SyntaxAt(1, 5)
AssertEqual 'VimwikiBold' , SyntaxAt(2, 5)
AssertEqual 'VimwikiItalic' , SyntaxAt(3, 5)
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 5)
AssertEqual 'VimwikiBoldItalic' , SyntaxAt(5, 5)
AssertEqual 'VimwikiBoldItalic' , SyntaxAt(6, 5)
AssertEqual 'VimwikiDelText' , SyntaxAt(7, 5)
AssertEqual 'VimwikiCode' , SyntaxAt(8, 5)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(9, 5)
AssertEqual 'VimwikiSubScript' , SyntaxAt(10, 5)
# 2 Links {{{1
#################
Given vimwiki (Wiki Links):
Plain link: >
[[This is a link]]
With description: >
[[This is a link source|Description of the link]]
Interwiki1: >
[[wiki1:This is a link]]
Interwiki2: >
[[wn.My Name:This is a link]]
Interwiki3: >
[[wn.MyWiki:This is a link source|Description of the link]]
Diary: >
[[diary:2012-03-05]]
Anchor1: >
[[Todo List#Tomorrow|Tasks for tomorrow]]
Anchor2: >
[[#Tomorrow]]
Raw1: >
https://github.com/vimwiki/vimwiki.git
Raw2: >
mailto:habamax@gmail.com
Raw3: >
ftp://vim.org
File1: >
[[file:/home/somebody/a/b/c/music.mp3]]
File2: >
[[file:C:/Users/somebody/d/e/f/music.mp3]]
File3: >
[[file:~/a/b/c/music.mp3]]
File4: >
[[file:../assets/data.csv|Important Data]]
File5: >
[[local:C:/Users/somebody/d/e/f/music.mp3]]
File6: >
[[file:/home/user/documents/|Link to a directory]]
Thumbnail links: >
[[http://someaddr.com/bigpicture.jpg|{{http://someaddr.com/thumbnail.jpg}}]]
Execute (Assert Syntax link):
AssertEqual 'VimwikiLink', SyntaxAt(2, 6)
AssertEqual 'VimwikiLink', SyntaxAt(4, 6)
AssertEqual 'VimwikiLink', SyntaxAt(6, 6)
AssertEqual 'VimwikiLink', SyntaxAt(8, 6)
AssertEqual 'VimwikiLink', SyntaxAt(10, 6)
AssertEqual 'VimwikiLink', SyntaxAt(12, 6)
AssertEqual 'VimwikiLink', SyntaxAt(14, 6)
AssertEqual 'VimwikiLink', SyntaxAt(16, 6)
AssertEqual 'VimwikiLink', SyntaxAt(18, 6)
AssertEqual 'VimwikiLink', SyntaxAt(20, 6)
AssertEqual 'VimwikiLink', SyntaxAt(22, 6)
AssertEqual 'VimwikiLink', SyntaxAt(24, 6)
AssertEqual 'VimwikiLink', SyntaxAt(26, 6)
AssertEqual 'VimwikiLink', SyntaxAt(28, 6)
AssertEqual 'VimwikiLink', SyntaxAt(30, 6)
AssertEqual 'VimwikiLink', SyntaxAt(32, 6)
AssertEqual 'VimwikiLink', SyntaxAt(34, 6)
AssertEqual 'VimwikiLink', SyntaxAt(36, 6)
Given vimwiki (Markdown Links):
Inline link: >
[Looks like this](URL)
Image link: >
![Looks like this](URL)
Reference-style links: >
a) [Link Name][Id]
b) [Id][], using the "implicit link name" shortcut
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax link):
AssertEqual 'VimwikiWeblink1' , SyntaxAt(2, 8)
AssertEqual 'VimwikiImage' , SyntaxAt(5, 8)
AssertEqual 'VimwikiWikiLink1' , SyntaxAt(8, 8)
AssertEqual 'VimwikiWikiLink1' , SyntaxAt(9, 8)
# 3 Header {{{1
###############
Given vimwiki (Markdown SetExt Headers):
One
===
two
---
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax Header SetExt):
AssertEqual 'VimwikiHeader1', SyntaxAt(1, 1)
AssertEqual 'VimwikiHeader1', SyntaxAt(2, 1)
AssertEqual 'VimwikiHeader2', SyntaxAt(3, 1)
AssertEqual 'VimwikiHeader2', SyntaxAt(4, 1)
Given vimwiki (Wiki Headers):
= Header level 1 =
== Header level 2 ==
=== Header level 3 ===
==== Header level 4 ====
===== Header level 5 =====
====== Header level 6 ======
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Wiki Syntax Header):
AssertEqual 'VimwikiHeader1', SyntaxAt(1, 10)
AssertEqual 'VimwikiHeader2', SyntaxAt(2, 10)
AssertEqual 'VimwikiHeader3', SyntaxAt(3, 10)
AssertEqual 'VimwikiHeader4', SyntaxAt(4, 10)
AssertEqual 'VimwikiHeader5', SyntaxAt(5, 10)
AssertEqual 'VimwikiHeader6', SyntaxAt(6, 10)
Given vimwiki (Markdown Headers):
# Header level 1
## Header level 2
### Header level 3
#### Header level 4
##### Header level 5
###### Header level 6
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Markdown Syntax Header):
Log "Syntax of first heading: " . string(GetSyntaxStack())
Log "Regex of rxListWithoutCb: " . vimwiki#vars#get_wikilocal('rxListItemWithoutCB')
Log "Bullet types: " . string(vimwiki#vars#get_wikilocal('bullet_types'))
AssertEqual 'VimwikiHeader1' , SyntaxAt(1, 10)
AssertEqual 'VimwikiHeader2' , SyntaxAt(2, 10)
AssertEqual 'VimwikiHeader3' , SyntaxAt(3, 10)
AssertEqual 'VimwikiHeader4' , SyntaxAt(4, 10)
AssertEqual 'VimwikiHeader5' , SyntaxAt(5, 10)
AssertEqual 'VimwikiHeader6' , SyntaxAt(6, 10)
# 4 Blockquote {{{1
# Issues: #55
###############
#### 4.1 Blokquotes markdown
Given vimwiki (BlockQuote restarts list numbering #55 {{{3):
1. Item 1
2. Item 2
Block Quote
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (Gototo):
Gototo
Expect (Good numbering):
1. Item 1
2. Item 2
Block Quote
3. toto
# 9 Comment {{{1
###############
Given vimwiki (%%):
%% This is a line comment
%% This is also a comment
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax VimwikiComment):
AssertEqual 'VimwikiComment' , SyntaxAt(1, 1)
AssertEqual 'VimwikiComment' , SyntaxAt(2, 4)
Given vimwiki (%%+, +%%):
%%+ This
is a
multiline
comment +%%
%%+ This is a comment on one line +%%
%%+ One +%% Not a comment %%+ Two +%% Not a comment
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax VimwikiMultilineComment):
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(1, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(1, 8)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(2, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(3, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(4, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(5, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 11)
AssertEqual '' , SyntaxAt(6, 12)
AssertEqual '' , SyntaxAt(6, 26)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 27)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 37)
AssertEqual '' , SyntaxAt(6, 38)
AssertEqual '' , SyntaxAt(6, 51)
# 10 Code {{{1
# 10.1 Code Indent (4 spaces) {{{2
#################################
Given vimwiki (Code indent):
this is markdown
this is code
Execute (Assert Syntax normal (i.e. no hi)):
AssertEqual SyntaxAt(1, 5), ''
AssertEqual SyntaxAt(2, 5), ''
# 10.2 Code Inline (1 backtick) {{{2
###################################
Given vimwiki (Code inline):
Well use the `man`
Execute (Assert Syntax Code):
AssertEqual SyntaxAt(1, 16), 'VimwikiCode'
# 10.3 Code Block (3 backtiks) {{{2
##################################
Given vimwiki (Markdown, Text and Vim):
this is markdown
this is TODO
```
this is text
```
```vim
" this is vim
set hlsearch
```
`````vim
" this is vim
set hlsearch
`````
~~~vim
" this is vim
set hlsearch
~~~
~~~~~vim
" this is vim
set hlsearch
~~~~~~~~~~~
Execute (Set syntax markdown):
let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
call SetSyntax('markdown')
Execute (Assert ft, normal syntax and VimwikiTodo):
AssertEqual &ft, 'vimwiki'
AssertEqual '', SyntaxAt(1, 1)
AssertEqual 'VimwikiTodo', SyntaxAt(2, 9)
Execute (Assert Code syntax):
AssertEqual 'VimwikiPreDelim', SyntaxAt(4, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(5, 1)
AssertEqual 'vimLineComment' , SyntaxAt(9, 1)
AssertEqual 'vimCommand' , SyntaxAt(10, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(13, 1)
AssertEqual 'vimLineComment' , SyntaxAt(14, 1)
AssertEqual 'vimCommand' , SyntaxAt(15, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(16, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(18, 1)
AssertEqual 'vimLineComment' , SyntaxAt(19, 1)
AssertEqual 'vimCommand' , SyntaxAt(20, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(21, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(23, 1)
AssertEqual 'vimLineComment' , SyntaxAt(24, 1)
AssertEqual 'vimCommand' , SyntaxAt(25, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(26, 1)
# 11 Math {{{1
# 11.1 Math Markdown {{{2
#######################
Given vimwiki (Math markdown):
math inline: $ aaaaaaaaaaaaaa \sum_i a_i^2 = 1 $
math block:
$$
\sum_i a_i^2
=
1
$$
math block env:
$$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
$$
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert math syntax 1):
AssertEqual 'textSnipTEX', SyntaxAt(1, 18)
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
# 11.2 Math Wiki {{{2
##############################
Given vimwiki (Math wiki):
math inline: $aaaaaaaaaaaaaaaaaaaaaaaaaa \sum_i a_i^2 = 1 $
math block:
{{$
\sum_i a_i^2
=
1
}}$
math block env:
{{$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
}}$
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert math syntax 2):
AssertEqual 'textSnipTEX', SyntaxAt(1, 18)
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
# 21 Highlight {{{1
##################
Given vimwiki (One line):
content
# GetHighlightTerm relies on execute(), which isn't available in all 7.4
# versions. Just test this for 8.0 and up to keep things simple:
Execute (Assert highlight typeface 1):
" Typeface 1
call AssertIfVersion(800, ['bold'], GetHighlightTerm('VimwikiBold', 'term'))
call AssertIfVersion(800, ['bold'], GetHighlightTerm('VimwikiBold', 'cterm'))
call AssertIfVersion(800, ['bold'], GetHighlightTerm('VimwikiBold', 'gui'))
call AssertIfVersion(800, ['italic'], GetHighlightTerm('VimwikiItalic', 'cterm'))
call AssertIfVersion(800, ['underline'], GetHighlightTerm('VimwikiUnderline', 'gui'))
Execute (Assert highlight typeface 2):
" Bold > Italic > Underline
call AssertIfVersion(800, sort(['bold', 'italic', '1']), sort(add(GetHighlightTerm('VimwikiBoldItalic', 'gui'), '1')))
call AssertIfVersion(800, sort(['bold', 'italic', '2']), sort(add(GetHighlightTerm('VimwikiBoldItalic', 'term'), '2')))
call AssertIfVersion(800, sort(['bold', 'underline', '3']), sort(add(GetHighlightTerm('VimwikiBoldUnderline', 'cterm'), '3')))
call AssertIfVersion(800, sort(['bold', 'underline', '4']), sort(add(GetHighlightTerm('VimwikiUnderlineBold', 'term'), '4')))
call AssertIfVersion(800, sort(['italic', 'underline', '5']), sort(add(GetHighlightTerm('VimwikiItalicUnderline', 'cterm'), '5')))
Execute (Assert highlight typeface 3):
call AssertIfVersion(800, sort(['bold', 'italic', 'underline', '1']), sort(add(GetHighlightTerm('VimwikiBoldItalicUnderline', 'gui'), '1')))
call AssertIfVersion(800, sort(['bold', 'italic', 'underline', '2']), sort(add(GetHighlightTerm('VimwikiBoldUnderlineItalic', 'cterm'), '2')))
call AssertIfVersion(800, sort(['bold', 'italic', 'underline', '3']), sort(add(GetHighlightTerm('VimwikiItalicBoldUnderline', 'term'), '3')))
call AssertIfVersion(800, sort(['bold', 'italic', 'underline', '4']), sort(add(GetHighlightTerm('VimwikiItalicUnderlineBold', 'gui'), '4')))
call AssertIfVersion(800, sort(['bold', 'italic', 'underline', '5']), sort(add(GetHighlightTerm('VimwikiUnderlineBoldItalic', 'cterm'), '5')))
call AssertIfVersion(800, sort(['bold', 'italic', 'underline', '6']), sort(add(GetHighlightTerm('VimwikiUnderlineItalicBold', 'term'), '6')))
Expect (One line):
content
# vim: foldmethod=marker foldlevel=30 sw=2

View File

@@ -0,0 +1,88 @@
# Table autoformating
# Very configurable: read doc/design_notes.md
# Move <Tab> at end of row if next row is badly formated {{{1
# See #1126
##########################
Given vimwiki (Header ok but 1 row bad):
| Service to be Build | Build Tag | Service to Deploy | Deploy Tag | Comments |
|---------------------|-----------|-------------------|------------|----------|
|||Provision/Core/Keycloak|release-3.8.0_RC9|This was done as part of release-3.7.0 hotfix and is not required if you are already on Keycloak 7|
|||Provision/DataPipeline/AnalyticsSpark|release-3.8.0_RC6||
|||OpsAdministration/Core/ESMapping|release-3.8.0_RC9|Choose `userv1,orgv2` for jenkins job parameter `indices_name`|
Do (i<tab> at end of first line):
$i\<Tab>
Expect(Crash (List required)):
# E714: List required <= tbl#goto_next_col, line 9
| Service to be Build | Build Tag | Service to Deploy | Deploy Tag | Comments |
|---------------------|-----------|-------------------|------------|----------|
|||Provision/Core/Keycloak|release-3.8.0_RC9|This was done as part of release-3.7.0 hotfix and is not required if you are already on Keycloak 7|
|||Provision/DataPipeline/AnalyticsSpark|release-3.8.0_RC6||
|||OpsAdministration/Core/ESMapping|release-3.8.0_RC9|Choose `userv1,orgv2` for jenkins job parameter `indices_name`|
# Move <Tab> and <S-Tab> map {{{1
# See #1048
##########################
Given vimwiki (Table Number):
| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
Execute (testmap):
imap testmap1 <Plug>VimwikiTableNextCell
imap testmap2 <Plug>VimwikiTablePrevCell
Do (2 x Next):
gga
testmap1
testmap1
\<Del>Z
Expect (One Z in B):
| A | Z | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
Do (4 X Next):
gga
testmap1
testmap1
testmap1
testmap1
\<Del>Z
Expect (One Z in 1):
| A | B | C |
|---|---|---|
| Z | 2 | 3 |
| 4 | 5 | 6 |
Do (4 X Next + 1 X Prev):
gga
testmap1
testmap1
testmap1
testmap1
testmap1
testmap2
\<Del>Z
Expect (One Z in 1):
| A | B | C |
|---|---|---|
| Z | 2 | 3 |
| 4 | 5 | 6 |
Execute (Clean #1048):
iunmap testmap1
iunmap testmap2
# vim: foldmethod=marker foldlevel=30

View File

@@ -0,0 +1,240 @@
# Table autoformating
# Very configurable: read doc/design_notes.md
# Do not consider \| {{{1
##########################
Given vimwiki (Table with \| #281):
| Head1 | Head2 |
| --- | --- |
| l1_1 | l1_2 |
| l2_1 \| with escaped pipe | l2_2 |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
call SetSyntax('markdown')
Do (A to trigger insertLeave #281):
A
Expect(Table aligned with \| in cells):
| Head1 | Head2 |
| --- | --- |
| l1_1 | l1_2 |
| l2_1 \| with escaped pipe | l2_2 |
# Do not alter config {{{1
##########################
Given vimwiki (Table Head \#891):
| foo | bar |
Execute (set tw=71):
set tw=71
AssertEqual &tw, 71
Do (A<Cr>):
A\<Cr>\<Esc>
Expect (Table Head \#891):
| foo | bar |
| | |
Execute (Assert tw=71):
AssertEqual &tw, 71
# Autoformat {{{1
#################
Given vimwiki (Unaligned table):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
Do (A to trigger insertLeave):
A
Expect (Table autoformat):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Do (gqq to reformats table after making changes.):
gqq
Expect (Table autoformat):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_reduce_last_col = 1):
let g:vimwiki_global_vars['table_reduce_last_col'] = 1
Do (A to trigger insertLeave):
A
Expect (Last column not expanded):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_reduce_last_col = 0 [restore]):
let g:vimwiki_global_vars['table_reduce_last_col'] = 0
Execute (Option table_auto_fmt = 0):
let g:vimwiki_global_vars['table_auto_fmt'] = 0
Expect (Same as input):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_auto_fmt = 1 [restore]):
let g:vimwiki_global_vars['table_auto_fmt'] = 1
# Move and edit cells {{{1
##########################
Do (Use <Tab> in insert mode):
GI
\<Tab>
this_is_16_chars
\<Tab>
this_is_16_chars
\<Esc>
Expect (Table autoformated with more content):
| title1 | title2 |
| - | - |
| a1 | b1 |
| this_is_16_charsa2 | this_is_16_chars |
Do (VimwikiTableMoveColumnRight):
gg:VimwikiTableMoveColumnRight\<CR>
Expect (Column inverted):
| title2 | title1 |
| - | - |
| b1 | a1 |
| | a2 |
Do (CR must insert new row):
GI\<Cr>a3
Expect (Table with new row starting by a3):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
| a3 | |
# VimwikiTable Command {{{1
###########################
Given (Nothing):
Execute (VimwikiTable):
VimwikiTable
Expect (Table 5 x 2):
| | | | | |
|---|---|---|---|---|
| | | | | |
Execute (VimwikiTable 8 3):
VimwikiTable 8 3
Expect (Table 8 x 3):
| | | | | | | | |
|---|---|---|---|---|---|---|---|
| | | | | | | | |
| | | | | | | | |
Given vimwiki (Table 5 x (1+3)):
| h1 | h2 | h3 | h4 | h5 |
|-----|-----|-----|-----|-----|
| l11 | l12 | l13 | l14 | l15 |
| l21 | l22 | l23 | l24 | l25 |
| l31 | l32 | l33 | l34 | l35 |
Execute (VimwikiTableMoveColumnRight):
VimwikiTableMoveColumnRight
Expect (Col: 1 -> 2):
| h2 | h1 | h3 | h4 | h5 |
|-----|-----|-----|-----|-----|
| l12 | l11 | l13 | l14 | l15 |
| l22 | l21 | l23 | l24 | l25 |
| l32 | l31 | l33 | l34 | l35 |
Execute (VimwikiTableMoveColumnLeft):
call cursor(5, 16)
VimwikiTableMoveColumnLeft
Expect (Col: 3 -> 2):
| h1 | h3 | h2 | h4 | h5 |
|-----|-----|-----|-----|-----|
| l11 | l13 | l12 | l14 | l15 |
| l21 | l23 | l22 | l24 | l25 |
| l31 | l33 | l32 | l34 | l35 |
# Justify Cell Content {{{1
###########################
Given vimwiki (To be justified from help file [Coffe price]):
| Date | Item | Price |
|------------|:------:|--------:|
| yest |Coffee |$15.00 |
| 2017-02-13 |Tea |$2.10 |
| 2017-03-14 |Cake |$143.12 |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
Do (A to trigger insertLeave):
A
Expect (Text justified):
| Date | Item | Price |
|------------|:------:|--------:|
| yest | Coffee | $15.00 |
| 2017-02-13 | Tea | $2.10 |
| 2017-03-14 | Cake | $143.12 |
Given vimwiki (To be left aligned):
| Date | Item |
|:------------|------:|
|yest|Coffee |
| 2017-02-13| Tea|
|2017-03-14 |Cake |
Do (A to trigger insertLeave):
A
Expect (Left justified and :--- -> ----):
| Date | Item |
|------------|-------:|
| yest | Coffee |
| 2017-02-13 | Tea |
| 2017-03-14 | Cake |
# vim: foldmethod=marker foldlevel=30

View File

@@ -0,0 +1,305 @@
# Tag generation and navigation
# Note: The Generate must be in Execute
Execute (Setup):
set sw=4
AssertEqual 4, &sw
######################################################################
Execute (Change delimiter <tag1|tag2> {{{1):
let g:vimwiki_tag_format = {'pre_mark': '<', 'post_mark': '>', 'sep': '|'}
unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init()
edit $HOME/testmarkdown/Test-Tag.md
AssertEqual $HOME . '/testmarkdown/Test-Tag.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Create File Content with <>):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
I
<tag-bar-1>\<CR>
\<CR>
# A header\<CR>
\<CR>
<tag-bar-2|tag-bar-3>\<CR>
\<CR>
# Another header\<CR>
\<CR>
Words here.
\<Esc>
:write\<CR>
:VimwikiRebuildTags!\<CR>
gg
Execute (Generate tags):
edit $HOME/testmarkdown/Test-Tag.md
AssertEqual 'VimwikiTag', SyntaxAt(1, 1)
VimwikiGenerateTagLinks
set tw=200
Expect (Correctly generated tags section {{{3):
<tag-bar-1>
# A header
<tag-bar-2|tag-bar-3>
# Another header
Words here.
# Generated Tags
## tag-bar-1
- [Test-Tag](Test-Tag)
## tag-bar-2
- [A header](Test-Tag#a-header)
## tag-bar-3
- [A header](Test-Tag#a-header)
Do (Write a quick tag for a quick jump):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
ggdG
I
[go1](Test-Tag#tag-bar-1)\<Cr>
[go2](#tag-bar-1)\<Cr>
bla\<Cr>
<tag-bar-1>\<Esc>
ggl\<Cr>A __HERE1__\<Esc>
ggjl\<Cr>A __HERE2__\<Esc>
Expect (Good jump {{{3):
[go1](Test-Tag#tag-bar-1)
[go2](#tag-bar-1)
bla
<tag-bar-1> __HERE1__ __HERE2__
Execute (Clean Test-Tag and .vimwiki_tags -2):
let g:vimwiki_tag_format = {}
unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init()
call system("rm $HOME/testmarkdown/Test.md")
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag.md")
call DeleteHiddenBuffers()
######################################################################
Execute (Default tag generation {{{1):
edit $HOME/testmarkdown/Test-Tag.md
AssertEqual $HOME . '/testmarkdown/Test-Tag.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
set tw=200
Do (Single file Part1):
:edit $HOME/testmarkdown/Test-Tag.md\<Cr>
ggdGO
:single-tag:\<Esc>
:write\<Cr>
:VimwikiRebuildTags!\<Cr>
Execute (Generate tags):
edit $HOME/testmarkdown/Test-Tag.md
AssertEqual 'VimwikiTag', SyntaxAt(1, 1)
VimwikiGenerateTagLinks
write
Expect (Single tags toc):
:single-tag:
# Generated Tags
## single-tag
- [Test-Tag](Test-Tag)
Do (Create File Content):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
ggdGO
:top-tag:\<CR>
\<CR>
# A header\<CR>
\<CR>
:test-tag:\<CR>
\<CR>
# Another header\<CR>
\<CR>
Words here.\<CR>
If tag isn't within 2 lines of header then it has a direct link instead of\<CR>
a link to the header.\<CR>
\<CR>
:second-tag:
\<Esc>
:write\<CR>
:VimwikiRebuildTags\<CR>
Execute (Edit tags file):
edit $HOME/testmarkdown/.vimwiki_tags
AssertEqual $HOME . '/testmarkdown/.vimwiki_tags', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
# Note: tags file uses tabs
Expect (Correctly formatted tags file):
!_TAG_FILE_FORMAT 2
!_TAG_FILE_SORTED 1
!_TAG_OUTPUT_MODE vimwiki-tags
!_TAG_PROGRAM_AUTHOR Vimwiki
!_TAG_PROGRAM_NAME Vimwiki Tags
!_TAG_PROGRAM_URL https://github.com/vimwiki/vimwiki
!_TAG_PROGRAM_VERSION 2022.12.02
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
top-tag Test-Tag.md 1;" vimwiki:Test-Tag\tTest-Tag\tTest-Tag
Execute (Generate tags):
edit $HOME/testmarkdown/Test-Tag.md
VimwikiGenerateTagLinks
Expect (Correctly generated tags section):
:top-tag:
# A header
:test-tag:
# Another header
Words here.
If tag isn't within 2 lines of header then it has a direct link instead of
a link to the header.
:second-tag:
# Generated Tags
## second-tag
- [second-tag](Test-Tag#second-tag)
## test-tag
- [A header](Test-Tag#a-header)
## top-tag
- [Test-Tag](Test-Tag)
Execute (Clean Test-Tag and .vimwiki_tags -1 ):
call system("rm $HOME/testmarkdown/Test.md")
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag.md")
call DeleteHiddenBuffers()
# vim: sw=2:foldlevel=30:foldmethod=marker:
######################################################################
Execute (Check first tags file):
call system("mkdir -p $HOME/testmarkdown/subdir1/subdir11")
edit $HOME/testmarkdown/Test-Tag-1.md
AssertEqual $HOME . '/testmarkdown/Test-Tag-1.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Build first tags file):
:edit $HOME/testmarkdown/Test-Tag-1.md\<Cr>
ggI
# A Header\<Cr>
:header-tag-1:\<Cr>
\<Cr>
# Another Header\<Cr>
:header-tag-2:\<Cr>
\<Cr>
:standalone-tag-1:
\<Esc>
:write\<Cr>
:VimwikiRebuildTags!\<CR>
Execute (Check second tags file):
edit $HOME/testmarkdown/subdir1/Test-Tag-2.md
AssertEqual $HOME . '/testmarkdown/subdir1/Test-Tag-2.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Build second tags file):
:edit $HOME/testmarkdown/subdir1/Test-Tag-2.md\<Cr>
ggI
# A Header\<Cr>
:header-tag-1:\<Cr>
\<Cr>
# Another Header\<Cr>
:header-tag-2:\<Cr>
\<Cr>
:standalone-tag-1:
\<Esc>
:write\<Cr>
:VimwikiRebuildTags!\<CR>
Execute (Build tag links in third file):
edit $HOME/testmarkdown/subdir1/subdir11/Test-Tag-Links.md
AssertEqual $HOME . '/testmarkdown/subdir1/subdir11/Test-Tag-Links.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
VimwikiGenerateTagLinks
write
Expect (Tag links relative to current file):
# Generated Tags
## header-tag-1
- [A Header](../../Test-Tag-1#a-header)
- [A Header](../Test-Tag-2#a-header)
## header-tag-2
- [Another Header](../../Test-Tag-1#another-header)
- [Another Header](../Test-Tag-2#another-header)
## standalone-tag-1
- [standalone-tag-1](../../Test-Tag-1#standalone-tag-1)
- [standalone-tag-1](../Test-Tag-2#standalone-tag-1)
Do (Delete some existing links to test updating generated tag links):
:edit $HOME/testmarkdown/subdir1/subdir11/Test-Tag-Links.md\<Cr>
7G
dd
12G
6dd
:write\<Cr>
:call vimwiki#tags#generate_tags(0)\<Cr>
Expect (Only update generated tag links for tags already existing in the file):
# Generated Tags
## header-tag-1
- [A Header](../../Test-Tag-1#a-header)
- [A Header](../Test-Tag-2#a-header)
## header-tag-2
- [Another Header](../../Test-Tag-1#another-header)
- [Another Header](../Test-Tag-2#another-header)
Execute (Clean relative tag setup):
call system("rm -rf $HOME/testmarkdown/subdir1")
call system("rm $HOME/testmarkdown/Test-Tag-1.md")

View File

@@ -0,0 +1,390 @@
" TODO treat if local (see $HOME in all tests)
" TODO mutualise (to prettify output) mode(1) to check if in -Es or not
" TODO test tabnext in at least one travis job (without -Es)
" IDEA fasten travis difefrent job with the same vimwiki git (-8s)
" Declare tipical Vim preambule
" vint: -ProhibitSetNoCompatible
set nocompatible
filetype plugin indent on
syntax enable
" Usefull var: for one day, making tests on local
let $TPLUGIN = '/testplugin'
let $THOME = $HOME
" Set chrooted virtual runtime path
let rtp=$ROOT.'/rtp.vim'
exe 'source '.rtp
" Load Vader
let vader=$ROOT.'/vader'
exe 'set runtimepath+='.vader
" Wikis configuration
" Declare default syntax
let vimwiki_default = {}
let vimwiki_default.path = $HOME . '/testwiki'
let vimwiki_default.path_html = $HOME . '/html/default'
let vimwiki_default.template_path = $HOME . '/testwiki/templates/'
let vimwiki_default.syntax = 'default'
let vimwiki_default.ext = '.wiki'
let vimwiki_default.name = 'DefaultSyntax'
let vimwiki_default.base_url = 'https://example.com/'
" Declare markdown syntax - https://github.github.com/gfm/
let vimwiki_markdown = {}
let vimwiki_markdown.path = $HOME . '/testmarkdown'
let vimwiki_markdown.path_html = $HOME . '/html/markdown'
let vimwiki_markdown.syntax = 'markdown'
let vimwiki_markdown.ext = '.md'
let vimwiki_markdown.name = 'MarkdownSyntax'
" Declare mediawiki syntax - https://www.mediawiki.org/wiki/Help:Formatting
let vimwiki_mediawiki = {}
let vimwiki_mediawiki.path = $HOME . '/testmediawiki'
let vimwiki_mediawiki.path_html = $HOME . '/html/mediawiki'
let vimwiki_mediawiki.syntax = 'media'
let vimwiki_mediawiki.ext = '.mw'
let vimwiki_mediawiki.name = 'MediaWikiSyntax'
" Declare default syntax with spaces
let vimwiki_default_space = {}
let vimwiki_default_space.path = $HOME . '/testwiki space'
let vimwiki_default_space.path_html = $HOME . '/html/testwiki space'
let vimwiki_default_space.template_path = $HOME . '/testwiki space/templates/'
let vimwiki_default_space.syntax = 'default'
let vimwiki_default_space.ext = '.wiki'
let vimwiki_default_space.name = 'DefaultSyntax'
let vimwiki_default_space.base_url = 'https://example.com/'
" Register the 4 wikis
let g:vimwiki_list = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki, vimwiki_default_space]
let g:vimwiki_list_vimrc = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki, vimwiki_default_space]
" Test VimwikiColorize and ,wc
let g:vimwiki_color_dic = {
\ 'default': ['', '#d79921'],
\ 'red': ['#cc241d', ''],
\ 'bred': ['', '#cc241d'],
\ 'green': ['#98971a', ''],
\ 'bgreen': ['', '#98971a'],
\ 'yellow': ['#d79921', ''],
\ 'byellow': ['', '#d79921'],
\ 'blue': ['#458588', ''],
\ 'bblue': ['', '#458588'],
\ 'purple': ['#b16286', ''],
\ 'bpurple': ['', '#b16286'],
\ 'orange': ['#d65d0e', ''],
\ 'borange': ['', '#d65d0e'],
\ 'gray': ['#a89984', ''],
\ 'bgray': ['', '#a89984']}
" Set basic settings
" Avoid more prompt
set nomore
set backspace=indent,eol,start
set wildmode=longest:full,full
set wildmenu
set wildignorecase
set splitbelow
set splitright
set timeoutlen=600
set ignorecase
set smartcase
set hidden
set laststatus=2
set hlsearch
" Map
" Map ctrl-p/n for history completion instead of up/down arrows
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
" Map jj to go back to command mode
inoremap jj <esc>
" Use <C-L> to clear the highlighting of :set hlsearch and also preserve the
" default behavior of redrawing the screen
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
" Define functions
function! SetSyntax(vw_syn)
" Change the syntax using a temporary wiki
" Change extension and wiki_nr
let index=0
if a:vw_syn ==# 'default'
let ext = 'wiki'
let index=0
elseif a:vw_syn ==# 'markdown'
let ext = 'md'
let index=1
elseif a:vw_syn ==# 'media'
let ext = 'mw'
let index=2
else
Log 'ERROR: Invalid syntax "' . a:vw_syn . '" in SetSyntax()'
Log 'NOTE: function only accepts "media" for setting mediawiki syntax'
return
endif
" Change temporary wiki
let path = expand('%:p:h')
let new_temp_wiki_settings = {
\ 'path': path,
\ 'ext': ext,
\ 'syntax': a:vw_syn,
\ 'bullet_types': g:vimwiki_wikilocal_vars[index]['bullet_types'],
\ }
" Remove any temporary wikis each time this function is called.
" This is necessary to ensure syntax is properly set when running multiple tests
" NOTE: this assumes there are 3 defined wikis in the vimrc. The last wiki
" contains default settings for temporary wikis (so there are always
" num wikis in vimrc + 1)
let num_wikis = len(g:vimwiki_wikilocal_vars)
while num_wikis > 4
call remove(g:vimwiki_wikilocal_vars, num_wikis - 1)
let num_wikis = num_wikis - 1
endwhile
" Add the new wiki
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
call vimwiki#vars#set_bufferlocal('wiki_nr', 3)
" Verify syntax was set correctly
Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn,
\ 'ERROR: Vimwiki syntax not set correctly: '
\ . 'Want: ' . a:vw_syn . ' '
\ . 'Have: ' . vimwiki#vars#get_wikilocal('syntax')
endfunction
function! UnloadVimwiki()
" Clear mappings so plugin can be reloaded
" this is needed if running manually multiple times
nmapclear
" UNlet what can be
" -- Note: getcompletion not present on vim7.3
for i in ['g:vimwiki_commentstring',
\ 'b:did_ftplugin',
\ 'g:loaded_vimwiki',
\ 'g:vimwiki_global_vars',
\ 'g:vimwiki_wikilocal_vars',
\ 'g:vimwiki_syntaxlocal_vars',
\ 'g:vimwiki_list',
\ ]
if exists(i)
exe 'unlet ' . i
endif
endfor
" Unlet ftplugin:
" -- Vader often staty in same buffer: [Vader-workbench]
if exists('b:did_ftplugin')
unlet b:did_ftplugin
endif
endfunction
function! LoadVimwiki()
" Source plugin
runtime! plugin/vimwiki.vim
endfunction
function! ReloadVimwiki()
" Reload plugin to change settings
call UnloadVimwiki()
" Reset list
let g:vimwiki_list = g:vimwiki_list_vimrc
call LoadVimwiki()
endfunction
function! ReloadVars()
" vars#init will not reload syntax varaible if not set
unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init()
endfunction
function! CopyResources()
" Copy wiki test resources so that vimtest user can write them
call system('cp -r /testplugin/test/resources/* $HOME/')
" Make diary directory
call system('mkdir $HOME/testwiki/diary')
call system('mkdir $HOME/testmarkdown/diary')
endfunction
function! DeleteHiddenBuffers()
" Delete Hidden buffer, usefull to clean
" See: https://stackoverflow.com/a/8459043/2544873
let tpbl=[]
call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))')
for buf in filter(range(1, bufnr('$')), 'bufexists(v:val) && index(tpbl, v:val)==-1')
if bufname(buf) =~? 'Vader'
continue
endif
silent execute 'bwipeout!' buf
endfor
endfunction
function! WriteMe()
" Write current file: helper to hide `set bt=`
set buftype=
write! %
endfunction
function! DeleteFile(path)
" Delete a file <- path <string>
let path = expand(a:path)
" Delete file
try
call delete(path)
catch | endtry
" Delete Buffer
try
execute 'bwipeout! ' . path
catch | endtry
endfunction
function! PrintCommand(cmd)
" Print a command output to the buffer
redir => message
silent execute a:cmd
redir END
if empty(message)
Log 'no output'
else
silent put=message
endif
endfunction
function! DestroyVar(var)
" Destroy a variable is exists (unlet)
if ! exists(a:var) | return | endif
execute 'unlet ' . a:var
endfunction
function! AssertTab(nr)
" Assert current tab is desired tab
" Vader is creating 2 tabs
AssertEqual a:nr + 2, tabpagenr()
endfunction
function! ConvertWiki2Html()
" Convert current buffer: wiki -> html
" No side effect (if no bug)
" Save fbuffer number (to come back)
let g:buf_vader = bufnr('%')
" Cut wiki content
let wiki_content = getline(1, '$')
1,$delete
" Paste to a named file
" Edit a new file in wiki_root
edit $HOME/testwiki/test_Convert2Html.wiki
" Ensure it is void
1,$delete
" Write wiki content
call setline(1, wiki_content)
" Dump buffer to disk
call WriteMe()
" Convert
"""""""""
Vimwiki2HTML
" Cut output
edit $HOME/html/default/test_Convert2Html.html
let html_content = getline(1, '$')
1,$delete
" Paste output in [Vader] buffer
execute 'buffer ' . g:buf_vader
call setline(1, html_content)
" Delete files
call DeleteFile('$HOME/html/default/test_Convert2Html.html')
call DeleteFile('$HOME/testwiki/test_Convert2Html.wiki')
endfunction
function! ConvertWiki2Body()
" Get only body
call ConvertWiki2Html()
" Empty b register
let @b = ''
" Copy body
/<body>/+1,/<.body>/-1:g/^/y B
" Delete All lines
1,$d
" Paste body
0put! b
" Remove last line
0d
endfunction
function! GetSyntaxGroup(line, col)
" Get normalized syntax group: usefull for boldItalic Vs italicBold
" -- Here, Vader's SyntaxAt is not enough
" From: https://stackoverflow.com/questions/9464844
let l:s = synID(a:line, a:col, 1)
return synIDattr(synIDtrans(l:s), 'name')
endfun
function! GetSyntaxStack()
" Debug helper
if !exists('*synstack')
return
endif
return map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
function! AssertIfVersion(version, one, two)
" Run Assert only if vim version is high enough
if v:version < a:version | return | endif
AssertEqual a:one, a:two
endfunction
function! GetHighlightTerm(group, term)
" Get output of `hi group`
"
" From: https://vi.stackexchange.com/a/12294/5026
" Return list ['bold','underline']
"
" Warning: must only be called if has("patch-7.4-2008")
" Or rather: If execute() exists - it's not available for all 7.4
" versions.
" https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
if has('patch-7.4-2008') != 1 | return [] | endif
" Store output of group to variable
let out = execute('hi ' . a:group)
" If links to, call parent
let parent = matchstr(out, 'links to *\zs[^ \t\n\r]*')
if parent !=# ''
" Return list_of_parent, parent
return GetHighlightTerm(parent, a:term)
endif
" Return the unique term we are looking for
let stg = matchstr(out, a:term.'=\zs[^ \t\n\r]*')
return split(stg, ',')
endfunction
" Copy Wiki's Resources
call CopyResources()
" vim: ft=vim:sw=2

View File

@@ -0,0 +1,10 @@
# Succeding test just to test the script when everything goes fine
Given (Text v0.01):
Text
Do (press escape):
\<Esc>
Expect (Text):
Text