4 Commits

Author SHA1 Message Date
Michael F. Schönitzer bfc3aa06fd Fix bug 2019-01-17 21:59:43 +01:00
Michael F. Schönitzer a597875dce Update documentation 2019-01-17 21:59:43 +01:00
Michael F. Schönitzer 5d38b8ddc2 Allow list symbols to be configured per wiki 2019-01-17 21:59:43 +01:00
Michael F. Schönitzer 37f54d92c3 Allow to specify additional chars for lists
See also #390 and #479 for earlier attempts
2019-01-17 21:59:43 +01:00
19 changed files with 499 additions and 1406 deletions
-11
View File
@@ -1,11 +0,0 @@
# Issue Checks
Prior to submitting a new issue make sure to complete these steps:
1. 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.
2. Post the syntax you are using (default/mediawiki/markdown) **and** your vimwiki settings from your `.vimrc`
3. Provide a detailed description of the problem including **steps to reproduce the issue**.
4. Include the output of `:VimwikiShowVersion`.
**DELETE THIS TEMPLATE TEXT PRIOR TO SUBMITTING THE ISSUE**
-9
View File
@@ -1,9 +0,0 @@
# Pull Request Checks
1. **ALL** pull requests should be made against the `dev` branch!
2. Take a look at [CONTRIBUTING.MD](https://github.com/vimwiki/vimwiki/blob/dev/CONTRIBUTING.md)
3. Reference any related issues.
4. Provide a description of the proposed changes and any testing that was done.
5. Make sure to update the documentation in `doc/vimwiki.txt` if applicable.
**DELETE THIS TEMPLATE TEXT PRIOR TO SUBMITTING YOUR PULL REQUEST**
+2 -11
View File
@@ -10,23 +10,14 @@ If you want to provide a pull request on GitHub, please start from the `dev` bra
`master` branch. (Caution, GitHub shows `master` as the default branch from which to start a PR.)
# 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 compatiblility. 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.
# More info for (aspiring) core developers
## Git branching model
- there are two branches with eternal lifetime:
- `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).
- `master`: This branch is for released states only. Whenever a reasonable set of changes has
- `master`: This branches 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
-186
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.
+55 -85
View File
@@ -1,62 +1,63 @@
VimWiki —— Vim 个人 Wiki 插件
一个私人的维基——vim插件
==============================================================================
[English](README.md)
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) *
![screenshot2](doc/screenshot_2.png)
介绍
------------------------------------------------------------------------------
Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法高亮的文本文件。
Vimwiki是私人维基的vim插件 -- 许多有自己代码高亮的text文件。
通过 Vimwiki,你可以:
通过Vimwiki,你可以:
* 组织笔记和想法
* 管理待办事项
* 写文档
* 坚持写日记
* 将这一切导出成 HTML 网页
* 制作代办事项
* 写文档
马上开始!按下 `<Leader>ww`(通常是 `\ww`)进入作为目录页的 wiki 文件,这个文件默认存放在 `~/vimwiki/index.wiki`
一个快速的开始,通常使用`<Leader>ww`(一般是`\ww`),然后创建你的index wiki文件
通常,它在:
在该文件中输入以下示例:
~/vimwiki/index.wiki
= 我的个人知识库 =
* 任务列表 -- _昨天_ 就该完成的事!!!
* Gutenberg 计划 -- 好书给我力量。
* 草稿 -- 临时记录一些东西。
在这个文件,输入如下的例子:
把光标移到 `任务` 二字上,按 Enter(回车)创建链接。按下后,`任务`二字会变成 `[[任务]]` —— 这是一个 Vimwiki 链接。再次按 Enter 即可进入这个链接(打开新的 wiki 文件)。编辑这个新文件,保存,然后按 Backspace(退格)就能回到目录页。
= My knowledge base =
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
如果 Vimwiki 链接长度不止一个单词(指的是英文单词),只需在 Visual 模式选择这段文本后按 Enter 即可。用上面的 `Gutenberg 计划` 试试吧。最终结果是这样:
将你的光标放到`Tasks`(任务)上,并且按回车键去创建一个链接。一旦按下,`Task`将会
变成`[[Tasks]]` -- 一个vimwiki的链接。再按一次回车去打开它。编辑文件,保存它,
然后按backspace来返回你的index。
= 我的个人知识库 =
* [[任务列表]] -- _昨天_ 就该完成的事!!!
* [[Gutenberg 计划]] -- 好书给我力量。
* 草稿 -- 临时记录一些东西。
一个vimwiki链接可以一句话创建。只需要通过选择visual模式选择这个句子,然后按回车。
你可以通过选择`Project Gutenberg`来尝试。结果像是这个样子:
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
基本标记
------------------------------------------------------------------------------
= 一级标题 =
== 二级标题 ==
=== 三级标题 ===
= Header1 =
== Header2 ==
=== Header3 ===
*bold* -- 粗体文本
_italic_ -- 斜体文本
(应用于句中的汉字文本时,必须在标记前后加空格,例如:一段 *中文* 文本)
*bold* -- bold text
_italic_ -- italic text
[[wiki link]] -- wiki 链接
[[wiki link|description]] -- 带有描述文本的 wiki 链接
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
列表
列表:
* bullet list item 1(无编号列表)
* bullet list item 1
- bullet list item 2
- bullet list item 3
* bullet list item 4
@@ -66,13 +67,13 @@ Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法
- bullet list item 8
- bullet list item 9
1. numbered list item 1(有编号列表)
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
更多格式说明,请阅 `:h vimwiki-syntax`
查看`:h vimwiki-syntax`
键位绑定
@@ -80,49 +81,46 @@ Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法
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 链接
* `<Leader>ww` -- 打开默认的wiki index文件
* `<Leader>wt` -- 通过tab实现上一个功能
* `<Leader>ws` -- 选择并打开index文件
* `<Leader>wd` -- 删除进入的wiki文件
* `<Leader>wr` -- 重命名你进入的wiki文件
* `<Enter>` -- 进入/创建 wiki 链接
* `<Shift-Enter>` -- 通过分屏模式sp,进入/创建wiki链接
* `<Ctrl-Enter>` -- 通过分屏模式vs,进入/创建wiki链接
* `<Backspace>` -- 返回父节点
* `<Tab>` -- 寻找下一个wiki链接
* `<Shift-Tab>` -- 寻找上一个wiki链接
更多快捷键说明,请阅 `:h vimwiki-mappings`
查看`:h vimwiki-mappings`
命令
------------------------------------------------------------------------------
* `:Vimwiki2HTML` -- 当前 wiki 文件转换成 HTML 网页
* `:VimwikiAll2HTML` -- 把所有 wiki 文件转换成 HTML 网页
* `:Vimwiki2HTML` -- 转换当前wiki成为html
* `:VimwikiAll2HTML` -- 转化你的全部wiki到html
* `:help vimwiki-commands` -- 显示全部命令
安装
安装细节
==============================================================================
准备工作
在安装之前,你需要做的
------------------------------------------------------------------------------
保在 `vimrc` 中加入了以下设置:
定在`vimrc`中,你的设置是这样的。
set nocompatible
filetype plugin on
syntax on
没有这些设置Vimwiki 将无法正常工作。
如果没有他们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) 安装
使用 pathogen (译者注:一个插件) (http://www.vim.org/scripts/script.php?script_id=2332 )
------------------------------------------------------------------------------
cd ~/.vim
@@ -130,32 +128,4 @@ normal 模式:
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) 插件。
然后启动vim,使用`:Helptags` 然后 `:help vimwiki`来确保他已经被安装了。
+3 -23
View File
@@ -1,8 +1,6 @@
A Personal Wiki For Vim
==============================================================================
[中文](README-cn.md)
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) *
@@ -107,19 +105,6 @@ 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)
If you would prefer to use either Markdown or MediaWiki syntaxes, set the following option in your .vimrc:
```
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
Installation
@@ -155,7 +140,7 @@ Installation using [Vim-Plug](https://github.com/junegunn/vim-plug)
Add the following to the plugin-configuration in your vimrc:
Plug 'vimwiki/vimwiki'
Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
Then run `:PlugInstall`.
@@ -174,13 +159,8 @@ Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was insta
Getting help
==============================================================================
Have a question? Visit the IRC channel `#vimwiki` on Freenode ([webchat](https://webchat.freenode.net/?channels=#vimwiki), also synced to Matrix/Riot: `#freenode_#vimwiki:matrix.org`) 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.
Have a question? Visit the IRC channel `#vimwiki` on Freenode ([webchat](https://webchat.freenode.net/?channels=#vimwiki))
or post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki).
----
+29 -107
View File
@@ -9,9 +9,6 @@ endif
let g:loaded_vimwiki_auto = 1
let g:vimwiki_max_scan_for_caption = 5
function! s:safesubstitute(text, search, replace, mode)
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
@@ -155,13 +152,7 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos.anchor = join(split_lnk[1:], '#')
endif
if link_text == '' " because the link was of the form '#anchor'
let expected_ext = vimwiki#u#escape(vimwiki#vars#get_wikilocal('ext')).'$'
if source_file =~# expected_ext
" Source file has expected extension. Remove it, it will be added later on
let ext_len = strlen(vimwiki#vars#get_wikilocal('ext'))
let link_text = fnamemodify(source_file, ':p:t')[:-ext_len-1]
endif
let link_text = fnamemodify(source_file, ':p:t:r')
endif
endif
@@ -200,10 +191,7 @@ function! vimwiki#base#resolve_link(link_text, ...)
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif
else
let ext = fnamemodify(link_text, ':e')
if ext == '' " append ext iff one not already present
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif
elseif link_infos.scheme ==# 'diary'
@@ -354,34 +342,17 @@ function! vimwiki#base#generate_links()
let bullet = repeat(' ', vimwiki#lst#get_list_margin()) . vimwiki#lst#default_symbol().' '
for link in links
let link_infos = vimwiki#base#resolve_link(link)
if !s:is_diary_file(link_infos.filename)
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
endif
let link_caption = vimwiki#base#read_caption(link_infos.filename)
if link_caption == '' " default to link if caption not found
let link_caption = link
endif
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', link, '')
let entry = s:safesubstitute(entry, '__LinkDescription__', link_caption, '')
call add(lines, bullet. entry)
let abs_filepath = vimwiki#path#abs_path_of_link(link)
if !s:is_diary_file(abs_filepath)
call add(lines, bullet.
\ s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
\ '__LinkUrl__', link, ''))
endif
endfor
let links_rx = '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
call vimwiki#base#update_listing_in_buffer(
\ lines,
\ vimwiki#vars#get_global('links_header'),
\ links_rx,
\ line('$')+1,
\ vimwiki#vars#get_global('links_header_level'),
\ 1)
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Links', links_rx, line('$')+1, 1)
endfunction
@@ -621,12 +592,7 @@ function! s:get_links(wikifile, idx)
endif
let syntax = vimwiki#vars#get_wikilocal('syntax', a:idx)
if syntax == 'markdown'
let rx_link = vimwiki#vars#get_syntaxlocal('rxWeblink1MatchUrl', syntax)
else
let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax)
endif
let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax)
let links = []
let lnum = 0
@@ -1022,11 +988,10 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort
let group='texMathZoneGroup'
endif
let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : ''
execute 'syntax region textSnip'.ft.
\ ' matchgroup='.a:textSnipHl.
\ ' start="'.a:start.'" end="'.a:end.'"'.
\ ' contains=@'.group.' keepend'.concealpre
\ ' contains=@'.group.' keepend'
" A workaround to Issue 115: Nested Perl syntax highlighting differs from
" regular one.
@@ -1044,14 +1009,14 @@ endfunction
" creates or updates auto-generated listings in a wiki file, like TOC, diary
" links, tags list etc.
" - the listing consists of a header and a list of strings as content
" - the listing consists of a level 1 header and a list of strings as content
" - a:content_regex is used to determine how long a potentially existing list is
" - a:default_lnum is the line number where the new listing should be placed if
" it's not already present
" - if a:create is true, it will be created if it doesn't exist, otherwise it
" will only be updated if it already exists
function! vimwiki#base#update_listing_in_buffer(strings, start_header,
\ content_regex, default_lnum, header_level, create)
\ content_regex, default_lnum, create)
" Vim behaves strangely when files change while in diff mode
if &diff || &readonly
return
@@ -1060,8 +1025,7 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
" check if the listing is already there
let already_there = 0
let header_level = 'rxH' . a:header_level . '_Template'
let header_rx = '\m^\s*'.substitute(vimwiki#vars#get_syntaxlocal(header_level),
let header_rx = '\m^\s*'.substitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'),
\ '__Header__', a:start_header, '') .'\s*$'
let start_lnum = 1
@@ -1107,39 +1071,23 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
let start_lnum = a:default_lnum
let is_cursor_after_listing = ( cursor_line > a:default_lnum )
let whitespaces_in_first_line = ''
" append newline if not replacing first line
if start_lnum > 1
keepjumps call append(start_lnum -1, '')
let start_lnum += 1
endif
endif
let start_of_listing = start_lnum
" write new listing
let new_header = whitespaces_in_first_line
\ . s:safesubstitute(vimwiki#vars#get_syntaxlocal(header_level),
\ . s:safesubstitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'),
\ '__Header__', a:start_header, '')
keepjumps call append(start_lnum - 1, new_header)
let start_lnum += 1
let lines_diff += 1
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
keepjumps call append(start_lnum - 1, '')
let start_lnum += 1
let lines_diff += 1
endfor
endif
let lines_diff += 1 + len(a:strings)
for string in a:strings
keepjumps call append(start_lnum - 1, string)
let start_lnum += 1
let lines_diff += 1
endfor
" remove empty line if end of file, otherwise append if needed
if start_lnum == line('$')
silent exe 'keepjumps ' . start_lnum.'delete _'
elseif start_lnum < line('$') && getline(start_lnum) !~# '\m^\s*$'
" append an empty line if there is not one
if start_lnum <= line('$') && getline(start_lnum) !~# '\m^\s*$'
keepjumps call append(start_lnum - 1, '')
let lines_diff += 1
endif
@@ -1246,7 +1194,7 @@ function! vimwiki#base#follow_link(split, ...)
else
if a:0 >= 3
execute "normal! ".a:3
elseif vimwiki#vars#get_global('create_link')
else
call vimwiki#base#normalize_link(0)
endif
endif
@@ -1664,10 +1612,7 @@ function! vimwiki#base#TO_table_col(inner, visual)
endfunction
function! vimwiki#base#AddHeaderLevel(...)
if a:1 > 1
call vimwiki#base#AddHeaderLevel(a:1 - 1)
endif
function! vimwiki#base#AddHeaderLevel()
let lnum = line('.')
let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
@@ -1695,10 +1640,7 @@ function! vimwiki#base#AddHeaderLevel(...)
endfunction
function! vimwiki#base#RemoveHeaderLevel(...)
if a:1 > 1
call vimwiki#base#RemoveHeaderLevel(a:1 - 1)
endif
function! vimwiki#base#RemoveHeaderLevel()
let lnum = line('.')
let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
@@ -1914,26 +1856,21 @@ function! vimwiki#base#table_of_contents(create)
let indentstring = repeat(' ', vimwiki#u#sw())
let bullet = vimwiki#lst#default_symbol().' '
for [lvl, link, desc] in complete_header_infos
let esc_link = substitute(link, "'", "''", 'g')
let esc_desc = substitute(desc, "'", "''", 'g')
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink2Template')
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
endif
let link = s:safesubstitute(link_tpl, '__LinkUrl__',
\ '#'.link, '')
let link = s:safesubstitute(link, '__LinkDescription__', desc, '')
\ '#'.esc_link, '')
let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '')
call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
endfor
let links_rx = '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
call vimwiki#base#update_listing_in_buffer(
\ lines,
\ toc_header_text,
\ links_rx,
\ 1,
\ vimwiki#vars#get_global('toc_header_level'),
\ a:create)
call vimwiki#base#update_listing_in_buffer(lines, toc_header_text, links_rx, 1, a:create)
endfunction
@@ -2145,21 +2082,6 @@ function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort
endfunction
function! vimwiki#base#read_caption(file)
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
if filereadable(a:file)
for line in readfile(a:file, '', g:vimwiki_max_scan_for_caption)
if line =~# rx_header
return vimwiki#u#trim(matchstr(line, rx_header))
endif
endfor
endif
return ''
endfunction
" -------------------------------------------------------------------------
" Load syntax-specific Wiki functionality
for s:syn in s:vimwiki_get_known_syntaxes()
+27 -121
View File
@@ -10,6 +10,9 @@ endif
let g:loaded_vimwiki_diary_auto = 1
let s:vimwiki_max_scan_for_caption = 5
function! s:prefix_zero(num)
if a:num < 10
return '0'.a:num
@@ -60,98 +63,26 @@ function! s:get_month_name(month)
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
endfunction
function! s:get_first_header(fl)
" 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)
" 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)
" 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)
" 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)
let result = {}
let caption_level = vimwiki#vars#get_wikilocal('diary_caption_level')
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
for fl in a:files
" remove paths and extensions
let fl_captions = {}
let fl_key = substitute(fnamemodify(fl, ':t'), vimwiki#vars#get_wikilocal('ext').'$', '', '')
" 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
if filereadable(fl)
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
if line =~# rx_header && !has_key(result, fl_key)
let result[fl_key] = vimwiki#u#trim(matchstr(line, rx_header))
endif
endif
endfor
endif
if !has_key(result, fl_key)
let result[fl_key] = ''
endif
let fl_key = substitute(fnamemodify(fl, ':t'), vimwiki#vars#get_wikilocal('ext').'$', '', '')
let result[fl_key] = fl_captions
endfor
return result
endfunction
@@ -207,13 +138,9 @@ function! s:format_diary()
let links_with_captions = s:read_captions(s: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(result) > 0
call add(result, '')
endif
for year in s:sort(keys(g_files))
call add(result, '')
call add(result,
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , ''))
@@ -222,43 +149,22 @@ function! s:format_diary()
call add(result, 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(result, '')
endfor
endif
for [fl, captions] in s:sort(items(g_files[year][month]))
let topcap = captions['top']
for [fl, cap] in s:sort(items(g_files[year][month]))
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
if empty(cap) " When using markdown syntax, we should ensure we always have a link description.
let cap = fl
endif
elseif empty(cap)
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
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, '')
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).bullet.entry)
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, '')
call add(result, repeat(' ', vimwiki#lst#get_list_margin() * (2 + depth)).'- '.entry)
endfor
let entry = substitute(link_tpl, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry)
endfor
endfor
@@ -379,10 +285,9 @@ function! vimwiki#diary#generate_diary_section()
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').'\)'
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)'
call vimwiki#base#update_listing_in_buffer(s:format_diary(),
\ vimwiki#vars#get_wikilocal('diary_header'), content_rx, 1, 1, 1)
\ vimwiki#vars#get_wikilocal('diary_header'), content_rx, line('$')+1, 1)
else
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
endif
@@ -419,3 +324,4 @@ function vimwiki#diary#calendar_sign(day, month, year)
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction
+12 -50
View File
@@ -344,27 +344,7 @@ endfunction
function! s:tag_code(value)
let l:retstr = '<code'
let l:str = s:mid(a:value, 1)
let l:match = match(l:str, '^#[a-fA-F0-9]\{6\}$')
if l:match != -1
let l:r = eval("0x".l:str[1:2])
let l:g = eval("0x".l:str[3:4])
let l:b = eval("0x".l:str[5:6])
let l:fg_color =
\ (((0.299 * r + 0.587 * g + 0.114 * b) / 0xFF) > 0.5)
\ ? "black" : "white"
let l:retstr .=
\ " style='background-color:" . l:str .
\ ";color:" . l:fg_color . ";'"
endif
let l:retstr .= '>'.s:safe_html_preformatted(l:str).'</code>'
return l:retstr
return '<code>'.s:safe_html_preformatted(s:mid(a:value, 1)).'</code>'
endfunction
@@ -906,8 +886,8 @@ function! s:process_tag_list(line, lists)
let st_tag = '<li>'
let chk = matchlist(a:line, a:rx_list)
if !empty(chk) && len(chk[1]) > 0
let completion = index(vimwiki#vars#get_syntaxlocal('listsyms_list'), chk[1])
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let completion = index(vimwiki#vars#get_wikilocal('listsyms_list'), chk[1])
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
if completion == 0
let st_tag = '<li class="done0">'
elseif completion == -1 && chk[1] == vimwiki#vars#get_global('listsym_rejected')
@@ -1092,13 +1072,11 @@ function! s:process_tag_h(line, id)
let h_text = num.' '.h_text
endif
let h_complete_id = s:escape_html_attribute(h_complete_id)
let h_part = '<div id="'.h_complete_id.'">'
let h_part .= '<h'.h_level.' id="'.h_id.'" class="header">'
let h_part .= '<a href="#'.h_complete_id.'"'
let h_part = '<div id="'.h_complete_id.'"><h'.h_level.' id="'.h_id.'"'
else
let h_part = '<div id="'.h_id.'" class="toc"><h'.h_level.' id="'.h_id.'"'
let h_part = '<div id="'.h_id.'" class="toc"><h1 id="'.h_id.'"'
endif
@@ -1110,7 +1088,7 @@ function! s:process_tag_h(line, id)
let h_text = s:process_inline_tags(h_text, a:id)
let line = h_part.h_text.'</a></h'.h_level.'></div>'
let line = h_part.h_text.'</h'.h_level.'></div>'
let processed = 1
endif
@@ -1418,38 +1396,24 @@ function! s:use_custom_wiki2html()
\ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html))
endfunction
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force)
call vimwiki#path#mkdir(a:path)
" fix for trailing / causing " to be escaped on windows, see #642
if has('win16') || has('win95') || has('win32') || has('win64')
let l:path = substitute(a:path, '\\$', '', '')
let l:css = substitute(shellescape(s:default_CSS_full_name(a:path)), '\\$', '', '')
" template path ends in / even on windows hence the different substitute
let l:tmpl = shellescape(expand(substitute(vimwiki#vars#get_wikilocal('template_path'), '/$', '', '')))
let l:rpath = substitute(shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))), '\\$', '', '')
else
let l:path = a:path
let l:css = shellescape(s:default_CSS_full_name(a:path))
let l:tmpl = shellescape(expand(vimwiki#vars#get_wikilocal('template_path')))
let l:rpath = shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir')))
endif
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '.
\ a:force. ' '.
\ vimwiki#vars#get_wikilocal('syntax'). ' '.
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '.
\ shellescape(l:path). ' '.
\ shellescape(a:path). ' '.
\ shellescape(a:wikifile). ' '.
\ l:css . ' '.
\ shellescape(s:default_CSS_full_name(a:path)). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ?
\ l:tmpl : '-'). ' '.
\ shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_default') : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '.
\ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ?
\ l:rpath : '-'). ' '.
\ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ?
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-'))
endfunction
@@ -1512,7 +1476,7 @@ function! s:convert_file(path_html, wikifile)
endif
" prepare regexps for lists
let s:bullets = '[*-]'
let s:bullets = vimwiki#vars#get_wikilocal('rx_bullet_char')
let s:numbers = '\C\%(#\|\d\+)\|\d\+\.\|[ivxlcdm]\+)\|[IVXLCDM]\+)\|\l\{1,2})\|\u\{1,2})\)'
for line in lsource
@@ -1563,7 +1527,6 @@ function! s:convert_file(path_html, wikifile)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
let wiki_path = strpart(s:current_wiki_file, strlen(vimwiki#vars#get_wikilocal('path')))
let html_lines = s:get_html_template(template_name)
@@ -1572,7 +1535,6 @@ function! s:convert_file(path_html, wikifile)
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
call map(html_lines, 'substitute(v:val, "%wiki_path%", "'. wiki_path .'", "g")')
let css_name = expand(vimwiki#vars#get_wikilocal('css_name'))
let css_name = substitute(css_name, '\', '/', 'g')
+17 -16
View File
@@ -137,7 +137,7 @@ endfunction
"Returns: the column where the text of a line starts (possible list item
"markers and checkboxes are skipped)
function! s:text_begin(lnum)
return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')))
return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem')))
endfunction
@@ -145,9 +145,9 @@ endfunction
" 1 for a marker and no text
" 0 for no marker at all (empty line or only text)
function! s:line_has_marker(lnum)
if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$'
if getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*$'
return 1
elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S'
elseif getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*\S'
return 2
else
return 0
@@ -172,7 +172,7 @@ function! s:get_item(lnum)
return item
endif
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem'))
if matches == [] ||
\ (matches[1] == '' && matches[2] == '') ||
\ (matches[1] != '' && matches[2] != '')
@@ -209,7 +209,7 @@ function! s:get_level(lnum)
let level = indent(a:lnum)
else
let level = s:string_length(matchstr(getline(a:lnum),
\ vimwiki#vars#get_syntaxlocal(rx_bullet_chars)))-1
\ vimwiki#vars#get_wikilocal(rx_bullet_chars)))-1
if level < 0
let level = (indent(a:lnum) == 0) ? 0 : 9999
endif
@@ -744,8 +744,8 @@ function! s:get_rate(item)
if state == vimwiki#vars#get_global('listsym_rejected')
return -1
endif
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 100/(n-1)
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
return index(vimwiki#vars#get_wikilocal('listsyms_list'), state) * 100/(n-1)
endfunction
@@ -784,7 +784,7 @@ function! s:set_state_plus_children(item, new_rate, ...)
if child_item.cb != vimwiki#vars#get_global('listsym_rejected')
let all_children_are_rejected = 0
endif
if child_item.cb != vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
if child_item.cb != vimwiki#vars#get_wikilocal('listsyms_list')[-1]
let all_children_are_done = 0
endif
if !all_children_are_done && !all_children_are_rejected
@@ -820,7 +820,7 @@ endfunction
"Returns: the appropriate symbol for a given percent rate
function! s:rate_to_state(rate)
let listsyms_list = vimwiki#vars#get_syntaxlocal('listsyms_list')
let listsyms_list = vimwiki#vars#get_wikilocal('listsyms_list')
let state = ''
let n = len(listsyms_list)
if a:rate == 100
@@ -997,7 +997,7 @@ function! vimwiki#lst#decrement_cb(from_line, to_line)
"if from_line has CB, decrement it and set all siblings to the same new state
let rate_first_line = s:get_rate(from_item)
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
let new_rate = max([rate_first_line - 100/(n-1)-1, 0])
call s:change_cb(a:from_line, a:to_line, new_rate)
@@ -1015,7 +1015,7 @@ function! vimwiki#lst#increment_cb(from_line, to_line)
"if from_line has CB, increment it and set all siblings to the same new state
let rate_first_line = s:get_rate(from_item)
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
let new_rate = min([rate_first_line + 100/(n-1)+1, 100])
call s:change_cb(a:from_line, a:to_line, new_rate)
@@ -1034,6 +1034,7 @@ endfunction
"in the lines of the given range
function! vimwiki#lst#toggle_rejected_cb(from_line, to_line)
return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1)
endfunction
@@ -1101,7 +1102,7 @@ endfunction
function! s:decrease_level(item)
let removed_indent = 0
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(a:item.mrkr)) > -1
if s:string_length(a:item.mrkr) >= 2
call s:substitute_string_in_line(a:item.lnum, s:first_char(a:item.mrkr), '')
@@ -1124,7 +1125,7 @@ endfunction
function! s:increase_level(item)
let additional_indent = 0
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(a:item.mrkr)) > -1
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
\ s:first_char(a:item.mrkr))
@@ -1148,7 +1149,7 @@ endfunction
function! s:indent_line_by(lnum, indent_by)
let item = s:get_item(a:lnum)
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(item.mrkr)) > -1
if a:indent_by > 0
call s:substitute_string_in_line(a:lnum, item.mrkr, item.mrkr . s:first_char(item.mrkr))
@@ -1323,7 +1324,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode)
endif
"handle markers like ***
if index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1
if index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1
"use *** if the item above has *** too
let item_above = s:get_prev_list_item(cur_item, 1)
if item_above.type == 1 && s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr)
@@ -1394,7 +1395,7 @@ function! s:adjust_mrkr(item)
"if possible, set e.g. *** if parent has ** as marker
if neighbor_item.type == 0 && a:item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(a:item.mrkr)) > -1
let parent_item = s:get_parent(a:item)
if parent_item.type == 1 && s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr)
-1
View File
@@ -25,7 +25,6 @@ del {text-decoration: line-through; color: #777777;}
.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 {
+10 -40
View File
@@ -296,7 +296,6 @@ function! vimwiki#tags#generate_tags(...) abort
let need_all_tags = (a:0 == 0)
let specific_tags = a:000
let header_level = vimwiki#vars#get_global('tags_header_level')
let metadata = s:load_tags_metadata()
" make a dictionary { tag_name: [tag_links, ...] }
@@ -311,55 +310,26 @@ function! vimwiki#tags#generate_tags(...) abort
endfor
endfor
let tag_match = printf('rxH%d', header_level + 1)
let tag_tpl = printf('rxH%d_Template', header_level + 1)
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(specific_tags, tagname) != -1
if len(lines) > 0
call add(lines, '')
endif
call add(lines,
\ substitute(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
call extend(lines, [
\ '',
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''),
\ '' ])
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)
let link_caption = vimwiki#base#read_caption(link_infos.filename)
let link_text = split(taglink, '#', 1)[0]
let entry = substitute(link_tpl, '__LinkUrl__', link_text, '')
let entry = substitute(entry, '__LinkAnchor__', link_infos.anchor, '')
let entry = substitute(entry, '__LinkDescription__', link_caption, '')
call add(lines, bullet.entry)
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
call add(lines, bullet . substitute(link_tpl, '__LinkUrl__', taglink, ''))
endif
call add(lines, bullet . substitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
\ '__LinkUrl__', taglink, ''))
endfor
endif
endfor
let links_rx = '^\%('.vimwiki#vars#get_syntaxlocal(tag_match).'\)\|'.
\ '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
let links_rx = '\m\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH2').'\)\|\%(^\s*'
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
\ .vimwiki#vars#get_syntaxlocal('rxWikiLink').'$\)'
call vimwiki#base#update_listing_in_buffer(
\ lines,
\ vimwiki#vars#get_global('tags_header'),
\ links_rx,
\ line('$')+1,
\ header_level,
\ 1)
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx, line('$')+1, 1)
endfunction
+84 -205
View File
@@ -63,7 +63,7 @@ endfunction
function! s:is_separator(line)
return a:line =~# '^\s*'.s:rxSep().'\(:\=--\+:\='.s:rxSep().'\)\+\s*$'
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
endfunction
@@ -72,11 +72,6 @@ function! s:is_separator_tail(line)
endfunction
function! s:is_last_column(lnum, cnum)
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction
function! s:is_last_column(lnum, cnum)
let line = strpart(getline(a:lnum), a:cnum - 1)
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
@@ -140,62 +135,56 @@ function! s:create_row_sep(cols)
endfunction
function! vimwiki#tbl#get_cells(line, ...)
function! vimwiki#tbl#get_cells(line)
let result = []
let cell = ''
let quote = ''
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
for idx in range(strlen(a:line))
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state ==# 'NONE'
if ch == '|'
let state = 'CELL'
endif
endfor
if state == 'NONE'
break
elseif state ==# 'CELL'
if ch == '[' || ch == '{'
let state = 'BEFORE_QUOTE_START'
let quote = ch
elseif ch == '|'
call add(result, vimwiki#u#trim(cell))
let cell = ""
else
let cell .= ch
endif
elseif state ==# 'BEFORE_QUOTE_START'
if ch == '[' || ch == '{'
let state = 'QUOTE'
let quote .= ch
else
let state = 'CELL'
let cell .= quote.ch
let quote = ''
endif
elseif state ==# 'QUOTE'
if ch == ']' || ch == '}'
let state = 'BEFORE_QUOTE_END'
endif
let quote .= ch
elseif state ==# 'BEFORE_QUOTE_END'
if ch == ']' || ch == '}'
let state = 'CELL'
endif
let cell .= quote.ch
let quote = ''
endif
endwhile
endfor
if cell.quote != ''
call add(result, vimwiki#u#trim(cell.quote, '|'))
endif
return result
endfunction
@@ -205,7 +194,7 @@ function! s:col_count(lnum)
endfunction
function! s:get_indent(lnum, depth)
function! s:get_indent(lnum)
if !s:is_table(getline(a:lnum))
return
endif
@@ -220,94 +209,50 @@ function! s:get_indent(lnum, depth)
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, ...)
function! s:get_rows(lnum)
if !s:is_table(getline(a:lnum))
return
endif
let rows = []
let upper_rows = []
let lower_rows = []
let lnum = a:lnum - 1
let depth = a:0 > 0 ? a:1 : 0
let ldepth = 0
while lnum >= 1 && (depth == 0 || ldepth < depth)
while lnum >= 1
let line = getline(lnum)
if s:is_table(line)
call insert(rows, [lnum, line])
call add(upper_rows, [lnum, line])
else
break
endif
let lnum -= 1
let ldepth += 1
endwhile
call reverse(upper_rows)
let lnum = a:lnum
while lnum <= line('$')
let line = getline(lnum)
if s:is_table(line)
if lnum == a:lnum
let cells = vimwiki#tbl#get_cells(line)
let clen = len(cells)
let max_lens = repeat([0], clen)
let aligns = repeat(['left'], clen)
let line = s:fmt_row(cells, max_lens, aligns, 0, 0)
endif
call add(rows, [lnum, line])
call add(lower_rows, [lnum, line])
else
break
endif
if depth > 0
break
endif
let lnum += 1
endwhile
return rows
endfunction
function! s:get_cell_aligns(lnum)
let aligns = {}
for [lnum, row] in s:get_rows(a:lnum)
let found_separator = s:is_separator(row)
if found_separator
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
return aligns
endif
endfor
if !found_separator
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let aligns[idx] = 'left'
endfor
endif
return aligns
return upper_rows + lower_rows
endfunction
function! s:get_cell_max_lens(lnum, ...)
let max_lens = {}
let rows = a:0 > 2 ? a:3 : s:get_rows(a:lnum)
for [lnum, row] in rows
for [lnum, row] in s:get_rows(a:lnum)
if s:is_separator(row)
continue
endif
@@ -325,54 +270,20 @@ function! s:get_cell_max_lens(lnum, ...)
endfunction
function! s:get_aligned_rows(lnum, col1, col2, depth)
let rows = []
let startlnum = 0
function! s:get_aligned_rows(lnum, col1, col2)
let rows = s:get_rows(a:lnum)
let startlnum = rows[0][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 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
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
let aligns = s:get_cell_aligns(a:lnum)
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)
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)
let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
else
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, aligns, a:col1, a:col2)
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, a:col1, a:col2)
endif
call add(result, [lnum, new_row])
endfor
@@ -401,25 +312,20 @@ function! s:cur_column()
endfunction
function! s:fmt_cell(cell, max_len, align)
function! s:fmt_cell(cell, max_len)
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
let cell .= repeat(' ', diff)
return cell
endfunction
function! s:fmt_row(cells, max_lens, aligns, col1, col2)
function! s:fmt_row(cells, max_lens, col1, col2)
let new_line = s:rxSep()
for idx in range(len(a:cells))
if idx == a:col1
@@ -428,36 +334,28 @@ function! s:fmt_row(cells, max_lens, aligns, col1, 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()
let new_line .= s:fmt_cell(value, a:max_lens[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 new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep()
let idx += 1
endwhile
return new_line
endfunction
function! s:fmt_cell_sep(max_len, align)
let cell = ''
function! s:fmt_cell_sep(max_len)
if a:max_len == 0
let cell .= '-'
return repeat('-', 3)
else
let cell .= repeat('-', a:max_len)
endif
if a:align == 'right'
return cell.'-:'
elseif a:align == 'left'
return cell.'--'
else
return ':'.cell.':'
return repeat('-', a:max_len+2)
endif
endfunction
function! s:fmt_sep(max_lens, aligns, col1, col2)
function! s:fmt_sep(max_lens, col1, col2)
let new_line = s:rxSep()
for idx in range(len(a:max_lens))
if idx == a:col1
@@ -465,7 +363,7 @@ function! s:fmt_sep(max_lens, aligns, col1, 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()
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
endfor
return new_line
endfunction
@@ -473,7 +371,7 @@ endfunction
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('.'), 2)\<CR>"
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>"
@@ -509,15 +407,8 @@ endfunction
function! vimwiki#tbl#goto_next_col()
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 newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
for cell_len in values(max_lens)
if newcol >= curcol-1
break
@@ -544,15 +435,8 @@ endfunction
function! vimwiki#tbl#goto_prev_col()
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 newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
let prev_cell_len = 0
for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
@@ -642,8 +526,6 @@ function! vimwiki#tbl#format(lnum, ...)
return
endif
let depth = a:0 == 1 ? a:1 : 0
if a:0 == 2
let col1 = a:1
let col2 = a:2
@@ -652,19 +534,16 @@ function! vimwiki#tbl#format(lnum, ...)
let col2 = 0
endif
let indent = s:get_indent(a:lnum, depth)
let indent = s:get_indent(a:lnum)
if &expandtab
let indentstring = repeat(' ', indent)
else
let indentstring = repeat(' ', 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)
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
let row = indentstring.row
if getline(lnum) != row
call setline(lnum, row)
endif
call setline(lnum, row)
endfor
let &tw = s:textwidth
@@ -707,9 +586,9 @@ function! vimwiki#tbl#create(...)
endfunction
function! vimwiki#tbl#align_or_cmd(cmd, ...)
function! vimwiki#tbl#align_or_cmd(cmd)
if s:is_table(getline('.'))
call call('vimwiki#tbl#format', [line('.')] + a:000)
call vimwiki#tbl#format(line('.'))
else
exe 'normal! '.a:cmd
endif
+146 -282
View File
@@ -13,7 +13,7 @@
" 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
" 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
@@ -28,10 +28,50 @@
function! s:populate_global_variables()
let g:vimwiki_global_vars = {}
let g:vimwiki_global_vars = {
\ 'CJK_length': 0,
\ 'auto_chdir': 0,
\ 'autowriteall': 1,
\ 'conceallevel': 2,
\ 'diary_months':
\ {
\ 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': '',
\ 'ext2syntax': {},
\ 'folding': '',
\ 'global_ext': 1,
\ 'hl_cb_checked': 0,
\ 'hl_headers': 0,
\ 'html_header_numbering': 0,
\ 'html_header_numbering_sym': '',
\ 'list_ignore_newline': 1,
\ 'text_ignore_newline': 1,
\ 'listsyms': ' .oOX',
\ 'listsym_rejected': '-',
\ 'map_prefix': '<Leader>w',
\ 'menu': 'Vimwiki',
\ 'table_auto_fmt': 1,
\ 'table_mappings': 1,
\ 'toc_header': 'Contents',
\ 'url_maxsave': 15,
\ 'use_calendar': 1,
\ 'use_mouse': 0,
\ 'user_htmls': '',
\ 'valid_html_tags': 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em',
\ 'w32_dir_enc': '',
\ }
call s:read_global_settings_from_user()
call s:normalize_global_settings()
" 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(g:vimwiki_global_vars)
if exists('g:vimwiki_'.key)
let g:vimwiki_global_vars[key] = g:vimwiki_{key}
endif
endfor
" non-configurable global variables:
@@ -85,8 +125,8 @@ function! s:populate_global_variables()
" 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
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]*[^[:blank:]!"$%&''()*+.,:;<=>?\[\]\\^`{}]'
" non-Ascii characters
let g:vimwiki_global_vars.rxWord = '[^[: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
@@ -139,142 +179,34 @@ function! s:populate_global_variables()
endfunction
function! s:read_global_settings_from_user()
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},
\ 'autowriteall': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'conceallevel': {'type': type(0), 'default': 2, 'min': 0, 'max': 3},
\ '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': {}},
\ 'folding': {'type': type(''), 'default': '', 'possible_values': ['', 'expr', 'syntax',
\ 'list', 'custom', ':quick', 'expr:quick', 'syntax:quick', 'list:quick',
\ 'custom:quick']},
\ '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': ''},
\ '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},
\ '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
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()
let keys = keys(g:vimwiki_global_vars.ext2syntax)
for ext in keys
" ensure the file extensions in ext2syntax start with a dot
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
" 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
endfor
endfunction
function! s:populate_wikilocal_options()
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_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': 1},
\ 'diary_caption_level': {'type': type(0), 'default': 0, 'min': -1, 'max': 6},
\ 'diary_sort': {'type': type(''), 'default': 'desc', 'possible_values': ['asc', 'desc']},
\ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1},
\ 'index': {'type': type(''), 'default': 'index', 'min_length': 1},
\ 'list_margin': {'type': type(0), 'default': -1, 'min': -1},
\ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ '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/'},
\ 'auto_diary_index': 0,
\ 'auto_export': 0,
\ 'auto_tags': 0,
\ 'auto_toc': 0,
\ 'automatic_nested_syntaxes': 1,
\ 'css_name': 'style.css',
\ 'custom_wiki2html': '',
\ 'custom_wiki2html_args': '',
\ 'diary_header': 'Diary',
\ 'diary_index': 'diary',
\ 'diary_rel_path': 'diary/',
\ 'diary_sort': 'desc',
\ 'ext': '.wiki',
\ 'index': 'index',
\ 'list_margin': -1,
\ 'maxhi': 0,
\ 'nested_syntaxes': {},
\ 'path': $HOME . '/vimwiki/',
\ 'path_html': '',
\ 'syntax': 'default',
\ 'template_default': 'default',
\ 'template_ext': '.tpl',
\ 'template_path': $HOME . '/vimwiki/templates/',
\ 'bullet_types': [],
\ 'listsyms': vimwiki#vars#get_global("listsyms"),
\ 'listsym_rejected': vimwiki#vars#get_global("listsym_rejected"),
\ }
let g:vimwiki_wikilocal_vars = []
@@ -282,10 +214,9 @@ function! s:populate_wikilocal_options()
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
let default_wiki_settings[key] = default_values[key]
endif
endfor
@@ -295,10 +226,11 @@ function! s:populate_wikilocal_options()
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)
let new_wiki_settings[key] = users_wiki_settings[key]
elseif exists('g:vimwiki_'.key)
let new_wiki_settings[key] = g:vimwiki_{key}
else
let new_wiki_settings[key] = default_wiki_settings[key]
let new_wiki_settings[key] = default_values[key]
endif
endfor
@@ -317,80 +249,19 @@ function! s:populate_wikilocal_options()
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
" Set up variables for the lists, depending on config and syntax
for wiki in g:vimwiki_wikilocal_vars
if len(wiki.bullet_types) == 0
let wiki.bullet_types = vimwiki#vars#get_syntaxlocal('bullet_types', wiki.syntax)
endif
call vimwiki#vars#populate_list_vars(wiki)
endfor
call s:normalize_wikilocal_settings()
call s:validate_settings()
endfunction
function! s:check_users_value(key, users_value, value_infos, comes_from_global_variable)
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)
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 g:vimwiki_%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 g:vimwiki_%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 g:vimwiki_%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 ''g:vimwiki_%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 g:vimwiki_%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 g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key)
endif
endfunction
function! s:normalize_wikilocal_settings()
function! s:validate_settings()
for wiki_settings in g:vimwiki_wikilocal_vars
let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
@@ -409,11 +280,6 @@ function! s:normalize_wikilocal_settings()
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
endfor
endfunction
@@ -452,9 +318,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
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*$'
@@ -471,8 +334,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
\ 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'] =
@@ -492,20 +353,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
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}'}
@@ -537,36 +384,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
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]\|$\)\)\@='
@@ -615,6 +432,63 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
endfunction
function! vimwiki#vars#populate_list_vars(wiki)
let syntax = a:wiki.syntax
let a:wiki.rx_bullet_char = '['.escape(join(a:wiki.bullet_types, ''), ']^-\').']'
let a:wiki.rx_bullet_chars = a:wiki.rx_bullet_char.'\+'
let recurring_bullets = vimwiki#vars#get_syntaxlocal('recurring_bullets')
let rxListNumber = vimwiki#vars#get_syntaxlocal('rxListNumber')
let a:wiki.multiple_bullet_chars =
\ recurring_bullets
\ ? a:wiki.bullet_types : []
"create regexp for bulleted list items
if !empty(a:wiki.bullet_types)
let rxListBullet =
\ join( map(a:wiki.bullet_types,
\'vimwiki#u#escape(v:val).'
\ .'repeat("\\+", recurring_bullets)'
\ ) , '\|')
else
"regex that matches nothing
let rxListBullet = '$^'
endif
"the user can set the listsyms as string, but vimwiki needs a list
let a:wiki.listsyms_list = split(a:wiki.listsyms, '\zs')
if match(a:wiki.listsyms, a:wiki.listsym_rejected) != -1
echomsg 'Vimwiki Warning: the value of listsym_rejected ('''
\ . a:wiki.listsym_rejected . ''') must not be a part of listsyms ('''
\ . a:wiki.listsyms . ''')'
endif
let a:wiki.rxListItemWithoutCB =
\ '^\s*\%(\('.rxListBullet.'\)\|\('
\ .rxListNumber.'\)\)\s'
let a:wiki.rxListItem =
\ a:wiki.rxListItemWithoutCB
\ . '\+\%(\[\(['.a:wiki.listsyms
\ . a:wiki.listsym_rejected.']\)\]\s\)\?'
if recurring_bullets
let a:wiki.rxListItemAndChildren =
\ '^\('.rxListBullet.'\)\s\+\[['
\ . a:wiki.listsyms_list[-1]
\ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\%('
\ .rxListBullet.'\).*\|^$\|\s.*\)\)*'
else
let a:wiki.rxListItemAndChildren =
\ '^\(\s*\)\%('.rxListBullet.'\|'
\ . rxListNumber.'\)\s\+\[['
\ . a:wiki.listsyms_list[-1]
\ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
endif
endfunction
function! s:populate_extra_markdown_vars()
let mkd_syntax = g:vimwiki_syntax_variables['markdown']
@@ -703,21 +577,10 @@ function! s:populate_extra_markdown_vars()
let mkd_syntax.rxWeblink1Prefix = '['
let mkd_syntax.rxWeblink1Suffix = ')'
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.rxWeblink1Separator. '__LinkUrl__'.
\ 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 = '[^\\]'
@@ -730,8 +593,8 @@ function! s:populate_extra_markdown_vars()
" 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.rxWeblink1Suffix
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1Separator.
\ mkd_syntax.rxWeblink1Descr . mkd_syntax.rxWeblink1Suffix
" 1b) match URL within [DESCRIPTION](URL)
let mkd_syntax.rxWeblink1MatchUrl = mkd_syntax.rxWeblink1Prefix.
\ mkd_syntax.rxWeblink1Descr. mkd_syntax.rxWeblink1Separator.
@@ -866,7 +729,7 @@ function! vimwiki#vars#add_temporary_wiki(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()
call s:validate_settings()
endfunction
@@ -874,3 +737,4 @@ endfunction
function! vimwiki#vars#number_of_wikis()
return len(g:vimwiki_wikilocal_vars) - 1
endfunction
+69 -187
View File
@@ -513,12 +513,6 @@ gqq Format table. If you made some changes to a table
or without swapping insert/normal modes this command
gww will reformat it.
*vimwiki_gq1* *vimwiki_gw1*
gq1 Fast format table. The same as the previous, except
or that only a few lines above the current line are
gw1 tested. If the alignment of the current line differs,
then the whole table gets reformatted.
*vimwiki_<A-Left>*
<A-Left> Move current table column to the left.
See |:VimwikiTableMoveColumnLeft|
@@ -713,7 +707,7 @@ Vimwiki file.
*:VimwikiGoto*
Goto link provided by an argument. For example: >
:VimwikiGoto HelloWorld
< opens/creates HelloWorld wiki page.
< opens opens/creates HelloWorld wiki page.
Supports |cmdline-completion| for link name.
@@ -883,21 +877,9 @@ is decorated: >
super^script^
sub,,script,,
For Markdown syntax these variations are used: >
**bold text** or __bold text__
*italic text* or _italic text_
***bold_italic text*** or ___italic_bold text___
Furthermore, there are a number of words which are highlighted extra flashy:
TODO, DONE, STARTED, FIXME, FIXED, XXX.
When rendered as HTML, code blocks containing only a hash prefixed 6 digit hex
number will be colored as themselves. For example >
`#ffe119`
Becomes >
<code style='background-color:#ffe119;color:black;'>#ffe119</code>
------------------------------------------------------------------------------
5.2. Links *vimwiki-syntax-links*
@@ -1441,7 +1423,7 @@ Hit |zr| one more time :
Note: If you use the default Vimwiki syntax, folding on list items will work
properly only if all of them are indented using the current 'shiftwidth'.
For Markdown and MediaWiki syntax, * or # should be in the first column.
For MediaWiki syntax, * or # should be in the first column.
To turn folding on/off check |g:vimwiki_folding|.
@@ -1674,7 +1656,7 @@ parent items: >
Parent items should change when their child items change. If not, use
|vimwiki_glr|. The symbol between [ ] depends on the percentage of toggled
child items (see also |g:vimwiki_listsyms|): >
child items (see also |vimwiki-listsyms|): >
[ ] -- 0%
[.] -- 1-33%
[o] -- 34-66%
@@ -1733,15 +1715,6 @@ values: >
To indent table indent the first row. Then format it with 'gqq'.
You can specify the type of horizontal alignment for columns in the separator
using the ':' character. The default is left-align. >
| Date | Item | Price |
|------------|:------:|--------:|
| yest | Coffee | $15.00 |
| 2017-02-13 | Tea | $2.10 |
| 2017-03-14 | Cake | $143.12 |
<
==============================================================================
10. Diary *vimwiki-diary*
@@ -2070,17 +2043,13 @@ Each template could look like: >
</html>
where
`%title%` is replaced by a wiki page name or by a |vimwiki-title|
`%date%` is replaced with the current date or by |vimwiki-date|
`%root_path%` is replaced by a count of ../ for pages buried in subdirs:
%title% is replaced by a wiki page name or by a |vimwiki-title|
%date% is replaced with the current date or by |vimwiki-date|
%root_path% is replaced by a count of ../ for pages buried in subdirs:
if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
`%root_path%` is replaced by '../../../'.
`%wiki_path%` Path to current wiki-file.` The file path to the current wiki
file. For example, if you are on page a/b.wiki %wiki-path% contains
"a/b.wiki". Mostly useful if you want to link the to raw wiki page from
the rendered version.
%root_path% is replaced by '../../../'.
`%content%` is replaced by a wiki file content.
%content% is replaced by a wiki file content.
The default template will be applied to all wiki pages unless a page specifies
@@ -2244,26 +2213,6 @@ Description~
Sort links in a diary index page.
*vimwiki-option-diary_caption_level*
------------------------------------------------------------------------------
Key Default value~
diary_caption_level 0
Description~
Controls the presence of captions in the diary index linking to headers within
the diary pages.
Possible values:
-1: No headers are read from the diary page.
0: The first header from the diary page is used as the caption.
There are no sub-captions.
1: Captions are created for headers of level 1 in the diary page.
2: Captions are created for headers up to level 2 in the diary page.
etc.
When the value is >= 1, the primary caption of each diary page is set to the
first header read from that page if it is the unique lowest-level header.
*vimwiki-option-custom_wiki2html*
------------------------------------------------------------------------------
Key Default value~
@@ -2331,8 +2280,55 @@ local mappings |vimwiki_glstar|, |vimwiki_gl#| |vimwiki_gl-|, |vimwiki_gl-|,
|vimwiki_gl1|, |vimwiki_gla|, |vimwiki_glA|, |vimwiki_gli|, |vimwiki_glI| and
|vimwiki_i_<C-L>_<C-M>|.
Note: if you use Markdown or MediaWiki syntax, you probably would like to set
this option to 0, because every indented line is considered verbatim text.
Note: if you use MediaWiki syntax, you probably would like to set this option
to 0, because every indented line is considered verbatim text.
*vimwiki-bullet_types*
------------------------------------------------------------------------------
Key Default value~
bullet_types ['-', '*', '#'] (default-syntax)
['-', '*', '+'] (markdown-syntax)
['*', '#'] (mediawiki-syntax)
List of the characters that can be used as bullets of lists. The default value
depends on the chosen syntax.
You can set it to include more fancy symbols like this:
>
let g:vimwiki_list = [{'path': '~/path/', 'bullet_types' = ['-', '•', '→']}]
*vimwiki-listsyms*
------------------------------------------------------------------------------
Key Default value~
listsyms ' .oOX'
String of at least two symbols to show the progression of todo list items.
Default value is ' .oOX'. This overwrites the global |g:vimwiki_listsyms| on a
per wiki base.
The first char is for 0% done items.
The last is for 100% done items.
You can set it to some more fancy symbols like this:
>
let g:vimwiki_list = [{'path': '~/path/', 'listsyms' = '✗○◐●✓'}]
*vimwiki-listsym_rejected*
------------------------------------------------------------------------------
Character that is used to show that an item of a todo list will not be done.
Default value is '-'. This overwrites the global |g:vimwiki_listsym_rejected| on a
per wiki base.
The character used here must not be part of |vimwiki-listsyms|.
You can set it to a more fancy symbol like this:
>
let g:vimwiki_list = [{'path': '~/path/', 'listsym_rejected' = '✗'}]
*vimwiki-option-auto_tags*
@@ -2372,7 +2368,7 @@ Global options are configured using the following pattern: >
Highlight headers with =Reddish=, ==Greenish==, ===Blueish=== colors.
Value Description~
1 Use VimwikiHeader1 - VimwikiHeader6 group colors to highlight
1 Use VimwikiHeader1-VimwikiHeader6 group colors to highlight
different header levels.
0 Use |hl-Title| color for headers.
Default: 0
@@ -2389,13 +2385,11 @@ Highlight checked list items with a special color:
Value Description~
0 Don't highlight anything.
1 Highlight only the first line of a checked [X] list item.
2 Highlight a complete checked list item and all its child items.
1 Highlight checked [X] list item with |group-name| "Comment".
2 Highlight checked [X] list item and all its child items.
Default: 0
The |group-name| "Comment" is used for highlighting.
Note: Option 2 does not work perfectly. Specifically, it might break if the
list item contains preformatted text or if you mix tabs and spaces for
indenting. Also, indented headers can be highlighted erroneously.
@@ -2462,7 +2456,8 @@ Default: 'Vimwiki'
*g:vimwiki_listsyms*
String of at least two symbols to show the progression of todo list items.
Default value is ' .oOX'.
Default value is ' .oOX'. You can also set this on a per-wiki level with
|vimwiki-listsyms|.
The first char is for 0% done items.
The last is for 100% done items.
@@ -2476,7 +2471,9 @@ You can set it to some more fancy symbols like this:
*g:vimwiki_listsym_rejected*
Character that is used to show that an item of a todo list will not be done.
Default value is '-'.
Default value is '-'. You can also set this on a per-wiki level with
|vimwiki-listsym_rejected|.
The character used here must not be part of |g:vimwiki_listsyms|.
@@ -2561,31 +2558,6 @@ Value Description~
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_create_link*
Create target wiki page if it does not exist. See |:VimwikiFollowLink|.
Value Description~
0 Do not create target wiki page.
1 Create target wiki page.
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_markdown_link_ext*
Append wiki file extension to links in Markdown. This is needed for
compatibility with other Markdown tools.
Value Description~
0 Do not append wiki file extension.
1 Append wiki file extension.
Default: 0
------------------------------------------------------------------------------
*VimwikiLinkHandler*
@@ -2719,21 +2691,6 @@ Value Description~
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_table_reduce_last_col*
If set, the last column separator will not be expanded to fill the cell. When
`:set wrap` this option improves how a table is displayed, particularly on
small screens. If |g:vimwiki_table_auto_fmt| is set to 0, this option has no
effect.
Value Description~
0 Enable table auto formating for all columns.
1 Disable table auto formating for the last column.
Default: 0
------------------------------------------------------------------------------
*g:vimwiki_w32_dir_enc*
@@ -2887,26 +2844,6 @@ URLs and hides markers and URL for links that have a description.
Default: 2
------------------------------------------------------------------------------
*g:vimwiki_conceal_pre*
Conceal preformatted text markers. For example,
>
{{{python
def say_hello():
print("Hello, world!")
}}}
>
would appear as simply
>
def say_hello():
print("Hello, world!")
>
in your wiki file.
Default: 0
------------------------------------------------------------------------------
*g:vimwiki_autowriteall*
@@ -2983,15 +2920,6 @@ appropriate word in your mother tongue like this: >
The default is 'Contents'.
------------------------------------------------------------------------------
*g:vimwiki_toc_header_level*
The header level of the Table of Contents (see |vimwiki-toc|). Valid values
are from 1 to 6.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_map_prefix*
@@ -3016,54 +2944,6 @@ Value Description~
Default: 0
------------------------------------------------------------------------------
*g:vimwiki_links_header*
A string with the magic header that tells Vimwiki where the generated links
are located in a file. You can change it to the appropriate word in your
mother tongue like this: >
let g:vimwiki_links_header = 'Generierte Links'
The default is 'Generated Links'.
------------------------------------------------------------------------------
*g:vimwiki_links_header_level*
The header level of generated links. Valid values are from 1 to 6.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_tags_header*
A string with the magic header that tells Vimwiki where the generated tags
are located in a file. You can change it to the appropriate word in your
mother tongue like this: >
let g:vimwiki_tags_header = 'Generierte Stichworte'
The default is 'Generated Tags'.
------------------------------------------------------------------------------
*g:vimwiki_tags_header_level*
The header level of generated tags. Valid values are from 1 to 5.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_markdown_header_style*
The number of newlines to be inserted after a header is generated. Valid
values are from 0 to 2.
The default is 1.
==============================================================================
13. Getting help *vimwiki-help*
@@ -3141,7 +3021,6 @@ Contributors and their Github usernames in roughly chronological order:
- Zhuang Ma (@mzlogin)
- Huy Le (@huynle)
- Nick Borden (@hcwndbyw)
- Steven Stallion (@sstallion)
==============================================================================
@@ -3162,6 +3041,9 @@ New:~
* glx on a list item marks a checkbox as won't do, see |vimwiki_glx|.
* Add the option |g:vimwiki_listsym_rejected| to set the character used
for won't-do list items.
* The effect of |g:vimwiki_listsyms| and |g:vimwiki_listsym_rejected| can
be set on a per wiki level, see |vimwiki-listsyms| and
|vimwili-listsym_rejected|
* gln and glp change the "done" status of a checkbox, see |vimwiki_gln|.
* |:VimwikiSplitLink| and |:VimwikiVSplitLink| can now reuse an existing
split window and not move the cursor.
@@ -3420,7 +3302,7 @@ http://code.google.com/p/vimwiki/issues/list
* Issue 210: HTML: para enclose header.
* Issue 214: External links containing Chinese characters get trimmed.
* Issue 218: Command to generate HTML file and open it in webbrowser. See
|:Vimwiki2HTMLBrowse|(bind to <Leader>whh)
|:Vimwiki2HTMLBrowse|(bind to <leader>whh)
* NEW: Added <Leader>wh mapping to call |:Vimwiki2HTML|
+5 -8
View File
@@ -127,7 +127,7 @@ setlocal formatoptions-=o
setlocal formatoptions-=2
setlocal formatoptions+=n
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem')
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
@@ -305,8 +305,8 @@ 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 VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq')
command! -buffer VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww')
command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left()
command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right()
@@ -584,8 +584,6 @@ endif
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
nnoremap <buffer> gq1 :VimwikiTableAlignQ 2<CR>
nnoremap <buffer> gw1 :VimwikiTableAlignW 2<CR>
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
endif
@@ -635,14 +633,13 @@ vnoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
\<C-U>call vimwiki#base#AddHeaderLevel(v:count)<CR>
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :<C-U>call vimwiki#base#AddHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
\<C-U>call vimwiki#base#RemoveHeaderLevel(v:count)<CR>
\<C-U>call vimwiki#base#RemoveHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiGoToParentHeader')
nmap <silent><buffer> ]u <Plug>VimwikiGoToParentHeader
+11 -35
View File
@@ -9,11 +9,6 @@ if exists("g:loaded_vimwiki") || &cp
endif
let g:loaded_vimwiki = 1
" Set to version number for release, otherwise -1 for dev-branch
let s:plugin_vers = -1
" Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h')
let s:old_cpo = &cpo
set cpo&vim
@@ -36,7 +31,7 @@ function! s:setup_buffer_leave()
let &autowriteall = s:vimwiki_autowriteall_saved
if !empty(vimwiki#vars#get_global('menu'))
if vimwiki#vars#get_global('menu') != ""
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
@@ -152,7 +147,7 @@ function! s:set_global_options()
let s:vimwiki_autowriteall_saved = &autowriteall
let &autowriteall = vimwiki#vars#get_global('autowriteall')
if !empty(vimwiki#vars#get_global('menu'))
if vimwiki#vars#get_global('menu') !=# ''
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
@@ -193,23 +188,6 @@ function! s:set_windowlocal_options()
endfunction
function! s:get_version()
if s:plugin_vers != -1
echo "Stable version: " . s:plugin_vers
else
let a:plugin_rev = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD")
let a:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD")
let a:plugin_date = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci")
if v:shell_error == 0
echo "Branch: " . a:plugin_branch
echo "Revision: " . a:plugin_rev
echo "Date: " . a:plugin_date
else
echo "Unknown version"
endif
endif
endfunction
" Initialization of Vimwiki starts here. Make sure everything below does not
@@ -261,7 +239,7 @@ augroup vimwiki
" 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 *'.s:ext.' call vimwiki#tbl#format(line("."), 2)'
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
if vimwiki#vars#get_global('folding') =~? ':quick$'
@@ -303,49 +281,47 @@ command! -count=1 VimwikiMakeTomorrowDiaryNote
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
command! VimwikiShowVersion call s:get_version()
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
if !hasmapto('<Plug>VimwikiIndex') && maparg(s:map_prefix.'w', 'n') == ""
if !hasmapto('<Plug>VimwikiIndex')
exe 'nmap <silent><unique> '.s:map_prefix.'w <Plug>VimwikiIndex'
endif
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabIndex') && maparg(s:map_prefix.'t', 'n') == ""
if !hasmapto('<Plug>VimwikiTabIndex')
exe 'nmap <silent><unique> '.s:map_prefix.'t <Plug>VimwikiTabIndex'
endif
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect') && maparg(s:map_prefix.'s', 'n') == ""
if !hasmapto('<Plug>VimwikiUISelect')
exe 'nmap <silent><unique> '.s:map_prefix.'s <Plug>VimwikiUISelect'
endif
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
if !hasmapto('<Plug>VimwikiDiaryIndex') && maparg(s:map_prefix.'i', 'n') == ""
if !hasmapto('<Plug>VimwikiDiaryIndex')
exe 'nmap <silent><unique> '.s:map_prefix.'i <Plug>VimwikiDiaryIndex'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks') && maparg(s:map_prefix.'<Leader>i', 'n') == ""
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote') && maparg(s:map_prefix.'<Leader>w', 'n') == ""
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote') && maparg(s:map_prefix.'<Leader>t', 'n') == ""
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote') && maparg(s:map_prefix.'<Leader>y', 'n') == ""
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote')
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
+9 -11
View File
@@ -253,18 +253,18 @@ syntax match VimwikiCellSeparator
" Lists
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_wikilocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_wikilocal('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]
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_wikilocal('rxListItemWithoutCB')
\ . '\s*\[['.vimwiki#vars#get_wikilocal('listsyms_list')[-1]
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ']\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
execute 'syntax match VimwikiCheckBoxDone /'
\ . vimwiki#vars#get_syntaxlocal('rxListItemAndChildren')
\ . vimwiki#vars#get_wikilocal('rxListItemAndChildren')
\ .'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
endif
@@ -297,7 +297,7 @@ execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItal
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'
\ '/ contained contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contains=VimwikiSuperScriptChar,@Spell'
@@ -318,9 +318,8 @@ execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').
" <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=@Spell'.concealpre
execute 'syntax region VimwikiPre start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell'
execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@Spell'
@@ -384,7 +383,7 @@ 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 VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def link VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic
@@ -396,7 +395,6 @@ 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
+20 -18
View File
@@ -13,36 +13,38 @@ let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$'
let s:markdown_syntax.char_eqin = '\$'
" text: **strong** or __strong__
" text: *strong*
" let s:markdown_syntax.rxBold = '\*[^*]\+\*'
let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(\*\|_\)\{2\}'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\1\{2\}'.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bold = '\*\*\|__'
let s:markdown_syntax.char_bold = '*'
" text: _emphasis_ or *emphasis*
" text: _emphasis_
" let s:markdown_syntax.rxItalic = '_[^_]\+_'
let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(\*\|_\)'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\1'.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italic = '\*\|_'
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\}'.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bolditalic = '\*\*\*'
let s:markdown_syntax.char_bolditalic = '\*_'
let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\(_\)\{3\}'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'\1\{3\}'.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italicbold = '___'
let s:markdown_syntax.char_italicbold = '_\*'
" text: `code`
let s:markdown_syntax.rxCode = '`[^`]\+`'