Removed vimwiki, fixed URL, removed windows.reg

This commit is contained in:
Anthony Rose 2022-06-22 14:49:50 +00:00
parent 58d74381f7
commit b0542a72c2
71 changed files with 3 additions and 30514 deletions

View file

@ -1,7 +0,0 @@
Prior to submitting a new issue make sure to complete these steps:
- [ ] Checkout the `dev` branch and confirm the issue is present there as well.
The `dev` branch contains fixes that may not have been merged to `master` yet.
- [ ] Post the syntax you are using (default/mediawiki/markdown) **and** your vimwiki settings from your `.vimrc`
- [ ] Provide a detailed description of the problem including **steps to reproduce the issue**.
- [ ] Include the output of `:VimwikiShowVersion`.

View file

@ -1,9 +0,0 @@
Steps for submitting a pull request:
- [ ] **ALL** pull requests should be made against the `dev` branch!
- [ ] Take a look at [CONTRIBUTING.MD](https://github.com/vimwiki/vimwiki/blob/dev/CONTRIBUTING.md)
- [ ] Reference any related issues.
- [ ] Provide a description of the proposed changes.
- [ ] PRs must pass Vint tests and add new Vader tests as applicable.
- [ ] Make sure to update the documentation in `doc/vimwiki.txt` if applicable,
including the Changelog and Contributors sections.

View file

@ -1,24 +0,0 @@
# Local stuff
# This section is devoted to this project
##############################
doc/tags
.tags
# Vim stuff
##############################
*.s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
# OS generated files
##############################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
vimtest

View file

@ -1,27 +0,0 @@
# No language: we download vim and compile it oursselves
language: generic
cache:
# Enable cache folder
bundler: true
directories:
- $HOME/docker_images
before_cache:
# Save tagged docker images. Info at https://github.com/travis-ci/travis-ci/issues/5358#issuecomment-248915326
- >
mkdir -p $HOME/docker_images && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
| xargs -n 2 -t sh -c 'test -e $HOME/docker_images/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker_images/$1.tar.gz'
before_install:
# Install docker
- n_image=$(ls -1 $HOME/docker_images/*.tar.gz | wc -l)
- if (( $n_image )); then ls $HOME/docker_images/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load";
else docker build --tag vimwiki .;
fi
script:
# Run All tests
- pushd test
- bash run_tests.sh
- popd

View file

@ -1,72 +0,0 @@
# Contributing to Vimwiki
# Filing a bug
Before filing a bug or starting to write a patch, check the latest development version from
https://github.com/vimwiki/vimwiki/tree/dev to see if your problem is already fixed.
Issues can be filed at https://github.com/vimwiki/vimwiki/issues/ .
# Creating a pull request
If you want to provide a pull request on GitHub, please start from the `dev` branch, not from the
`master` branch. (Caution, GitHub shows `master` as the default branch from which to start a PR.)
Make sure to update `doc/vimwiki.txt` with the following information:
1. Update the changelog to include information on the new feature the PR introduces or the bug it
is fixing.
2. Add a help section to describe any new features or options.
3. If you are a first time contributor add your name to the list of contributors.
**Testing:** Vimwiki uses [vader](https://github.com/junegunn/vader.vim) for unit tests and
[vint](https://github.com/Kuniwak/vint) for linting. Any new PRs must add new tests and pass all
linter checks. See the [test README](test/README.md) for more info.
- In addition to the included tests, there are more example wikis that can be used for testing
[here](https://github.com/vimwiki/testwikis).
# More info and advice for (aspiring) core developers
- Before implementing a non-trivial feature, think twice what it means for the user. We should
always try to keep backward compatibility. If you are not sure, discuss it on GitHub.
- Also, when thinking about adding a new feature, it should be something which fits into the
overall design of Vimwiki and which a significant portion of the users may like. Keep in mind
that everybody has their own way to use Vimwiki.
- Keep the coding style consistent.
- Test your changes. Keep in mind that Vim has a ton of options and the users tons of different
setups. Take a little time to think about under which circumstances your changes could break.
## Git branching model
- There are two branches with eternal lifetime:
1. `dev`: This is where the main development happens. Tasks which are done in one or only a few
commits go here directly. Always try to keep this branch in a working state, that is, if the
task you work on requires multiple commits, make sure intermediate commits don't make
Vimwiki unusable (or at least push these commits at one go).
2. `master`: This branch is for released states only. Whenever a reasonable set of changes has
piled up in the `dev` branch, a [release is done](#preparing-a-release). After a release,
`dev` has been merged into `master` and `master` got exactly one additional commit in which
the version number in `plugin/vimwiki.vim` is updated. Apart from these commits and the
merge commit from `dev`, nothing happens on `master`. Never should `master` merge into
`dev`. When the users ask, we should recommend this branch for them to use.
- Larger changes which require multiple commits are done in feature branches. They are based on
`dev` and merge into `dev` when the work is done.
## Preparing a release
1. `git checkout dev`
2. Update the changelog in the doc, nicely grouped, with a new version number and release date.
3. Update the list of contributors.
4. Update the version number at the top of the doc file.
5. If necessary, update the Readme and the home page.
6. `git checkout master && git merge dev`
7. Update the version number at the top of plugin/vimwiki.vim.
8. Set a tag with the version number in Git: `git tag vX.Y`
9. `git push --tags`
10. In GitHub, go to _Releases_ -> _Draft a new release_ -> choose the tag, convert the changelog
from the doc to markdown and post it there. Make plans to build an automatic converter and
immediately forget this plan.
11. Tell the world.
<!-- vim:tw=99 -->

View file

@ -1,186 +0,0 @@
# Design Notes
This file is meant to document design decisions and algorithms inside vimwiki
which are too large for code comments, and not necessarily interesting to
users. Please create a new section to document each behavior.
## Formatting tables
In vimwiki, formatting tables occurs dynamically, when navigating between cells
and adding new rows in a table in the Insert mode, or statically, when pressing
`gqq` or `gqw` (which are mappings for commands `VimwikiTableAlignQ` and
`VimwikiTableAlignW` respectively) in the Normal mode. It also triggers when
leaving Insert mode, provided variable `g:vimwiki_table_auto_fmt` is set. In
this section, the original and the newer optimized algorithms of table
formatting will be described and compared.
### The older table formatting algorithm and why this is not optimal
Let's consider a simple example. Open a new file, say _tmp.wiki_, and create a
new table with command `VimwikiTable`. This should create a blank table.
```
| | | | | |
|---|---|---|---|---|
| | | | | |
```
Let's put the cursor in the first header column of the table, enter the Insert
mode and type a name, say _Col1_. Then press _Tab_: the cursor will move to the
second column of the header and the table will get aligned (in the context of
the table formatting story, words _aligned_ and _formatted_ are considered as
synonyms). Now the table looks as in the following snippet.
```
| Col1 | | | | |
|------|---|---|---|---|
| | | | | |
```
Then, when moving cursor to the first data row (i.e. to the third line of the
table below the separator line) and typing anything here and there while
navigating using _Tab_ or _Enter_ (pressing this creates a new row below the
current row), the table shall keep formatting. Below is a result of such a
random edit.
```
| Col1 | | | | |
|------|-------|---|-------|----------|
| | Data1 | | Data2 | |
| | | | | New data |
```
The lowest row gets aligned when leaving the Insert mode. Let's copy _Data1_
(using `viwy` or another keystroke) and paste it (using `p`) in the second data
row of the first column. Now the table looks mis-aligned (as we did not enter
the Insert mode).
```
| Col1 | | | | |
|------|-------|---|-------|----------|
| | Data1 | | Data2 | |
| Data1 | | | | New data |
```
This is not a big problem though, because we can put the cursor at _any_ place
in the table and press `gqq`: the table will get aligned.
```
| Col1 | | | | |
|-------|-------|---|-------|----------|
| | Data1 | | Data2 | |
| Data1 | | | | New data |
```
Now let's make real problems! Move the cursor to the lowest row and copy it
with `yy`. Then 500-fold paste it with `500p`. Now the table very long. Move
the cursor to the lowest row (by pressing `G`), enter the Insert mode, and try
a new random editing session by typing anything in cells with _Tab_ and _Enter_
navigation interleaves. The editing got painfully slow, did not?
The reason of the slowing down is the older table formatting algorithm. Every
time _Tab_ or _Enter_ get pressed down, all rows in the table get visited to
calculate a new alignment. Moreover, by design it may happen even more than
once per one press!
```vim
function! s:kbd_create_new_row(cols, goto_first)
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>0"
if a:goto_first
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>"
else
let cmd .= (col('.')-1)."l"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
endif
let cmd .= "a"
return cmd
endfunction
```
Function `s:kbd_create_new_row()` is called when _Tab_ or _Enter_ get pressed.
Formatting of the whole table happens in function `vimwiki#tbl#format()`. But
remember that leaving the Insert mode triggers re-formatting of a table when
variable `g:vimwiki_table_auto_fmt` is set. This means that formatting of the
whole table is called on all those multiple interleaves between the Insert and
the Normal mode in `s:kbd_create_new_row` (notice `\<ESC>`, `o`, etc.).
### The newer table formating algorithm
The newer algorithm was introduced to struggle against performance issues when
formatting large tables.
Let's take the table from the previous example in an intermediate state.
```
| Col1 | | | | |
|------|-------|---|-------|----------|
| | Data1 | | Data2 | |
| Data1 | | | | New data |
```
Then move the cursor to the first data row, copy it with `yy`, go down to the
mis-aligned line, and press `5p`. Now we have a slightly bigger mis-aligned
table.
```
| Col1 | | | | |
|------|-------|---|-------|----------|
| | Data1 | | Data2 | |
| Data1 | | | | New data |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
```
Go down to the lowest, the 7th, data row and press `gq1`. Nothing happened.
Let's go to the second or the third data row and press `gq1` once again. Now
the table gets aligned. Let's undo formatting with `u`, go to the fourth row,
and press `gq1`. Now the table should look like in the following snippet.
```
| Col1 | | | | |
|------|-------|---|-------|----------|
| | Data1 | | Data2 | |
| Data1 | | | | New data |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
| | Data1 | | Data2 | |
```
What a peculiar command! Does using it make any sense? Not much, honestly.
Except it shows how the newer optimized table formatting algorithm works in the
Insert mode.
Indeed, the newer table formatting algorithm introduces a _viewport_ on a table.
Now, when pressing _Tab_ or _Enter_ in the Insert mode, only a small part of
rows are checked for possible formatting: two rows above the current line and
the current line itself (the latter gets preliminary shrunk with function
`s:fmt_row()`). If all three lines in the viewport are of the same length, then
nothing happens (case 1 in the example). If the second or the shrunk current
line is longer then the topmost line in the viewport, then the algorithm falls
back to the older formatting algorithm and the whole table gets aligned
(case 2). If the topmost line in the viewport is longer than the second
and the shrunk current line, then the two lowest lines get aligned according to
the topmost line (case 3).
Performance of the newer formatting algorithm should not depend on the height
of the table. The newer algorithm should also be consistent with respect to
user editing experience. Indeed, as soon as a table should normally be edited
row by row from the top to the bottom, dynamic formatting should be both fast
(watching only three rows in a table, re-formatting only when the shrunk
current row gets longer than any of the two rows above) and eager (a table
should look formatted on every press on _Tab_ and _Enter_). However, the newer
algorithm differs from the older algorithm when starting editing a mis-aligned
table in an area where mis-aligned rows do not get into the viewport: in this
case the newer algorithm will format the table partly (in the rows of the
viewport) until one of the being edited cells grows in length to a value big
enough to trigger the older algorithm and the whole table gets aligned. When
partial formatting is not desirable, the whole table can be formatted by
pressing `gqq` in the Normal mode.

View file

@ -1,23 +0,0 @@
FROM testbed/vim:17
# add packages
RUN apk --no-cache add bash=~5.0
RUN apk --no-cache add git=~2.22
RUN apk --no-cache add python3=~3.7
# get vint for linting
RUN pip3 install vim-vint==0.3.21
# get vader for unit tests
RUN git clone -n https://github.com/junegunn/vader.vim /vader
WORKDIR /vader
RUN git checkout de8a976f1eae2c2b680604205c3e8b5c8882493c
# build vim and neovim versions we want to test
# TODO uncomment nvim tag
WORKDIR /
RUN install_vim -tag v7.3.429 -name vim_7.3.429 -build \
-tag v7.4.1099 -name vim_7.4.1099 -build \
-tag v7.4.1546 -name vim_7.4.1546 -build \
-tag v8.0.0027 -name vim_8.0.0027 -build \
-tag v8.1.0519 -name vim_8.1.0519 -build \

View file

@ -1,22 +0,0 @@
MIT License
Copyright (c) 2008-2010 Maxim Kim
2013-2017 Daniel Schemala
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,161 +0,0 @@
VimWiki —— Vim 个人 Wiki 插件
==============================================================================
[English](README.md)
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) *
介绍
------------------------------------------------------------------------------
Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法高亮的文本文件。
通过 Vimwiki你可以:
* 组织笔记和想法
* 管理待办事项
* 编写文档
* 坚持写日记
* 将这一切导出成 HTML 网页
马上开始!按下 `<Leader>ww`(通常是 `\ww`)进入作为目录页的 wiki 文件,这个文件默认存放在 `~/vimwiki/index.wiki`
在该文件中输入以下示例:
= 我的个人知识库 =
* 任务列表 -- _昨天_ 就该完成的事!!!
* Gutenberg 计划 -- 好书给我力量。
* 草稿 -- 临时记录一些东西。
把光标移到 `任务` 二字上,按 Enter回车创建链接。按下后`任务`二字会变成 `[[任务]]` —— 这是一个 Vimwiki 链接。再次按 Enter 即可进入这个链接(打开新的 wiki 文件)。编辑这个新文件,保存,然后按 Backspace退格就能回到目录页。
如果 Vimwiki 链接长度不止一个单词(指的是英文单词),只需在 Visual 模式选择这段文本后按 Enter 即可。用上面的 `Gutenberg 计划` 试试吧。最终结果是这样:
= 我的个人知识库 =
* [[任务列表]] -- _昨天_ 就该完成的事!!!
* [[Gutenberg 计划]] -- 好书给我力量。
* 草稿 -- 临时记录一些东西。
基本标记
------------------------------------------------------------------------------
= 一级标题 =
== 二级标题 ==
=== 三级标题 ===
*bold* -- 粗体文本
_italic_ -- 斜体文本
(应用于句中的汉字文本时,必须在标记前后加空格,例如:一段 *中文* 文本)
[[wiki link]] -- wiki 链接
[[wiki link|description]] -- 带有描述文本的 wiki 链接
列表:
* bullet list item 1无编号列表
- bullet list item 2
- bullet list item 3
* bullet list item 4
* bullet list item 5
* bullet list item 6
* bullet list item 7
- bullet list item 8
- bullet list item 9
1. numbered list item 1有编号列表
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
更多格式说明,请阅 `:h vimwiki-syntax`
键位绑定
------------------------------------------------------------------------------
normal 模式:
* `<Leader>ww` -- 打开默认的 wiki 目录文件
* `<Leader>wt` -- 在新标签Tab中打开 wiki 目录文件
* `<Leader>ws` -- 在多个 wiki 中选择并打开该 wiki 的目录文件
* `<Leader>wd` -- 删除当前 wiki 文件
* `<Leader>wr` -- 重命名当前 wiki 文件
* `<Enter>` -- 创建或打开 wiki 链接
* `<Shift-Enter>` -- 先上下分屏再打开 wiki 链接(若非链接则先创建)
* `<Ctrl-Enter>` -- 先左右分屏再打开 wiki 链接(若非链接则先创建)
* `<Backspace>` -- 返回之前浏览的 wiki 文件
* `<Tab>` -- 跳到本文件中下一个 wiki 链接
* `<Shift-Tab>` -- 跳到本文件中上一个 wiki 链接
更多快捷键说明,请阅 `:h vimwiki-mappings`
命令
------------------------------------------------------------------------------
* `:Vimwiki2HTML` -- 将当前 wiki 文件转换成 HTML 网页
* `:VimwikiAll2HTML` -- 把所有 wiki 文件转换成 HTML 网页
* `:help vimwiki-commands` -- 显示全部命令
安装
==============================================================================
准备工作
------------------------------------------------------------------------------
确保在 `vimrc` 中加入了以下设置:
set nocompatible
filetype plugin on
syntax on
没有这些设置Vimwiki 将无法正常工作。
通过 [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) 安装Vim 7.4.1528 后)
------------------------------------------------------------------------------
git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
通过 [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) 安装
------------------------------------------------------------------------------
cd ~/.vim
mkdir bundle
cd bundle
git clone https://github.com/vimwiki/vimwiki.git
通过 [Vim-Plug](https://github.com/junegunn/vim-plug) 安装
------------------------------------------------------------------------------
`vimrc` 中加入以下插件设置:
Plug 'vimwiki/vimwiki'
然后运行 `:PlugInstall`
通过 [Vundle](https://github.com/VundleVim/Vundle.vim) 安装
------------------------------------------------------------------------------
`vimrc` 中加入 `Plugin 'vimwiki/vimwiki'`,然后执行:
vim +PluginInstall +qall
或者下载 [zip 压缩包](https://github.com/vimwiki/vimwiki/archive/master.zip)然后解压到 `~/.vim/bundle/` 目录下。
安装后,启动 Vim 并执行 `:Helptags` 以及 `:help vimwiki`,检查安装是否成功。
获取帮助
==============================================================================
遇到问题?在 Freenode 的 IRC 频道 `#vimwiki`[网页聊天](https://webchat.freenode.net/?channels=#vimwiki))提问,或者发送问题到[邮件列表](https://groups.google.com/forum/#!forum/vimwiki)上吧。
----
\* 前面截图中用的是 [solarized 配色方案](https://github.com/altercation/vim-colors-solarized)以及 [lightline](https://github.com/itchyny/lightline.vim) 插件。

View file

@ -1,283 +0,0 @@
![VimWiki: A Personal Wiki For Vim](doc/splash.png)
[中文](README-cn.md)
- [Intro](#intro)
- [Screenshots](#screenshots)
- [Installation](#installation)
- [Prerequisites](#prerequisites)
- [VIM Packages](#installation-using-vim-packages-since-vim-741528)
- [Pathogen](#installation-using-pathogen)
- [Vim-Plug](#installation-using-vim-plug)
- [Vundle](#installation-using-vundle)
- [Basic Markup](#basic-markup)
- [Lists](#lists)
- [Key Bindings](#key-bindings)
- [Commands](#commands)
- [Changing Wiki Syntax](#changing-wiki-syntax)
- [Getting Help](#getting-help)
- [Helping VimWiki](#helping-vimwiki)
- [Wiki](https://github.com/vimwiki/vimwiki/wiki)
- [License](#license)
----
## Introduction
VimWiki is a personal wiki for Vim -- a number of linked text files that have
their own syntax highlighting. See the [VimWiki Wiki](https://vimwiki.github.io/vimwikiwiki/)
for an example website built with VimWiki!
For the latest features and fixes checkout the [dev branch](https://github.com/vimwiki/vimwiki/tree/dev).
If you are interested in contributing see [this section](#helping-vimwiki).
With VimWiki, you can:
- Organize notes and ideas
- Manage to-do lists
- Write documentation
- Maintain a diary
- Export everything to HTML
To do a quick start, press `<Leader>ww` (default is `\ww`) to go to your index
wiki file. By default, it is located in `~/vimwiki/index.wiki`. See `:h vimwiki_list`
for registering a different path/wiki.
Feed it with the following example:
```text
= My knowledge base =
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
```
Place your cursor on `Tasks` and press Enter to create a link. Once pressed,
`Tasks` will become `[[Tasks]]` -- a VimWiki link. Press Enter again to
open it. Edit the file, save it, and then press Backspace to jump back to your
index.
A VimWiki link can be constructed from more than one word. Just visually
select the words to be linked and press Enter. Try it, with `Project Gutenberg`.
The result should look something like:
```text
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
```
## Screenshots
![Lists View](doc/lists.png)
![Entries View](doc/entries.png)
![Todos View](doc/todos.png)
![Wiki View](doc/wiki.png)
## Installation
VimWiki has been tested on **Vim >= 7.3**. It will likely work on older
versions but will not be officially supported.
### Prerequisites
Make sure you have these settings in your vimrc file:
```vim
set nocompatible
filetype plugin on
syntax on
```
Without them, VimWiki will not work properly.
#### Installation using [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528)
```sh
git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
# to generate documentation i.e. ':h vimwiki'
vim -c 'helptags ~/.vim/pack/plugins/start/vimwiki/doc' -c quit
```
Notes:
- See `:h helptags` for issues with installing the documentation.
- For general information on vim packages see `:h packages`.
#### Installation using [Pathogen](https://github.com/tpope/vim-pathogen)
```sh
cd ~/.vim
mkdir bundle
cd bundle
git clone https://github.com/vimwiki/vimwiki.git
```
#### Installation using [Vim-Plug](https://github.com/junegunn/vim-plug)
Add the following to the plugin-configuration in your vimrc:
```vim
Plug 'vimwiki/vimwiki'
```
Then run `:PlugInstall`.
#### Installation using [Vundle](https://github.com/VundleVim/Vundle.vim)
Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run:
```sh
vim +PluginInstall +qall
```
#### Manual Install
Download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip)
and extract it in `~/.vim/bundle/`
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was
installed.
## Basic Markup
```text
= Header1 =
== Header2 ==
=== Header3 ===
*bold* -- bold text
_italic_ -- italic text
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
```
### Lists
```text
* bullet list item 1
- bullet list item 2
- bullet list item 3
* bullet list item 4
* bullet list item 5
* bullet list item 6
* bullet list item 7
- bullet list item 8
- bullet list item 9
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
```
For other syntax elements, see `:h vimwiki-syntax`
## Key bindings
### Normal mode
**Note:** your terminal may prevent capturing some of the default bindings
listed below. See `:h vimwiki-local-mappings` for suggestions for alternative
bindings if you encounter a problem.
#### Basic key bindings
- `<Leader>ww` -- Open default wiki index file.
- `<Leader>wt` -- Open default wiki index file in a new tab.
- `<Leader>ws` -- Select and open wiki index file.
- `<Leader>wd` -- Delete wiki file you are in.
- `<Leader>wr` -- Rename wiki file you are in.
- `<Enter>` -- Follow/Create wiki link.
- `<Shift-Enter>` -- Split and follow/create wiki link.
- `<Ctrl-Enter>` -- Vertical split and follow/create wiki link.
- `<Backspace>` -- Go back to parent(previous) wiki link.
- `<Tab>` -- Find next wiki link.
- `<Shift-Tab>` -- Find previous wiki link.
#### Advanced key bindings
Refer to the complete documentation at `:h vimwiki-mappings` to see many
more bindings.
## Commands
- `:Vimwiki2HTML` -- Convert current wiki link to HTML.
- `:VimwikiAll2HTML` -- Convert all your wiki links to HTML.
- `:help vimwiki-commands` -- List all commands.
- `:help vimwiki` -- General vimwiki help docs.
## Changing Wiki Syntax
VimWiki currently ships with 3 syntaxes: VimWiki (default), Markdown
(markdown), and MediaWiki (media).
**NOTE:** Only the default syntax ships with a built-in HTML converter. For
Markdown or MediaWiki see `:h vimwiki-option-custom_wiki2html`. Some examples
and 3rd party tools are available [here](https://vimwiki.github.io/vimwikiwiki/Related%20Tools.html#Related%20Tools-External%20Tools).
If you would prefer to use either Markdown or MediaWiki syntaxes, set the
following option in your `.vimrc`:
```vim
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
## Getting help
[GitHub issues](https://github.com/vimwiki/vimwiki/issues) are the primary
method for raising bug reports or feature requests.
Additional resources include the IRC channel [#vimwiki](https://webchat.freenode.net/?channels=#vimwiki) on Freenode
([webchat](https://webchat.freenode.net/?channels=#vimwiki), also synced to Matrix/Riot: `#freenode_#vimwiki:matrix.org` and [Telegram](https://t.me/joinchat/JqBaKBfWs04qNVrp5oWcMg))
or post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki).
## Helping VimWiki
VimWiki has a lot of users but only very few recurring developers or people
helping the community. Your help is therefore appreciated. Everyone can help!
See [#625](https://github.com/vimwiki/vimwiki/issues/625) for information on how you can help.
Also, take a look at [CONTRIBUTING.md](https://github.com/vimwiki/vimwiki/blob/master/CONTRIBUTING.md).
----
## License
MIT License
Copyright (c) 2008-2010 Maxim Kim
2013-2017 Daniel Schemala
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because it is too large Load diff

View file

@ -1,62 +0,0 @@
#!/bin/bash
#
# This script converts markdown into html, to be used with vimwiki's
# "customwiki2html" option. Experiment with the two proposed methods by
# commenting / uncommenting the relevant lines below.
#
# NEW! An alternative converter was developed by Jason6Anderson, and can
# be located at https://github.com/vimwiki-backup/vimwiki/issues/384
#
#
# To use this script, you must have the Discount converter installed.
#
# http://www.pell.portland.or.us/~orc/Code/discount/
#
# To verify your installation, check that the commands markdown and mkd2text,
# are on your path.
#
# Also verify that this file is executable.
#
# Then, in your .vimrc file, set:
#
# g:vimwiki_customwiki2html=$HOME.'/.vim/autoload/vimwiki/customwiki2html.sh'
#
# On your next restart, Vimwiki will run this script instead of using the
# internal wiki2html converter.
#
MARKDOWN=markdown
MKD2HTML=mkd2html
FORCE="$1"
SYNTAX="$2"
EXTENSION="$3"
OUTPUTDIR="$4"
INPUT="$5"
CSSFILE="$6"
FORCEFLAG=
[ $FORCE -eq 0 ] || { FORCEFLAG="-f"; };
[ $SYNTAX = "markdown" ] || { echo "Error: Unsupported syntax"; exit -2; };
OUTPUT="$OUTPUTDIR"/$(basename "$INPUT" .$EXTENSION).html
# # Method 1:
# # markdown [-d] [-T] [-V] [-b url-base] [-C prefix] [-F bitmap] [-f flags] [-o file] [-s text] [-t text] [textfile]
#
# URLBASE=http://example.com
# $MARKDOWN -T -b $URLBASE -o $OUTPUT $INPUT
# Method 2:
# mkd2html [-css file] [-header string] [-footer string] [file]
$MKD2HTML -css "$CSSFILE" "$INPUT"
OUTPUTTMP=$(dirname "$INPUT")/$(basename "$INPUT" ."$EXTENSION").html
mv -f "$OUTPUTTMP" "$OUTPUT"

View file

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
<title>%title%</title>
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
%content%
</body>
</html>

View file

@ -1,436 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Description: Handle diary notes
" Home: https://github.com/vimwiki/vimwiki/
if exists('g:loaded_vimwiki_diary_auto') || &compatible
finish
endif
let g:loaded_vimwiki_diary_auto = 1
function! s:prefix_zero(num) abort
if a:num < 10
return '0'.a:num
endif
return a:num
endfunction
function! s:diary_path(...) abort
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
endfunction
function! s:diary_index(...) abort
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).
\ vimwiki#vars#get_wikilocal('ext', idx)
endfunction
function! vimwiki#diary#diary_date_link(...) abort
if a:0
return strftime('%Y-%m-%d', a:1)
else
return strftime('%Y-%m-%d')
endif
endfunction
function! s:get_position_links(link) abort
let idx = -1
let links = []
if a:link =~# '^\d\{4}-\d\d-\d\d'
let links = map(vimwiki#diary#get_diary_files(), 'fnamemodify(v:val, ":t:r")')
" include 'today' into links
if index(links, vimwiki#diary#diary_date_link()) == -1
call add(links, vimwiki#diary#diary_date_link())
endif
call sort(links)
let idx = index(links, a:link)
endif
return [idx, links]
endfunction
function! s:get_month_name(month) abort
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
endfunction
function! s:get_first_header(fl) abort
" Get the first header in the file within the first s:vimwiki_max_scan_for_caption lines.
let header_rx = vimwiki#vars#get_syntaxlocal('rxHeader')
for line in readfile(a:fl, '', g:vimwiki_max_scan_for_caption)
if line =~# header_rx
return vimwiki#u#trim(matchstr(line, header_rx))
endif
endfor
return ''
endfunction
function! s:get_all_headers(fl, maxlevel) abort
" Get a list of all headers in a file up to a given level.
" Returns a list whose elements are pairs [level, title]
let headers_rx = {}
for i in range(1, a:maxlevel)
let headers_rx[i] = vimwiki#vars#get_syntaxlocal('rxH'.i.'_Text')
endfor
let headers = []
for line in readfile(a:fl, '')
for [i, header_rx] in items(headers_rx)
if line =~# header_rx
call add(headers, [i, vimwiki#u#trim(matchstr(line, header_rx))])
break
endif
endfor
endfor
return headers
endfunction
function! s:count_headers_level_less_equal(headers, maxlevel) abort
" Count headers with level <= maxlevel in a list of [level, title] pairs.
let l:count = 0
for [header_level, _] in a:headers
if header_level <= a:maxlevel
let l:count += 1
endif
endfor
return l:count
endfunction
function! s:get_min_header_level(headers) abort
" The minimum level of any header in a list of [level, title] pairs.
if len(a:headers) == 0
return 0
endif
let minlevel = a:headers[0][0]
for [level, _] in a:headers
let minlevel = min([minlevel, level])
endfor
return minlevel
endfunction
function! s:read_captions(files) abort
let result = {}
let caption_level = vimwiki#vars#get_wikilocal('diary_caption_level')
for fl in a:files
" remove paths and extensions
let fl_captions = {}
" Default; no captions from the file.
let fl_captions['top'] = ''
let fl_captions['rest'] = []
if caption_level >= 0 && filereadable(fl)
if caption_level == 0
" Take first header of any level as the top caption.
let fl_captions['top'] = s:get_first_header(fl)
else
let headers = s:get_all_headers(fl, caption_level)
if len(headers) > 0
" If first header is the only one at its level or less, then make it the top caption.
let [first_level, first_header] = headers[0]
if s:count_headers_level_less_equal(headers, first_level) == 1
let fl_captions['top'] = first_header
call remove(headers, 0)
endif
let min_header_level = s:get_min_header_level(headers)
for [level, header] in headers
call add(fl_captions['rest'], [level - min_header_level, header])
endfor
endif
endif
endif
let fl_key = substitute(fnamemodify(fl, ':t'), vimwiki#vars#get_wikilocal('ext').'$', '', '')
let result[fl_key] = fl_captions
endfor
return result
endfunction
function! vimwiki#diary#get_diary_files() abort
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(vimwiki#vars#get_wikilocal('path').
\ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
" remove backup files (.wiki~)
call filter(files, 'v:val !~# ''.*\~$''')
return files
endfunction
function! s:group_links(links) abort
let result = {}
let p_year = 0
let p_month = 0
for fl in sort(keys(a:links))
let year = strpart(fl, 0, 4)
let month = strpart(fl, 5, 2)
if p_year != year
let result[year] = {}
let p_month = 0
endif
if p_month != month
let result[year][month] = {}
endif
let result[year][month][fl] = a:links[fl]
let p_year = year
let p_month = month
endfor
return result
endfunction
function! s:sort(lst) abort
if vimwiki#vars#get_wikilocal('diary_sort') ==? 'desc'
return reverse(sort(a:lst))
else
return sort(a:lst)
endif
endfunction
" The given wiki number a:wnum is 1 for the first wiki, 2 for the second and so on. This is in
" contrast to most other places, where counting starts with 0. When a:wnum is 0, the current wiki
" is used.
function! vimwiki#diary#make_note(wnum, ...) abort
if a:wnum == 0
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
if wiki_nr < 0 " this happens when e.g. VimwikiMakeDiaryNote was called outside a wiki buffer
let wiki_nr = 0
endif
else
let wiki_nr = a:wnum - 1
endif
if wiki_nr >= vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.wiki_nr.' is not registered in g:vimwiki_list!'
return
endif
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', wiki_nr).
\ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr))
let cmd = 'edit'
if a:0
if a:1 == 1
let cmd = 'tabedit'
elseif a:1 == 2
let cmd = 'split'
elseif a:1 == 3
let cmd = 'vsplit'
endif
endif
if a:0>1
let link = 'diary:'.a:2
else
let link = 'diary:'.vimwiki#diary#diary_date_link()
endif
call vimwiki#base#open_link(cmd, link, s:diary_index(wiki_nr))
endfunction
function! vimwiki#diary#goto_diary_index(wnum) abort
" if wnum = 0 the current wiki is used
if a:wnum == 0
let idx = vimwiki#vars#get_bufferlocal('wiki_nr')
if idx < 0 " not in a wiki
let idx = 0
endif
else
let idx = a:wnum - 1 " convert to 0 based counting
endif
if a:wnum > vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
return
endif
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
if vimwiki#vars#get_wikilocal('auto_diary_index')
call vimwiki#diary#generate_diary_section()
write! " save changes
endif
endfunction
function! vimwiki#diary#goto_next_day() abort
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == (len(links) - 1)
return
endif
if idx != -1 && idx < len(links) - 1
let link = 'diary:'.links[idx+1]
else
" goto today
let link = 'diary:'.vimwiki#diary#diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction
function! vimwiki#diary#goto_prev_day() abort
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == 0
return
endif
if idx > 0
let link = 'diary:'.links[idx-1]
else
" goto today
let link = 'diary:'.vimwiki#diary#diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction
function! vimwiki#diary#generate_diary_section() abort
let GeneratorDiary = copy(l:)
function! GeneratorDiary.f() abort
let lines = []
let links_with_captions = s:read_captions(vimwiki#diary#get_diary_files())
let g_files = s:group_links(links_with_captions)
let g_keys = s:sort(keys(g_files))
for year in g_keys
if len(lines) > 0
call add(lines, '')
endif
call add(lines, substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , ''))
for month in s:sort(keys(g_files[year]))
call add(lines, '')
call add(lines, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'),
\ '__Header__', s:get_month_name(month), ''))
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
call add(lines, '')
endfor
endif
for [fl, captions] in s:sort(items(g_files[year][month]))
let topcap = captions['top']
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
if empty(topcap) " When using markdown syntax, we should ensure we always have a link description.
let topcap = fl
endif
endif
if empty(topcap)
let top_link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
else
let top_link_tpl = link_tpl
endif
let bullet = vimwiki#lst#default_symbol().' '
let entry = substitute(top_link_tpl, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', topcap, '')
" If single H1 then that will be used as the description for the link to the file
" if multple H1 then the filename will be used as the description for the link to the
" file and multiple H1 headers will be indented by shiftwidth
call add(lines, repeat(' ', vimwiki#lst#get_list_margin()).bullet.entry)
let startindent = repeat(' ', vimwiki#lst#get_list_margin())
let indentstring = repeat(' ', vimwiki#u#sw())
for [depth, subcap] in captions['rest']
if empty(subcap)
continue
endif
let entry = substitute(link_tpl, '__LinkUrl__', fl.'#'.subcap, '')
let entry = substitute(entry, '__LinkDescription__', subcap, '')
" if single H1 then depth H2=0, H3=1, H4=2, H5=3, H6=4
" if multiple H1 then depth H1= 0, H2=1, H3=2, H4=3, H5=4, H6=5
" indent subsequent headers levels by shiftwidth
call add(lines, startindent.repeat(indentstring, depth+1).bullet.entry)
endfor
endfor
endfor
endfor
return lines
endfunction
let current_file = vimwiki#path#path_norm(expand('%:p'))
let diary_file = vimwiki#path#path_norm(s:diary_index())
if vimwiki#path#is_equal(current_file, diary_file)
let content_rx = '^\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)\|'.
\ '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
call vimwiki#base#update_listing_in_buffer(
\ GeneratorDiary,
\ vimwiki#vars#get_wikilocal('diary_header'),
\ content_rx,
\ 1,
\ 1,
\ 1)
else
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
endif
endfunction
" Callback function for Calendar.vim
function! vimwiki#diary#calendar_action(day, month, year, week, dir) abort
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let link = a:year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir ==? 'V'
vsplit
else
split
endif
else
wincmd p
if !&hidden && &modified
new
endif
endif
call vimwiki#diary#make_note(0, 0, link)
endfunction
function! vimwiki#diary#calendar_sign(day, month, year) abort
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,162 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Description: Link functions for markdown syntax
" Home: https://github.com/vimwiki/vimwiki/
function! s:safesubstitute(text, search, replace, mode) abort
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
return substitute(a:text, a:search, escaped, a:mode)
endfunction
function! vimwiki#markdown_base#scan_reflinks() abort
let mkd_refs = {}
" construct list of references using vimgrep
try
" Why noautocmd? Because https://github.com/vimwiki/vimwiki/issues/121
noautocmd execute 'vimgrep #'.vimwiki#vars#get_syntaxlocal('rxMkdRef').'#j %'
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
"Ignore it, and move on to the next file
endtry
for d in getqflist()
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr'))
let url = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchUrl'))
if descr !=? '' && url !=? ''
let mkd_refs[descr] = url
endif
endfor
call vimwiki#vars#set_bufferlocal('markdown_refs', mkd_refs)
return mkd_refs
endfunction
" try markdown reference links
function! vimwiki#markdown_base#open_reflink(link) abort
" echom "vimwiki#markdown_base#open_reflink"
let link = a:link
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
if has_key(mkd_refs, link)
let url = mkd_refs[link]
call vimwiki#base#system_open_link(url)
return 1
else
return 0
endif
endfunction
function! s:normalize_link_syntax_n() abort
let lnum = line('.')
" try WikiIncl
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl'))
if !empty(lnk)
" NO-OP !!
return
endif
" try WikiLink0: replace with WikiLink1
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
\ vimwiki#vars#get_syntaxlocal('WikiLink1Template2'))
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'), sub)
return
endif
" try WikiLink1: replace with WikiLink0
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), sub)
return
endif
" try Weblink
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'),
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchDescr'),
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'), sub)
return
endif
" try Word (any characters except separators)
" rxWord is less permissive than rxWikiLinkUrl which is used in
" normalize_link_syntax_v
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWord'))
if !empty(lnk)
if vimwiki#base#is_diary_file(expand('%:p'))
let sub = vimwiki#base#normalize_link_in_diary(lnk)
else
let sub = vimwiki#base#normalize_link_helper(lnk,
\ vimwiki#vars#get_global('rxWord'), '',
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
endif
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
return
endif
endfunction
function! s:normalize_link_syntax_v() abort
let lnum = line('.')
let sel_save = &selection
let &selection = 'old'
let rv = @"
let rt = getregtype('"')
let done = 0
try
norm! gvy
let visual_selection = @"
if vimwiki#base#is_diary_file(expand('%:p'))
let link = vimwiki#base#normalize_link_in_diary(visual_selection)
else
let link = s:safesubstitute(vimwiki#vars#get_syntaxlocal('Weblink1Template'),
\ '__LinkUrl__', visual_selection, '')
endif
" replace spaces with new character if option is set
let link = substitute(link, '\s', vimwiki#vars#get_wikilocal('links_space_char'), 'g')
let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
call setreg('"', substitute(link, '\n', '', ''), visualmode())
" paste result
norm! `>""pgvd
finally
call setreg('"', rv, rt)
let &selection = sel_save
endtry
endfunction
function! vimwiki#markdown_base#normalize_link(is_visual_mode) abort
if 0
" Syntax-specific links
else
if !a:is_visual_mode
call s:normalize_link_syntax_n()
elseif line("'<") == line("'>")
" action undefined for multi-line visual mode selections
call s:normalize_link_syntax_v()
endif
endif
endfunction

View file

@ -1,210 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Description: Path manipulation functions
" Home: https://github.com/vimwiki/vimwiki/
function! vimwiki#path#chomp_slash(str) abort
return substitute(a:str, '[/\\]\+$', '', '')
endfunction
" Define path-compare function, either case-sensitive or not, depending on OS.
if vimwiki#u#is_windows()
function! vimwiki#path#is_equal(p1, p2) abort
return a:p1 ==? a:p2
endfunction
else
function! vimwiki#path#is_equal(p1, p2) abort
return a:p1 ==# a:p2
endfunction
endif
" collapse sections like /a/b/../c to /a/c and /a/b/./c to /a/b/c
function! vimwiki#path#normalize(path) abort
let path = a:path
while 1
let intermediateResult = substitute(path, '/[^/]\+/\.\.', '', '')
let result = substitute(intermediateResult, '/\./', '/', '')
if result ==# path
break
endif
let path = result
endwhile
return result
endfunction
function! vimwiki#path#path_norm(path) abort
" /-slashes
if a:path !~# '^scp:'
let path = substitute(a:path, '\', '/', 'g')
" treat multiple consecutive slashes as one path separator
let path = substitute(path, '/\+', '/', 'g')
" ensure that we are not fooled by a symbolic link
return resolve(path)
else
return a:path
endif
endfunction
function! vimwiki#path#is_link_to_dir(link) abort
" Check if link is to a directory.
" It should be ended with \ or /.
return a:link =~# '\m[/\\]$'
endfunction
function! vimwiki#path#abs_path_of_link(link) abort
return vimwiki#path#normalize(expand('%:p:h').'/'.a:link)
endfunction
" return longest common path prefix of 2 given paths.
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
function! vimwiki#path#path_common_pfx(path1, path2) abort
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
let idx = 0
let minlen = min([len(p1), len(p2)])
while (idx < minlen) && vimwiki#path#is_equal(p1[idx], p2[idx])
let idx = idx + 1
endwhile
if idx == 0
return ''
else
return join(p1[: idx-1], '/')
endif
endfunction
function! vimwiki#path#wikify_path(path) abort
let result = resolve(fnamemodify(a:path, ':p'))
if vimwiki#u#is_windows()
let result = substitute(result, '\\', '/', 'g')
endif
let result = vimwiki#path#chomp_slash(result)
return result
endfunction
function! vimwiki#path#current_wiki_file() abort
return vimwiki#path#wikify_path(expand('%:p'))
endfunction
" Returns: the relative path from a:dir to a:file
function! vimwiki#path#relpath(dir, file) abort
" Check if dir here ('.') -> return file
if empty(a:dir) || a:dir =~# '^\.[/\\]\?$'
return a:file
endif
let result = []
if vimwiki#u#is_windows()
" TODO temporary fix see #478
" not sure why paths get converted back to using forward slash
" when passed to the function in the form C:\path\to\file
let dir = substitute(a:dir, '/', '\', 'g')
let file = substitute(a:file, '/', '\', 'g')
let dir = split(dir, '\')
let file = split(file, '\')
else
let dir = split(a:dir, '/')
let file = split(a:file, '/')
endif
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
call remove(dir, 0)
call remove(file, 0)
endwhile
if empty(dir) && empty(file)
if vimwiki#u#is_windows()
" TODO temporary fix see #478
return '.\'
else
return './'
endif
endif
for segment in dir
let result += ['..']
endfor
for segment in file
let result += [segment]
endfor
if vimwiki#u#is_windows()
" TODO temporary fix see #478
let result_path = join(result, '\')
if a:file =~? '\m\\$'
let result_path .= '\'
endif
else
let result_path = join(result, '/')
if a:file =~? '\m/$'
let result_path .= '/'
endif
endif
return result_path
endfunction
" If the optional argument provided and nonzero,
" it will ask before creating a directory
" Returns: 1 iff directory exists or successfully created
function! vimwiki#path#mkdir(path, ...) abort
let path = expand(a:path)
if path =~# '^scp:'
" we can not do much, so let's pretend everything is ok
return 1
endif
if isdirectory(path)
return 1
else
if !exists('*mkdir')
return 0
endif
let path = vimwiki#path#chomp_slash(path)
if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc'))
let path = iconv(path, &encoding, vimwiki#vars#get_global('w32_dir_enc'))
endif
if a:0 && a:1 && input('Vimwiki: Make new directory: '.path."\n [y]es/[N]o? ") !~? '^y'
return 0
endif
call mkdir(path, 'p')
return 1
endif
endfunction
function! vimwiki#path#is_absolute(path) abort
if vimwiki#u#is_windows()
return a:path =~? '\m^\a:'
else
return a:path =~# '\m^/\|\~/'
endif
endfunction
" Combine a directory and a file into one path, doesn't generate duplicate
" path separator in case the directory is also having an ending / or \. This
" is because on windows ~\vimwiki//.tags is invalid but ~\vimwiki/.tags is a
" valid path.
if vimwiki#u#is_windows()
function! vimwiki#path#join_path(directory, file) abort
let directory = vimwiki#path#chomp_slash(a:directory)
let file = substitute(a:file, '\m^[\\/]\+', '', '')
return directory . '/' . file
endfunction
else
function! vimwiki#path#join_path(directory, file) abort
let directory = substitute(a:directory, '\m/\+$', '', '')
let file = substitute(a:file, '\m^/\+', '', '')
return directory . '/' . file
endfunction
endif

View file

@ -1,187 +0,0 @@
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;;
margin: 2em 4em 2em 4em;
font-size: 120%;
line-height: 130%;
}
h1, h2, h3, h4, h5, h6 {
font-weight: bold;
line-height:100%;
margin-top: 1.5em;
margin-bottom: 0.5em;
}
h1 {font-size: 2em; color: #000000;}
h2 {font-size: 1.8em; color: #404040;}
h3 {font-size: 1.6em; color: #707070;}
h4 {font-size: 1.4em; color: #909090;}
h5 {font-size: 1.2em; color: #989898;}
h6 {font-size: 1em; color: #9c9c9c;}
p, pre, blockquote, table, ul, ol, dl {
margin-top: 1em;
margin-bottom: 1em;
}
ul ul, ul ol, ol ol, ol ul {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
li { margin: 0.3em auto; }
ul {
margin-left: 2em;
padding-left: 0;
}
dt { font-weight: bold; }
img { border: none; }
pre {
border-left: 5px solid #dcdcdc;
background-color: #f5f5f5;
padding-left: 1em;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
font-size: 0.8em;
border-radius: 6px;
}
p > a {
color: white;
text-decoration: none;
font-size: 0.7em;
padding: 3px 6px;
border-radius: 3px;
background-color: #1e90ff;
text-transform: uppercase;
font-weight: bold;
}
p > a:hover {
color: #dcdcdc;
background-color: #484848;
}
li > a {
color: #1e90ff;
font-weight: bold;
text-decoration: none;
}
li > a:hover { color: #ff4500; }
blockquote {
color: #686868;
font-size: 0.8em;
line-height: 120%;
padding: 0.8em;
border-left: 5px solid #dcdcdc;
}
th, td {
border: 1px solid #ccc;
padding: 0.3em;
}
th { background-color: #f0f0f0; }
hr {
border: none;
border-top: 1px solid #ccc;
width: 100%;
}
del {
text-decoration: line-through;
color: #777777;
}
.toc li { list-style-type: none; }
.todo {
font-weight: bold;
background-color: #ff4500 ;
color: white;
font-size: 0.8em;
padding: 3px 6px;
border-radius: 3px;
}
.justleft { text-align: left; }
.justright { text-align: right; }
.justcenter { text-align: center; }
.center {
margin-left: auto;
margin-right: auto;
}
.tag {
background-color: #eeeeee;
font-family: monospace;
padding: 2px;
}
.header a {
text-decoration: none;
color: inherit;
}
/* classes for items of todo lists */
.rejected {
/* list-style: none; */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAAACXBIWXMAAADFAAAAxQEdzbqoAAAAB3RJTUUH4QgEFhAtuWgv9wAAAPZQTFRFmpqam5iYnJaWnJeXnpSUn5OTopCQpoqKpouLp4iIqIiIrYCAt3V1vW1tv2xsmZmZmpeXnpKS/x4e/x8f/yAg/yIi/yQk/yUl/yYm/ygo/ykp/yws/zAw/zIy/zMz/zQ0/zU1/zY2/zw8/0BA/0ZG/0pK/1FR/1JS/1NT/1RU/1VV/1ZW/1dX/1pa/15e/19f/2Zm/2lp/21t/25u/3R0/3p6/4CA/4GB/4SE/4iI/46O/4+P/52d/6am/6ur/66u/7Oz/7S0/7e3/87O/9fX/9zc/93d/+Dg/+vr/+3t/+/v//Dw//Ly//X1//f3//n5//z8////gzaKowAAAA90Uk5T/Pz8/Pz8/Pz8/Pz8/f39ppQKWQAAAAFiS0dEEnu8bAAAAACuSURBVAhbPY9ZF4FQFEZPSKbIMmWep4gMGTKLkIv6/3/GPbfF97b3w17rA0kQOPgvAeHW6uJ6+5h7HqLdwowgOzejXRXBdx6UdSru216xuOMBHHNU0clTzeSUA6EhF8V8kqroluMiU6HKcuf4phGPr1o2q9kYZWwNq1qfRRmTaXpqsyjj17KkWCxKBUBgXWueHIyiAIg18gsse4KHkLF5IKIY10WQgv7fOy4ST34BRiopZ8WLNrgAAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: 0 .2em;
padding-left: 1.5em;
}
.done0 {
/* list-style: none; */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .2em;
padding-left: 1.5em;
}
.done1 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
padding-left: 1.5em;
}
.done2 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: 0 .15em;
padding-left: 1.5em;
}
.done3 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .15em;
padding-left: 1.5em;
}
.done4 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
padding-left: 1.5em;
}
code {
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
padding: 0px 3px;
display: inline-block;
color: #52595d;
border: 1px solid #ccc;
background-color: #f9f9f9;
}

View file

@ -1,405 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
let s:TAGS_METADATA_FILE_NAME = '.vimwiki_tags'
" Tags metadata in-memory format:
" metadata := { 'pagename': [entries, ...] }
" entry := { 'tagname':..., 'lineno':..., 'link':... }
" Tags metadata in-file format:
"
" Is based on CTags format (see |tags-file-format|).
"
" {tagaddress} is set to lineno. We'll let vim search by exact line number; we
" can afford that, we assume metadata file is always updated before use.
"
" Pagename and link are not saved in standard ctags fields, so we'll add
" an optional field, "vimwiki:". In this field, we encode tab-separated values
" of missing parameters -- "pagename" and "link".
" Update tags metadata.
" a:full_rebuild == 1: re-scan entire wiki
" a:full_rebuild == 0: only re-scan current page
" a:all_files == '': only if the file is newer than .tags
function! vimwiki#tags#update_tags(full_rebuild, all_files) abort
let all_files = a:all_files !=? ''
if !a:full_rebuild
" Updating for one page (current)
let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r')
" Collect tags in current file
let tags = s:scan_tags(getline(1, '$'), page_name)
" Load metadata file
let metadata = s:load_tags_metadata()
" Drop old tags
let metadata = s:remove_page_from_tags(metadata, page_name)
" Merge in the new ones
let metadata = s:merge_tags(metadata, page_name, tags)
" Save
call s:write_tags_metadata(metadata)
else " full rebuild
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let tags_file_last_modification = getftime(vimwiki#tags#metadata_file_path())
let metadata = s:load_tags_metadata()
for file in files
if all_files || getftime(file) >= tags_file_last_modification
let subdir = vimwiki#base#subdir(wiki_base_dir, file)
let page_name = subdir . fnamemodify(file, ':t:r')
let tags = s:scan_tags(readfile(file), page_name)
let metadata = s:remove_page_from_tags(metadata, page_name)
let metadata = s:merge_tags(metadata, page_name, tags)
endif
endfor
call s:write_tags_metadata(metadata)
endif
endfunction
function! s:safesubstitute(text, search, replace, mode) abort
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
return substitute(a:text, a:search, escaped, a:mode)
endfunction
" Scans the list of text lines (argument) and produces tags metadata as a list of tag entries.
function! s:scan_tags(lines, page_name) abort
let entries = []
" Code wireframe to scan for headers -- borrowed from
" vimwiki#base#get_anchors(), with minor modifications.
let rxheader = vimwiki#vars#get_syntaxlocal('header_search')
let rxtag = vimwiki#vars#get_syntaxlocal('tag_search')
let anchor_level = ['', '', '', '', '', '', '']
let current_complete_anchor = ''
let PROXIMITY_LINES_NR = 2
let header_line_nr = - (2 * PROXIMITY_LINES_NR)
for line_nr in range(1, len(a:lines))
let line = a:lines[line_nr - 1]
" ignore verbatim blocks
if vimwiki#u#is_codeblock(line_nr)
continue
endif
" process headers
let h_match = matchlist(line, rxheader)
if !empty(h_match) " got a header
let header_line_nr = line_nr
let header = vimwiki#u#trim(h_match[2])
let level = len(h_match[1])
let anchor_level[level-1] = header
for l in range(level, 6)
let anchor_level[l] = ''
endfor
if level == 1
let current_complete_anchor = header
else
let current_complete_anchor = ''
for l in range(level-1)
if anchor_level[l] !=? ''
let current_complete_anchor .= anchor_level[l].'#'
endif
endfor
let current_complete_anchor .= header
endif
continue " tags are not allowed in headers
endif
" Scan line for tags. There can be many of them.
let str = line
while 1
let tag_group = matchstr(str, rxtag)
if tag_group ==? ''
break
endif
let tagend = matchend(str, rxtag)
let str = str[(tagend):]
for tag in split(tag_group, ':')
" Create metadata entry
let entry = {}
let entry.tagname = tag
let entry.lineno = line_nr
if line_nr <= PROXIMITY_LINES_NR && header_line_nr < 0
" Tag appeared at the top of the file
let entry.link = a:page_name
elseif line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
" Tag appeared right below a header
let entry.link = a:page_name . '#' . current_complete_anchor
else
" Tag stands on its own
let entry.link = a:page_name . '#' . tag
endif
call add(entries, entry)
endfor
endwhile
endfor " loop over lines
return entries
endfunction
" Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'),
\ s:TAGS_METADATA_FILE_NAME), ':p')
endfunction
" Loads tags metadata from file, returns a dictionary
function! s:load_tags_metadata() abort
let metadata_path = vimwiki#tags#metadata_file_path()
if !filereadable(metadata_path)
return {}
endif
let metadata = {}
for line in readfile(metadata_path)
if line =~# '^!_TAG_.*$'
continue
endif
let parts = matchlist(line, '^\(.\{-}\);"\(.*\)$')
if parts[0] ==? '' || parts[1] ==? '' || parts[2] ==? ''
throw 'VimwikiTags1: Metadata file corrupted'
endif
let std_fields = split(parts[1], '\t')
if len(std_fields) != 3
throw 'VimwikiTags2: Metadata file corrupted'
endif
let vw_part = parts[2]
if vw_part[0] !=? "\t"
throw 'VimwikiTags3: Metadata file corrupted'
endif
let vw_fields = split(vw_part[1:], "\t")
if len(vw_fields) != 1 || vw_fields[0] !~# '^vimwiki:'
throw 'VimwikiTags4: Metadata file corrupted'
endif
let vw_data = substitute(vw_fields[0], '^vimwiki:', '', '')
let vw_data = substitute(vw_data, '\\n', "\n", 'g')
let vw_data = substitute(vw_data, '\\r', "\r", 'g')
let vw_data = substitute(vw_data, '\\t', "\t", 'g')
let vw_data = substitute(vw_data, '\\\\', "\\", 'g')
let vw_fields = split(vw_data, "\t")
if len(vw_fields) != 2
throw 'VimwikiTags5: Metadata file corrupted'
endif
let pagename = vw_fields[0]
let entry = {}
let entry.tagname = std_fields[0]
let entry.lineno = std_fields[2]
let entry.link = vw_fields[1]
if has_key(metadata, pagename)
call add(metadata[pagename], entry)
else
let metadata[pagename] = [entry]
endif
endfor
return metadata
endfunction
" Removes all entries for given page from metadata in-place. Returns updated
" metadata (just in case).
function! s:remove_page_from_tags(metadata, page_name) abort
if has_key(a:metadata, a:page_name)
call remove(a:metadata, a:page_name)
return a:metadata
else
return a:metadata
endif
endfunction
" Merges metadata of one file into a:metadata
function! s:merge_tags(metadata, pagename, file_metadata) abort
let metadata = a:metadata
let metadata[a:pagename] = a:file_metadata
return metadata
endfunction
" Compares two actual lines from tags file. Return value is in strcmp style.
" See help on sort() -- that's what this function is going to be used for.
" See also s:write_tags_metadata below -- that's where we compose these tags
" file lines.
"
" This function is needed for tags sorting, since plain sort() compares line
" numbers as strings, not integers, and so, for example, tag at line 14
" preceeds the same tag on the same page at line 9. (Because string "14" is
" alphabetically 'less than' string "9".)
function! s:tags_entry_cmp(i1, i2) abort
let items = []
for orig_item in [a:i1, a:i2]
let fields = split(orig_item, "\t")
let item = {}
let item.text = fields[0]."\t".fields[1]
let item.lineno = 0 + matchstr(fields[2], '\m\d\+')
call add(items, item)
endfor
if items[0].text ># items[1].text
return 1
elseif items[0].text <# items[1].text
return -1
elseif items[0].lineno > items[1].lineno
return 1
elseif items[0].lineno < items[1].lineno
return -1
else
return 0
endif
endfunction
" Saves metadata object into a file. Throws exceptions in case of problems.
function! s:write_tags_metadata(metadata) abort
let metadata_path = vimwiki#tags#metadata_file_path()
let tags = []
for pagename in keys(a:metadata)
for entry in a:metadata[pagename]
let entry_data = pagename . "\t" . entry.link
let entry_data = substitute(entry_data, "\\", '\\\\', 'g')
let entry_data = substitute(entry_data, "\t", '\\t', 'g')
let entry_data = substitute(entry_data, "\r", '\\r', 'g')
let entry_data = substitute(entry_data, "\n", '\\n', 'g')
call add(tags,
\ entry.tagname . "\t"
\ . pagename . vimwiki#vars#get_wikilocal('ext') . "\t"
\ . entry.lineno
\ . ';"'
\ . "\t" . 'vimwiki:' . entry_data
\)
endfor
endfor
call sort(tags, 's:tags_entry_cmp')
let tag_comments = [
\ "!_TAG_PROGRAM_VERSION\t2.5",
\ "!_TAG_PROGRAM_URL\thttps://github.com/vimwiki/vimwiki",
\ "!_TAG_PROGRAM_NAME\tVimwiki Tags",
\ "!_TAG_PROGRAM_AUTHOR\tVimwiki",
\ "!_TAG_OUTPUT_MODE\tvimwiki-tags",
\ "!_TAG_FILE_SORTED\t1",
\ "!_TAG_FILE_FORMAT\t2",
\ ]
for c in tag_comments
call insert(tags, c)
endfor
call writefile(tags, metadata_path)
endfunction
" Returns list of unique tags found in the .tags file
function! vimwiki#tags#get_tags() abort
let metadata = s:load_tags_metadata()
let tags = {}
for entries in values(metadata)
for entry in entries
let tags[entry.tagname] = 1
endfor
endfor
return keys(tags)
endfunction
" Similar to vimwiki#base#generate_links. In the current buffer, appends
" tags and references to all their instances. If no arguments (tags) are
" specified, outputs all tags.
function! vimwiki#tags#generate_tags(create, ...) abort
let specific_tags = a:000
let header_level = vimwiki#vars#get_global('tags_header_level')
" use a dictionary function for closure like capability
" copy all local variables into dict (add a: if arguments are needed)
let GeneratorTags = copy(l:)
function! GeneratorTags.f() abort
let need_all_tags = empty(self.specific_tags)
let metadata = s:load_tags_metadata()
" make a dictionary { tag_name: [tag_links, ...] }
let tags_entries = {}
for entries in values(metadata)
for entry in entries
if has_key(tags_entries, entry.tagname)
call add(tags_entries[entry.tagname], entry.link)
else
let tags_entries[entry.tagname] = [entry.link]
endif
endfor
unlet entry " needed for older vims with sticky type checking since name is reused
endfor
let lines = []
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' '
for tagname in sort(keys(tags_entries))
if need_all_tags || index(self.specific_tags, tagname) != -1
if len(lines) > 0
call add(lines, '')
endif
let tag_tpl = printf('rxH%d_Template', self.header_level + 1)
call add(lines, s:safesubstitute(vimwiki#vars#get_syntaxlocal(tag_tpl), '__Header__', tagname, ''))
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
call add(lines, '')
endfor
endif
for taglink in sort(tags_entries[tagname])
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink3Template')
let link_infos = vimwiki#base#resolve_link(taglink)
if empty(link_infos.anchor)
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', taglink, '')
let entry = s:safesubstitute(entry, '__LinkDescription__', taglink, '')
else
let link_caption = split(link_infos.anchor, '#', 0)[-1]
let link_text = split(taglink, '#', 1)[0]
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', link_text, '')
let entry = s:safesubstitute(entry, '__LinkAnchor__', link_infos.anchor, '')
let entry = s:safesubstitute(entry, '__LinkDescription__', link_caption, '')
endif
call add(lines, bullet . entry)
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
call add(lines, bullet . substitute(link_tpl, '__LinkUrl__', taglink, ''))
endif
endfor
endif
endfor
return lines
endfunction
let tag_match = printf('rxH%d', header_level + 1)
let links_rx = '^\%('.vimwiki#vars#get_syntaxlocal(tag_match).'\)\|'.
\ '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
call vimwiki#base#update_listing_in_buffer(
\ GeneratorTags,
\ vimwiki#vars#get_global('tags_header'),
\ links_rx,
\ line('$')+1,
\ header_level,
\ a:create)
endfunction
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort
" We can safely ignore args if we use -custom=complete option, Vim engine
" will do the job of filtering.
let taglist = vimwiki#tags#get_tags()
return join(taglist, "\n")
endfunction

View file

@ -1,861 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Description: Tables
" | Easily | manageable | text | tables | ! |
" |--------|------------|-------|--------|---------|
" | Have | fun! | Drink | tea | Period. |
"
" Home: https://github.com/vimwiki/vimwiki/
if exists('g:loaded_vimwiki_tbl_auto') || &compatible
finish
endif
let g:loaded_vimwiki_tbl_auto = 1
let s:textwidth = &textwidth
function! s:rxSep() abort
return vimwiki#vars#get_syntaxlocal('rxTableSep')
endfunction
function! s:wide_len(str) abort
" vim73 has new function that gives correct string width.
if exists('*strdisplaywidth')
return strdisplaywidth(a:str)
endif
" get str display width in vim ver < 7.2
if !vimwiki#vars#get_global('CJK_length')
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
else
let savemodified = &modified
let save_cursor = getpos('.')
exe "norm! o\<esc>"
call setline(line('.'), a:str)
let ret = virtcol('$') - 1
d
call setpos('.', save_cursor)
let &modified = savemodified
endif
return ret
endfunction
function! s:cell_splitter() abort
return '\s*'.s:rxSep().'\s*'
endfunction
function! s:sep_splitter() abort
return '-'.s:rxSep().'-'
endfunction
function! s:is_table(line) abort
return s:is_separator(a:line) ||
\ (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
endfunction
function! s:is_separator(line) abort
return a:line =~# '^\s*'.s:rxSep().'\(:\=--\+:\='.s:rxSep().'\)\+\s*$'
endfunction
function! s:is_separator_tail(line) abort
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction
function! s:is_last_column(lnum, cnum) abort
let line = strpart(getline(a:lnum), a:cnum - 1)
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
endfunction
function! s:is_first_column(lnum, cnum) abort
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
return line =~# '^\s*$' ||
\ (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction
function! s:count_separators_up(lnum) abort
let lnum = a:lnum - 1
while lnum > 1
if !s:is_separator(getline(lnum))
break
endif
let lnum -= 1
endwhile
return (a:lnum-lnum)
endfunction
function! s:count_separators_down(lnum) abort
let lnum = a:lnum + 1
while lnum < line('$')
if !s:is_separator(getline(lnum))
break
endif
let lnum += 1
endwhile
return (lnum-a:lnum)
endfunction
function! s:create_empty_row(cols) abort
let row = s:rxSep()
let cell = ' '.s:rxSep()
for c in range(a:cols)
let row .= cell
endfor
return row
endfunction
function! s:create_row_sep(cols) abort
let row = s:rxSep()
let cell = '---'.s:rxSep()
for c in range(a:cols)
let row .= cell
endfor
return row
endfunction
function! vimwiki#tbl#get_cells(line, ...) abort
let result = []
let state = 'NONE'
let cell_start = 0
let quote_start = 0
let len = strlen(a:line) - 1
" 'Simple' FSM
while state !=# 'CELL'
if quote_start != 0 && state !=# 'CELL'
let state = 'CELL'
endif
for idx in range(quote_start, len)
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state ==# 'NONE'
if ch ==# '|'
let cell_start = idx + 1
let state = 'CELL'
endif
elseif state ==# 'CELL'
if ch ==# '[' || ch ==# '{'
let state = 'BEFORE_QUOTE_START'
let quote_start = idx
elseif ch ==# '|'
let cell = strpart(a:line, cell_start, idx - cell_start)
if a:0 && a:1
let cell = substitute(cell, '^ \(.*\) $', '\1', '')
else
let cell = vimwiki#u#trim(cell)
endif
call add(result, cell)
let cell_start = idx + 1
endif
elseif state ==# 'BEFORE_QUOTE_START'
if ch ==# '[' || ch ==# '{'
let state = 'QUOTE'
let quote_start = idx
else
let state = 'CELL'
endif
elseif state ==# 'QUOTE'
if ch ==# ']' || ch ==# '}'
let state = 'BEFORE_QUOTE_END'
endif
elseif state ==# 'BEFORE_QUOTE_END'
if ch ==# ']' || ch ==# '}'
let state = 'CELL'
endif
endif
endfor
if state ==# 'NONE'
break
endif
endwhile
return result
endfunction
function! s:col_count(lnum) abort
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
endfunction
function! s:get_indent(lnum, depth) abort
if !s:is_table(getline(a:lnum))
return
endif
let indent = 0
let lnum = a:lnum - 1
while lnum > 1
let line = getline(lnum)
if !s:is_table(line)
let indent = indent(lnum+1)
break
endif
let lnum -= 1
if a:depth > 0 && lnum < a:lnum - a:depth
break
endif
endwhile
return indent
endfunction
function! s:get_rows(lnum, ...) abort
if !s:is_table(getline(a:lnum))
return
endif
let rows = []
let lnum = a:lnum - 1
let depth = a:0 > 0 ? a:1 : 0
let ldepth = 0
while lnum >= 1 && (depth == 0 || ldepth < depth)
let line = getline(lnum)
if s:is_table(line)
call insert(rows, [lnum, line])
else
break
endif
let lnum -= 1
let ldepth += 1
endwhile
let lnum = a:lnum
while lnum <= line('$')
let line = getline(lnum)
if s:is_table(line)
call add(rows, [lnum, line])
else
break
endif
if depth > 0
break
endif
let lnum += 1
endwhile
return rows
endfunction
function! s:get_cell_aligns(lnum, ...) abort
let aligns = {}
let depth = a:0 > 0 ? a:1 : 0
for [lnum, row] in s:get_rows(a:lnum, depth)
if s:is_separator(row)
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let cell = cells[idx]
if cell =~# '^--\+:'
let aligns[idx] = 'right'
elseif cell =~# '^:--\+:'
let aligns[idx] = 'center'
else
let aligns[idx] = 'left'
endif
endfor
else
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
if !has_key(aligns, idx)
let aligns[idx] = 'left'
endif
endfor
endif
endfor
return aligns
endfunction
function! s:get_cell_aligns_fast(rows) abort
let aligns = {}
let clen = 0
for [lnum, row] in a:rows
if s:is_separator(row)
return s:get_cell_aligns(lnum, 1)
endif
let cells = vimwiki#tbl#get_cells(row, 1)
let clen = len(cells)
for idx in range(clen)
let cell = cells[idx]
if !has_key(aligns, idx)
let cs = matchlist(cell, '^\(\s*\)[^[:space:]].\{-}\(\s*\)$')
if !empty(cs)
let lstart = len(cs[1])
let lend = len(cs[2])
if lstart > 0 && lend > 0
let aligns[idx] = 'center'
elseif lend > 0
let aligns[idx] = 'left'
elseif lstart > 0
let aligns[idx] = 'right'
endif
endif
endif
endfor
endfor
for idx in range(clen)
if !has_key(aligns, idx)
return {}
endif
endfor
return aligns
endfunction
function! s:get_cell_max_lens(lnum, ...) abort
let max_lens = {}
let rows = a:0 > 2 ? a:3 : s:get_rows(a:lnum)
for [lnum, row] in rows
if s:is_separator(row)
continue
endif
let cells = a:0 > 1 ? a:1[lnum - a:2] : vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let value = cells[idx]
if has_key(max_lens, idx)
let max_lens[idx] = max([s:wide_len(value), max_lens[idx]])
else
let max_lens[idx] = s:wide_len(value)
endif
endfor
endfor
return max_lens
endfunction
function! s:get_aligned_rows(lnum, col1, col2, depth) abort
let rows = []
let aligns = {}
let startlnum = 0
let cells = []
let max_lens = {}
let check_all = 1
if a:depth > 0
let rows = s:get_rows(a:lnum, a:depth)
let startlnum = rows[0][0]
let lrows = len(rows)
if lrows == a:depth + 1
let line = rows[-1][1]
if !s:is_separator(line)
let lcells = vimwiki#tbl#get_cells(line)
let lclen = len(lcells)
let lmax_lens = repeat([0], lclen)
let laligns = repeat(['left'], lclen)
let rows[-1][1] = s:fmt_row(lcells, lmax_lens, laligns, 0, 0)
endif
let i = 1
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, i != lrows - 1))
let i += 1
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
" user option not to expand last call
if vimwiki#vars#get_global('table_reduce_last_col')
let last_index = keys(max_lens)[-1]
let max_lens[last_index] = 1
endif
let fst_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows[0:0])
let check_all = max_lens != fst_lens
let aligns = s:get_cell_aligns_fast(rows[0:-2])
let rows[-1][1] = line
endif
endif
if check_all
" all the table must be re-formatted
let rows = s:get_rows(a:lnum)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row))
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
" user option not to expand last call
if vimwiki#vars#get_global('table_reduce_last_col')
let last_index = keys(max_lens)[-1]
let max_lens[last_index] = 1
endif
endif
if empty(aligns)
let aligns = s:get_cell_aligns(a:lnum)
endif
let result = []
for [lnum, row] in rows
if s:is_separator(row)
let new_row = s:fmt_sep(max_lens, aligns, a:col1, a:col2)
else
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, aligns, a:col1, a:col2)
endif
call add(result, [lnum, new_row])
endfor
return result
endfunction
" Number of the current column. Starts from 0.
function! s:cur_column() abort
let line = getline('.')
if !s:is_table(line)
return -1
endif
" TODO: do we need conditional: if s:is_separator(line)
let curs_pos = col('.')
let mpos = match(line, s:rxSep(), 0)
let col = -1
while mpos < curs_pos && mpos != -1
let mpos = match(line, s:rxSep(), mpos+1)
if mpos != -1
let col += 1
endif
endwhile
return col
endfunction
function! s:fmt_cell(cell, max_len, align) abort
let cell = ' '.a:cell.' '
let diff = a:max_len - s:wide_len(a:cell)
if diff == 0 && empty(a:cell)
let diff = 1
endif
if a:align ==# 'left'
let cell .= repeat(' ', diff)
elseif a:align ==# 'right'
let cell = repeat(' ',diff).cell
else
let cell = repeat(' ',diff/2).cell.repeat(' ',diff-diff/2)
endif
return cell
endfunction
function! s:fmt_row(cells, max_lens, aligns, col1, col2) abort
let new_line = s:rxSep()
for idx in range(len(a:cells))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
let value = a:cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx], a:aligns[idx]).s:rxSep()
endfor
let idx = len(a:cells)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx], a:aligns[idx]).s:rxSep()
let idx += 1
endwhile
return new_line
endfunction
function! s:fmt_cell_sep(max_len, align) abort
let cell = ''
if a:max_len == 0
let cell .= '-'
else
let cell .= repeat('-', a:max_len)
endif
if a:align ==# 'right'
return cell.'-:'
elseif a:align ==# 'left'
return cell.'--'
else
return ':'.cell.':'
endif
endfunction
function! s:fmt_sep(max_lens, aligns, col1, col2) abort
let new_line = s:rxSep()
for idx in range(len(a:max_lens))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
let new_line .= s:fmt_cell_sep(a:max_lens[idx], a:aligns[idx]).s:rxSep()
endfor
return new_line
endfunction
function! s:kbd_create_new_row(cols, goto_first) abort
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'), 2)\<CR>"
let cmd .= "\<ESC>0"
if a:goto_first
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>"
else
let cmd .= (col('.')-1).'l'
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
endif
let cmd .= 'a'
return cmd
endfunction
function! s:kbd_goto_next_row() abort
let cmd = "\<ESC>j"
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= 'a'
return cmd
endfunction
function! s:kbd_goto_prev_row() abort
let cmd = "\<ESC>k"
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= 'a'
return cmd
endfunction
" Used in s:kbd_goto_next_col
function! vimwiki#tbl#goto_next_col() abort
let curcol = virtcol('.')
let lnum = line('.')
let depth = 2
let newcol = s:get_indent(lnum, depth)
let rows = s:get_rows(lnum, depth)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, 1))
endfor
let max_lens = s:get_cell_max_lens(lnum, cells, startlnum, rows)
for cell_len in values(max_lens)
if newcol >= curcol-1
break
endif
let newcol += cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction
function! s:kbd_goto_next_col(jumpdown) abort
let cmd = "\<ESC>"
if a:jumpdown
let seps = s:count_separators_down(line('.'))
let cmd .= seps.'j0'
endif
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
return cmd
endfunction
" Used in s:kbd_goto_prev_col
function! vimwiki#tbl#goto_prev_col() abort
let curcol = virtcol('.')
let lnum = line('.')
let depth = 2
let newcol = s:get_indent(lnum, depth)
let rows = s:get_rows(lnum, depth)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, 1))
endfor
let max_lens = s:get_cell_max_lens(lnum, cells, startlnum, rows)
let prev_cell_len = 0
for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
if newcol + delta > curcol-1
let newcol -= (prev_cell_len + 3) " +3 == 2 spaces + 1 separator |<space>...<space>
break
elseif newcol + delta == curcol-1
break
endif
let prev_cell_len = cell_len
let newcol += delta
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction
function! s:kbd_goto_prev_col(jumpup) abort
let cmd = "\<ESC>"
if a:jumpup
let seps = s:count_separators_up(line('.'))
let cmd .= seps.'k'
let cmd .= '$'
endif
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd
endfunction
function! vimwiki#tbl#kbd_cr() abort
let lnum = line('.')
if !s:is_table(getline(lnum))
return ''
endif
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 0)
else
return s:kbd_goto_next_row()
endif
endfunction
function! vimwiki#tbl#kbd_tab() abort
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<Tab>"
endif
let last = s:is_last_column(lnum, col('.'))
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> last=".last.", is_sep=".is_sep
if (is_sep || last) && !s:is_table(getline(lnum+1))
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(is_sep || last)
endfunction
function! vimwiki#tbl#kbd_shift_tab() abort
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<S-Tab>"
endif
let first = s:is_first_column(lnum, col('.'))
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> ".first
if (is_sep || first) && !s:is_table(getline(lnum-1))
return ''
endif
return s:kbd_goto_prev_col(is_sep || first)
endfunction
function! vimwiki#tbl#format(lnum, ...) abort
if !vimwiki#u#ft_is_vw()
return
endif
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let depth = a:0 == 1 ? a:1 : 0
if a:0 == 2
let col1 = a:1
let col2 = a:2
else
let col1 = 0
let col2 = 0
endif
let indent = s:get_indent(a:lnum, depth)
if &expandtab
let indentstring = repeat(' ', indent)
else
execute "let indentstring = repeat('\<TAB>', indent / &tabstop) . repeat(' ', indent % &tabstop)"
endif
" getting N = depth last rows is enough for having been formatted tables
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2, depth)
let row = indentstring.row
if getline(lnum) != row
call setline(lnum, row)
endif
endfor
let &textwidth = s:textwidth
endfunction
function! vimwiki#tbl#create(...) abort
if a:0 > 1
let cols = a:1
let rows = a:2
elseif a:0 == 1
let cols = a:1
let rows = 2
elseif a:0 == 0
let cols = 5
let rows = 2
endif
if cols < 1
let cols = 5
endif
if rows < 1
let rows = 2
endif
let lines = []
let row = s:create_empty_row(cols)
call add(lines, row)
if rows > 1
call add(lines, s:create_row_sep(cols))
endif
for r in range(rows - 1)
call add(lines, row)
endfor
call append(line('.'), lines)
endfunction
function! vimwiki#tbl#align_or_cmd(cmd, ...) abort
if s:is_table(getline('.'))
call call('vimwiki#tbl#format', [line('.')] + a:000)
else
exe 'normal! '.a:cmd
endif
endfunction
function! vimwiki#tbl#reset_tw(lnum) abort
if !vimwiki#u#ft_is_vw()
return
endif
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let s:textwidth = &textwidth
let &textwidth = 0
endfunction
" TODO: move_column_left and move_column_right are good candidates to be refactored.
function! vimwiki#tbl#move_column_left() abort
"echomsg "DEBUG move_column_left: "
let line = getline('.')
if !s:is_table(line)
return
endif
let cur_col = s:cur_column()
if cur_col == -1
return
endif
if cur_col > 0
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep().'\).\zs'
let mpos = -1
let col = -1
while col < cur_col-1
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
break
endif
endwhile
endif
endfunction
function! vimwiki#tbl#move_column_right() abort
let line = getline('.')
if !s:is_table(line)
return
endif
let cur_col = s:cur_column()
if cur_col == -1
return
endif
if cur_col < s:col_count(line('.'))-1
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep().'\).\zs'
let mpos = -1
let col = -1
while col < cur_col+1
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
break
endif
endwhile
endif
endfunction
function! vimwiki#tbl#get_rows(lnum) abort
return s:get_rows(a:lnum)
endfunction
function! vimwiki#tbl#is_table(line) abort
return s:is_table(a:line)
endfunction
function! vimwiki#tbl#is_separator(line) abort
return s:is_separator(a:line)
endfunction
function! vimwiki#tbl#cell_splitter() abort
return s:cell_splitter()
endfunction
function! vimwiki#tbl#sep_splitter() abort
return s:sep_splitter()
endfunction

View file

@ -1,157 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Description: Utility functions
" Home: https://github.com/vimwiki/vimwiki/
" Execute: string v:count times
function! vimwiki#u#count_exe(cmd) abort
for i in range( max([1, v:count]) )
exe a:cmd
endfor
endfunction
function! vimwiki#u#trim(string, ...) abort
let chars = ''
if a:0 > 0
let chars = a:1
endif
let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
return res
endfunction
" Builtin cursor doesn't work right with unicode characters.
function! vimwiki#u#cursor(lnum, cnum) abort
exe a:lnum
exe 'normal! 0'.a:cnum.'|'
endfunction
" Returns: OS name, human readable
function! vimwiki#u#os_name() abort
if vimwiki#u#is_windows()
return 'Windows'
elseif vimwiki#u#is_macos()
return 'Mac'
else
return 'Linux'
endif
endfunction
function! vimwiki#u#is_windows() abort
return has('win32') || has('win64') || has('win95') || has('win16')
endfunction
function! vimwiki#u#is_macos() abort
if has('mac') || has('macunix') || has('gui_mac')
return 1
endif
" that still doesn't mean we are not on Mac OS
let os = substitute(system('uname'), '\n', '', '')
return os ==? 'Darwin' || os ==? 'Mac'
endfunction
function! vimwiki#u#count_first_sym(line) abort
let first_sym = matchstr(a:line, '\S')
return len(matchstr(a:line, first_sym.'\+'))
endfunction
function! vimwiki#u#escape(string) abort
return escape(a:string, '~.*[]\^$')
endfunction
" Load concrete Wiki syntax: sets regexes and templates for headers and links
function! vimwiki#u#reload_regexes() abort
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'.vim'
endfunction
" Load syntax-specific functionality
function! vimwiki#u#reload_regexes_custom() abort
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'_custom.vim'
endfunction
" Backward compatible version of the built-in function shiftwidth()
if exists('*shiftwidth')
function! vimwiki#u#sw() abort
return shiftwidth()
endfunc
else
function! vimwiki#u#sw() abort
return &shiftwidth
endfunc
endif
" a:mode single character indicating the mode as defined by :h maparg
" a:key the key sequence to map
" a:plug the plug command the key sequence should be mapped to
" a:1 optional argument with the following functionality:
" if a:1==1 then the hasmapto(<Plug>) check is skipped.
" this can be used to map different keys to the same <Plug> definition
" if a:1==2 then the mapping is not <buffer> specific i.e. it is global
function! vimwiki#u#map_key(mode, key, plug, ...) abort
if a:0 && a:1 == 2
" global mappings
if !hasmapto(a:plug) && maparg(a:key, a:mode) ==# ''
exe a:mode . 'map ' . a:key . ' ' . a:plug
endif
elseif a:0 && a:1 == 1
" vimwiki buffer mappings, repeat mapping to the same <Plug> definition
exe a:mode . 'map <buffer> ' . a:key . ' ' . a:plug
else
" vimwiki buffer mappings
if !hasmapto(a:plug)
exe a:mode . 'map <buffer> ' . a:key . ' ' . a:plug
endif
endif
endfunction
" returns 1 if line is a code block or math block
"
" The last two conditions are needed for this to correctly
" detect nested syntaxes within code blocks
function! vimwiki#u#is_codeblock(lnum) abort
let syn_g = synIDattr(synID(a:lnum,1,1),'name')
if syn_g =~# 'Vimwiki\(Pre.*\|IndentedCodeBlock\|Math.*\)'
\ || (syn_g !~# 'Vimwiki.*' && syn_g !=? '')
return 1
else
return 0
endif
endfunction
" Sets the filetype to vimwiki
" If g:vimwiki_filetypes variable is set
" the filetype will be vimwiki.<ft1>.<ft2> etc.
function! vimwiki#u#ft_set() abort
let ftypelist = vimwiki#vars#get_global('filetypes')
let ftype = 'vimwiki'
for ftypeadd in ftypelist
let ftype = ftype . '.' . ftypeadd
endfor
let &filetype = ftype
endfunction
" Returns: 1 if filetype is vimwiki, 0 else
" If multiple fileytpes are in use 1 is returned only if the
" first ft is vimwiki which should always be the case unless
" the user manually changes it to something else
function! vimwiki#u#ft_is_vw() abort
" Clause: is filetype defined
if &filetype ==# '' | return 0 | endif
if split(&filetype, '\.')[0] ==? 'vimwiki'
return 1
else
return 0
endif
endfunction

View file

@ -1,984 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Home: https://github.com/vimwiki/vimwiki/
" ------------------------------------------------------------------------------------------------
" This file provides functions to manage the various state variables which are needed during a
" Vimwiki session.
" They consist of:
"
" - global variables. These are stored in the dict g:vimwiki_global_vars. They consist mainly of
" global user variables and syntax stuff which is the same for every syntax.
"
" - wiki-local variables. They are stored in g:vimwiki_wikilocal_vars which is a list of
" dictionaries, one dict for every registered wiki. The last dictionary contains default values
" (used for temporary wikis).
"
" - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and
" other stuff which is needed for highlighting.
"
" - buffer-local variables. They are stored as buffer variables directly (b:foo)
" As a developer, you should, if possible, only use the get_ and set_ functions for these types of
" variables, not the underlying dicts!
" ------------------------------------------------------------------------------------------------
function! s:populate_global_variables() abort
let g:vimwiki_global_vars = {}
call s:read_global_settings_from_user()
call s:normalize_global_settings()
" non-configurable global variables:
" Scheme regexes must be defined even if syntax file is not loaded yet cause users should be
" able to <leader>w<leader>w without opening any vimwiki file first
let g:vimwiki_global_vars.schemes = join(['wiki\d\+', 'diary', 'local'], '\|')
let g:vimwiki_global_vars.web_schemes1 = join(['http', 'https', 'file', 'ftp', 'gopher',
\ 'telnet', 'nntp', 'ldap', 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh',
\ 'git', 'ssh', 'fish', 'sftp'], '\|')
let web_schemes2 =
\ join(['mailto', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data'], '\|')
let g:vimwiki_global_vars.rxSchemes = '\%('.
\ g:vimwiki_global_vars.schemes . '\|'.
\ g:vimwiki_global_vars.web_schemes1 . '\|'.
\ web_schemes2 .
\ '\)'
" match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme
" http://tools.ietf.org/html/rfc3986
let rxWebProtocols =
\ '\%('.
\ '\%('.
\ '\%('.g:vimwiki_global_vars.web_schemes1 . '\):'.
\ '\%(//\)'.
\ '\)'.
\ '\|'.
\ '\%('.web_schemes2.'\):'.
\ '\)'
let g:vimwiki_global_vars.rxWeblinkUrl = rxWebProtocols . '\S\{-1,}'. '\%(([^ \t()]*)\)\='
let wikilink_prefix = '[['
let wikilink_suffix = ']]'
let wikilink_separator = '|'
let g:vimwiki_global_vars.rx_wikilink_prefix = vimwiki#u#escape(wikilink_prefix)
let g:vimwiki_global_vars.rx_wikilink_suffix = vimwiki#u#escape(wikilink_suffix)
let g:vimwiki_global_vars.rx_wikilink_separator = vimwiki#u#escape(wikilink_separator)
" templates for the creation of wiki links
" [[URL]]
let g:vimwiki_global_vars.WikiLinkTemplate1 = wikilink_prefix . '__LinkUrl__'. wikilink_suffix
" [[URL|DESCRIPTION]]
let g:vimwiki_global_vars.WikiLinkTemplate2 = wikilink_prefix . '__LinkUrl__'. wikilink_separator
\ . '__LinkDescription__' . wikilink_suffix
let valid_chars = '[^\\\]]'
let g:vimwiki_global_vars.rxWikiLinkUrl = valid_chars.'\{-}'
let g:vimwiki_global_vars.rxWikiLinkDescr = valid_chars.'\{-}'
" this regexp defines what can form a link when the user presses <CR> in the
" buffer (and not on a link) to create a link
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
" non-Ascii characters, except that . is not accepted as the last character
" TODO look behind for . reduces the second part of the regex that is the same with '.' added
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]*[^[:blank:]!"$%&''()*+.,:;<=>?\[\]\\^`{}]'
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix .
\ g:vimwiki_global_vars.rxWikiLinkUrl . g:vimwiki_global_vars.rx_wikilink_separator
let g:vimwiki_global_vars.rx_wikilink_suffix1 = g:vimwiki_global_vars.rx_wikilink_suffix
let g:vimwiki_global_vars.rxWikiInclPrefix = '{{'
let g:vimwiki_global_vars.rxWikiInclSuffix = '}}'
let g:vimwiki_global_vars.rxWikiInclSeparator = '|'
" '{{__LinkUrl__}}'
let g:vimwiki_global_vars.WikiInclTemplate1 = g:vimwiki_global_vars.rxWikiInclPrefix
\ .'__LinkUrl__'. g:vimwiki_global_vars.rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}'
let g:vimwiki_global_vars.WikiInclTemplate2 = g:vimwiki_global_vars.rxWikiInclPrefix
\ . '__LinkUrl__' . g:vimwiki_global_vars.rxWikiInclSeparator . '__LinkDescription__'
\ . g:vimwiki_global_vars.rxWikiInclSuffix
let valid_chars = '[^\\\}]'
let g:vimwiki_global_vars.rxWikiInclUrl = valid_chars.'\{-}'
let g:vimwiki_global_vars.rxWikiInclArg = valid_chars.'\{-}'
let g:vimwiki_global_vars.rxWikiInclArgs = '\%('. g:vimwiki_global_vars.rxWikiInclSeparator.
\ g:vimwiki_global_vars.rxWikiInclArg. '\)'.'\{-}'
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]}
let g:vimwiki_global_vars.rxWikiIncl = g:vimwiki_global_vars.rxWikiInclPrefix.
\ g:vimwiki_global_vars.rxWikiInclUrl.
\ g:vimwiki_global_vars.rxWikiInclArgs. g:vimwiki_global_vars.rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]}
let g:vimwiki_global_vars.rxWikiInclMatchUrl = g:vimwiki_global_vars.rxWikiInclPrefix.
\ '\zs'. g:vimwiki_global_vars.rxWikiInclUrl . '\ze'.
\ g:vimwiki_global_vars.rxWikiInclArgs . g:vimwiki_global_vars.rxWikiInclSuffix
let g:vimwiki_global_vars.rxWikiInclPrefix1 = g:vimwiki_global_vars.rxWikiInclPrefix.
\ g:vimwiki_global_vars.rxWikiInclUrl . g:vimwiki_global_vars.rxWikiInclSeparator
let g:vimwiki_global_vars.rxWikiInclSuffix1 = g:vimwiki_global_vars.rxWikiInclArgs.
\ g:vimwiki_global_vars.rxWikiInclSuffix
let g:vimwiki_global_vars.rxTodo = '\C\<\%(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>'
" default colors when headers of different levels are highlighted differently
" not making it yet another option; needed by ColorScheme autocommand
let g:vimwiki_global_vars.hcolor_guifg_light = ['#aa5858', '#507030', '#1030a0', '#103040'
\ , '#505050', '#636363']
let g:vimwiki_global_vars.hcolor_ctermfg_light = ['DarkRed', 'DarkGreen', 'DarkBlue', 'Black'
\ , 'Black', 'Black']
let g:vimwiki_global_vars.hcolor_guifg_dark = ['#e08090', '#80e090', '#6090e0', '#c0c0f0'
\ , '#e0e0f0', '#f0f0f0']
let g:vimwiki_global_vars.hcolor_ctermfg_dark = ['Red', 'Green', 'Blue', 'White', 'White'
\ , 'White']
endfunction
function! s:read_global_settings_from_user() abort
let global_settings = {
\ 'CJK_length': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_chdir': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_header': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'autowriteall': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'conceallevel': {'type': type(0), 'default': 2, 'min': 0, 'max': 3},
\ 'conceal_onechar_markers': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'conceal_pre': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'create_link': {'type': type(0), 'default': 1, 'min':0, 'max': 1},
\ 'diary_months': {'type': type({}), 'default':
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ }},
\ 'dir_link': {'type': type(''), 'default': ''},
\ 'ext2syntax': {'type': type({}), 'default': {'.md': 'markdown', '.mkdn': 'markdown',
\ '.mdwn': 'markdown', '.mdown': 'markdown', '.markdown': 'markdown', '.mw': 'media'}},
\ 'folding': {'type': type(''), 'default': '', 'possible_values': ['', 'expr', 'syntax',
\ 'list', 'custom', ':quick', 'expr:quick', 'syntax:quick', 'list:quick',
\ 'custom:quick']},
\ 'filetypes': {'type': type([]), 'default': []},
\ 'global_ext': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'hl_cb_checked': {'type': type(0), 'default': 0, 'min': 0, 'max': 2},
\ 'hl_headers': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'html_header_numbering': {'type': type(0), 'default': 0, 'min': 0, 'max': 6},
\ 'html_header_numbering_sym': {'type': type(''), 'default': ''},
\ 'key_mappings': {'type': type({}), 'default':
\ {
\ 'all_maps': 1, 'global': 1, 'headers': 1, 'text_objs': 1,
\ 'table_format': 1, 'table_mappings': 1, 'lists': 1, 'links': 1,
\ 'html': 1, 'mouse': 0,
\ }},
\ 'list_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'text_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'links_header': {'type': type(''), 'default': 'Generated Links', 'min_length': 1},
\ 'links_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 6},
\ 'listsyms': {'type': type(''), 'default': ' .oOX', 'min_length': 2},
\ 'listsym_rejected': {'type': type(''), 'default': '-', 'length': 1},
\ 'map_prefix': {'type': type(''), 'default': '<Leader>w'},
\ 'markdown_header_style': {'type': type(0), 'default': 1, 'min':0, 'max': 2},
\ 'markdown_link_ext': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'menu': {'type': type(''), 'default': 'Vimwiki'},
\ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'table_reduce_last_col': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'table_mappings': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'tags_header': {'type': type(''), 'default': 'Generated Tags', 'min_length': 1},
\ 'tags_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 5},
\ 'toc_header': {'type': type(''), 'default': 'Contents', 'min_length': 1},
\ 'toc_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 6},
\ 'toc_link_format': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'url_maxsave': {'type': type(0), 'default': 15, 'min': 0},
\ 'use_calendar': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'use_mouse': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'user_htmls': {'type': type(''), 'default': ''},
\ 'valid_html_tags': {'type': type(''), 'default':
\ 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em'},
\ 'w32_dir_enc': {'type': type(''), 'default': ''},
\ }
" copy the user's settings from variables of the form g:vimwiki_<option> into the dict
" g:vimwiki_global_vars (or set a default value)
for key in keys(global_settings)
if exists('g:vimwiki_'.key)
let users_value = g:vimwiki_{key}
let value_infos = global_settings[key]
call s:check_users_value(key, users_value, value_infos, 1)
let g:vimwiki_global_vars[key] = users_value
" Remove users_value to prevent type mismatch (E706) errors in vim <7.4.1546
unlet users_value
else
let g:vimwiki_global_vars[key] = global_settings[key].default
endif
endfor
" validate some settings individually
let key = 'diary_months'
let users_value = g:vimwiki_global_vars[key]
for month in range(1, 12)
if !has_key(users_value, month) || type(users_value[month]) != type('') ||
\ empty(users_value[month])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
let key = 'ext2syntax'
let users_value = g:vimwiki_global_vars[key]
for ext in keys(users_value)
if empty(ext) || index(['markdown', 'media', 'mediawiki', 'default'], users_value[ext]) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
endfunction
function! s:normalize_global_settings() abort
let keys = keys(g:vimwiki_global_vars.ext2syntax)
for ext in keys
" for convenience, we also allow the term 'mediawiki'
if g:vimwiki_global_vars.ext2syntax[ext] ==# 'mediawiki'
let g:vimwiki_global_vars.ext2syntax[ext] = 'media'
endif
" ensure the file extensions in ext2syntax start with a dot
" make sure this occurs after anything else that tries to access
" the entry using the index 'ext' since this removes that index
if ext[0] !=# '.'
let new_ext = '.' . ext
let g:vimwiki_global_vars.ext2syntax[new_ext] = g:vimwiki_global_vars.ext2syntax[ext]
call remove(g:vimwiki_global_vars.ext2syntax, ext)
endif
endfor
" ensure key_mappings dictionary has all required keys
if !has_key(g:vimwiki_global_vars.key_mappings, 'all_maps')
let g:vimwiki_global_vars.key_mappings.all_maps = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'global')
let g:vimwiki_global_vars.key_mappings.global = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'headers')
let g:vimwiki_global_vars.key_mappings.headers = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'text_objs')
let g:vimwiki_global_vars.key_mappings.text_objs = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'table_format')
let g:vimwiki_global_vars.key_mappings.table_format = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'table_mappings')
let g:vimwiki_global_vars.key_mappings.table_mappings = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'lists')
let g:vimwiki_global_vars.key_mappings.lists = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'links')
let g:vimwiki_global_vars.key_mappings.links = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'html')
let g:vimwiki_global_vars.key_mappings.html = 1
endif
if !has_key(g:vimwiki_global_vars.key_mappings, 'mouse')
let g:vimwiki_global_vars.key_mappings.mouse = 0
endif
" disable all key mappings if all_maps == 0
if !g:vimwiki_global_vars.key_mappings.all_maps
let g:vimwiki_global_vars.key_mappings.global = 0
let g:vimwiki_global_vars.key_mappings.headers = 0
let g:vimwiki_global_vars.key_mappings.text_objs = 0
let g:vimwiki_global_vars.key_mappings.table_format = 0
let g:vimwiki_global_vars.key_mappings.table_mappings = 0
let g:vimwiki_global_vars.table_mappings = 0 " kept for backwards compatibility
let g:vimwiki_global_vars.key_mappings.lists = 0
let g:vimwiki_global_vars.key_mappings.links = 0
let g:vimwiki_global_vars.key_mappings.html = 0
let g:vimwiki_global_vars.key_mappings.mouse = 0
let g:vimwiki_global_vars.use_mouse = 0 " kept for backwards compatibility
endif
" TODO remove these checks and the table_mappings and use_mouse variables
" backwards compatibility checks
" if the old option isn't its default value then overwrite the new option
if g:vimwiki_global_vars.table_mappings == 0
let g:vimwiki_global_vars.key_mappings.table_mappings = 0 && g:vimwiki_global_vars.key_mappings.table_mappings == 1
endif
if g:vimwiki_global_vars.use_mouse == 1 && g:vimwiki_global_vars.key_mappings.mouse == 0
let g:vimwiki_global_vars.key_mappings.mouse = 1
endif
endfunction
let s:margin_set_by_user = 0
function! s:populate_wikilocal_options() abort
let default_values = {
\ 'auto_diary_index': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_export': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_generate_links': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_generate_tags': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_tags': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_toc': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'automatic_nested_syntaxes': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'css_name': {'type': type(''), 'default': 'style.css', 'min_length': 1},
\ 'custom_wiki2html': {'type': type(''), 'default': ''},
\ 'custom_wiki2html_args': {'type': type(''), 'default': ''},
\ 'diary_header': {'type': type(''), 'default': 'Diary', 'min_length': 1},
\ 'diary_index': {'type': type(''), 'default': 'diary', 'min_length': 1},
\ 'diary_rel_path': {'type': type(''), 'default': 'diary/', 'min_length': 0},
\ 'diary_caption_level': {'type': type(0), 'default': 0, 'min': -1, 'max': 6},
\ 'diary_sort': {'type': type(''), 'default': 'desc', 'possible_values': ['asc', 'desc']},
\ 'exclude_files': {'type': type([]), 'default': []},
\ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1},
\ 'index': {'type': type(''), 'default': 'index', 'min_length': 1},
\ 'links_space_char': {'type': type(''), 'default': ' ', 'min_length': 1},
\ 'list_margin': {'type': type(0), 'default': -1, 'min': -1},
\ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'name': {'type': type(''), 'default': ''},
\ 'nested_syntaxes': {'type': type({}), 'default': {}},
\ 'path': {'type': type(''), 'default': $HOME . '/vimwiki/', 'min_length': 1},
\ 'path_html': {'type': type(''), 'default': ''},
\ 'syntax': {'type': type(''), 'default': 'default',
\ 'possible_values': ['default', 'markdown', 'media', 'mediawiki']},
\ 'template_default': {'type': type(''), 'default': 'default', 'min_length': 1},
\ 'template_ext': {'type': type(''), 'default': '.tpl'},
\ 'template_path': {'type': type(''), 'default': $HOME . '/vimwiki/templates/'},
\ 'html_filename_parameterization': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ }
let g:vimwiki_wikilocal_vars = []
let default_wiki_settings = {}
for key in keys(default_values)
if exists('g:vimwiki_'.key)
call s:check_users_value(key, g:vimwiki_{key}, default_values[key], 1)
let default_wiki_settings[key] = g:vimwiki_{key}
else
let default_wiki_settings[key] = default_values[key].default
endif
endfor
" set the wiki-local variables according to g:vimwiki_list (or the default settings)
if exists('g:vimwiki_list')
for users_wiki_settings in g:vimwiki_list
let new_wiki_settings = {}
for key in keys(default_values)
if has_key(users_wiki_settings, key)
call s:check_users_value(key, users_wiki_settings[key], default_values[key], 0)
if key ==# 'list_margin'
let s:margin_set_by_user = 1
endif
let new_wiki_settings[key] = users_wiki_settings[key]
else
let new_wiki_settings[key] = default_wiki_settings[key]
endif
endfor
let new_wiki_settings.is_temporary_wiki = 0
call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
endfor
else
" if the user hasn't registered any wiki, we register one wiki using the default values
let new_wiki_settings = deepcopy(default_wiki_settings)
let new_wiki_settings.is_temporary_wiki = 0
call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
endif
" default values for temporary wikis
let temporary_wiki_settings = deepcopy(default_wiki_settings)
let temporary_wiki_settings.is_temporary_wiki = 1
call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings)
" check some values individually
let key = 'nested_syntaxes'
for wiki_settings in g:vimwiki_wikilocal_vars
let users_value = wiki_settings[key]
for keyword in keys(users_value)
if type(keyword) != type('') || empty(keyword) || type(users_value[keyword]) != type('') ||
\ empty(users_value[keyword])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
endfor
call s:normalize_wikilocal_settings()
endfunction
function! s:check_users_value(key, users_value, value_infos, comes_from_global_variable) abort
let type_code_to_name = {
\ type(0): 'number',
\ type(''): 'string',
\ type([]): 'list',
\ type({}): 'dictionary'}
let setting_origin = a:comes_from_global_variable ?
\ printf('''g:vimwiki_%s''', a:key) :
\ printf('''%s'' in g:vimwiki_list', a:key)
let help_text = a:comes_from_global_variable ?
\ 'g:vimwiki_' :
\ 'vimwiki-option-'
if has_key(a:value_infos, 'type') && type(a:users_value) != a:value_infos.type
echom printf('Vimwiki Error: The provided value of the option %s is a %s, ' .
\ 'but expected is a %s. See '':h '.help_text.'%s''.', setting_origin,
\ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key)
endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'min') &&
\ a:users_value < a:value_infos.min
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
\ . ' too small. The minimum value is %i. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, a:value_infos.min, a:key)
endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'max') &&
\ a:users_value > a:value_infos.max
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
\ . ' too large. The maximum value is %i. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, a:value_infos.max, a:key)
endif
if has_key(a:value_infos, 'possible_values') &&
\ index(a:value_infos.possible_values, a:users_value) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s is'
\ . ' invalid. Allowed values are %s. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, string(a:value_infos.possible_values), a:key)
endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'length') &&
\ strwidth(a:users_value) != a:value_infos.length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
\ . ' contain exactly %i character(s) but has %i. See '':h '.help_text.'_%s''.',
\ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key)
endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'min_length') &&
\ strwidth(a:users_value) < a:value_infos.min_length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
\ . ' have at least %d character(s) but has %d. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key)
endif
endfunction
function! s:normalize_wikilocal_settings() abort
for wiki_settings in g:vimwiki_wikilocal_vars
let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
let path_html = wiki_settings['path_html']
if !empty(path_html)
let wiki_settings['path_html'] = s:normalize_path(path_html)
else
let wiki_settings['path_html'] = s:normalize_path(
\ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/')
endif
let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path'])
let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path'])
let ext = wiki_settings['ext']
if !empty(ext) && ext[0] !=# '.'
let wiki_settings['ext'] = '.' . ext
endif
" for convenience, we also allow the term 'mediawiki'
if wiki_settings.syntax ==# 'mediawiki'
let wiki_settings.syntax = 'media'
endif
if wiki_settings.syntax ==# 'markdown' && !s:margin_set_by_user
" default list margin to 0
let wiki_settings.list_margin = 0
endif
endfor
endfunction
function! s:normalize_path(path) abort
" trim trailing / and \ because otherwise resolve() doesn't work quite right
let path = substitute(a:path, '[/\\]\+$', '', '')
if path !~# '^scp:'
return resolve(expand(path)).'/'
else
return path.'/'
endif
endfunction
function! vimwiki#vars#populate_syntax_vars(syntax) abort
if !exists('g:vimwiki_syntax_variables')
let g:vimwiki_syntax_variables = {}
endif
if has_key(g:vimwiki_syntax_variables, a:syntax)
return
endif
let g:vimwiki_syntax_variables[a:syntax] = {}
execute 'runtime! syntax/vimwiki_'.a:syntax.'.vim'
" generic stuff
let header_symbol = g:vimwiki_syntax_variables[a:syntax].rxH
if g:vimwiki_syntax_variables[a:syntax].symH
" symmetric headers
for i in range(1,6)
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] =
\ repeat(header_symbol, i).' __Header__ '.repeat(header_symbol, i)
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
\ .header_symbol.'\{'.i.'}\s*$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Text'] =
\ '^\s*'.header_symbol.'\{'.i.'}\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze'
\ .header_symbol.'\{'.i.'}\s*$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
\ .header_symbol.'\{'.i.'}\s*$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
\ .header_symbol.'\{1,'.i.'}\s*$'
endfor
let g:vimwiki_syntax_variables[a:syntax].rxHeader =
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze\1\s*$'
else
" asymmetric
for i in range(1,6)
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] =
\ repeat(header_symbol, i).' __Header__'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Text'] =
\ '^\s*'.header_symbol.'\{'.i.'}\zs[^'.header_symbol.'].*\ze$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*$'
endfor
let g:vimwiki_syntax_variables[a:syntax].rxHeader =
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*\ze$'
endif
let g:vimwiki_syntax_variables[a:syntax].rxPreStart =
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreStart
let g:vimwiki_syntax_variables[a:syntax].rxPreEnd =
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreEnd.'\s*$'
let g:vimwiki_syntax_variables[a:syntax].rxMathStart =
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathStart
let g:vimwiki_syntax_variables[a:syntax].rxMathEnd =
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$'
" list stuff
let g:vimwiki_syntax_variables[a:syntax].rx_bullet_chars =
\ '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+'
let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars =
\ g:vimwiki_syntax_variables[a:syntax].recurring_bullets
\ ? g:vimwiki_syntax_variables[a:syntax].bullet_types : []
let g:vimwiki_syntax_variables[a:syntax].number_kinds = []
let g:vimwiki_syntax_variables[a:syntax].number_divisors = ''
for i in g:vimwiki_syntax_variables[a:syntax].number_types
call add(g:vimwiki_syntax_variables[a:syntax].number_kinds, i[0])
let g:vimwiki_syntax_variables[a:syntax].number_divisors .= vimwiki#u#escape(i[1])
endfor
let char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+',
\ 'a': '\l\{1,2}', 'A': '\u\{1,2}'}
"create regexp for bulleted list items
if !empty(g:vimwiki_syntax_variables[a:syntax].bullet_types)
let g:vimwiki_syntax_variables[a:syntax].rxListBullet =
\ join( map(copy(g:vimwiki_syntax_variables[a:syntax].bullet_types),
\'vimwiki#u#escape(v:val).'
\ .'repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)'
\ ) , '\|')
else
"regex that matches nothing
let g:vimwiki_syntax_variables[a:syntax].rxListBullet = '$^'
endif
"create regex for numbered list items
if !empty(g:vimwiki_syntax_variables[a:syntax].number_types)
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '\C\%('
for type in g:vimwiki_syntax_variables[a:syntax].number_types[:-2]
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[type[0]] .
\ vimwiki#u#escape(type[1]) . '\|'
endfor
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .=
\ char_to_rx[g:vimwiki_syntax_variables[a:syntax].number_types[-1][0]].
\ vimwiki#u#escape(g:vimwiki_syntax_variables[a:syntax].number_types[-1][1]) . '\)'
else
"regex that matches nothing
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '$^'
endif
"the user can set the listsyms as string, but vimwiki needs a list
let g:vimwiki_syntax_variables[a:syntax].listsyms_list =
\ split(vimwiki#vars#get_global('listsyms'), '\zs')
if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1
echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected ('''
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ''') must not be a part of g:vimwiki_listsyms ('''
\ . vimwiki#vars#get_global('listsyms') . ''')'
endif
let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB =
\ '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\('
\ .g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s'
let g:vimwiki_syntax_variables[a:syntax].rxListItem =
\ g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB
\ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms')
\ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?'
if g:vimwiki_syntax_variables[a:syntax].recurring_bullets
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
\ '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\[['
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1]
\ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\%('
\ .g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*'
else
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
\ '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|'
\ . g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\[['
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1]
\ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
endif
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
let g:vimwiki_syntax_variables[a:syntax].rxWeblink =
\ '\<'. g:vimwiki_global_vars.rxWeblinkUrl . '[^[:space:]>]*'
" 0a) match URL within URL
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchUrl =
\ g:vimwiki_syntax_variables[a:syntax].rxWeblink
" 0b) match DESCRIPTION within URL
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchDescr = ''
" template for matching all wiki links with a given target file
let g:vimwiki_syntax_variables[a:syntax].WikiLinkMatchUrlTemplate =
\ g:vimwiki_global_vars.rx_wikilink_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ g:vimwiki_global_vars.rx_wikilink_suffix .
\ '\|' .
\ g:vimwiki_global_vars.rx_wikilink_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ g:vimwiki_global_vars.rx_wikilink_separator .
\ '.*' .
\ g:vimwiki_global_vars.rx_wikilink_suffix
" a) match [[URL|DESCRIPTION]]
let g:vimwiki_syntax_variables[a:syntax].rxWikiLink = g:vimwiki_global_vars.rx_wikilink_prefix.
\ g:vimwiki_global_vars.rxWikiLinkUrl.'\%('.g:vimwiki_global_vars.rx_wikilink_separator.
\ g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
let g:vimwiki_syntax_variables[a:syntax].rxAnyLink =
\ g:vimwiki_syntax_variables[a:syntax].rxWikiLink.'\|'.
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.g:vimwiki_syntax_variables[a:syntax].rxWeblink
" b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_syntax_variables[a:syntax].rxWikiLinkMatchUrl =
\ g:vimwiki_global_vars.rx_wikilink_prefix . '\zs'. g:vimwiki_global_vars.rxWikiLinkUrl
\ .'\ze\%('. g:vimwiki_global_vars.rx_wikilink_separator
\ . g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_syntax_variables[a:syntax].rxWikiLinkMatchDescr =
\ g:vimwiki_global_vars.rx_wikilink_prefix . g:vimwiki_global_vars.rxWikiLinkUrl
\ . g:vimwiki_global_vars.rx_wikilink_separator.'\%(\zs'
\ . g:vimwiki_global_vars.rxWikiLinkDescr. '\ze\)\?'
\ . g:vimwiki_global_vars.rx_wikilink_suffix
if a:syntax ==# 'markdown'
call s:populate_extra_markdown_vars()
endif
endfunction
function! s:populate_extra_markdown_vars() abort
let mkd_syntax = g:vimwiki_syntax_variables['markdown']
" 0a) match [[URL|DESCRIPTION]]
let mkd_syntax.rxWikiLink0 = mkd_syntax.rxWikiLink
" 0b) match URL within [[URL|DESCRIPTION]]
let mkd_syntax.rxWikiLink0MatchUrl = mkd_syntax.rxWikiLinkMatchUrl
" 0c) match DESCRIPTION within [[URL|DESCRIPTION]]
let mkd_syntax.rxWikiLink0MatchDescr = mkd_syntax.rxWikiLinkMatchDescr
let wikilink_md_prefix = '['
let wikilink_md_suffix = ']'
let wikilink_md_separator = ']['
let rx_wikilink_md_separator = vimwiki#u#escape(wikilink_md_separator)
let mkd_syntax.rx_wikilink_md_prefix = vimwiki#u#escape(wikilink_md_prefix)
let mkd_syntax.rx_wikilink_md_suffix = vimwiki#u#escape(wikilink_md_suffix)
" [URL][]
let mkd_syntax.WikiLink1Template1 = wikilink_md_prefix . '__LinkUrl__'.
\ wikilink_md_separator. wikilink_md_suffix
" [DESCRIPTION][URL]
let mkd_syntax.WikiLink1Template2 = wikilink_md_prefix. '__LinkDescription__'.
\ wikilink_md_separator. '__LinkUrl__'. wikilink_md_suffix
let valid_chars = '[^\\\[\]]'
let mkd_syntax.rxWikiLink1Url = valid_chars.'\{-}'
let mkd_syntax.rxWikiLink1Descr = valid_chars.'\{-}'
let mkd_syntax.rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
let mkd_syntax.rxWikiLink1InvalidSuffix = '[\]\[]\@!'
let mkd_syntax.rx_wikilink_md_prefix = mkd_syntax.rxWikiLink1InvalidPrefix.
\ mkd_syntax.rx_wikilink_md_prefix
let mkd_syntax.rx_wikilink_md_suffix = mkd_syntax.rx_wikilink_md_suffix.
\ mkd_syntax.rxWikiLink1InvalidSuffix
" 1. match [URL][], [DESCRIPTION][URL]
let mkd_syntax.rxWikiLink1 = mkd_syntax.rx_wikilink_md_prefix.
\ mkd_syntax.rxWikiLink1Url. rx_wikilink_md_separator.
\ mkd_syntax.rx_wikilink_md_suffix.
\ '\|'. mkd_syntax.rx_wikilink_md_prefix.
\ mkd_syntax.rxWikiLink1Descr . rx_wikilink_md_separator.
\ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix
" 2. match URL within [URL][], [DESCRIPTION][URL]
let mkd_syntax.rxWikiLink1MatchUrl = mkd_syntax.rx_wikilink_md_prefix.
\ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. rx_wikilink_md_separator.
\ mkd_syntax.rx_wikilink_md_suffix.
\ '\|'. mkd_syntax.rx_wikilink_md_prefix.
\ mkd_syntax.rxWikiLink1Descr. rx_wikilink_md_separator.
\ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. mkd_syntax.rx_wikilink_md_suffix
" 3. match DESCRIPTION within [DESCRIPTION][URL]
let mkd_syntax.rxWikiLink1MatchDescr = mkd_syntax.rx_wikilink_md_prefix.
\ '\zs'. mkd_syntax.rxWikiLink1Descr.'\ze'. rx_wikilink_md_separator.
\ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix
let mkd_syntax.rxWikiLink1Prefix1 = mkd_syntax.rx_wikilink_md_prefix
let mkd_syntax.rxWikiLink1Suffix1 = rx_wikilink_md_separator.
\ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix
" 1. match ANY wikilink
let mkd_syntax.rxWikiLink = mkd_syntax.rxWikiLink0 . '\|' . mkd_syntax.rxWikiLink1
" 2. match URL within ANY wikilink
let mkd_syntax.rxWikiLinkMatchUrl = mkd_syntax.rxWikiLink0MatchUrl . '\|' .
\ mkd_syntax.rxWikiLink1MatchUrl
" 3. match DESCRIPTION within ANY wikilink
let mkd_syntax.rxWikiLinkMatchDescr = mkd_syntax.rxWikiLink0MatchDescr . '\|' .
\ mkd_syntax.rxWikiLink1MatchDescr
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
let mkd_syntax.rxWeblink0 = mkd_syntax.rxWeblink
" 0a) match URL within URL
let mkd_syntax.rxWeblinkMatchUrl0 = mkd_syntax.rxWeblinkMatchUrl
" 0b) match DESCRIPTION within URL
let mkd_syntax.rxWeblinkMatchDescr0 = mkd_syntax.rxWeblinkMatchDescr
let mkd_syntax.rxWeblink1Prefix = '['
let mkd_syntax.rxWeblink1Suffix = ')'
let mkd_syntax.rxWeblink1EscapeCharsSuffix = '\(\\\)\@<!\()\)'
let mkd_syntax.rxWeblink1Separator = ']('
let mkd_syntax.rxWeblink1Ext = ''
if vimwiki#vars#get_global('markdown_link_ext')
let mkd_syntax.rxWeblink1Ext = vimwiki#vars#get_wikilocal('ext')
endif
" [DESCRIPTION](URL)
let mkd_syntax.Weblink1Template = mkd_syntax.rxWeblink1Prefix . '__LinkDescription__'.
\ mkd_syntax.rxWeblink1Separator. '__LinkUrl__'. mkd_syntax.rxWeblink1Ext.
\ mkd_syntax.rxWeblink1Suffix
" [DESCRIPTION](ANCHOR)
let mkd_syntax.Weblink2Template = mkd_syntax.rxWeblink1Prefix . '__LinkDescription__'.
\ mkd_syntax.rxWeblink1Separator. '__LinkUrl__'. mkd_syntax.rxWeblink1Suffix
" [DESCRIPTION](FILE#ANCHOR)
let mkd_syntax.Weblink3Template = mkd_syntax.rxWeblink1Prefix . '__LinkDescription__'.
\ mkd_syntax.rxWeblink1Separator. '__LinkUrl__'. mkd_syntax.rxWeblink1Ext.
\ '#__LinkAnchor__'. mkd_syntax.rxWeblink1Suffix
let valid_chars = '[^\\\]]'
" spaces and '\' must be allowed for filename and escaped chars
let valid_chars_url = '[^[:cntrl:]]'
let mkd_syntax.rxWeblink1Prefix = vimwiki#u#escape(mkd_syntax.rxWeblink1Prefix)
let mkd_syntax.rxWeblink1Separator = vimwiki#u#escape(mkd_syntax.rxWeblink1Separator)
let mkd_syntax.rxWeblink1Url = valid_chars_url.'\{-}'
let mkd_syntax.rxWeblink1Descr = valid_chars.'\{-}'
let mkd_syntax.WikiLinkMatchUrlTemplate =
\ mkd_syntax.rx_wikilink_md_prefix .
\ '.*' .
\ rx_wikilink_md_separator .
\ '\zs__LinkUrl__\ze\%(#.*\)\?\%('.vimwiki#vars#get_wikilocal('ext').'\)\?'.
\ mkd_syntax.rx_wikilink_md_suffix .
\ '\|' .
\ mkd_syntax.rx_wikilink_md_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?\%('.vimwiki#vars#get_wikilocal('ext').'\)\?'.
\ rx_wikilink_md_separator .
\ mkd_syntax.rx_wikilink_md_suffix .
\ '\|' .
\ mkd_syntax.rxWeblink1Prefix.
\ '.*' .
\ mkd_syntax.rxWeblink1Separator.
\ '\zs__LinkUrl__\ze\%(#.*\)\?\%('.vimwiki#vars#get_wikilocal('ext').'\)\?'.
\ mkd_syntax.rxWeblink1EscapeCharsSuffix
" 1. [DESCRIPTION](URL)
" 1a) match [DESCRIPTION](URL)
let mkd_syntax.rxWeblink1 = mkd_syntax.rxWeblink1Prefix.
\ mkd_syntax.rxWeblink1Descr . mkd_syntax.rxWeblink1Separator.
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1EscapeCharsSuffix
" 1b) match URL within [DESCRIPTION](URL)
let mkd_syntax.rxWeblink1MatchUrl = mkd_syntax.rxWeblink1Prefix.
\ mkd_syntax.rxWeblink1Descr. mkd_syntax.rxWeblink1Separator.
\ '\zs' . mkd_syntax.rxWeblink1Url . '\ze' . mkd_syntax.rxWeblink1EscapeCharsSuffix
" 1c) match DESCRIPTION within [DESCRIPTION](URL)
let mkd_syntax.rxWeblink1MatchDescr = mkd_syntax.rxWeblink1Prefix.
\ '\zs'.mkd_syntax.rxWeblink1Descr.'\ze'. mkd_syntax.rxWeblink1Separator.
\ mkd_syntax.rxWeblink1Url. mkd_syntax.rxWeblink1EscapeCharsSuffix
" image ![DESCRIPTION](URL)
let mkd_syntax.rxImage = '!' . mkd_syntax.rxWeblink1Prefix.
\ mkd_syntax.rxWeblink1Descr . mkd_syntax.rxWeblink1Separator.
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1EscapeCharsSuffix
let mkd_syntax.rxWeblink1Prefix1 = mkd_syntax.rxWeblink1Prefix
let mkd_syntax.rxWeblink1Suffix1 = mkd_syntax.rxWeblink1Separator.
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1EscapeCharsSuffix
" *a) match ANY weblink (exclude image links starting with !)
let mkd_syntax.rxWeblink = '\(!\)\@<!'.
\ mkd_syntax.rxWeblink1.'\|'.
\ mkd_syntax.rxWeblink0
" *b) match URL within ANY weblink
let mkd_syntax.rxWeblinkMatchUrl = ''.
\ mkd_syntax.rxWeblink1MatchUrl.'\|'.
\ mkd_syntax.rxWeblinkMatchUrl0
" *c) match DESCRIPTION within ANY weblink
let mkd_syntax.rxWeblinkMatchDescr = ''.
\ mkd_syntax.rxWeblink1MatchDescr.'\|'.
\ mkd_syntax.rxWeblinkMatchDescr0
let mkd_syntax.rxAnyLink = mkd_syntax.rxWikiLink.'\|'.
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.mkd_syntax.rxWeblink .'\|'.
\ mkd_syntax.rxImage
let mkd_syntax.rxMkdRef = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
\ mkd_syntax.rxWeblink0
let mkd_syntax.rxMkdRefMatchDescr =
\ '\[\zs'.g:vimwiki_global_vars.rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'. mkd_syntax.rxWeblink0
let mkd_syntax.rxMkdRefMatchUrl =
\ '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
\ mkd_syntax.rxWeblink0.'\ze'
endfunction
function! vimwiki#vars#init() abort
call s:populate_global_variables()
call s:populate_wikilocal_options()
endfunction
function! vimwiki#vars#get_syntaxlocal(key, ...) abort
if a:0
let syntax = a:1
else
let syntax = vimwiki#vars#get_wikilocal('syntax')
endif
if !exists('g:vimwiki_syntax_variables') || !has_key(g:vimwiki_syntax_variables, syntax)
call vimwiki#vars#populate_syntax_vars(syntax)
endif
return g:vimwiki_syntax_variables[syntax][a:key]
endfunction
" Get a variable for the buffer we are currently in or for the given buffer (number or name).
" Populate the variable, if it doesn't exist.
function! vimwiki#vars#get_bufferlocal(key, ...) abort
let buffer = a:0 ? a:1 : '%'
" 'get(getbufvar(...' handles vim < v7.3.831 that didn't allow a default value for getbufvar
let value = get(getbufvar(buffer, ''), 'vimwiki_'.a:key, '/\/\')
if type(value) != 1 || value !=# '/\/\'
return value
elseif a:key ==# 'wiki_nr'
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
elseif a:key ==# 'subdir'
call setbufvar(buffer, 'vimwiki_subdir', vimwiki#base#current_subdir())
elseif a:key ==# 'invsubdir'
let subdir = vimwiki#vars#get_bufferlocal('subdir')
call setbufvar(buffer, 'vimwiki_invsubdir', vimwiki#base#invsubdir(subdir))
elseif a:key ==# 'existing_wikifiles'
call setbufvar(buffer, 'vimwiki_existing_wikifiles',
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 1, ''))
elseif a:key ==# 'existing_wikidirs'
call setbufvar(buffer, 'vimwiki_existing_wikidirs',
\ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr')))
elseif a:key ==# 'prev_links'
call setbufvar(buffer, 'vimwiki_prev_links', [])
elseif a:key ==# 'markdown_refs'
call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks())
else
echoerr 'Vimwiki Error: unknown buffer variable ' . string(a:key)
endif
return getbufvar(buffer, 'vimwiki_'.a:key)
endfunction
function! vimwiki#vars#set_bufferlocal(key, value, ...) abort
let buffer = a:0 ? a:1 : '%'
call setbufvar(buffer, 'vimwiki_' . a:key, a:value)
endfunction
function! vimwiki#vars#get_global(key) abort
return g:vimwiki_global_vars[a:key]
endfunction
" the second argument can be a wiki number. When absent, the wiki of the currently active buffer is
" used
function! vimwiki#vars#get_wikilocal(key, ...) abort
if a:0
return g:vimwiki_wikilocal_vars[a:1][a:key]
else
return g:vimwiki_wikilocal_vars[vimwiki#vars#get_bufferlocal('wiki_nr')][a:key]
endif
endfunction
function! vimwiki#vars#get_wikilocal_default(key) abort
return g:vimwiki_wikilocal_vars[-1][a:key]
endfunction
function! vimwiki#vars#set_wikilocal(key, value, wiki_nr) abort
if a:wiki_nr == len(g:vimwiki_wikilocal_vars) - 1
call insert(g:vimwiki_wikilocal_vars, {}, -1)
endif
let g:vimwiki_wikilocal_vars[a:wiki_nr][a:key] = a:value
endfunction
function! vimwiki#vars#add_temporary_wiki(settings) abort
let new_temp_wiki_settings = copy(g:vimwiki_wikilocal_vars[-1])
for [key, value] in items(a:settings)
let new_temp_wiki_settings[key] = value
endfor
call insert(g:vimwiki_wikilocal_vars, new_temp_wiki_settings, -1)
call s:normalize_wikilocal_settings()
endfunction
" number of registered wikis + temporary
function! vimwiki#vars#number_of_wikis() abort
return len(g:vimwiki_wikilocal_vars) - 1
endfunction

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 KiB

View file

@ -1,701 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki filetype plugin file
" Home: https://github.com/vimwiki/vimwiki/
if exists('b:did_ftplugin')
finish
endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
setlocal commentstring=%%%s
if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel')
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
endif
" This is for GOTO FILE: gf
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
setlocal isfname-=[,]
exe 'setlocal tags+=' . escape(vimwiki#tags#metadata_file_path(), ' \|"')
function! Complete_wikifiles(findstart, base) abort
if a:findstart == 1
let column = col('.')-2
let line = getline('.')[:column]
let startoflink = match(line, '\[\[\zs[^\\[\]]*$')
if startoflink != -1
let s:line_context = '['
return startoflink
endif
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
if startofinlinelink != -1
let s:line_context = '['
return startofinlinelink
endif
endif
let startoftag = match(line, ':\zs[^:[:space:]]*$')
if startoftag != -1
let s:line_context = ':'
return startoftag
endif
let s:line_context = ''
return -1
else
" Completion works for wikilinks/anchors, and for tags. s:line_content
" tells us which string came before a:base. There seems to be no easier
" solution, because calling col('.') here returns garbage.
if s:line_context ==? ''
return []
elseif s:line_context ==# ':'
" Tags completion
let tags = vimwiki#tags#get_tags()
if a:base !=? ''
call filter(tags,
\ 'v:val[:' . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
endif
return tags
elseif a:base !~# '#'
" we look for wiki files
if a:base =~# '\m^wiki\d\+:'
let wikinumber = eval(matchstr(a:base, '\m^wiki\zs\d\+'))
if wikinumber >= vimwiki#vars#number_of_wikis()
return []
endif
let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*')
let scheme = matchstr(a:base, '\m^wiki\d\+:\ze')
elseif a:base =~# '^diary:'
let wikinumber = -1
let prefix = matchstr(a:base, '^diary:\zs.*')
let scheme = matchstr(a:base, '^diary:\ze')
else " current wiki
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
let prefix = a:base
let scheme = ''
endif
let links = vimwiki#base#get_wikilinks(wikinumber, 1, '')
let result = []
for wikifile in links
if wikifile =~ '^'.vimwiki#u#escape(prefix)
call add(result, scheme . wikifile)
endif
endfor
return result
else
" we look for anchors in the given wikifile
let segments = split(a:base, '#', 1)
let given_wikifile = segments[0] ==? '' ? expand('%:t:r') : segments[0]
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
let wikifile = link_infos.filename
let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index)
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
let filtered_anchors = []
let given_anchor = join(segments[1:], '#')
for anchor in anchors
if anchor =~# '^'.vimwiki#u#escape(given_anchor)
call add(filtered_anchors, segments[0].'#'.anchor)
endif
endfor
return filtered_anchors
endif
endif
endfunction
setlocal omnifunc=Complete_wikifiles
" settings necessary for the automatic formatting of lists
setlocal autoindent
setlocal nosmartindent
setlocal nocindent
setlocal comments=""
setlocal formatoptions-=c
setlocal formatoptions-=r
setlocal formatoptions-=o
setlocal formatoptions-=2
setlocal formatoptions+=n
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
" ------------------------------------------------
" Folding stuff
" ------------------------------------------------
function! VimwikiFoldListLevel(lnum) abort
return vimwiki#lst#fold_level(a:lnum)
endfunction
function! VimwikiFoldLevel(lnum) abort
let line = getline(a:lnum)
" Header/section folding...
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader') && !vimwiki#u#is_codeblock(a:lnum)
return '>'.vimwiki#u#count_first_sym(line)
" Code block folding...
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
return 'a1'
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
return 's1'
else
return '='
endif
endfunction
" Constants used by VimwikiFoldText
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
let s:ellipsis = (&encoding ==? 'utf-8') ? "\u2026" : '...'
let s:ell_len = strlen(s:ellipsis)
let s:newline = (&encoding ==? 'utf-8') ? "\u21b2 " : ' '
let s:tolerance = 5
" unused
function! s:shorten_text_simple(text, len) abort
let spare_len = a:len - len(a:text)
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
endfunction
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
" for long enough "text", the string's length is within s:tolerance of "len"
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
function! s:shorten_text(text, len) abort
" returns [string, spare]
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
" trick here -- replace all non-spaces with dot, calculate lengths and
" indexes on it, then use original string to break at selected index.
let text_pattern = substitute(a:text, '\m\S', '.', 'g')
let spare_len = a:len - strlen(text_pattern)
if (spare_len + s:tolerance >= 0)
return [a:text, spare_len]
endif
" try to break on a space; assumes a:len-s:ell_len >= s:tolerance
let newlen = a:len - s:ell_len
let idx = strridx(text_pattern, ' ', newlen + s:tolerance)
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis, newlen - break_idx]
endfunction
function! VimwikiFoldText() abort
let line = getline(v:foldstart)
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
let fold_len = v:foldend - v:foldstart + 1
let len_text = ' ['.fold_len.'] '
if line !~# vimwiki#vars#get_syntaxlocal('rxPreStart')
let [main_text, spare_len] = s:shorten_text(main_text, 50)
return main_text.len_text
else
" fold-text for code blocks: use one or two of the starting lines
let [main_text, spare_len] = s:shorten_text(main_text, 24)
let line1 = substitute(getline(v:foldstart+1), '^\s*', ' ', '')
let [content_text, spare_len] = s:shorten_text(line1, spare_len+20)
if spare_len > s:tolerance && fold_len > 3
let line2 = substitute(getline(v:foldstart+2), '^\s*', s:newline, '')
let [more_text, spare_len] = s:shorten_text(line2, spare_len+12)
let content_text .= more_text
endif
return main_text.len_text.content_text
endif
endfunction
" ------------------------------------------------
" Commands
" ------------------------------------------------
command! -buffer Vimwiki2HTML
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
\ <bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
command! -buffer Vimwiki2HTMLBrowse
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%')))
command! -buffer -bang VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')), <bang>0)
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
command! -buffer VimwikiNextTask call vimwiki#base#find_next_task()
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
command! -buffer VimwikiDeleteFile call vimwiki#base#delete_link()
command! -buffer VimwikiDeleteLink
\ call vimwiki#base#deprecate("VimwikiDeleteLink", "VimwikiDeleteFile") |
\ call vimwiki#base#delete_link()
command! -buffer VimwikiRenameFile call vimwiki#base#rename_link()
command! -buffer VimwikiRenameLink
\ call vimwiki#base#deprecate("VimwikiRenameLink", "VimwikiRenameFile") |
\ call vimwiki#base#rename_link()
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1)
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', <f-args>)
command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', <f-args>)
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tab', 0, 1)
command! -buffer -nargs=? VimwikiGenerateLinks call vimwiki#base#generate_links(1, <f-args>)
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
command! -buffer -nargs=* VimwikiSearch call vimwiki#base#search(<q-args>)
command! -buffer -nargs=* VWS call vimwiki#base#search(<q-args>)
command! -buffer -nargs=* -complete=customlist,vimwiki#base#complete_links_escaped
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
command! -buffer VimwikiCheckLinks call vimwiki#base#check_links()
" list commands
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo
\ call vimwiki#lst#change_marker_in_list(<f-args>)
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
command! -buffer -range VimwikiToggleRejectedListItem
\ call vimwiki#lst#toggle_rejected_cb(<line1>, <line2>)
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
command! -buffer -range -nargs=+ VimwikiListChangeLvl
\ call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
command! -buffer VimwikiRenumberAllLists call vimwiki#lst#adjust_whole_buffer()
command! -buffer VimwikiListToggle call vimwiki#lst#toggle_list_item()
" table commands
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
command! -buffer -nargs=? VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq', <f-args>)
command! -buffer -nargs=? VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww', <f-args>)
command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left()
command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right()
" diary commands
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
" tags commands
command! -buffer -bang VimwikiRebuildTags call vimwiki#tags#update_tags(1, '<bang>')
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
\ VimwikiSearchTags VimwikiSearch /:<args>:/
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
\ VimwikiGenerateTagLinks call vimwiki#tags#generate_tags(1, <f-args>)
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
\ VimwikiGenerateTags
\ call vimwiki#base#deprecate("VimwikiGenerateTags", "VimwikiGenerateTagLinks") |
\ call vimwiki#tags#generate_tags(1, <f-args>)
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
" ------------------------------------------------
" Keybindings
" ------------------------------------------------
" mouse mappings
if str2nr(vimwiki#vars#get_global('key_mappings').mouse)
nmap <buffer> <S-LeftMouse> <NOP>
nmap <buffer> <C-LeftMouse> <NOP>
nnoremap <silent><buffer> <2-LeftMouse>
\ :call vimwiki#base#follow_link('nosplit', 0, 1, "\<lt>2-LeftMouse>")<CR>
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
endif
" <Plug> HTML definitions
nnoremap <script><buffer> <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
nnoremap <script><buffer> <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
" default HTML key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').html)
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'h', '<Plug>Vimwiki2HTML')
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'hh', '<Plug>Vimwiki2HTMLBrowse')
endif
" <Plug> links definitions
nnoremap <silent><script><buffer> <Plug>VimwikiFollowLink
\ :VimwikiFollowLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiSplitLink
\ :VimwikiSplitLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiVSplitLink
\ :VimwikiVSplitLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLink
\ :VimwikiNormalizeLink 0<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisual
\ :<C-U>VimwikiNormalizeLink 1<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisualCR
\ :<C-U>VimwikiNormalizeLink 1<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiTabnewLink
\ :VimwikiTabnewLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiGoBackLink
\ :VimwikiGoBackLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiNextLink
\ :VimwikiNextLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiPrevLink
\ :VimwikiPrevLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiGoto
\ :VimwikiGoto<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiDeleteFile
\ :VimwikiDeleteFile<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiRenameFile
\ :VimwikiRenameFile<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryNextDay
\ :VimwikiDiaryNextDay<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryPrevDay
\ :VimwikiDiaryPrevDay<CR>
" default links key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').links)
call vimwiki#u#map_key('n', '<CR>', '<Plug>VimwikiFollowLink')
call vimwiki#u#map_key('n', '<S-CR>', '<Plug>VimwikiSplitLink')
call vimwiki#u#map_key('n', '<C-CR>', '<Plug>VimwikiVSplitLink')
call vimwiki#u#map_key('n', '+', '<Plug>VimwikiNormalizeLink')
call vimwiki#u#map_key('v', '+', '<Plug>VimwikiNormalizeLinkVisual')
call vimwiki#u#map_key('v', '<CR>', '<Plug>VimwikiNormalizeLinkVisualCR')
call vimwiki#u#map_key('n', '<D-CR>', '<Plug>VimwikiTabnewLink')
call vimwiki#u#map_key('n', '<C-S-CR>', '<Plug>VimwikiTabnewLink', 1)
call vimwiki#u#map_key('n', '<BS>', '<Plug>VimwikiGoBackLink')
call vimwiki#u#map_key('n', '<TAB>', '<Plug>VimwikiNextLink')
call vimwiki#u#map_key('n', '<S-TAB>', '<Plug>VimwikiPrevLink')
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'n', '<Plug>VimwikiGoto')
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'d', '<Plug>VimwikiDeleteFile')
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'r', '<Plug>VimwikiRenameFile')
call vimwiki#u#map_key('n', '<C-Down>', '<Plug>VimwikiDiaryNextDay')
call vimwiki#u#map_key('n', '<C-Up>', '<Plug>VimwikiDiaryPrevDay')
endif
" <Plug> lists definitions
nnoremap <silent><script><buffer> <Plug>VimwikiNextTask
\ :VimwikiNextTask<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem
\ :VimwikiToggleListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem
\ :VimwikiToggleListItem<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiToggleRejectedListItem
\ :VimwikiToggleRejectedListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiToggleRejectedListItem
\ :VimwikiToggleRejectedListItem<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem
\ :VimwikiIncrementListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem
\ :VimwikiIncrementListItem<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem
\ :VimwikiDecrementListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem
\ :VimwikiDecrementListItem<CR>
inoremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
\ <C-O>:VimwikiListChangeLvl decrease 0<CR>
inoremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
\ <C-O>:VimwikiListChangeLvl increase 0<CR>
inoremap <silent><script><buffer> <Plug>VimwikiListNextSymbol
\ <C-O>:VimwikiListChangeSymbolI next<CR>
inoremap <silent><script><buffer> <Plug>VimwikiListPrevSymbol
\ <C-O>:VimwikiListChangeSymbolI prev<CR>
inoremap <silent><script><buffer> <Plug>VimwikiListToggle
\ <Esc>:VimwikiListToggle<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiRenumberList
\ :VimwikiRenumberList<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiRenumberAllLists
\ :VimwikiRenumberAllLists<CR>
noremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
\ :VimwikiListChangeLvl decrease 0<CR>
noremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
\ :VimwikiListChangeLvl increase 0<CR>
noremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlWholeItem
\ :VimwikiListChangeLvl decrease 1<CR>
noremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlWholeItem
\ :VimwikiListChangeLvl increase 1<CR>
noremap <silent><script><buffer> <Plug>VimwikiRemoveSingleCB
\ :VimwikiRemoveSingleCB<CR>
noremap <silent><script><buffer> <Plug>VimwikiRemoveCBInList
\ :VimwikiRemoveCBInList<CR>
nnoremap <silent><buffer> <Plug>VimwikiListo
\ :<C-U>call vimwiki#u#count_exe('call vimwiki#lst#kbd_o()')<CR>
nnoremap <silent><buffer> <Plug>VimwikiListO
\ :<C-U>call vimwiki#u#count_exe('call vimwiki#lst#kbd_O()')<CR>
" default lists key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').lists)
call vimwiki#u#map_key('n', 'gnt', '<Plug>VimwikiNextTask')
call vimwiki#u#map_key('n', '<C-Space>', '<Plug>VimwikiToggleListItem')
call vimwiki#u#map_key('v', '<C-Space>', '<Plug>VimwikiToggleListItem', 1)
if has('unix')
call vimwiki#u#map_key('n', '<C-@>', '<Plug>VimwikiToggleListItem', 1)
call vimwiki#u#map_key('v', '<C-@>', '<Plug>VimwikiToggleListItem', 1)
endif
call vimwiki#u#map_key('n', 'glx', '<Plug>VimwikiToggleRejectedListItem')
call vimwiki#u#map_key('v', 'glx', '<Plug>VimwikiToggleRejectedListItem', 1)
call vimwiki#u#map_key('n', 'gln', '<Plug>VimwikiIncrementListItem')
call vimwiki#u#map_key('v', 'gln', '<Plug>VimwikiIncrementListItem', 1)
call vimwiki#u#map_key('n', 'glp', '<Plug>VimwikiDecrementListItem')
call vimwiki#u#map_key('v', 'glp', '<Plug>VimwikiDecrementListItem', 1)
call vimwiki#u#map_key('i', '<C-D>', '<Plug>VimwikiDecreaseLvlSingleItem')
call vimwiki#u#map_key('i', '<C-T>', '<Plug>VimwikiIncreaseLvlSingleItem')
call vimwiki#u#map_key('n', 'glh', '<Plug>VimwikiDecreaseLvlSingleItem', 1)
call vimwiki#u#map_key('n', 'gll', '<Plug>VimwikiIncreaseLvlSingleItem', 1)
call vimwiki#u#map_key('n', 'gLh', '<Plug>VimwikiDecreaseLvlWholeItem')
call vimwiki#u#map_key('n', 'gLH', '<Plug>VimwikiDecreaseLvlWholeItem', 1)
call vimwiki#u#map_key('n', 'gLl', '<Plug>VimwikiIncreaseLvlWholeItem')
call vimwiki#u#map_key('n', 'gLL', '<Plug>VimwikiIncreaseLvlWholeItem', 1)
call vimwiki#u#map_key('i', '<C-L><C-J>', '<Plug>VimwikiListNextSymbol')
call vimwiki#u#map_key('i', '<C-L><C-K>', '<Plug>VimwikiListPrevSymbol')
call vimwiki#u#map_key('i', '<C-L><C-M>', '<Plug>VimwikiListToggle')
call vimwiki#u#map_key('n', 'glr', '<Plug>VimwikiRenumberList')
call vimwiki#u#map_key('n', 'gLr', '<Plug>VimwikiRenumberAllLists')
call vimwiki#u#map_key('n', 'gLR', '<Plug>VimwikiRenumberAllLists', 1)
call vimwiki#u#map_key('n', 'gl', '<Plug>VimwikiRemoveSingleCB')
call vimwiki#u#map_key('n', 'gL', '<Plug>VimwikiRemoveCBInList')
call vimwiki#u#map_key('n', 'o', '<Plug>VimwikiListo')
call vimwiki#u#map_key('n', 'O', '<Plug>VimwikiListO')
" handle case of existing VimwikiReturn mappings outside the <Plug> definition
if maparg('<CR>', 'i') !~# '.*VimwikiReturn*.'
if has('patch-7.3.489')
" expand iabbrev on enter
inoremap <silent><buffer> <CR> <C-]><Esc>:VimwikiReturn 1 5<CR>
else
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 5<CR>
endif
endif
if maparg('<S-CR>', 'i') !~# '.*VimwikiReturn*.'
inoremap <silent><buffer> <S-CR> <Esc>:VimwikiReturn 2 2<CR>
endif
" change symbol for bulleted lists
for s:char in vimwiki#vars#get_syntaxlocal('bullet_types')
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
endif
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'<CR>')
exe 'noremap <silent><buffer> gL'.s:char.' :VimwikiChangeSymbolInListTo '.s:char.'<CR>'
endif
endfor
" change symbol for numbered lists
for s:typ in vimwiki#vars#get_syntaxlocal('number_types')
if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'<CR>')
exe 'noremap <silent><buffer> gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'<CR>'
endif
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'<CR>')
exe 'noremap <silent><buffer> gL'.s:typ[0].' :VimwikiChangeSymbolInListTo '.s:typ.'<CR>'
endif
endfor
" insert items in a list using langmap characters (see :h langmap)
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
let s:l_o = matchstr(&langmap, '\C,\zs.\zeo,')
if s:l_o
exe 'nnoremap <silent><buffer> '.s:l_o.' :call vimwiki#lst#kbd_o()<CR>a'
endif
let s:l_O = matchstr(&langmap, '\C,\zs.\zeO,')
if s:l_O
exe 'nnoremap <silent><buffer> '.s:l_O.' :call vimwiki#lst#kbd_O()<CR>a'
endif
endif
endif
function! s:CR(normal, just_mrkr) abort
let res = vimwiki#tbl#kbd_cr()
if res !=? ''
exe 'normal! ' . res . "\<Right>"
startinsert
return
endif
call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr)
endfunction
" insert mode table mappings
if str2nr(vimwiki#vars#get_global('key_mappings').table_mappings)
inoremap <expr><buffer> <Tab> vimwiki#tbl#kbd_tab()
inoremap <expr><buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif
" <Plug> table formatting definitions
nnoremap <silent><buffer> <Plug>VimwikiTableAlignQ
\ :VimwikiTableAlignQ<CR>
nnoremap <silent><buffer> <Plug>VimwikiTableAlignQ1
\ :VimwikiTableAlignQ 2<CR>
nnoremap <silent><buffer> <Plug>VimwikiTableAlignW
\ :VimwikiTableAlignW<CR>
nnoremap <silent><buffer> <Plug>VimwikiTableAlignW1
\ :VimwikiTableAlignW 2<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiTableMoveColumnLeft
\ :VimwikiTableMoveColumnLeft<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiTableMoveColumnRight
\ :VimwikiTableMoveColumnRight<CR>
" default table formatting key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').table_format)
call vimwiki#u#map_key('n', 'gqq', '<Plug>VimwikiTableAlignQ')
call vimwiki#u#map_key('n', 'gq1', '<Plug>VimwikiTableAlignQ1')
call vimwiki#u#map_key('n', 'gww', '<Plug>VimwikiTableAlignW')
call vimwiki#u#map_key('n', 'gw1', '<Plug>VimwikiTableAlignW1')
call vimwiki#u#map_key('n', '<A-Left>', '<Plug>VimwikiTableMoveColumnLeft')
call vimwiki#u#map_key('n', '<A-Right>', '<Plug>VimwikiTableMoveColumnRight')
endif
" <Plug> text object definitions
onoremap <silent><buffer> <Plug>VimwikiTextObjHeader
\ :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderV
\ :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjHeaderContent
\ :<C-U>call vimwiki#base#TO_header(1, 0, v:count1)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderContentV
\ :<C-U>call vimwiki#base#TO_header(1, 0, v:count1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSub
\ :<C-U>call vimwiki#base#TO_header(0, 1, v:count1)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSubV
\ :<C-U>call vimwiki#base#TO_header(0, 1, v:count1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSubContent
\ :<C-U>call vimwiki#base#TO_header(1, 1, v:count1)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSubContentV
\ :<C-U>call vimwiki#base#TO_header(1, 1, v:count1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjTableCell
\ :<C-U>call vimwiki#base#TO_table_cell(0, 0)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjTableCellV
\ :<C-U>call vimwiki#base#TO_table_cell(0, 1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjTableCellInner
\ :<C-U>call vimwiki#base#TO_table_cell(1, 0)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjTableCellInnerV
\ :<C-U>call vimwiki#base#TO_table_cell(1, 1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjColumn
\ :<C-U>call vimwiki#base#TO_table_col(0, 0)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjColumnV
\ :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjColumnInner
\ :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjColumnInnerV
\ :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjListChildren
\ :<C-U>call vimwiki#lst#TO_list_item(0, 0)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjListChildrenV
\ :<C-U>call vimwiki#lst#TO_list_item(0, 1)<CR>
onoremap <silent><buffer> <Plug>VimwikiTextObjListSingle
\ :<C-U>call vimwiki#lst#TO_list_item(1, 0)<CR>
vnoremap <silent><buffer> <Plug>VimwikiTextObjListSingleV
\ :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
" default text object key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').text_objs)
call vimwiki#u#map_key('o', 'ah', '<Plug>VimwikiTextObjHeader')
call vimwiki#u#map_key('v', 'ah', '<Plug>VimwikiTextObjHeaderV')
call vimwiki#u#map_key('o', 'ih', '<Plug>VimwikiTextObjHeaderContent')
call vimwiki#u#map_key('v', 'ih', '<Plug>VimwikiTextObjHeaderContentV')
call vimwiki#u#map_key('o', 'aH', '<Plug>VimwikiTextObjHeaderSub')
call vimwiki#u#map_key('v', 'aH', '<Plug>VimwikiTextObjHeaderSubV')
call vimwiki#u#map_key('o', 'iH', '<Plug>VimwikiTextObjHeaderSubContent')
call vimwiki#u#map_key('v', 'iH', '<Plug>VimwikiTextObjHeaderSubContentV')
call vimwiki#u#map_key('o', 'a\', '<Plug>VimwikiTextObjTableCell')
call vimwiki#u#map_key('v', 'a\', '<Plug>VimwikiTextObjTableCellV')
call vimwiki#u#map_key('o', 'i\', '<Plug>VimwikiTextObjTableCellInner')
call vimwiki#u#map_key('v', 'i\', '<Plug>VimwikiTextObjTableCellInnerV')
call vimwiki#u#map_key('o', 'ac', '<Plug>VimwikiTextObjColumn')
call vimwiki#u#map_key('v', 'ac', '<Plug>VimwikiTextObjColumnV')
call vimwiki#u#map_key('o', 'ic', '<Plug>VimwikiTextObjColumnInner')
call vimwiki#u#map_key('v', 'ic', '<Plug>VimwikiTextObjColumnInnerV')
call vimwiki#u#map_key('o', 'al', '<Plug>VimwikiTextObjListChildren')
call vimwiki#u#map_key('v', 'al', '<Plug>VimwikiTextObjListChildrenV')
call vimwiki#u#map_key('o', 'il', '<Plug>VimwikiTextObjListSingle')
call vimwiki#u#map_key('v', 'il', '<Plug>VimwikiTextObjListSingleV')
endif
" <Plug> header definitions
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel
\ :<C-U>call vimwiki#base#AddHeaderLevel(v:count)<CR>
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel
\ :<C-U>call vimwiki#base#RemoveHeaderLevel(v:count)<CR>
nnoremap <silent><buffer> <Plug>VimwikiGoToParentHeader
\ :<C-u>call vimwiki#base#goto_parent_header()<CR>
nnoremap <silent><buffer> <Plug>VimwikiGoToNextHeader
\ :<C-u>call vimwiki#base#goto_next_header()<CR>
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevHeader
\ :<C-u>call vimwiki#base#goto_prev_header()<CR>
nnoremap <silent><buffer> <Plug>VimwikiGoToNextSiblingHeader
\ :<C-u>call vimwiki#base#goto_sibling(+1)<CR>
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader
\ :<C-u>call vimwiki#base#goto_sibling(-1)<CR>
" default header key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').headers)
call vimwiki#u#map_key('n', '=', '<Plug>VimwikiAddHeaderLevel')
call vimwiki#u#map_key('n', '-', '<Plug>VimwikiRemoveHeaderLevel')
call vimwiki#u#map_key('n', ']u', '<Plug>VimwikiGoToParentHeader')
call vimwiki#u#map_key('n', '[u', '<Plug>VimwikiGoToParentHeader', 1)
call vimwiki#u#map_key('n', ']]', '<Plug>VimwikiGoToNextHeader')
call vimwiki#u#map_key('n', '[[', '<Plug>VimwikiGoToPrevHeader')
call vimwiki#u#map_key('n', ']=', '<Plug>VimwikiGoToNextSiblingHeader')
call vimwiki#u#map_key('n', '[=', '<Plug>VimwikiGoToPrevSiblingHeader')
endif
if vimwiki#vars#get_wikilocal('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
augroup END
endif
if vimwiki#vars#get_wikilocal('auto_toc')
" Automatically update the TOC *before* the file is written
augroup vimwiki
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
augroup END
endif
if vimwiki#vars#get_wikilocal('auto_tags')
" Automatically update tags metadata on page write.
augroup vimwiki
au BufWritePre <buffer> call vimwiki#tags#update_tags(0, '')
augroup END
endif
if vimwiki#vars#get_wikilocal('auto_generate_links')
" Automatically generate links *before* the file is written
augroup vimwiki
au BufWritePre <buffer> call vimwiki#base#generate_links(0)
augroup END
endif
if vimwiki#vars#get_wikilocal('auto_generate_tags')
" Automatically generate tags *before* the file is written
augroup vimwiki
au BufWritePre <buffer> call vimwiki#tags#generate_tags(0)
augroup END
endif

View file

@ -1,469 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki plugin file
" Home: https://github.com/vimwiki/vimwiki/
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
if exists('g:loaded_vimwiki') || &compatible
finish
endif
let g:loaded_vimwiki = 1
" Set to version number for release, otherwise -1 for dev-branch
let s:plugin_vers = 2.5
" Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h')
let s:old_cpo = &cpoptions
set cpoptions&vim
if exists('g:vimwiki_autowriteall')
let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall
else
let s:vimwiki_autowriteall_saved = 1
endif
" this is called when the cursor leaves the buffer
function! s:setup_buffer_leave() abort
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
let &autowriteall = s:vimwiki_autowriteall_saved
if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
" create a new temporary wiki for the current buffer
function! s:create_temporary_wiki() abort
let path = expand('%:p:h')
let ext = '.'.expand('%:e')
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
if has_key(syntax_mapping, ext)
let syntax = syntax_mapping[ext]
else
let syntax = vimwiki#vars#get_wikilocal_default('syntax')
endif
let new_temp_wiki_settings = {'path': path,
\ 'ext': ext,
\ 'syntax': syntax,
\ }
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
" Update the wiki number of the current buffer, because it may have changed when adding this
" temporary wiki.
call vimwiki#vars#set_bufferlocal('wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
endfunction
" This function is called when Vim opens a new buffer with a known wiki
" extension. Both when the buffer has never been opened in this session and
" when it has.
function! s:setup_new_wiki_buffer() abort
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
if wiki_nr == -1 " it's not in a known wiki directory
if vimwiki#vars#get_global('global_ext')
call s:create_temporary_wiki()
else
" the user does not want a temporary wiki, so do nothing
return
endif
endif
if vimwiki#vars#get_wikilocal('maxhi')
call vimwiki#vars#set_bufferlocal('existing_wikifiles', vimwiki#base#get_wikilinks(wiki_nr, 1, ''))
call vimwiki#vars#set_bufferlocal('existing_wikidirs',
\ vimwiki#base#get_wiki_directories(wiki_nr))
endif
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
" sourced
call vimwiki#u#ft_set()
endfunction
" this is called when the cursor enters the buffer
function! s:setup_buffer_enter() abort
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
call s:set_global_options()
endfunction
" this is called when the buffer enters a window or when running a diff
function! s:setup_buffer_win_enter() abort
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
if !vimwiki#u#ft_is_vw()
call vimwiki#u#ft_set()
endif
call s:set_windowlocal_options()
endfunction
function! s:setup_cleared_syntax() abort
" highlight groups that get cleared
" on colorscheme change because they are not linked to Vim-predefined groups
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def VimwikiUnderline gui=underline
if vimwiki#vars#get_global('hl_headers') == 1
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='
\ . vimwiki#vars#get_global('hcolor_guifg_'.&background)[i-1]
\ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&background)[i-1]
\ .' term=bold cterm=bold'
endfor
endif
endfunction
function! s:vimwiki_get_known_extensions() abort
" Getting all extensions that different wikis could have
let extensions = {}
for idx in range(vimwiki#vars#number_of_wikis())
let ext = vimwiki#vars#get_wikilocal('ext', idx)
let extensions[ext] = 1
endfor
" append extensions from g:vimwiki_ext2syntax
for ext in keys(vimwiki#vars#get_global('ext2syntax'))
let extensions[ext] = 1
endfor
return keys(extensions)
endfunction
" Set settings which are global for Vim, but should only be executed for
" Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer
" and reset when the cursor leaves the buffer.
function! s:set_global_options() abort
let s:vimwiki_autowriteall_saved = &autowriteall
let &autowriteall = vimwiki#vars#get_global('autowriteall')
if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
" Set settings which are local to a window. In a new tab they would be reset to
" Vim defaults. So we enforce our settings here when the cursor enters a
" Vimwiki buffer.
function! s:set_windowlocal_options() abort
if !&diff " if Vim is currently in diff mode, don't interfere with its folding
let foldmethod = vimwiki#vars#get_global('folding')
if foldmethod =~? '^expr.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^syntax.*'
setlocal foldmethod=syntax
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^custom.*'
" do nothing
else
setlocal foldmethod=manual
normal! zE
endif
endif
if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel')
let &conceallevel = vimwiki#vars#get_global('conceallevel')
endif
if vimwiki#vars#get_global('auto_chdir')
exe 'lcd' vimwiki#vars#get_wikilocal('path')
endif
endfunction
function! s:get_version() abort
if s:plugin_vers != -1
echo 'Stable version: ' . string(s:plugin_vers)
else
let l:plugin_rev = system('git --git-dir ' . s:plugin_dir . '/.git rev-parse --short HEAD')
let l:plugin_branch = system('git --git-dir ' . s:plugin_dir . '/.git rev-parse --abbrev-ref HEAD')
let l:plugin_date = system('git --git-dir ' . s:plugin_dir . '/.git show -s --format=%ci')
if v:shell_error == 0
echo 'Os: ' . vimwiki#u#os_name()
echo 'Vim: ' . v:version
echo 'Branch: ' . l:plugin_branch
echo 'Revision: ' . l:plugin_rev
echo 'Date: ' . l:plugin_date
else
echo 'Unknown version'
endif
endif
endfunction
" Initialization of Vimwiki starts here. Make sure everything below does not
" cause autoload/vimwiki/base.vim to be loaded
call vimwiki#vars#init()
" Define callback functions which the user can redefine
if !exists('*VimwikiLinkHandler')
function VimwikiLinkHandler(url)
return 0
endfunction
endif
if !exists('*VimwikiLinkConverter')
function VimwikiLinkConverter(url, source, target)
" Return the empty string when unable to process link
return ''
endfunction
endif
if !exists('*VimwikiWikiIncludeHandler')
function! VimwikiWikiIncludeHandler(value)
return ''
endfunction
endif
" write a level 1 header to new wiki files
" a:fname should be an absolute filepath
function! s:create_h1(fname) abort
if vimwiki#vars#get_global('auto_header')
let idx = vimwiki#vars#get_bufferlocal('wiki_nr')
" don't do anything for unregistered wikis
if idx == -1
return
endif
" don't create header for the diary index page
if vimwiki#path#is_equal(a:fname,
\ vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx).
\ vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx))
return
endif
" get tail of filename without extension
let title = expand('%:t:r')
" don't insert header for index page
if title ==# vimwiki#vars#get_wikilocal('index', idx)
return
endif
" don't substitute space char for diary pages
if title !~# '^\d\{4}-\d\d-\d\d'
" NOTE: it is possible this could remove desired characters if the 'links_space_char'
" character matches characters that are intentionally used in the title.
let title = substitute(title, vimwiki#vars#get_wikilocal('links_space_char'), ' ', 'g')
endif
" insert the header
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
keepjumps call append(0, '# ' . title)
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
keepjumps call append(1, '')
endfor
else
keepjumps call append(0, '= ' . title . ' =')
endif
endif
endfunction
" Define autocommands for all known wiki extensions
let s:known_extensions = s:vimwiki_get_known_extensions()
if index(s:known_extensions, '.wiki') > -1
augroup filetypedetect
" clear FlexWiki's stuff
au! * *.wiki
augroup end
endif
augroup vimwiki
autocmd!
autocmd ColorScheme * call s:setup_cleared_syntax()
" ['.md', '.mdown'] => *.md,*.mdown
let pat = join(map(s:known_extensions, '"*" . v:val'), ',')
exe 'autocmd BufNewFile,BufRead '.pat.' call s:setup_new_wiki_buffer()'
exe 'autocmd BufEnter '.pat.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave '.pat.' call s:setup_buffer_leave()'
exe 'autocmd BufWinEnter '.pat.' call s:setup_buffer_win_enter()'
if exists('##DiffUpdated')
exe 'autocmd DiffUpdated '.pat.' call s:setup_buffer_win_enter()'
endif
" automatically generate a level 1 header for new files
exe 'autocmd BufNewFile '.pat.' call s:create_h1(expand("%:p"))'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
if vimwiki#vars#get_global('table_auto_fmt')
exe 'autocmd InsertLeave '.pat.' call vimwiki#tbl#format(line("."), 2)'
exe 'autocmd InsertEnter '.pat.' call vimwiki#tbl#reset_tw(line("."))'
endif
if vimwiki#vars#get_global('folding') =~? ':quick$'
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
" Don't screw up folds when inserting text that might affect them, until
" leaving insert mode. Foldmethod is local to the window. Protect against
" screwing up folding when switching between windows.
exe 'autocmd InsertEnter '.pat.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'.
\ ' | setlocal foldmethod=manual | endif'
exe 'autocmd InsertLeave,WinLeave '.pat.' if exists("w:last_fdm") |'.
\ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
endif
augroup END
command! VimwikiUISelect call vimwiki#base#ui_select()
" these commands take a count e.g. :VimwikiIndex 2
" the default behavior is to open the index, diary etc.
" for the CURRENT wiki if no count is given
command! -count=0 VimwikiIndex
\ call vimwiki#base#goto_index(<count>)
command! -count=0 VimwikiTabIndex
\ call vimwiki#base#goto_index(<count>, 1)
command! -count=0 VimwikiDiaryIndex
\ call vimwiki#diary#goto_diary_index(<count>)
command! -count=0 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(<count>)
command! -count=0 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(<count>, 1)
command! -count=0 VimwikiMakeYesterdayDiaryNote
\ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
command! -count=0 VimwikiMakeTomorrowDiaryNote
\ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
command! VimwikiShowVersion call s:get_version()
" <Plug> global definitions
nnoremap <silent><script> <Plug>VimwikiIndex
\ :<C-U>call vimwiki#base#goto_index(v:count)<CR>
nnoremap <silent><script> <Plug>VimwikiTabIndex
\ :<C-U>call vimwiki#base#goto_index(v:count, 1)<CR>
nnoremap <silent><script> <Plug>VimwikiUISelect
\ :VimwikiUISelect<CR>
nnoremap <silent><script> <Plug>VimwikiDiaryIndex
\ :<C-U>call vimwiki#diary#goto_diary_index(v:count)<CR>
nnoremap <silent><script> <Plug>VimwikiDiaryGenerateLinks
\ :VimwikiDiaryGenerateLinks<CR>
nnoremap <silent><script> <Plug>VimwikiMakeDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count)<CR>
nnoremap <silent><script> <Plug>VimwikiTabMakeDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 1)<CR>
nnoremap <silent><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))<CR>
nnoremap <silent><script> <Plug>VimwikiMakeTomorrowDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))<CR>
" get the user defined prefix (default <leader>w)
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
" default global key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').global)
call vimwiki#u#map_key('n', s:map_prefix . 'w', '<Plug>VimwikiIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . 't', '<Plug>VimwikiTabIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . 's', '<Plug>VimwikiUISelect', 2)
call vimwiki#u#map_key('n', s:map_prefix . 'i', '<Plug>VimwikiDiaryIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>i', '<Plug>VimwikiDiaryGenerateLinks', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>w', '<Plug>VimwikiMakeDiaryNote', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>t', '<Plug>VimwikiTabMakeDiaryNote', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>y', '<Plug>VimwikiMakeYesterdayDiaryNote', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>m', '<Plug>VimwikiMakeTomorrowDiaryNote', 2)
endif
function! s:build_menu(topmenu) abort
let wnamelist = []
for idx in range(vimwiki#vars#number_of_wikis())
let wname = vimwiki#vars#get_wikilocal('name', idx)
if wname ==? ''
" fall back to the path if wiki isn't named
let wname = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
endif
if index(wnamelist, wname) != -1
" append wiki index number to duplicate entries
let wname = wname . ' ' . string(idx + 1)
endif
" add entry to the list of names for duplicate checks
call add(wnamelist, wname)
" escape spaces and periods
let wname = escape(wname, '\ \.')
" build the menu
execute 'menu '.a:topmenu.'.Open\ index.'.wname.
\ ' :call vimwiki#base#goto_index('.(idx+1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.wname.
\ ' :call vimwiki#diary#make_note('.(idx+1).')<CR>'
endfor
endfunction
function! s:build_table_menu(topmenu) abort
exe 'menu '.a:topmenu.'.-Sep- :'
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
exe 'nmenu '.a:topmenu.
\ '.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
exe 'nmenu disable '.a:topmenu.'.Table'
endfunction
if !empty(vimwiki#vars#get_global('menu'))
call s:build_menu(vimwiki#vars#get_global('menu'))
call s:build_table_menu(vimwiki#vars#get_global('menu'))
endif
" Hook for calendar.vim
if vimwiki#vars#get_global('use_calendar')
let g:calendar_action = 'vimwiki#diary#calendar_action'
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
endif
let &cpoptions = s:old_cpo

View file

@ -1,490 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Home: https://github.com/vimwiki/vimwiki/
" Quit if syntax file is already loaded
if v:version < 600
syntax clear
elseif exists('b:current_syntax')
finish
endif
let s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
" LINKS: highlighting is complicated due to "nonexistent" links feature
function! s:add_target_syntax_ON(target, type) abort
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction
function! s:add_target_syntax_OFF(target) abort
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction
function! s:highlight_existing_links() abort
" Wikilink
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = '\%('.vimwiki#base#file_pattern(
\ vimwiki#vars#get_bufferlocal('existing_wikifiles')) . '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
" match [[URL]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction
" use max highlighting - could be quite slow if there are too many wikifiles
if vimwiki#vars#get_wikilocal('maxhi')
" WikiLink
call s:add_target_syntax_OFF(vimwiki#vars#get_syntaxlocal('rxWikiLink'))
" WikiIncl
call s:add_target_syntax_OFF(vimwiki#vars#get_global('rxWikiIncl'))
" Subsequently, links verified on vimwiki's path are highlighted as existing
call s:highlight_existing_links()
else
" Wikilink
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink'), 'VimwikiLink')
" WikiIncl
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiIncl'), 'VimwikiLink')
endif
" Weblink
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiLink')
" WikiLink
" All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" Header levels, 1-6
for s:i in range(1,6)
execute 'syntax match VimwikiHeader'.s:i
\ . ' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
\ 'VimwikiLink,@Spell'
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).'/ end=/'.
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).
\ '/me=s-1 transparent fold'
endfor
" possibly concealed chars
let s:conceal = exists('+conceallevel') ? ' conceal' : ''
if vimwiki#vars#get_global('conceal_onechar_markers')
execute 'syn match VimwikiEqInChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_eqin').'/'.s:conceal
execute 'syn match VimwikiBoldChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_bold').'/'.s:conceal
execute 'syn match VimwikiItalicChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_italic').'/'.s:conceal
execute 'syn match VimwikiBoldItalicChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'.s:conceal
execute 'syn match VimwikiItalicBoldChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_italicbold').'/'.s:conceal
execute 'syn match VimwikiCodeChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_code').'/'.s:conceal
execute 'syn match VimwikiDelTextChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_deltext').'/'.s:conceal
execute 'syn match VimwikiSuperScript contained /'.
\ vimwiki#vars#get_syntaxlocal('char_superscript').'/'.s:conceal
execute 'syn match VimwikiSubScript contained /'.
\ vimwiki#vars#get_syntaxlocal('char_subscript').'/'.s:conceal
endif
let s:options = ' contained transparent contains=NONE'
if exists('+conceallevel')
let s:options .= s:conceal
endif
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
" VimwikiLinkRest group is left undefined if link shortening is not desired
if exists('+conceallevel') && vimwiki#vars#get_global('url_maxsave') > 0
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
\.'\%([/#?]\w\|\S\{'.vimwiki#vars#get_global('url_maxsave').'}\)`'.' cchar=~'.s:options
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix1').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix1').'/'.s:options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix1').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1').'/'.s:options
" non concealed chars
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.
\ vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH').
\ '\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_eqin').'/'
execute 'syn match VimwikiBoldCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_bold').'/'
execute 'syn match VimwikiItalicCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_italic').'/'
execute 'syn match VimwikiBoldItalicCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'
execute 'syn match VimwikiItalicBoldCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_italicbold').'/'
execute 'syn match VimwikiCodeCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_code').'/'
execute 'syn match VimwikiDelTextCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_deltext').'/'
execute 'syn match VimwikiSuperScriptT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_superscript').'/'
execute 'syn match VimwikiSubScriptT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_subscript').'/'
execute 'syntax match VimwikiTodo /'. vimwiki#vars#get_global('rxTodo') .'/'
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiNoExistsLinkT,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
\ VimwikiBoldItalicT,
\ VimwikiItalicBoldT,
\ VimwikiDelTextT,
\ VimwikiSuperScriptT,
\ VimwikiSubScriptT,
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" Lists
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
if vimwiki#vars#get_global('hl_cb_checked') == 1
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
\ . '\s*\[['.vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ']\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
execute 'syntax match VimwikiCheckBoxDone /'
\ . vimwiki#vars#get_syntaxlocal('rxListItemAndChildren')
\ .'/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endif
execute 'syntax match VimwikiEqIn /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
\ '/ contains=VimwikiEqInChar,@NoSpell'
execute 'syntax match VimwikiEqInT /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
\ '/ contained contains=VimwikiEqInCharT,@NoSpell'
execute 'syntax match VimwikiBold /'.vimwiki#vars#get_syntaxlocal('rxBold').
\ '/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.vimwiki#vars#get_syntaxlocal('rxBold').
\ '/ contained contains=VimwikiBoldCharT,@Spell'
execute 'syntax match VimwikiItalic /'.vimwiki#vars#get_syntaxlocal('rxItalic').
\ '/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /'.vimwiki#vars#get_syntaxlocal('rxItalic').
\ '/ contained contains=VimwikiItalicCharT,@Spell'
execute 'syntax match VimwikiBoldItalic /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
\ '/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiItalicBold /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
\ '/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contained contains=VimwikiDelTextCharT,@Spell'
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contained contains=VimwikiSuperScriptCharT,@Spell'
execute 'syntax match VimwikiSubScript /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
\ '/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
\ '/ contained contains=VimwikiSubScriptCharT,@Spell'
execute 'syntax match VimwikiCode /'.vimwiki#vars#get_syntaxlocal('rxCode').
\ '/ contains=VimwikiCodeChar,@NoSpell'
execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').
\ '/ contained contains=VimwikiCodeCharT'
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : ''
execute 'syntax region VimwikiPre matchgroup=VimwikiPreDelim start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@NoSpell'.concealpre
execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@NoSpell'
" placeholders
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
syntax match VimwikiPlaceholder
\ /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder
\ /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder
\ /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholderParam /.*/ contained
" html tags
if vimwiki#vars#get_global('valid_html_tags') !=? ''
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').
\ '/ contains=@Spell,VimwikiTodo'
endif
" tags
execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
" header groups highlighting
if vimwiki#vars#get_global('hl_headers') == 0
" Strangely in default colorscheme Title group is not set to bold for cterm...
if !exists('g:colors_name')
hi Title cterm=bold
endif
for s:i in range(1,6)
execute 'hi def link VimwikiHeader'.s:i.' Title'
endfor
else
for s:i in range(1,6)
execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='
\ .vimwiki#vars#get_global('hcolor_guifg_'.&background)[s:i-1].' gui=bold ctermfg='
\ .vimwiki#vars#get_global('hcolor_ctermfg_'.&background)[s:i-1].' term=bold cterm=bold'
endfor
endif
hi def link VimwikiMarkers Normal
hi def link VimwikiEqIn Number
hi def link VimwikiEqInT VimwikiEqIn
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def link VimwikiBoldT VimwikiBold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def link VimwikiItalicT VimwikiItalic
hi def VimwikiBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic
hi def link VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic
hi def VimwikiUnderline gui=underline
hi def link VimwikiCode PreProc
hi def link VimwikiCodeT VimwikiCode
hi def link VimwikiPre PreProc
hi def link VimwikiPreT VimwikiPre
hi def link VimwikiPreDelim VimwikiPre
hi def link VimwikiMath Number
hi def link VimwikiMathT VimwikiMath
hi def link VimwikiNoExistsLink SpellBad
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
hi def link VimwikiLink Underlined
hi def link VimwikiLinkT VimwikiLink
hi def link VimwikiList Identifier
hi def link VimwikiListTodo VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiHR Identifier
hi def link VimwikiTag Keyword
hi def link VimwikiDelText Constant
hi def link VimwikiDelTextT VimwikiDelText
hi def link VimwikiSuperScript Number
hi def link VimwikiSuperScriptT VimwikiSuperScript
hi def link VimwikiSubScript Number
hi def link VimwikiSubScriptT VimwikiSubScript
hi def link VimwikiTodo Todo
hi def link VimwikiComment Comment
hi def link VimwikiPlaceholder SpecialKey
hi def link VimwikiPlaceholderParam String
hi def link VimwikiHTMLtag SpecialKey
hi def link VimwikiEqInChar VimwikiMarkers
hi def link VimwikiCellSeparator VimwikiMarkers
hi def link VimwikiBoldChar VimwikiMarkers
hi def link VimwikiItalicChar VimwikiMarkers
hi def link VimwikiBoldItalicChar VimwikiMarkers
hi def link VimwikiItalicBoldChar VimwikiMarkers
hi def link VimwikiDelTextChar VimwikiMarkers
hi def link VimwikiSuperScriptChar VimwikiMarkers
hi def link VimwikiSubScriptChar VimwikiMarkers
hi def link VimwikiCodeChar VimwikiMarkers
hi def link VimwikiHeaderChar VimwikiMarkers
hi def link VimwikiEqInCharT VimwikiMarkers
hi def link VimwikiBoldCharT VimwikiMarkers
hi def link VimwikiItalicCharT VimwikiMarkers
hi def link VimwikiBoldItalicCharT VimwikiMarkers
hi def link VimwikiItalicBoldCharT VimwikiMarkers
hi def link VimwikiDelTextCharT VimwikiMarkers
hi def link VimwikiSuperScriptCharT VimwikiMarkers
hi def link VimwikiSubScriptCharT VimwikiMarkers
hi def link VimwikiCodeCharT VimwikiMarkers
hi def link VimwikiHeaderCharT VimwikiMarkers
hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
" Load syntax-specific functionality
call vimwiki#u#reload_regexes_custom()
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
let b:current_syntax='vimwiki'
" EMBEDDED syntax setup
let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes')
if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes')
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), 'keep')
endif
if !empty(s:nested)
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
call vimwiki#base#nested_syntax(s:vim_syntax,
\ vimwiki#vars#get_syntaxlocal('rxPreStart').'\%(.*[[:blank:][:punct:]]\)\?'.
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ vimwiki#vars#get_syntaxlocal('rxPreEnd'), 'VimwikiPre')
endfor
endif
" LaTeX
call vimwiki#base#nested_syntax('tex',
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
\ '\%([[:blank:][:punct:]].*\)\?',
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
syntax spell toplevel

View file

@ -1,110 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Description: Defines default syntax
" Home: https://github.com/vimwiki/vimwiki/
" s:default_syntax is kind of a reference to the dict in
" g:vimwiki_syntax_variables['default']. It is used here simply as an
" abbreviation for the latter.
let s:default_syntax = g:vimwiki_syntax_variables['default']
" text: $ equation_inline $
let s:default_syntax.rxEqIn = '\$[^$`]\+\$'
let s:default_syntax.char_eqin = '\$'
" text: *strong*
" let s:default_syntax.rxBold = '\*[^*]\+\*'
let s:default_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.char_bold = '*'
" text: _emphasis_
" let s:default_syntax.rxItalic = '_[^_]\+_'
let s:default_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let s:default_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.char_bolditalic = '\*_'
let s:default_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.char_italicbold = '_\*'
" text: `code`
let s:default_syntax.rxCode = '`[^`]\+`'
let s:default_syntax.char_code = '`'
" text: ~~deleted text~~
let s:default_syntax.rxDelText = '\~\~[^~`]\+\~\~'
let s:default_syntax.char_deltext = '\~\~'
" text: ^superscript^
let s:default_syntax.rxSuperScript = '\^[^^`]\+\^'
let s:default_syntax.char_superscript = '^'
" text: ,,subscript,,
let s:default_syntax.rxSubScript = ',,[^,`]\+,,'
let s:default_syntax.char_subscript = ',,'
" generic headers
let s:default_syntax.rxH = '='
let s:default_syntax.symH = 1
" <hr>, horizontal rule
let s:default_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let s:default_syntax.rxTableSep = '|'
" Lists
let s:default_syntax.bullet_types = ['-', '*', '#']
" 1 means the bullets can be repeatet to indicate the level, like * ** ***
" 0 means the bullets stand on their own and the level is indicated by the indentation
let s:default_syntax.recurring_bullets = 0
let s:default_syntax.number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
"this should contain at least one element
"it is used for i_<C-L><C-J> among other things
let s:default_syntax.list_markers = ['-', '1.', '*', 'I)', 'a)']
let s:default_syntax.rxListDefine = '::\(\s\|$\)'
" Preformatted text
let s:default_syntax.rxPreStart = '{{{'
let s:default_syntax.rxPreEnd = '}}}'
" Math block
let s:default_syntax.rxMathStart = '{{\$'
let s:default_syntax.rxMathEnd = '}}\$'
let s:default_syntax.rxComment = '^\s*%%.*$'
let s:default_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\)\@='
let s:default_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let s:default_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let s:default_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*'.
\ '[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
\ '\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let s:default_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let s:default_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'

View file

@ -1,104 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Description: Defines markdown syntax
" Home: https://github.com/vimwiki/vimwiki/
" see the comments in vimwiki_default.vim for some info about this file
let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
" text: $ equation_inline $
let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$'
let s:markdown_syntax.char_eqin = '\$'
" text: **strong** or __strong__
let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(\*\|_\)\{2\}'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\1\{2\}'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bold = '\*\*\|__'
" text: _emphasis_ or *emphasis*
let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(\*\|_\)'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\1'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italic = '\*\|_'
" text: *_bold italic_* or _*italic bold*_
let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(\*\)\{3\}'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\1\{3\}'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bolditalic = '\*\*\*'
let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(_\)\{3\}'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'\1\{3\}'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italicbold = '___'
" text: `code`
let s:markdown_syntax.rxCode = '`[^`]\+`'
let s:markdown_syntax.char_code = '`'
" text: ~~deleted text~~
let s:markdown_syntax.rxDelText = '\~\~[^~`]\+\~\~'
let s:markdown_syntax.char_deltext = '\~\~'
" text: ^superscript^
let s:markdown_syntax.rxSuperScript = '\^[^^`]\+\^'
let s:markdown_syntax.char_superscript = '^'
" text: ,,subscript,,
let s:markdown_syntax.rxSubScript = ',,[^,`]\+,,'
let s:markdown_syntax.char_subscript = ',,'
" generic headers
let s:markdown_syntax.rxH = '#'
let s:markdown_syntax.symH = 0
" <hr>, horizontal rule
let s:markdown_syntax.rxHR = '\(^---*$\|^___*$\|^\*\*\**$\)'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let s:markdown_syntax.rxTableSep = '|'
" Lists
let s:markdown_syntax.bullet_types = ['-', '*', '+']
let s:markdown_syntax.recurring_bullets = 0
let s:markdown_syntax.number_types = ['1.']
let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
" Preformatted text (code blocks)
let s:markdown_syntax.rxPreStart = '\%(`\{3,}\|\~\{3,}\)'
let s:markdown_syntax.rxPreEnd = '\%(`\{3,}\|\~\{3,}\)'
" TODO see syntax/vimwiki_markdown_custom.vim for more info
" let s:markdown_syntax.rxIndentedCodeBlock = '\%(^\n\)\@1<=\%(\%(\s\{4,}\|\t\+\).*\n\)\+'
" Math block
let s:markdown_syntax.rxMathStart = '\$\$'
let s:markdown_syntax.rxMathEnd = '\$\$'
let s:markdown_syntax.rxComment = '^\s*%%.*$\|<!--[^>]*-->'
let s:markdown_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
let s:markdown_syntax.header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
let s:markdown_syntax.header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
let s:markdown_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs'.
\ '\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
\ '\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let s:markdown_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let s:markdown_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'

View file

@ -1,206 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Description: Defines markdown custom syntax
" Home: https://github.com/vimwiki/vimwiki/
function! s:add_target_syntax_ON(target, type) abort
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction
function! s:add_target_syntax_OFF(target, type) abort
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction
function! s:wrap_wikilink1_rx(target) abort
return vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidPrefix') . a:target.
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidSuffix')
endfunction
function! s:existing_mkd_refs() abort
return keys(vimwiki#markdown_base#scan_reflinks())
endfunction
function! s:highlight_existing_links() abort
" Wikilink1
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = '\%('.
\ vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
\ '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
" Ref links are cached
let safe_reflinks = vimwiki#base#file_pattern(s:existing_mkd_refs())
" match [URL][]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ safe_links, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][URL]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ safe_links, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DIRURL][]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ safe_dirs, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][DIRURL]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ safe_dirs, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [MKDREF][]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][MKDREF]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
endfunction
" use max highlighting - could be quite slow if there are too many wikifiles
if vimwiki#vars#get_wikilocal('maxhi')
" WikiLink
call s:add_target_syntax_OFF(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
" Subsequently, links verified on vimwiki's path are highlighted as existing
call s:highlight_existing_links()
else
" Wikilink
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
endif
" Weblink
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink1'), 'VimwikiWeblink1')
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxImage'), 'VimwikiImage')
" WikiLink
" All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ '\):'
" a) match [nonwiki-scheme-URL]
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" b) match [DESCRIPTION][nonwiki-scheme-URL]
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" Header levels, 1-6
for s:i in range(1,6)
execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i).
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
\ 'VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endfor
" concealed chars
if exists('+conceallevel')
syntax conceal on
endif
syntax spell toplevel
" VimwikiWikiLink1Char is for syntax markers (and also URL when a description
" is present) and may be concealed
let s:options = ' contained transparent contains=NONE'
" conceal wikilink1
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rx_wikilink_md_prefix').'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rx_wikilink_md_suffix').'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Prefix1').'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Suffix1').'/'.s:options
" conceal weblink1
execute 'syn match VimwikiWeblink1Char "'.
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Prefix1').'"'.s:options
execute 'syn match VimwikiWeblink1Char "'.
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options
"image
execute 'syn match VimwikiImageChar "!"'.s:options
execute 'syn match VimwikiImageChar "'.
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Prefix1').'"'.s:options
execute 'syn match VimwikiImageChar "'.
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options
if exists('+conceallevel')
syntax conceal off
endif
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiWeblink1T,
\ VimwikiWikiLink1T,
\ VimwikiNoExistsLinkT,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
\ VimwikiBoldItalicT,
\ VimwikiItalicBoldT,
\ VimwikiDelTextT,
\ VimwikiSuperScriptT,
\ VimwikiSubScriptT,
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
" TODO fix behavior within lists https://github.github.com/gfm/#list-items
" indented code blocks https://github.github.com/gfm/#indented-code-blocks
" execute 'syntax match VimwikiIndentedCodeBlock /' . vimwiki#vars#get_syntaxlocal('rxIndentedCodeBlock') . '/'
" hi def link VimwikiIndentedCodeBlock VimwikiPre
" syntax group highlighting
hi def link VimwikiImage VimwikiLink
hi def link VimwikiImageT VimwikiLink
hi def link VimwikiWeblink1 VimwikiLink
hi def link VimwikiWeblink1T VimwikiLink
hi def link VimwikiWikiLink1 VimwikiLink
hi def link VimwikiWikiLink1T VimwikiLink

View file

@ -1,85 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Description: Defines mediaWiki syntax
" Home: https://github.com/vimwiki/vimwiki/
" see the comments in vimwiki_default.vim for some info about this file
let s:media_syntax = g:vimwiki_syntax_variables['media']
" text: $ equation_inline $
let s:media_syntax.rxEqIn = '\$[^$`]\+\$'
let s:media_syntax.char_eqin = '\$'
" text: '''strong'''
let s:media_syntax.rxBold = "'''[^']\\+'''"
let s:media_syntax.char_bold = "'''"
" text: ''emphasis''
let s:media_syntax.rxItalic = "''[^']\\+''"
let s:media_syntax.char_italic = "''"
" text: '''''strong italic'''''
let s:media_syntax.rxBoldItalic = "'''''[^']\\+'''''"
let s:media_syntax.rxItalicBold = s:media_syntax.rxBoldItalic
let s:media_syntax.char_bolditalic = "'''''"
let s:media_syntax.char_italicbold = s:media_syntax.char_bolditalic
" text: `code`
let s:media_syntax.rxCode = '`[^`]\+`'
let s:media_syntax.char_code = '`'
" text: ~~deleted text~~
let s:media_syntax.rxDelText = '\~\~[^~]\+\~\~'
let s:media_syntax.char_deltext = '\~\~'
" text: ^superscript^
let s:media_syntax.rxSuperScript = '\^[^^]\+\^'
let s:media_syntax.char_superscript = '^'
" text: ,,subscript,,
let s:media_syntax.rxSubScript = ',,[^,]\+,,'
let s:media_syntax.char_subscript = ',,'
" generic headers
let s:media_syntax.rxH = '='
let s:media_syntax.symH = 1
" <hr>, horizontal rule
let s:media_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let s:media_syntax.rxTableSep = '|'
" Lists
let s:media_syntax.bullet_types = ['*', '#']
let s:media_syntax.recurring_bullets = 1
let s:media_syntax.number_types = []
let s:media_syntax.list_markers = ['*', '#']
let s:media_syntax.rxListDefine = '^\%(;\|:\)\s'
" Preformatted text
let s:media_syntax.rxPreStart = '<pre>'
let s:media_syntax.rxPreEnd = '<\/pre>'
" Math block
let s:media_syntax.rxMathStart = '{{\$'
let s:media_syntax.rxMathEnd = '}}\$'
let s:media_syntax.rxComment = '^\s*%%.*$'
let s:media_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
let s:media_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let s:media_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let s:media_syntax.bold_search = "'''\\zs[^']\\+\\ze'''"
let s:media_syntax.bold_match = '''''''__Text__'''''''
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
" want to call escape() on this string, we must keep it in single quotes
let s:media_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let s:media_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let s:media_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'

View file

@ -1,75 +0,0 @@
# 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`.
## 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

@ -1,103 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
# 1 VimwikiGenerateLinks
##########################
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)
Do (Save Test.md && Re-GenerateLinks):
:edit $HOME/testmarkdown/Test.md\<CR>
:set bt=\<CR>
:write %\<CR>
:VimwikiGenerateLinks\<CR>
Expect (The links with a header with file Test):
# Generated Links
- [Generated Links](Test)
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
# 2 VimwikiDiaryGenerateLinks
#############################
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
## 2019
### December
- [2019-12-10](2019-12-10)
### July
- [informative title](2019-07-13)
### March
- [2019-03-01](2019-03-01)
Execute (Clean):
Log "End: Clean"
call system("rm $HOME/testmarkdown/diary/2019-12-10.md")
call system("rm $HOME/testmarkdown/diary/2019-07-13.md")
call system("rm $HOME/testmarkdown/diary/2019-03-01.md")
call system("rm $HOME/testmarkdown/diary/diary.md")
Include: vader_includes/vader_teardown.vader
" vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View file

@ -1,96 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (Setup):
set sw=4
AssertEqual 4, &sw
Execute (Edit Test-Tag.md):
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):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
I
: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 2.5
second-tag Test-Tag.md 13;" vimwiki:Test-Tag\tTest-Tag#second-tag
test-tag Test-Tag.md 5;" vimwiki:Test-Tag\tTest-Tag#A header
top-tag Test-Tag.md 1;" vimwiki:Test-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):
Log "End: Clean"
call system("rm $HOME/testmarkdown/Test.md")
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag.md")
call DeleteHiddenBuffers()
Include: vader_includes/vader_teardown.vader

View file

@ -1,64 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (VimwikiGoto buzz_bozz && Assert):
VimwikiIndex 2
VimwikiGoto buzz_bozz
AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')
Do (VimwikiGoto <CR> buzz_bozz && Assert):
:VimwikiIndex 2\<CR>
:VimwikiGoto\<CR>
buzz_bozz\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Execute (:VimwikiGoto + Completion):
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):
Log "End: Clean"
call system("rm $HOME/testmarkdown/dir1")
Include: vader_includes/vader_teardown.vader
# vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View file

@ -1,189 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
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")
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()
Do (RenameLink in_dir11 -> new_dir11):
: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')
Include: vader_includes/vader_teardown.vader
# vim: sw=2 foldmethod=indent foldlevel=30 foldignore=#

View file

@ -1,149 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Reset TOC header to default):
let g:vimwiki_global_vars['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 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# 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 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# 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 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# 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):
let g:vimwiki_global_vars['toc_header'] = "Sommaire"
VimwikiTOC
Expect (Append a Sommaire && Leave Contents alone):
# Sommaire
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# 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 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Include: vader_includes/vader_teardown.vader
" vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View file

@ -1,59 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
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>
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>
Include: vader_includes/vader_teardown.vader

View file

@ -1,461 +0,0 @@
Include: vader_setup
# 0 Configure {{{1
##################
Execute (Configure: Set vimwiki list to markdown resource):
Log "Let mapleader = ,"
let mapleader = ','
Log "Declare function DestroyVar"
function! DestroyVar(var)
if ! exists(a:var) | return | endif
execute "unlet " . a:var
endfunction
Log "Declare function AssertTab"
function! AssertTab(nr)
" Vader is creating 2 tabs
AssertEqual a:nr + 2, tabpagenr()
endfunction
Log "Destroy vimrc or previous run heritage"
call DestroyVar('g:vimwiki_list')
call DestroyVar('g:vimwiki_global_vars')
call DestroyVar('g:vimwiki_wikilocal_vars')
Log "Destroy vimrc variable, works better that way"
call DestroyVar('g:vimwiki_default')
call DestroyVar('g:vimwiki_markdown')
call DestroyVar('g:vimwiki_mediawiki')
Log "Declare my vimwiki_list"
let g:vimwiki_list = [{
\ 'path': 'test/resources/testmarkdown',
\ 'syntax': 'markdown',
\ 'ext': '.md'
\ }]
Log "Declare my extension for temporary wiki"
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
Log "Reload vimwiki <- vader_setup.vader"
call ReloadVimwiki()
Execute (Assert: 2 wiki in Index):
AssertEqual 2, len(vimwiki_wikilocal_vars)
Execute (VimwikiIndex):
VimwikiIndex 1
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
AssertEqual 'vimwiki', &filetype
AssertEqual 'test/resources/testmarkdown/', vimwiki_wikilocal_vars[0]['path']
AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
Execute (Open buzz bozz):
edit test/resources/testmarkdown/buzz_bozz.md
AssertEqual 'test/resources/testmarkdown/buzz_bozz.md', expand('%')
# 1 Global {{{1
###############
Execute (===========================================================):
Log "Checking global map"
Do (,ww -> open index [Assert]):
,ww
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wt -> open index in tab [Assert]):
,wt
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,w,w -> open diary [Assert]):
,w,w
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,t -> open diary in tab [Assert]):
,w,t
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,ws -> list and select wiki [Assert]):
,ws
1
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wi -> open diary index [Assert]):
,wi
:AssertEqual 'test/resources/testmarkdown/diary/diary.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,y -> open yesterday [Assert]):
,w,y
:AssertEqual 'test/resources/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 'test/resources/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.1 Heading {{{2
##############
Do (,wn -> Create new wiki [Assert]):
,wn
new_file1
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file1.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wd -> Delete wiki yes [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 2
\<Esc>
,wd
yes
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
Do (,wd -> Delete wiki no [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 1
\<Esc>
,wd
no
\<CR>
:AssertEqual 'test/resources/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 'test/resources/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
##############
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
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
# 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
Include: vader_teardown
# vim: foldmethod=marker foldlevel=30 sw=2

View file

@ -1,66 +0,0 @@
Include: vader_setup
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)
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
Assert match(output, 'VimwikiSearch: No match found.') > -1, "expected custom error"
Include: vader_teardown

View file

@ -1 +0,0 @@
../vader_includes/vader_setup.vader

View file

@ -1 +0,0 @@
../vader_includes/vader_teardown.vader

View file

@ -1,125 +0,0 @@
Include: vader_includes/vader_setup.vader
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]]
Include: vader_includes/vader_teardown.vader

View file

@ -1,225 +0,0 @@
Include: vader_includes/vader_setup.vader
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):
file 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):
bd! /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)
Include: vader_includes/vader_teardown.vader

View file

@ -1,282 +0,0 @@
# 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`
Include: vader_includes/vader_setup.vader
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.
---
Include: vader_includes/vader_teardown.vader

View file

@ -1,108 +0,0 @@
Include: vader_includes/vader_setup.vader
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
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
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
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
Expect (Links with margin == 5):
# Generated Links
- [page1](page1)
- [page2](page2)
- [page3](page3)
Execute (Return to default location & cleanup):
cd /testplugin
Include: vader_includes/vader_teardown.vader

View file

@ -1,191 +0,0 @@
Include: vader_includes/vader_setup.vader
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
Include: vader_includes/vader_teardown.vader

File diff suppressed because it is too large Load diff

View file

@ -1,3 +0,0 @@
# 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

@ -1,59 +0,0 @@
# 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

@ -1,3 +0,0 @@
= 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

@ -1,30 +0,0 @@
= 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

@ -1,3 +0,0 @@
= 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

@ -1,35 +0,0 @@
= 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

@ -1,248 +0,0 @@
#!/usr/bin/env bash
# credit to https://github.com/w0rp/ale for script ideas and the color vader
# output function.
printHelp() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Runs Vimwiki Vader tests or Vint in a Docker container"
echo ""
echo "-h Print help message"
echo ""
echo "-n Specify vim/nvim version to run tests for."
echo " Multiple versions can be specified by quoting the value and"
echo " separating versions with a space. E.g. -v \"vim1 vim2\"."
echo " Default is all available versions."
echo ""
echo "-l List available versions that can be used with the '-v' option"
echo ""
echo "-t Select test type: 'vader', 'vint', or 'all'"
echo ""
echo "-o Comma seperated list of tests to run."
echo " E.g. -o \"list_margin,command_toc\""
echo ""
echo "-v Turn on verbose output."
exit 0
}
printVersions() {
# print the names of all vim/nvim versions
getVers
}
runVader() {
echo "Starting Docker container and Vader tests."
if [[ -z $only ]]; then
ind="test/independent_runs/*.vader"
res="test/*"
else
IFS=',' read -ra TEST <<< "$only"
for i in "${TEST[@]}"; do
if [[ -f "$i" ]]; then
res="$res test/${i}"
elif [[ -f "${i}.vader" ]]; then
res="$res test/${i}.vader"
elif [[ -f "independent_runs/${i}" ]]; then
ind="$ind test/independent_runs/${i}"
elif [[ -f "independent_runs/${i}.vader" ]]; then
ind="$ind test/independent_runs/${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 ""
echo "Running version: $v"
vim="/vim-build/bin/$v -u test/vimrc -i NONE"
test_cmd="for VF in ${ind}; do $vim \"+Vader! \$VF\"; done"
set -o pipefail
# tests that must be run in individual vim instances
# see README.md for more information
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
/bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color
# remaining tests
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
"$v" -u test/vimrc -i NONE "+Vader! ${res}" 2>&1 | vader_filter | vader_color
set +o pipefail
done
}
runVint() {
echo "Starting Docker container and running Vint."
docker run -a stdout "${flags[@]}" vint -s .
}
getVers() {
sed -n 's/.* -name \([^ ]*\) .*/\1/p' ../Dockerfile
}
vader_filter() {
local err=0
while read -r; do
if [[ "$verbose" == 0 ]]; then
# only print 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"
fi
else
# just print everything
echo "$REPLY"
fi
done
if [[ "$err" == 1 ]]; then
echo ""
echo "!---------Failed tests detected---------!"
echo "Run with the '-v' flag for verbose output"
echo ""
fi
}
# Say Hi
echo -en "Starting $(basename $0) for VimWiki\n"
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"
}
# 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
only=""
# docker flags
flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki)
while getopts ":hvn:lt:o:" opt; do
case ${opt} in
h )
printHelp
;;
n )
vers="$OPTARG"
;;
v )
verbose=1
;;
l )
printVersions
;;
t )
type="$OPTARG"
;;
o )
only="$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
# select which tests should run
o_error=0
case $type in
"vader" )
runVader
echo "Vader: returned $?"
o_error=$(( $? | $o_error ))
;;
"vint" )
runVint
echo "Vint: returned $?"
o_error=$(( $? | $o_error ))
;;
"all" )
runVint
echo "Vint: returned $?"
o_error=$(( $? | $o_error ))
runVader
echo "Vader: returned $?"
o_error=$(( $? | $o_error ))
;;
* )
echo "Error: invalid type - '$type'" 1>&2
exit 1
esac
echo "Script $(basename $0) exiting: $o_error"
exit $o_error

View file

@ -1,318 +0,0 @@
Include: vader_includes/vader_setup.vader
# 1 Typeface {{{1
#################
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 (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 SyntaxAt(1, 4), 'VimwikiBold'
AssertEqual SyntaxAt(2, 4), 'VimwikiBold'
AssertEqual SyntaxAt(3, 4), 'VimwikiItalic'
AssertEqual SyntaxAt(4, 4), 'VimwikiItalic'
AssertEqual SyntaxAt(5, 4), 'VimwikiBoldItalic'
AssertEqual SyntaxAt(6, 4), 'VimwikiItalicBold'
AssertEqual SyntaxAt(7, 4), 'VimwikiDelText'
AssertEqual SyntaxAt(8, 4), 'VimwikiCode'
AssertEqual SyntaxAt(9, 4), 'VimwikiSuperScript'
AssertEqual SyntaxAt(10, 4), 'VimwikiSubScript'
# 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 SyntaxAt(2, 6), 'VimwikiLink'
AssertEqual SyntaxAt(4, 6), 'VimwikiLink'
AssertEqual SyntaxAt(6, 6), 'VimwikiLink'
AssertEqual SyntaxAt(8, 6), 'VimwikiLink'
AssertEqual SyntaxAt(10, 6), 'VimwikiLink'
AssertEqual SyntaxAt(12, 6), 'VimwikiLink'
AssertEqual SyntaxAt(14, 6), 'VimwikiLink'
AssertEqual SyntaxAt(16, 6), 'VimwikiLink'
AssertEqual SyntaxAt(18, 6), 'VimwikiLink'
AssertEqual SyntaxAt(20, 6), 'VimwikiLink'
AssertEqual SyntaxAt(22, 6), 'VimwikiLink'
AssertEqual SyntaxAt(24, 6), 'VimwikiLink'
AssertEqual SyntaxAt(26, 6), 'VimwikiLink'
AssertEqual SyntaxAt(28, 6), 'VimwikiLink'
AssertEqual SyntaxAt(30, 6), 'VimwikiLink'
AssertEqual SyntaxAt(32, 6), 'VimwikiLink'
AssertEqual SyntaxAt(34, 6), 'VimwikiLink'
AssertEqual SyntaxAt(36, 6), 'VimwikiLink'
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 SyntaxAt(2, 8), 'VimwikiWeblink1'
AssertEqual SyntaxAt(5, 8), 'VimwikiImage'
AssertEqual SyntaxAt(8, 8), 'VimwikiWikiLink1'
AssertEqual SyntaxAt(9, 8), 'VimwikiWikiLink1'
# 3 Header {{{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 Syntax Header):
AssertEqual SyntaxAt(1, 10), 'VimwikiHeader1'
AssertEqual SyntaxAt(2, 10), 'VimwikiHeader2'
AssertEqual SyntaxAt(3, 10), 'VimwikiHeader3'
AssertEqual SyntaxAt(4, 10), 'VimwikiHeader4'
AssertEqual SyntaxAt(5, 10), 'VimwikiHeader5'
AssertEqual SyntaxAt(6, 10), 'VimwikiHeader6'
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 Syntax Header):
AssertEqual SyntaxAt(1, 10), 'VimwikiHeader1'
AssertEqual SyntaxAt(2, 10), 'VimwikiHeader2'
AssertEqual SyntaxAt(3, 10), 'VimwikiHeader3'
AssertEqual SyntaxAt(4, 10), 'VimwikiHeader4'
AssertEqual SyntaxAt(5, 10), 'VimwikiHeader5'
AssertEqual SyntaxAt(6, 10), 'VimwikiHeader6'
# 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 SyntaxAt(2, 9), 'VimwikiTodo'
Execute (Assert Code syntax):
AssertEqual SyntaxAt(4, 1), 'VimwikiPreDelim'
AssertEqual SyntaxAt(5, 1), 'VimwikiPre'
AssertEqual SyntaxAt(9, 1), 'vimLineComment'
AssertEqual SyntaxAt(10, 1), 'vimCommand'
AssertEqual SyntaxAt(13, 1), 'VimwikiPre'
AssertEqual SyntaxAt(14, 1), 'vimLineComment'
AssertEqual SyntaxAt(15, 1), 'vimCommand'
AssertEqual SyntaxAt(16, 1), 'VimwikiPre'
AssertEqual SyntaxAt(18, 1), 'VimwikiPre'
AssertEqual SyntaxAt(19, 1), 'vimLineComment'
AssertEqual SyntaxAt(20, 1), 'vimCommand'
AssertEqual SyntaxAt(21, 1), 'VimwikiPre'
AssertEqual SyntaxAt(23, 1), 'VimwikiPre'
AssertEqual SyntaxAt(24, 1), 'vimLineComment'
AssertEqual SyntaxAt(25, 1), 'vimCommand'
AssertEqual SyntaxAt(26, 1), 'VimwikiPre'
# 11 Math {{{1
# 11.1 Math Markdown {{{2
#######################
Given vimwiki (Math markdown):
math inline: $ \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):
AssertEqual SyntaxAt(1, 18), 'VimwikiEqIn'
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: $ \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):
AssertEqual SyntaxAt(1, 18), 'VimwikiEqIn'
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'
Include: vader_includes/vader_teardown.vader
# vim: foldmethod=marker foldlevel=30 sw=2

View file

@ -1,157 +0,0 @@
Include: vader_includes/vader_setup.vader
# 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):
| | | | | | | | |
|---|---|---|---|---|---|---|---|
| | | | | | | | |
| | | | | | | | |
# 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 |
Include: vader_includes/vader_teardown.vader
# vim: foldmethod=marker foldlevel=30

View file

@ -1,32 +0,0 @@
Include: vader_includes/vader_setup.vader
Execute (Set fold method):
let g:vimwiki_folding = 'expr:quick'
call ReloadVimwiki()
Execute (Expect < 0.5 second delay: Issue #580):
" prep
edit test/resources/delay.wiki
normal! 50%
# TODO set ft and set wiki syntax or this error (no fold found)
# normal! zozo
tabedit
" run test
let start = reltime()
tabprev
redraw
let end = str2float(reltimestr(reltime(start)))
" cleanup
bdelete test/resources/delay.wiki
" verify
Log 'Elapsed time = ' . string(end)
Assert end < 0.5, 'Took longer than expected: ' . string(end) . ' seconds'
Execute (Reset variables):
let g:vimwiki_folding = ''
call ReloadVimwiki()
Include: vader_includes/vader_teardown.vader

View file

@ -1,89 +0,0 @@
Before (Define functions):
" change the syntax using a temporary wiki
function! SetSyntax(vw_syn)
if a:vw_syn ==# 'default'
let ext = 'wiki'
elseif a:vw_syn ==# 'markdown'
let ext = 'md'
elseif a:vw_syn ==# 'media'
let ext = 'mw'
else
Log 'ERROR: Invalid syntax "' . a:vw_syn . '" in SetSyntax()'
Log 'NOTE: function only accepts "media" for setting mediawiki syntax'
return
endif
let path = expand('%:p:h')
let new_temp_wiki_settings = {'path': path,
\ 'ext': ext,
\ 'syntax': a:vw_syn,
\ }
" 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.'
endfunction
" reload plugin to change settings
function! ReloadVimwiki()
" clear mappings so plugin can be reloaded
" this is needed if running manually multiple times
nmapclear
unlet g:loaded_vimwiki
source plugin/vimwiki.vim
endfunction
" Copy wiki test resources so that vimtest user can write them
function! CopyResources()
call system('cp -r /testplugin/test/resources/* $HOME/')
" Make diary directory
call system('mkdir $HOME/testwiki/diary')
call system('mkdir $HOME/testmarkdown/diary')
endfunction
" Delete Hidden buffer, usefull to clean
" Stole from: https://stackoverflow.com/a/8459043/2544873
function! DeleteHiddenBuffers()
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
" Write current file: helper to hide `set bt=`
function! WriteMe()
set buftype=
write %
endfunction
" print a command output to the buffer
function! PrintCommand(cmd)
redir => message
silent execute a:cmd
redir END
if empty(message)
Log 'no output'
else
silent put=message
endif
endfunction
# vim: ft=vim

View file

@ -1,6 +0,0 @@
After (Cleanup):
delfunction SetSyntax
delfunction ReloadVimwiki
delfunction DeleteHiddenBuffers
delfunction WriteMe
delfunction PrintCommand

View file

@ -1,67 +0,0 @@
source /rtp.vim
set runtimepath+=/vader
" vint: -ProhibitSetNoCompatible
set nocompatible
filetype plugin indent on
syntax enable
" Wiki's resources to be used after:
" :!cp -r /testplugin/test/resources/* $HOME/
" or from a test.vader file Execute block:
" call CopyResources()
" This complication aims for these copies to be writable
" default syntax
let vimwiki_default = {}
let vimwiki_default.path = $HOME . '/testwiki'
let vimwiki_default.path_html = $HOME . '/html/default'
let vimwiki_default.syntax = 'default'
let vimwiki_default.ext = '.wiki'
let vimwiki_default.name = 'DefaultSyntax'
" 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'
" 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'
" register the 3 wikis
let g:vimwiki_list = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki]
" basic settings
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
" use ctrl-p/n for history completion instead of up/down arrows
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
" 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

View file

@ -17,4 +17,3 @@ Git submodules are slow, so handle this manually.
* [vim-actodo](https://github.com/acperkins/vim-actodo)
* [vim-speeddating](https://github.com/tpope/vim-speeddating)
* [vim-surround](https://github.com/tpope/vim-surround)
* [vimwiki](https://github.com/vimwiki/vimwiki)

5
vimrc
View file

@ -1,6 +1,7 @@
" Anthony Perkins https://git.acperkins.com/acp/vimfiles
" Anthony Perkins
" https://github.com/acperkins/vimfiles
"
" Distributed under the VIM license. See ':help license' for a copy. Files
" Distributed under the VIM license. See ':help license' for a copy. Files
" under pack/ and coc/extensions/node_modules/ have their own licenses.
"
" Includes parts from Tim Pope's «sensible.vim»

View file

@ -1,48 +0,0 @@
Windows Registry Editor Version 5.00
;=======================================================================
; Add "Edit with Vim" to all file types.
[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\gvim]
@="Edit with Vim"
[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\gvim\command]
; Maps to "\"%USERPROFILE%\\Apps\\vim\\vim80\\gvim.exe" \"%1\""
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,41,00,70,00,70,00,73,00,5c,00,76,00,69,00,6d,00,5c,00,\
76,00,69,00,6d,00,38,00,30,00,5c,00,67,00,76,00,69,00,6d,00,2e,00,65,00,78,\
00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\gvim-ro]
@="View with Vim (read-only)"
[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\gvim-ro\command]
; Maps to "\"%USERPROFILE%\\Apps\\vim\\vim80\\gvim.exe" -R \"%1\""
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,41,00,70,00,70,00,73,00,5c,00,76,00,69,00,6d,00,5c,00,\
76,00,69,00,6d,00,38,00,30,00,5c,00,67,00,76,00,69,00,6d,00,2e,00,65,00,78,\
00,65,00,22,00,20,00,2d,00,52,00,20,00,22,00,25,00,31,00,22,00,00,00
;=======================================================================
; Define "Vim" file type to open with gVim
[HKEY_CURRENT_USER\SOFTWARE\Classes\Vim\DefaultIcon]
@="%SystemRoot%\\System32\\imageres.dll,97"
[HKEY_CURRENT_USER\SOFTWARE\Classes\Vim\shell\open]
@="Open"
[HKEY_CURRENT_USER\SOFTWARE\Classes\Vim\shell\open\command]
; Maps to "\"%USERPROFILE%\\Apps\\vim\\vim80\\gvim.exe" \"%1\""
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,41,00,70,00,70,00,73,00,5c,00,76,00,69,00,6d,00,5c,00,\
76,00,69,00,6d,00,38,00,30,00,5c,00,67,00,76,00,69,00,6d,00,2e,00,65,00,78,\
00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,00,00
;=======================================================================
; Vim file
[HKEY_CURRENT_USER\SOFTWARE\Classes\.vim]
@="Vim"
"Content Type"="text/x-vim"
"PerceivedType"="text"