Compare commits
231 Commits
Author | SHA1 | Date | |
---|---|---|---|
2f95a6a651 | |||
c799d61b19 | |||
da899311c7 | |||
b794a3bd3b | |||
debd308eea | |||
ad4a12612c | |||
82c435c1e4 | |||
2c0e6ebfd9 | |||
3901b7566b | |||
0931685ba2 | |||
e8164bb58a | |||
a043e7d973 | |||
977f234f6d | |||
52634a6753 | |||
642a94ffae | |||
2afff4c411 | |||
854219f42e | |||
d7becafbdd | |||
3142e08095 | |||
5e382fe079 | |||
d502d653f7 | |||
477d54ca51 | |||
7aa273fd7c | |||
b808dcfdc1 | |||
d28b615286 | |||
a2a28a2d91 | |||
3a333881d8 | |||
8bbe0408f9 | |||
6c77fd9101 | |||
f7725fb506 | |||
6846459255 | |||
b53dd48429 | |||
b5da4ffc8a | |||
baf3be038a | |||
41b40374f9 | |||
77607f635a | |||
4617576c20 | |||
fd66db5551 | |||
99494655c2 | |||
62da755350 | |||
6607a3f641 | |||
c543f8cfb1 | |||
28114d8c85 | |||
4ab0bdf3da | |||
f823589076 | |||
d20e03d660 | |||
4511bf09e6 | |||
6922836a0c | |||
55adfca6a1 | |||
8d7d568214 | |||
7e87e92954 | |||
8055ef8608 | |||
7bc2fcb3a7 | |||
3a39498604 | |||
df5e49c7fd | |||
ac4f66586a | |||
41bce9ae42 | |||
e4de62b7d5 | |||
6716ba709f | |||
9ada4d2041 | |||
b240b52a3f | |||
bf1eb62c32 | |||
827b3a8974 | |||
68b82a15c6 | |||
42f427e718 | |||
13bdb43a54 | |||
e34e160a34 | |||
3d3586417d | |||
10293f60d7 | |||
556f686431 | |||
de11957fca | |||
d2ff96717e | |||
be9667cfa6 | |||
0511b51a5f | |||
17cfd6e613 | |||
f5e1cbe721 | |||
13e76aed2e | |||
43cad87426 | |||
8f24644967 | |||
918b07342d | |||
22ab2bfd9b | |||
b912e4e3c7 | |||
d72ef4dd70 | |||
28af35bcfe | |||
b99a3dc988 | |||
8a0433dec5 | |||
66626ad415 | |||
e6f6fdd359 | |||
e44b188a49 | |||
a62bebceb2 | |||
df91772d7e | |||
4f639cebee | |||
a01290160c | |||
c7436a44cf | |||
6cafc97c9c | |||
2d0616343d | |||
19cc1b873a | |||
7f5e517162 | |||
91b73c2aac | |||
37dafcf8c7 | |||
6b0be58392 | |||
edb72680a1 | |||
b89c22fe03 | |||
2804a4495d | |||
37ef87b930 | |||
f419b04346 | |||
53ecfdcc68 | |||
e5c5a1420d | |||
931b40ade1 | |||
eb02e0be9a | |||
a091bd5a76 | |||
c7366625a3 | |||
b990ed1966 | |||
eb254c9573 | |||
19465760b4 | |||
a3e06e4e8d | |||
9fa06803d6 | |||
f47f3c4e26 | |||
bc0f310889 | |||
d8853c5a34 | |||
3906294180 | |||
6b9edefecc | |||
a579e258a1 | |||
f7df798b25 | |||
395cfec299 | |||
bb815bcdd8 | |||
f7bacc3e75 | |||
7d07397a98 | |||
39b6239820 | |||
fb5ea2886b | |||
c1a5bb51ad | |||
f02fbffaf1 | |||
ec4066ad83 | |||
24d690f32d | |||
e8ad164fb0 | |||
21b3f63a47 | |||
fb8bbef69b | |||
4da4f19611 | |||
d7488e3291 | |||
3e480e9e3f | |||
f109e0e488 | |||
b954923cbf | |||
2dd9a153bc | |||
502212b58d | |||
1b6b50a3b7 | |||
41ddc28c9e | |||
fcd908791b | |||
77bc1b709b | |||
a099a2cf3c | |||
aeaa994fb6 | |||
bd1fb39f6c | |||
8d0e49272b | |||
57143c2c74 | |||
aa32fc2ba5 | |||
4a04fc7519 | |||
c0ead893b4 | |||
d33c64f791 | |||
ab36532f75 | |||
9f92a375c1 | |||
88b61f4e30 | |||
8167c65499 | |||
93ca39202c | |||
3dbac3a8b7 | |||
a036ca54c6 | |||
ddab77bb8f | |||
2eccebc7ea | |||
29fa46f0c5 | |||
44436f4581 | |||
2c03d82a0e | |||
81b7ee0327 | |||
b1362ac161 | |||
8f6768d7e6 | |||
8097083f46 | |||
cec6acd2f0 | |||
1e4f4eb39a | |||
e6735215ed | |||
23db33ed17 | |||
b68eb77648 | |||
1762492469 | |||
69c17a5fec | |||
976c39140a | |||
74c3372c44 | |||
41d46eb42a | |||
68ae7d57fb | |||
9810ff1c55 | |||
96dfabb03b | |||
f5634c92e1 | |||
072ba175f7 | |||
19e4cf90ef | |||
ea95f3fc36 | |||
373ad1cee5 | |||
9821aaf528 | |||
3be4ba8fd2 | |||
b37db4e109 | |||
140d32fcdd | |||
e9b1b66807 | |||
a389d7ebd7 | |||
0be8924759 | |||
eb44af27c2 | |||
c036ac34c9 | |||
5038b319a2 | |||
c09d31d1a8 | |||
391cbd827d | |||
3eaaf12b2d | |||
8a46108ef6 | |||
b09077c908 | |||
a4e168fb6e | |||
b170eb52f3 | |||
a3a499080b | |||
b61b74d037 | |||
c3ba10ca12 | |||
6317912520 | |||
911f2d4a8c | |||
c6e110a368 | |||
e30aa56722 | |||
b26591437b | |||
5b2f01094b | |||
0822759ac3 | |||
8c5760ae98 | |||
58e072fa92 | |||
79b78dc9ee | |||
6805438779 | |||
d873113118 | |||
aa6849082c | |||
6d15d32652 | |||
a405c7317a | |||
a36bbbb54a | |||
2e3883c851 | |||
813b3bb5a3 | |||
8744a31031 | |||
1c88deeee0 |
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# Local stuff
|
||||
# This section is devoted to this project
|
||||
##############################
|
||||
doc/tags
|
||||
|
||||
# Vim stuff
|
||||
##############################
|
||||
*.s[a-w][a-z]
|
||||
*.un~
|
||||
Session.vim
|
||||
.netrwhist
|
||||
*~
|
||||
|
||||
# OS generated files
|
||||
##############################
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
131
README-cn.md
Normal file
131
README-cn.md
Normal file
@ -0,0 +1,131 @@
|
||||
一个私人的维基——vim插件
|
||||
==============================================================================
|
||||
|
||||

|
||||

|
||||
|
||||
介绍
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Vimwiki是私人维基的vim插件 -- 许多有自己代码高亮的text文件。
|
||||
|
||||
通过Vimwiki,你可以:
|
||||
|
||||
* 组织笔记和想法
|
||||
* 制作代办事项表
|
||||
* 写文档
|
||||
|
||||
一个快速的开始,通常使用`<Leader>ww`(一般是`\ww`),然后创建你的index wiki文件。
|
||||
通常,它在:
|
||||
|
||||
~/vimwiki/index.wiki
|
||||
|
||||
在这个文件,输入如下的例子:
|
||||
|
||||
= My knowledge base =
|
||||
* Tasks -- things to be done _yesterday_!!!
|
||||
* Project Gutenberg -- good books are power.
|
||||
* Scratchpad -- various temporary stuff.
|
||||
|
||||
将你的光标放到`Tasks`(任务)上,并且按回车键去创建一个链接。一旦按下,`Task`将会
|
||||
变成`[[Tasks]]` -- 一个vimwiki的链接。再按一次回车去打开它。编辑文件,保存它,
|
||||
然后按backspace来返回你的index。
|
||||
|
||||
一个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* -- bold text
|
||||
_italic_ -- italic text
|
||||
|
||||
[[wiki link]] -- wiki link
|
||||
[[wiki link|description]] -- wiki link with description
|
||||
|
||||
|
||||
列表:
|
||||
|
||||
* bullet list item 1
|
||||
- bullet list item 2
|
||||
- bullet list item 3
|
||||
* bullet list item 4
|
||||
* bullet list item 5
|
||||
* bullet list item 6
|
||||
* bullet list item 7
|
||||
- bullet list item 8
|
||||
- bullet list item 9
|
||||
|
||||
1. numbered list item 1
|
||||
2. numbered list item 2
|
||||
a) numbered list item 3
|
||||
b) numbered list item 4
|
||||
|
||||
|
||||
查看`:h vimwiki-syntax`
|
||||
|
||||
|
||||
键位绑定
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
normal 模式:
|
||||
|
||||
* `<Leader>ww` -- 打开默认的wiki 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`
|
||||
|
||||
|
||||
命令
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
* `:Vimwiki2HTML` -- 转换当前wiki成为html
|
||||
* `:VimwikiAll2HTML` -- 转化你的全部wiki到html
|
||||
* `:help vimwiki-commands` -- 显示全部命令
|
||||
|
||||
|
||||
安装细节
|
||||
==============================================================================
|
||||
|
||||
在安装之前,你需要做的
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
确定在`vimrc`中,你的设置是这样的。
|
||||
|
||||
set nocompatible
|
||||
filetype plugin on
|
||||
syntax on
|
||||
|
||||
如果没有他们,Vimwiki将无法正常工作。
|
||||
|
||||
|
||||
|
||||
使用 pathogen (译者注:一个插件) (http://www.vim.org/scripts/script.php?script_id=2332 )
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
cd ~/.vim
|
||||
mkdir bundle
|
||||
cd bundle
|
||||
git clone https://github.com/vimwiki/vimwiki.git
|
||||
|
||||
然后启动vim,使用`:Helptags` 然后 `:help vimwiki`来确保他已经被安装了。
|
146
README.md
146
README.md
@ -1,38 +1,25 @@
|
||||
A Personal Wiki For Vim Plugin
|
||||
A Personal Wiki For Vim
|
||||
==============================================================================
|
||||
|
||||
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2226
|
||||
|
||||
Screenshots are available on http://code.google.com/p/vimwiki/
|
||||
There are also zipped vimwiki files there in case you do not like vimball archives.
|
||||
|
||||
|
||||
Prerequisites
|
||||
==============================================================================
|
||||
|
||||
Make sure you have these settings in your vimrc file:
|
||||
|
||||
set nocompatible
|
||||
filetype plugin on
|
||||
syntax on
|
||||
|
||||
Without them Vimwiki will not work properly.
|
||||
|
||||

|
||||

|
||||
|
||||
Intro
|
||||
==============================================================================
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Vimwiki is a personal wiki for Vim -- a number of linked text files that have
|
||||
their own syntax highlighting.
|
||||
|
||||
With vimwiki you can:
|
||||
With Vimwiki you can:
|
||||
|
||||
* organize notes and ideas;
|
||||
* manage todo-lists;
|
||||
* write documentation.
|
||||
* organize notes and ideas
|
||||
* manage todo-lists
|
||||
* write documentation
|
||||
* maintain a diary
|
||||
* export everything to HTML
|
||||
|
||||
To do a quick start press <Leader>ww (this is usually \ww) to go to your index
|
||||
wiki file. By default it is located in:
|
||||
~/vimwiki/index.wiki
|
||||
To do a quick start press `<Leader>ww` (this is usually `\ww`) to go to your index
|
||||
wiki file. By default it is located in `~/vimwiki/index.wiki`.
|
||||
|
||||
Feed it with the following example:
|
||||
|
||||
@ -41,32 +28,35 @@ Feed it with the following example:
|
||||
* Project Gutenberg -- good books are power.
|
||||
* Scratchpad -- various temporary stuff.
|
||||
|
||||
Place your cursor on 'Tasks' and press Enter to create a link. Once pressed,
|
||||
'Tasks' will become '[[Tasks]]' -- a vimwiki link. Press Enter again to
|
||||
Place your cursor on `Tasks` and press Enter to create a link. Once pressed,
|
||||
`Tasks` will become `[[Tasks]]` -- a Vimwiki link. Press Enter again to
|
||||
open it. Edit the file, save it, and then press Backspace to jump back to your
|
||||
index.
|
||||
|
||||
A vimwiki link can be constructed from more than one word. Just visually
|
||||
select the words to be linked and press Enter. Try it with 'Project
|
||||
Gutenberg'. The result should look something like:
|
||||
A Vimwiki link can be constructed from more than one word. Just visually
|
||||
select the words to be linked and press Enter. Try it with `Project Gutenberg`.
|
||||
The result should look something like:
|
||||
|
||||
= My knowledge base =
|
||||
* [[Tasks]] -- things to be done _yesterday_!!!
|
||||
* [[Project Gutenberg]] -- good books are power.
|
||||
* Scratchpad -- various temporary stuff.
|
||||
|
||||
For the various options see `:h vimwiki-options`.
|
||||
|
||||
|
||||
Basic Markup
|
||||
==============================================================================
|
||||
see `:h vimwiki-syntax`
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
*bold* -- bold
|
||||
_italic_ -- italic
|
||||
= Header1 =
|
||||
== Header2 ==
|
||||
=== Header3 ===
|
||||
|
||||
|
||||
*bold* -- bold text
|
||||
_italic_ -- italic text
|
||||
|
||||
[[wiki link]] -- wiki link
|
||||
[[wiki link|description]] -- wiki link with description
|
||||
|
||||
[[wiki link]] -- link with spaces
|
||||
[[wiki link|description]] -- link with description
|
||||
|
||||
Lists:
|
||||
|
||||
@ -80,50 +70,66 @@ Lists:
|
||||
- bullet list item 8
|
||||
- bullet list item 9
|
||||
|
||||
# numbered list item 1
|
||||
# numbered list item 2
|
||||
# numbered list item 3
|
||||
# numbered list item 4
|
||||
1. numbered list item 1
|
||||
2. numbered list item 2
|
||||
a) numbered list item 3
|
||||
b) numbered list item 4
|
||||
|
||||
= Header1 =
|
||||
== Header2 ==
|
||||
=== Header3 ===
|
||||
|
||||
For other syntax elements, see `:h vimwiki-syntax`
|
||||
|
||||
|
||||
Key bindings
|
||||
==============================================================================
|
||||
see `:h vimwiki-mappings`
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
normal mode:
|
||||
normal mode:
|
||||
|
||||
* `<Leader>ww` -- Open default wiki index file.
|
||||
* `<Leader>wt` -- Open default wiki index file in a new tab.
|
||||
* `<Leader>ws` -- Select and open wiki index file.
|
||||
* `<Leader>wd` -- Delete wiki file you are in.
|
||||
* `<Leader>wr` -- Rename wiki file you are in.
|
||||
* `<Enter>` -- Folow/Create wiki link
|
||||
* `<Shift-Enter>` -- Split and folow/create wiki link
|
||||
* `<Ctrl-Enter>` -- Vertical split and folow/create wiki link
|
||||
* `<Backspace>` -- Go back to parent(previous) wiki link
|
||||
* `<Tab>` -- Find next wiki link
|
||||
* `<Shift-Tab>` -- Find previous wiki link
|
||||
* `<Leader>ww` -- Open default wiki index file.
|
||||
* `<Leader>wt` -- Open default wiki index file in a new tab.
|
||||
* `<Leader>ws` -- Select and open wiki index file.
|
||||
* `<Leader>wd` -- Delete wiki file you are in.
|
||||
* `<Leader>wr` -- Rename wiki file you are in.
|
||||
* `<Enter>` -- Follow/Create wiki link
|
||||
* `<Shift-Enter>` -- Split and follow/create wiki link
|
||||
* `<Ctrl-Enter>` -- Vertical split and follow/create wiki link
|
||||
* `<Backspace>` -- Go back to parent(previous) wiki link
|
||||
* `<Tab>` -- Find next wiki link
|
||||
* `<Shift-Tab>` -- Find previous wiki link
|
||||
|
||||
For more keys, see `:h vimwiki-mappings`
|
||||
|
||||
|
||||
Commands
|
||||
==============================================================================
|
||||
Commands
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
* `:Vimwiki2HTML` -- Convert current wiki link to HTML
|
||||
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
|
||||
* `:Vimwiki2HTML` -- Convert current wiki link to HTML
|
||||
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
|
||||
* `:help vimwiki-commands` -- list all commands
|
||||
|
||||
Install details
|
||||
==============================================================================
|
||||
|
||||
Using pathogen (http://www.vim.org/scripts/script.php?script_id=2332)
|
||||
|
||||
Installation
|
||||
==============================================================================
|
||||
|
||||
Prerequisites
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Make sure you have these settings in your vimrc file:
|
||||
|
||||
set nocompatible
|
||||
filetype plugin on
|
||||
syntax on
|
||||
|
||||
Without them Vimwiki will not work properly.
|
||||
|
||||
|
||||
Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
cd ~/.vim
|
||||
mkdir bundle
|
||||
cd bundle
|
||||
git clone git://github.com/vim-scripts/vimwiki.git
|
||||
git clone https://github.com/vimwiki/vimwiki.git
|
||||
|
||||
Then launch vim and run `:help vimwiki` to verify it was installed.
|
||||
Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it in `~/.vim/bundle/`
|
||||
|
||||
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
# commenting / uncommenting the relevant lines below.
|
||||
#
|
||||
# NEW! An alternative converter was developed by Jason6Anderson, and can
|
||||
# be located at http://code.google.com/p/vimwiki/issues/detail?id=384
|
||||
# be located at https://github.com/vimwiki-backup/vimwiki/issues/384
|
||||
#
|
||||
#
|
||||
# To use this script, you must have the Discount converter installed.
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
|
||||
|
@ -1,8 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Desc: Handle diary notes
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" Load only once {{{
|
||||
if exists("g:loaded_vimwiki_diary_auto") || &cp
|
||||
@ -25,17 +24,6 @@ function! s:get_date_link(fmt) "{{{
|
||||
return strftime(a:fmt)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:link_exists(lines, link) "{{{
|
||||
let link_exists = 0
|
||||
for line in a:lines
|
||||
if line =~ escape(a:link, '[]\')
|
||||
let link_exists = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
return link_exists
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_path(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
|
||||
@ -54,7 +42,7 @@ endfunction "}}}
|
||||
function! s:get_position_links(link) "{{{
|
||||
let idx = -1
|
||||
let links = []
|
||||
if a:link =~ '^\d\{4}-\d\d-\d\d'
|
||||
if a:link =~# '^\d\{4}-\d\d-\d\d'
|
||||
let links = keys(s:get_diary_links())
|
||||
" include 'today' into links
|
||||
if index(links, s:diary_date_link()) == -1
|
||||
@ -81,7 +69,7 @@ fun! s:read_captions(files) "{{{
|
||||
|
||||
if filereadable(fl)
|
||||
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
|
||||
if line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
|
||||
if line =~# g:vimwiki_rxHeader && !has_key(result, fl_key)
|
||||
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
|
||||
endif
|
||||
endfor
|
||||
@ -99,10 +87,10 @@ fun! s:get_diary_links(...) "{{{
|
||||
let rx = '^\d\{4}-\d\d-\d\d'
|
||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||
let files = split(s_files, '\n')
|
||||
call filter(files, 'fnamemodify(v:val, ":t") =~ "'.escape(rx, '\').'"')
|
||||
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
|
||||
|
||||
" remove backup files (.wiki~)
|
||||
call filter(files, 'v:val !~ ''.*\~$''')
|
||||
call filter(files, 'v:val !~# ''.*\~$''')
|
||||
|
||||
if a:0
|
||||
call add(files, a:1)
|
||||
@ -133,36 +121,31 @@ fun! s:group_links(links) "{{{
|
||||
return result
|
||||
endfun "}}}
|
||||
|
||||
fun! s:sort(lst) "{{{
|
||||
if VimwikiGet("diary_sort") == 'desc'
|
||||
function! s:sort(lst) "{{{
|
||||
if VimwikiGet("diary_sort") ==? 'desc'
|
||||
return reverse(sort(a:lst))
|
||||
else
|
||||
return sort(a:lst)
|
||||
endif
|
||||
endfun "}}}
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:format_diary(...) "{{{
|
||||
function! s:format_diary(...) "{{{
|
||||
let result = []
|
||||
|
||||
call add(result, substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''))
|
||||
|
||||
if a:0
|
||||
let g_files = s:group_links(s:get_diary_links(a:1))
|
||||
else
|
||||
let g_files = s:group_links(s:get_diary_links())
|
||||
endif
|
||||
|
||||
" for year in s:rev(sort(keys(g_files)))
|
||||
for year in s:sort(keys(g_files))
|
||||
call add(result, '')
|
||||
call add(result, substitute(g:vimwiki_rxH2_Template, '__Header__', year , ''))
|
||||
|
||||
" for month in s:rev(sort(keys(g_files[year])))
|
||||
for month in s:sort(keys(g_files[year]))
|
||||
call add(result, '')
|
||||
call add(result, substitute(g:vimwiki_rxH3_Template, '__Header__', s:get_month_name(month), ''))
|
||||
|
||||
" for [fl, cap] in s:rev(sort(items(g_files[year][month])))
|
||||
for [fl, cap] in s:sort(items(g_files[year][month]))
|
||||
if empty(cap)
|
||||
let entry = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', fl, '')
|
||||
@ -177,46 +160,8 @@ fun! s:format_diary(...) "{{{
|
||||
|
||||
endfor
|
||||
endfor
|
||||
call add(result, '')
|
||||
|
||||
return result
|
||||
endfun "}}}
|
||||
|
||||
function! s:delete_diary_section() "{{{
|
||||
" remove diary section
|
||||
let old_pos = getpos('.')
|
||||
let ln_start = -1
|
||||
let ln_end = -1
|
||||
call cursor(1, 1)
|
||||
if search(substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''), 'Wc')
|
||||
let ln_start = line('.')
|
||||
if search(g:vimwiki_rxH1, 'W')
|
||||
let ln_end = line('.') - 1
|
||||
else
|
||||
let ln_end = line('$')
|
||||
endif
|
||||
endif
|
||||
|
||||
if ln_start < 0 || ln_end < 0
|
||||
call setpos('.', old_pos)
|
||||
return
|
||||
endif
|
||||
|
||||
if !&readonly
|
||||
exe ln_start.",".ln_end."delete _"
|
||||
endif
|
||||
|
||||
call setpos('.', old_pos)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:insert_diary_section() "{{{
|
||||
if !&readonly
|
||||
let ln = line('.')
|
||||
call append(ln, s:format_diary())
|
||||
if ln == 1 && getline(ln) == ''
|
||||
1,1delete
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" Diary index stuff }}}
|
||||
@ -234,8 +179,7 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
let idx = 0
|
||||
endif
|
||||
|
||||
call vimwiki#base#validate_wiki_options(idx)
|
||||
call vimwiki#base#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
|
||||
call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
|
||||
|
||||
if a:0 && a:1 == 1
|
||||
let cmd = 'tabedit'
|
||||
@ -265,8 +209,7 @@ function! vimwiki#diary#goto_diary_index(wnum) "{{{
|
||||
let idx = 0
|
||||
endif
|
||||
|
||||
call vimwiki#base#validate_wiki_options(idx)
|
||||
call vimwiki#base#edit_file('e', s:diary_index(idx))
|
||||
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
endfunction "}}}
|
||||
|
||||
@ -311,11 +254,12 @@ function! vimwiki#diary#goto_prev_day() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#diary#generate_diary_section() "{{{
|
||||
let current_file = vimwiki#u#path_norm(expand("%:p"))
|
||||
let diary_file = vimwiki#u#path_norm(s:diary_index())
|
||||
if current_file == diary_file
|
||||
call s:delete_diary_section()
|
||||
call s:insert_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 = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.g:vimwiki_rxHeader.'\)'
|
||||
call vimwiki#base#update_listing_in_buffer(s:format_diary(),
|
||||
\ VimwikiGet('diary_header'), content_rx, line('$')+1, 1)
|
||||
else
|
||||
echom "vimwiki: You can generate diary links only in a diary index page!"
|
||||
endif
|
||||
@ -329,7 +273,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
|
||||
let link = a:year.'-'.month.'-'.day
|
||||
if winnr('#') == 0
|
||||
if a:dir == 'V'
|
||||
if a:dir ==? 'V'
|
||||
vsplit
|
||||
else
|
||||
split
|
||||
@ -341,8 +285,8 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
endif
|
||||
endif
|
||||
|
||||
" Create diary note for a selected date in default wiki.
|
||||
call vimwiki#diary#make_note(1, 0, link)
|
||||
" XXX: Well, +1 is for inconsistent index basing...
|
||||
call vimwiki#diary#make_note(g:vimwiki_current_idx+1, 0, link)
|
||||
endfunction "}}}
|
||||
|
||||
" Sign function.
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Desc: Link functions for markdown syntax
|
||||
" Author: Stuart Andrews <stu.andrews@gmail.com> (.. i.e. don't blame Maxim!)
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
|
||||
" MISC helper functions {{{
|
||||
@ -17,7 +16,8 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{
|
||||
let mkd_refs = {}
|
||||
" construct list of references using vimgrep
|
||||
try
|
||||
execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
|
||||
" Why noautocmd? Because https://github.com/vimwiki/vimwiki/issues/121
|
||||
noautocmd execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
|
||||
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
||||
"Ignore it, and move on to the next file
|
||||
endtry
|
||||
@ -66,48 +66,11 @@ function! vimwiki#markdown_base#open_reflink(link) " {{{
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_path
|
||||
" s:path_html
|
||||
" vimwiki#base#apply_wiki_options
|
||||
" vimwiki#base#read_wiki_options
|
||||
" vimwiki#base#validate_wiki_options
|
||||
" vimwiki#base#setup_buffer_state
|
||||
" vimwiki#base#cache_buffer_state
|
||||
" vimwiki#base#recall_buffer_state
|
||||
" vimwiki#base#print_wiki_state
|
||||
" vimwiki#base#mkdir
|
||||
" vimwiki#base#file_pattern
|
||||
" vimwiki#base#branched_pattern
|
||||
" vimwiki#base#subdir
|
||||
" vimwiki#base#current_subdir
|
||||
" vimwiki#base#invsubdir
|
||||
" vimwiki#base#resolve_scheme
|
||||
" vimwiki#base#system_open_link
|
||||
" vimwiki#base#open_link
|
||||
" vimwiki#base#generate_links
|
||||
" vimwiki#base#goto
|
||||
" vimwiki#base#backlinks
|
||||
" vimwiki#base#get_links
|
||||
" vimwiki#base#edit_file
|
||||
" vimwiki#base#search_word
|
||||
" vimwiki#base#matchstr_at_cursor
|
||||
" vimwiki#base#replacestr_at_cursor
|
||||
" s:print_wiki_list
|
||||
" s:update_wiki_link
|
||||
" s:update_wiki_links_dir
|
||||
" s:tail_name
|
||||
" s:update_wiki_links
|
||||
" s:get_wiki_buffers
|
||||
" s:open_wiki_buffer
|
||||
" vimwiki#base#nested_syntax
|
||||
" }}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
" vimwiki#base#find_next_link
|
||||
" vimwiki#base#find_prev_link
|
||||
|
||||
" vimwiki#base#follow_link
|
||||
" vimwiki#markdown_base#follow_link
|
||||
function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
|
||||
" to VimwikiLinkHandler, or failing that, the default open_link handler
|
||||
" echom "markdown_base#follow_link"
|
||||
@ -118,11 +81,11 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
|
||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
else
|
||||
if a:split == "split"
|
||||
if a:split ==# "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
elseif a:split ==# "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
elseif a:split ==# "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
@ -160,29 +123,7 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#go_back_link
|
||||
" vimwiki#base#goto_index
|
||||
" vimwiki#base#delete_link
|
||||
" vimwiki#base#rename_link
|
||||
" vimwiki#base#ui_select
|
||||
|
||||
" TEXT OBJECTS functions {{{
|
||||
" vimwiki#base#TO_header
|
||||
" vimwiki#base#TO_table_cell
|
||||
" vimwiki#base#TO_table_col
|
||||
" }}}
|
||||
|
||||
" HEADER functions {{{
|
||||
" vimwiki#base#AddHeaderLevel
|
||||
" vimwiki#base#RemoveHeaderLevel
|
||||
"}}}
|
||||
|
||||
" LINK functions {{{
|
||||
" vimwiki#base#apply_template
|
||||
|
||||
" s:clean_url
|
||||
" vimwiki#base#normalize_link_helper
|
||||
" vimwiki#base#normalize_imagelink_helper
|
||||
|
||||
" s:normalize_link_syntax_n
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
|
150
autoload/vimwiki/path.vim
Normal file
150
autoload/vimwiki/path.vim
Normal file
@ -0,0 +1,150 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Desc: Path manipulation functions
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
|
||||
function! vimwiki#path#chomp_slash(str) "{{{
|
||||
return substitute(a:str, '[/\\]\+$', '', '')
|
||||
endfunction "}}}
|
||||
|
||||
" Define path-compare function, either case-sensitive or not, depending on OS.
|
||||
"{{{ " function! vimwiki#path#is_equal(p1, p2)
|
||||
if vimwiki#u#is_windows()
|
||||
function! vimwiki#path#is_equal(p1, p2)
|
||||
return a:p1 ==? a:p2
|
||||
endfunction
|
||||
else
|
||||
function! vimwiki#path#is_equal(p1, p2)
|
||||
return a:p1 ==# a:p2
|
||||
endfunction
|
||||
endif "}}}
|
||||
|
||||
" collapse sections like /a/b/../c to /a/c
|
||||
function! vimwiki#path#normalize(path) "{{{
|
||||
let path = a:path
|
||||
while 1
|
||||
let result = substitute(path, '/[^/]\+/\.\.', '', '')
|
||||
if result ==# path
|
||||
break
|
||||
endif
|
||||
let path = result
|
||||
endwhile
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#path#path_norm(path) "{{{
|
||||
" /-slashes
|
||||
if a:path !~# '^scp:'
|
||||
let path = substitute(a:path, '\', '/', 'g')
|
||||
" treat multiple consecutive slashes as one path separator
|
||||
let path = substitute(path, '/\+', '/', 'g')
|
||||
" ensure that we are not fooled by a symbolic link
|
||||
return resolve(path)
|
||||
else
|
||||
return a:path
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#path#is_link_to_dir(link) "{{{
|
||||
" Check if link is to a directory.
|
||||
" It should be ended with \ or /.
|
||||
return a:link =~# '\m[/\\]$'
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#path#abs_path_of_link(link) "{{{
|
||||
return vimwiki#path#normalize(expand("%:p:h").'/'.a:link)
|
||||
endfunction "}}}
|
||||
|
||||
" return longest common path prefix of 2 given paths.
|
||||
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
|
||||
function! vimwiki#path#path_common_pfx(path1, path2) "{{{
|
||||
let p1 = split(a:path1, '[/\\]', 1)
|
||||
let p2 = split(a:path2, '[/\\]', 1)
|
||||
|
||||
let idx = 0
|
||||
let minlen = min([len(p1), len(p2)])
|
||||
while (idx < minlen) && vimwiki#path#is_equal(p1[idx], p2[idx])
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
if idx == 0
|
||||
return ''
|
||||
else
|
||||
return join(p1[: idx-1], '/')
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#path#wikify_path(path) "{{{
|
||||
let result = resolve(expand(a:path, ':p'))
|
||||
if vimwiki#u#is_windows()
|
||||
let result = substitute(result, '\\', '/', 'g')
|
||||
endif
|
||||
let result = vimwiki#path#chomp_slash(result)
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" Returns: the relative path from a:dir to a:file
|
||||
function! vimwiki#path#relpath(dir, file) "{{{
|
||||
let result = []
|
||||
let dir = split(a:dir, '/')
|
||||
let file = split(a:file, '/')
|
||||
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
|
||||
call remove(dir, 0)
|
||||
call remove(file, 0)
|
||||
endwhile
|
||||
if empty(dir) && empty(file)
|
||||
return './'
|
||||
endif
|
||||
for segment in dir
|
||||
let result += ['..']
|
||||
endfor
|
||||
for segment in file
|
||||
let result += [segment]
|
||||
endfor
|
||||
let result_path = join(result, '/')
|
||||
if a:file =~ '\m/$'
|
||||
let result_path .= '/'
|
||||
endif
|
||||
return result_path
|
||||
endfunction "}}}
|
||||
|
||||
" If the optional argument provided and nonzero,
|
||||
" it will ask before creating a directory
|
||||
" Returns: 1 iff directory exists or successfully created
|
||||
function! vimwiki#path#mkdir(path, ...) "{{{
|
||||
let path = expand(a:path)
|
||||
|
||||
if path =~# '^scp:'
|
||||
" we can not do much, so let's pretend everything is ok
|
||||
return 1
|
||||
endif
|
||||
|
||||
if isdirectory(path)
|
||||
return 1
|
||||
else
|
||||
if !exists("*mkdir")
|
||||
return 0
|
||||
endif
|
||||
|
||||
let path = vimwiki#path#chomp_slash(path)
|
||||
if vimwiki#u#is_windows() && !empty(g:vimwiki_w32_dir_enc)
|
||||
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
||||
endif
|
||||
|
||||
if a:0 && a:1 && input("Vimwiki: Make new directory: "
|
||||
\ .path."\n [y]es/[N]o? ") !~? '^y'
|
||||
return 0
|
||||
endif
|
||||
|
||||
call mkdir(path, "p")
|
||||
return 1
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#path#is_absolute(path) "{{{
|
||||
if vimwiki#u#is_windows()
|
||||
return a:path =~? '\m^\a:'
|
||||
else
|
||||
return a:path =~# '\m^/\|\~/'
|
||||
endif
|
||||
endfunction "}}}
|
@ -24,6 +24,7 @@ del {text-decoration: line-through; color: #777777;}
|
||||
.justright {text-align: right;}
|
||||
.justcenter {text-align: center;}
|
||||
.center {margin-left: auto; margin-right: auto;}
|
||||
.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;}
|
||||
|
||||
/* classes for items of todo lists */
|
||||
.done0 {
|
||||
@ -31,35 +32,30 @@ del {text-decoration: line-through; color: #777777;}
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 .2em;
|
||||
margin-left: -2em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
.done1 {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 .15em;
|
||||
margin-left: -2em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
.done2 {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 .15em;
|
||||
margin-left: -2em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
.done3 {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 .15em;
|
||||
margin-left: -2em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
.done4 {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 .15em;
|
||||
margin-left: -2em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
|
308
autoload/vimwiki/tags.vim
Normal file
308
autoload/vimwiki/tags.vim
Normal file
@ -0,0 +1,308 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
|
||||
|
||||
let s:TAGS_METADATA_FILE_NAME = '.tags'
|
||||
|
||||
" Tags metadata in-memory format:
|
||||
" metadata := { 'pagename': [entries, ...] }
|
||||
" entry := { 'tagname':..., 'lineno':..., 'link':... }
|
||||
|
||||
" Tags metadata in-file format:
|
||||
"
|
||||
" Is based on CTags format (see |tags-file-format|).
|
||||
"
|
||||
" {tagaddress} is set to lineno. We'll let vim search by exact line number; we
|
||||
" can afford that, we assume metadata file is always updated before use.
|
||||
"
|
||||
" Pagename and link are not saved in standard ctags fields, so we'll add
|
||||
" an optional field, "vimwiki:". In this field, we encode tab-separated values
|
||||
" of missing parameters -- "pagename" and "link".
|
||||
|
||||
" vimwiki#tags#update_tags
|
||||
" Update tags metadata.
|
||||
" a:full_rebuild == 1: re-scan entire wiki
|
||||
" a:full_rebuild == 0: only re-scan current page
|
||||
" a:all_files == '': only if the file is newer than .tags
|
||||
function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
|
||||
let all_files = a:all_files != ''
|
||||
if !a:full_rebuild
|
||||
" Updating for one page (current)
|
||||
let page_name = VimwikiGet('subdir') . expand('%:t:r')
|
||||
" Collect tags in current file
|
||||
let tags = s:scan_tags(getline(1, '$'), page_name)
|
||||
" Load metadata file
|
||||
let metadata = s:load_tags_metadata()
|
||||
" Drop old tags
|
||||
let metadata = s:remove_page_from_tags(metadata, page_name)
|
||||
" Merge in the new ones
|
||||
let metadata = s:merge_tags(metadata, page_name, tags)
|
||||
" Save
|
||||
call s:write_tags_metadata(metadata)
|
||||
else " full rebuild
|
||||
let files = vimwiki#base#find_files(g:vimwiki_current_idx, 0)
|
||||
let tags_file_last_modification =
|
||||
\ getftime(vimwiki#tags#metadata_file_path())
|
||||
let metadata = s:load_tags_metadata()
|
||||
for file in files
|
||||
if all_files || getftime(file) >= tags_file_last_modification
|
||||
let page_name = fnamemodify(file, ':t:r')
|
||||
let tags = s:scan_tags(readfile(file), page_name)
|
||||
let metadata = s:remove_page_from_tags(metadata, page_name)
|
||||
let metadata = s:merge_tags(metadata, page_name, tags)
|
||||
endif
|
||||
endfor
|
||||
call s:write_tags_metadata(metadata)
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:scan_tags
|
||||
" Scans the list of text lines (argument) and produces tags metadata as a
|
||||
" list of tag entries.
|
||||
function! s:scan_tags(lines, page_name) "{{{
|
||||
|
||||
let entries = []
|
||||
|
||||
" Code wireframe to scan for headers -- borrowed from
|
||||
" vimwiki#base#get_anchors(), with minor modifications.
|
||||
|
||||
let rxheader = g:vimwiki_{VimwikiGet('syntax')}_header_search
|
||||
let rxtag = g:vimwiki_{VimwikiGet('syntax')}_tag_search
|
||||
|
||||
let anchor_level = ['', '', '', '', '', '', '']
|
||||
let current_complete_anchor = ''
|
||||
|
||||
let PROXIMITY_LINES_NR = 2
|
||||
let header_line_nr = - (2 * PROXIMITY_LINES_NR)
|
||||
|
||||
for line_nr in range(1, len(a:lines))
|
||||
let line = a:lines[line_nr - 1]
|
||||
|
||||
" process headers
|
||||
let h_match = matchlist(line, rxheader)
|
||||
if !empty(h_match) " got a header
|
||||
let header_line_nr = line_nr
|
||||
let header = vimwiki#u#trim(h_match[2])
|
||||
let level = len(h_match[1])
|
||||
let anchor_level[level-1] = header
|
||||
for l in range(level, 6)
|
||||
let anchor_level[l] = ''
|
||||
endfor
|
||||
if level == 1
|
||||
let current_complete_anchor = header
|
||||
else
|
||||
let current_complete_anchor = ''
|
||||
for l in range(level-1)
|
||||
if anchor_level[l] != ''
|
||||
let current_complete_anchor .= anchor_level[l].'#'
|
||||
endif
|
||||
endfor
|
||||
let current_complete_anchor .= header
|
||||
endif
|
||||
continue " tags are not allowed in headers
|
||||
endif
|
||||
|
||||
" TODO ignore verbatim blocks
|
||||
|
||||
" Scan line for tags. There can be many of them.
|
||||
let str = line
|
||||
while 1
|
||||
let tag_group = matchstr(str, rxtag)
|
||||
if tag_group == ''
|
||||
break
|
||||
endif
|
||||
let tagend = matchend(str, rxtag)
|
||||
let str = str[(tagend):]
|
||||
for tag in split(tag_group, ':')
|
||||
" Create metadata entry
|
||||
let entry = {}
|
||||
let entry.tagname = tag
|
||||
let entry.lineno = line_nr
|
||||
if line_nr <= PROXIMITY_LINES_NR && header_line_nr < 0
|
||||
" Tag appeared at the top of the file
|
||||
let entry.link = a:page_name
|
||||
elseif line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
|
||||
" Tag appeared right below a header
|
||||
let entry.link = a:page_name . '#' . current_complete_anchor
|
||||
else
|
||||
" Tag stands on its own
|
||||
let entry.link = a:page_name . '#' . tag
|
||||
endif
|
||||
call add(entries, entry)
|
||||
endfor
|
||||
endwhile
|
||||
|
||||
endfor " loop over lines
|
||||
return entries
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#tags#metadata_file_path
|
||||
" Returns tags metadata file path
|
||||
function! vimwiki#tags#metadata_file_path() abort "{{{
|
||||
return fnamemodify(VimwikiGet('path') . '/' . s:TAGS_METADATA_FILE_NAME, ':p')
|
||||
endfunction " }}}
|
||||
|
||||
" s:load_tags_metadata
|
||||
" Loads tags metadata from file, returns a dictionary
|
||||
function! s:load_tags_metadata() abort "{{{
|
||||
let metadata_path = vimwiki#tags#metadata_file_path()
|
||||
if !filereadable(metadata_path)
|
||||
return {}
|
||||
endif
|
||||
let metadata = {}
|
||||
for line in readfile(metadata_path)
|
||||
if line =~ '^!_TAG_FILE_'
|
||||
continue
|
||||
endif
|
||||
let parts = matchlist(line, '^\(.\{-}\);"\(.*\)$')
|
||||
if parts[0] == '' || parts[1] == '' || parts[2] == ''
|
||||
throw 'VimwikiTags1: Metadata file corrupted'
|
||||
endif
|
||||
let std_fields = split(parts[1], '\t')
|
||||
if len(std_fields) != 3
|
||||
throw 'VimwikiTags2: Metadata file corrupted'
|
||||
endif
|
||||
let vw_part = parts[2]
|
||||
if vw_part[0] != "\t"
|
||||
throw 'VimwikiTags3: Metadata file corrupted'
|
||||
endif
|
||||
let vw_fields = split(vw_part[1:], "\t")
|
||||
if len(vw_fields) != 1 || vw_fields[0] !~ '^vimwiki:'
|
||||
throw 'VimwikiTags4: Metadata file corrupted'
|
||||
endif
|
||||
let vw_data = substitute(vw_fields[0], '^vimwiki:', '', '')
|
||||
let vw_data = substitute(vw_data, '\\n', "\n", 'g')
|
||||
let vw_data = substitute(vw_data, '\\r', "\r", 'g')
|
||||
let vw_data = substitute(vw_data, '\\t', "\t", 'g')
|
||||
let vw_data = substitute(vw_data, '\\\\', "\\", 'g')
|
||||
let vw_fields = split(vw_data, "\t")
|
||||
if len(vw_fields) != 2
|
||||
throw 'VimwikiTags5: Metadata file corrupted'
|
||||
endif
|
||||
let pagename = vw_fields[0]
|
||||
let entry = {}
|
||||
let entry.tagname = std_fields[0]
|
||||
let entry.lineno = std_fields[2]
|
||||
let entry.link = vw_fields[1]
|
||||
if has_key(metadata, pagename)
|
||||
call add(metadata[pagename], entry)
|
||||
else
|
||||
let metadata[pagename] = [entry]
|
||||
endif
|
||||
endfor
|
||||
return metadata
|
||||
endfunction " }}}
|
||||
|
||||
" s:remove_page_from_tags
|
||||
" Removes all entries for given page from metadata in-place. Returns updated
|
||||
" metadata (just in case).
|
||||
function! s:remove_page_from_tags(metadata, page_name) "{{{
|
||||
if has_key(a:metadata, a:page_name)
|
||||
call remove(a:metadata, a:page_name)
|
||||
return a:metadata
|
||||
else
|
||||
return a:metadata
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:merge_tags
|
||||
" Merges metadata of one file into a:metadata
|
||||
function! s:merge_tags(metadata, pagename, file_metadata) "{{{
|
||||
let metadata = a:metadata
|
||||
let metadata[a:pagename] = a:file_metadata
|
||||
return metadata
|
||||
endfunction " }}}
|
||||
|
||||
" s:write_tags_metadata
|
||||
" Saves metadata object into a file. Throws exceptions in case of problems.
|
||||
function! s:write_tags_metadata(metadata) "{{{
|
||||
let metadata_path = vimwiki#tags#metadata_file_path()
|
||||
let tags = []
|
||||
for pagename in keys(a:metadata)
|
||||
for entry in a:metadata[pagename]
|
||||
let entry_data = pagename . "\t" . entry.link
|
||||
let entry_data = substitute(entry_data, "\\", '\\\\', 'g')
|
||||
let entry_data = substitute(entry_data, "\t", '\\t', 'g')
|
||||
let entry_data = substitute(entry_data, "\r", '\\r', 'g')
|
||||
let entry_data = substitute(entry_data, "\n", '\\n', 'g')
|
||||
call add(tags,
|
||||
\ entry.tagname . "\t"
|
||||
\ . pagename . VimwikiGet('ext') . "\t"
|
||||
\ . entry.lineno
|
||||
\ . ';"'
|
||||
\ . "\t" . "vimwiki:" . entry_data
|
||||
\)
|
||||
endfor
|
||||
endfor
|
||||
call sort(tags)
|
||||
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
|
||||
call writefile(tags, metadata_path)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#tags#get_tags
|
||||
" Returns list of unique tags found in the .tags file
|
||||
function! vimwiki#tags#get_tags() "{{{
|
||||
let metadata = s:load_tags_metadata()
|
||||
let tags = {}
|
||||
for entries in values(metadata)
|
||||
for entry in entries
|
||||
let tags[entry.tagname] = 1
|
||||
endfor
|
||||
endfor
|
||||
return keys(tags)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#tags#generate_tags
|
||||
" Similar to vimwiki#base#generate_links. In the current buffer, appends
|
||||
" tags and references to all their instances. If no arguments (tags) are
|
||||
" specified, outputs all tags.
|
||||
function! vimwiki#tags#generate_tags(...) abort "{{{
|
||||
let need_all_tags = (a:0 == 0)
|
||||
let specific_tags = a:000
|
||||
|
||||
let metadata = s:load_tags_metadata()
|
||||
|
||||
" make a dictionary { tag_name: [tag_links, ...] }
|
||||
let tags_entries = {}
|
||||
for entries in values(metadata)
|
||||
for entry in entries
|
||||
if has_key(tags_entries, entry.tagname)
|
||||
call add(tags_entries[entry.tagname], entry.link)
|
||||
else
|
||||
let tags_entries[entry.tagname] = [entry.link]
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
let lines = []
|
||||
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
|
||||
\ vimwiki#lst#default_symbol().' '
|
||||
for tagname in sort(keys(tags_entries))
|
||||
if need_all_tags || index(specific_tags, tagname) != -1
|
||||
call extend(lines, [
|
||||
\ '',
|
||||
\ substitute(g:vimwiki_rxH2_Template, '__Header__', tagname, ''),
|
||||
\ '' ])
|
||||
for taglink in tags_entries[tagname]
|
||||
call add(lines, bullet .
|
||||
\ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', taglink, ''))
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
let links_rx = '\m\%(^\s*$\)\|\%('.g:vimwiki_rxH2.'\)\|\%(^\s*'
|
||||
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
||||
\ .g:vimwiki_rxWikiLink.'$\)'
|
||||
|
||||
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx,
|
||||
\ line('$')+1, 1)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#tags#complete_tags
|
||||
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort " {{{
|
||||
" We can safely ignore args if we use -custom=complete option, Vim engine
|
||||
" will do the job of filtering.
|
||||
let taglist = vimwiki#tags#get_tags()
|
||||
return join(taglist, "\n")
|
||||
endfunction " }}}
|
||||
|
@ -5,8 +5,7 @@
|
||||
" |--------|------------|-------|--------|---------|
|
||||
" | Have | fun! | Drink | tea | Period. |
|
||||
"
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" Load only once {{{
|
||||
if exists("g:loaded_vimwiki_tbl_auto") || &cp
|
||||
@ -54,28 +53,28 @@ function! s:sep_splitter() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_table(line) "{{{
|
||||
return s:is_separator(a:line) || (a:line !~ s:rxSep().s:rxSep() && a:line =~ '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
|
||||
return s:is_separator(a:line) || (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_separator(line) "{{{
|
||||
return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
|
||||
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_separator_tail(line) "{{{
|
||||
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
|
||||
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)
|
||||
"echomsg "DEBUG is_last_column> ".(line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$')
|
||||
return line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$'
|
||||
"echomsg "DEBUG is_last_column> ".(line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$')
|
||||
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_first_column(lnum, cnum) "{{{
|
||||
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
|
||||
"echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||
return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||
"echomsg "DEBUG is_first_column> ".(line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||
return line =~# '^\s*$' || (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||
endfunction "}}}
|
||||
|
||||
function! s:count_separators_up(lnum) "{{{
|
||||
@ -134,11 +133,11 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
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 state ==# 'NONE'
|
||||
if ch == '|'
|
||||
let state = 'CELL'
|
||||
endif
|
||||
elseif state == 'CELL'
|
||||
elseif state ==# 'CELL'
|
||||
if ch == '[' || ch == '{'
|
||||
let state = 'BEFORE_QUOTE_START'
|
||||
let quote = ch
|
||||
@ -148,7 +147,7 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
else
|
||||
let cell .= ch
|
||||
endif
|
||||
elseif state == 'BEFORE_QUOTE_START'
|
||||
elseif state ==# 'BEFORE_QUOTE_START'
|
||||
if ch == '[' || ch == '{'
|
||||
let state = 'QUOTE'
|
||||
let quote .= ch
|
||||
@ -157,12 +156,12 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
let cell .= quote.ch
|
||||
let quote = ''
|
||||
endif
|
||||
elseif state == 'QUOTE'
|
||||
elseif state ==# 'QUOTE'
|
||||
if ch == ']' || ch == '}'
|
||||
let state = 'BEFORE_QUOTE_END'
|
||||
endif
|
||||
let quote .= ch
|
||||
elseif state == 'BEFORE_QUOTE_END'
|
||||
elseif state ==# 'BEFORE_QUOTE_END'
|
||||
if ch == ']' || ch == '}'
|
||||
let state = 'CELL'
|
||||
endif
|
||||
@ -235,13 +234,13 @@ function! s:get_rows(lnum) "{{{
|
||||
return upper_rows + lower_rows
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_cell_max_lens(lnum) "{{{
|
||||
function! s:get_cell_max_lens(lnum, ...) "{{{
|
||||
let max_lens = {}
|
||||
for [lnum, row] in s:get_rows(a:lnum)
|
||||
if s:is_separator(row)
|
||||
continue
|
||||
endif
|
||||
let cells = vimwiki#tbl#get_cells(row)
|
||||
let cells = a:0 > 1 ? a:1[lnum - a:2] : vimwiki#tbl#get_cells(row)
|
||||
for idx in range(len(cells))
|
||||
let value = cells[idx]
|
||||
if has_key(max_lens, idx)
|
||||
@ -255,17 +254,23 @@ function! s:get_cell_max_lens(lnum) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_aligned_rows(lnum, col1, col2) "{{{
|
||||
let max_lens = s:get_cell_max_lens(a:lnum)
|
||||
let rows = []
|
||||
for [lnum, row] in s:get_rows(a:lnum)
|
||||
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)
|
||||
let result = []
|
||||
for [lnum, row] in rows
|
||||
if s:is_separator(row)
|
||||
let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
|
||||
else
|
||||
let new_row = s:fmt_row(row, max_lens, a:col1, a:col2)
|
||||
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, a:col1, a:col2)
|
||||
endif
|
||||
call add(rows, [lnum, new_row])
|
||||
call add(result, [lnum, new_row])
|
||||
endfor
|
||||
return rows
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" Number of the current column. Starts from 0.
|
||||
@ -303,20 +308,19 @@ function! s:fmt_cell(cell, max_len) "{{{
|
||||
return cell
|
||||
endfunction "}}}
|
||||
|
||||
function! s:fmt_row(line, max_lens, col1, col2) "{{{
|
||||
function! s:fmt_row(cells, max_lens, col1, col2) "{{{
|
||||
let new_line = s:rxSep()
|
||||
let cells = vimwiki#tbl#get_cells(a:line)
|
||||
for idx in range(len(cells))
|
||||
for idx in range(len(a:cells))
|
||||
if idx == a:col1
|
||||
let idx = a:col2
|
||||
elseif idx == a:col2
|
||||
let idx = a:col1
|
||||
endif
|
||||
let value = cells[idx]
|
||||
let value = a:cells[idx]
|
||||
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep()
|
||||
endfor
|
||||
|
||||
let idx = len(cells)
|
||||
let idx = len(a:cells)
|
||||
while idx < len(a:max_lens)
|
||||
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep()
|
||||
let idx += 1
|
||||
@ -447,7 +451,7 @@ endfunction "}}}
|
||||
function! vimwiki#tbl#kbd_cr() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<CR>"
|
||||
return ""
|
||||
endif
|
||||
|
||||
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
|
||||
@ -490,7 +494,7 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
if !(&filetype ==? 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
@ -507,9 +511,14 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
endif
|
||||
|
||||
let indent = s:get_indent(a:lnum)
|
||||
if &expandtab
|
||||
let indentstring = repeat(' ', indent)
|
||||
else
|
||||
let indentstring = repeat(' ', indent / &tabstop) . repeat(' ', indent % &tabstop)
|
||||
endif
|
||||
|
||||
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
|
||||
let row = repeat(' ', indent).row
|
||||
let row = indentstring.row
|
||||
call setline(lnum, row)
|
||||
endfor
|
||||
|
||||
@ -560,7 +569,7 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
if !(&filetype ==? 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
|
@ -1,8 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Utility functions
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Desc: Utility functions
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
function! vimwiki#u#trim(string, ...) "{{{
|
||||
let chars = ''
|
||||
@ -14,7 +13,6 @@ function! vimwiki#u#trim(string, ...) "{{{
|
||||
return res
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" Builtin cursor doesn't work right with unicode characters.
|
||||
function! vimwiki#u#cursor(lnum, cnum) "{{{
|
||||
exe a:lnum
|
||||
@ -25,53 +23,51 @@ function! vimwiki#u#is_windows() "{{{
|
||||
return has("win32") || has("win64") || has("win95") || has("win16")
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#u#chomp_slash(str) "{{{
|
||||
return substitute(a:str, '[/\\]\+$', '', '')
|
||||
endfunction "}}}
|
||||
function! vimwiki#u#is_macos()
|
||||
if has("mac") || has("macunix") || has("gui_mac")
|
||||
return 1
|
||||
endif
|
||||
" that still doesn't mean we are not on Mac OS
|
||||
let os = substitute(system('uname'), '\n', '', '')
|
||||
return os == 'Darwin' || os == 'Mac'
|
||||
endfunction
|
||||
|
||||
function! vimwiki#u#time(starttime) "{{{
|
||||
" measure the elapsed time and cut away miliseconds and smaller
|
||||
return matchstr(reltimestr(reltime(a:starttime)),'\d\+\(\.\d\d\)\=')
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#u#path_norm(path) "{{{
|
||||
" /-slashes
|
||||
let path = substitute(a:path, '\', '/', 'g')
|
||||
" treat multiple consecutive slashes as one path separator
|
||||
let path = substitute(path, '/\+', '/', 'g')
|
||||
" ensure that we are not fooled by a symbolic link
|
||||
return resolve(path)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#u#is_link_to_dir(link) "{{{
|
||||
" Check if link is to a directory.
|
||||
" It should be ended with \ or /.
|
||||
if a:link =~ '.\+[/\\]$'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#u#count_first_sym(line) "{{{
|
||||
let first_sym = matchstr(a:line, '\S')
|
||||
return len(matchstr(a:line, first_sym.'\+'))
|
||||
endfunction "}}}
|
||||
|
||||
" return longest common path prefix of 2 given paths.
|
||||
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
|
||||
function! vimwiki#u#path_common_pfx(path1, path2) "{{{
|
||||
let p1 = split(a:path1, '[/\\]', 1)
|
||||
let p2 = split(a:path2, '[/\\]', 1)
|
||||
|
||||
let idx = 0
|
||||
let minlen = min([len(p1), len(p2)])
|
||||
while (idx < minlen) && (p1[idx] ==? p2[idx])
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
if idx == 0
|
||||
return ''
|
||||
else
|
||||
return join(p1[: idx-1], '/')
|
||||
endif
|
||||
function! vimwiki#u#escape(string) "{{{
|
||||
return escape(a:string, '.*[]\^$')
|
||||
endfunction "}}}
|
||||
|
||||
" Load concrete Wiki syntax: sets regexes and templates for headers and links
|
||||
function vimwiki#u#reload_regexes() "{{{
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
|
||||
endfunction "}}}
|
||||
|
||||
" Load omnipresent Wiki syntax
|
||||
function vimwiki#u#reload_omni_regexes() "{{{
|
||||
execute 'runtime! syntax/omnipresent_syntax.vim'
|
||||
endfunction "}}}
|
||||
|
||||
" Load syntax-specific functionality
|
||||
function vimwiki#u#reload_regexes_custom() "{{{
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
|
||||
endfunction "}}}
|
||||
|
||||
" Backward compatible version of the built-in function shiftwidth()
|
||||
if exists('*shiftwidth') "{{{
|
||||
func vimwiki#u#sw()
|
||||
return shiftwidth()
|
||||
endfunc
|
||||
else
|
||||
func vimwiki#u#sw()
|
||||
return &sw
|
||||
endfunc
|
||||
endif "}}}
|
||||
|
BIN
doc/screenshot_1.png
Normal file
BIN
doc/screenshot_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
BIN
doc/screenshot_2.png
Normal file
BIN
doc/screenshot_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
1609
doc/vimwiki.txt
1609
doc/vimwiki.txt
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,19 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki filetype plugin file
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
|
||||
|
||||
call vimwiki#u#reload_regexes()
|
||||
call vimwiki#u#reload_omni_regexes()
|
||||
|
||||
" UNDO list {{{
|
||||
" Reset the following options to undo this plugin.
|
||||
let b:undo_ftplugin = "setlocal ".
|
||||
\ "suffixesadd< isfname< comments< ".
|
||||
\ "suffixesadd< isfname< formatlistpat< ".
|
||||
\ "formatoptions< foldtext< ".
|
||||
\ "foldmethod< foldexpr< commentstring< "
|
||||
" UNDO }}}
|
||||
@ -24,171 +26,156 @@ if g:vimwiki_conceallevel && exists("+conceallevel")
|
||||
let &l:conceallevel = g:vimwiki_conceallevel
|
||||
endif
|
||||
|
||||
" MISC }}}
|
||||
|
||||
" GOTO FILE: gf {{{
|
||||
execute 'setlocal suffixesadd='.VimwikiGet('ext')
|
||||
setlocal isfname-=[,]
|
||||
" gf}}}
|
||||
|
||||
" Autocreate list items {{{
|
||||
" for list items, and list items with checkboxes
|
||||
setlocal formatoptions+=tnro
|
||||
setlocal formatoptions-=cq
|
||||
if VimwikiGet('syntax') == 'default'
|
||||
setl comments=b:*,b:#,b:-
|
||||
setl formatlistpat=^\\s*[*#-]\\s*
|
||||
elseif VimwikiGet('syntax') == 'markdown'
|
||||
setlocal comments=fb:*,fb:-,fb:+,nb:> commentstring=\ >\ %s
|
||||
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+j
|
||||
else
|
||||
setl comments=n:*,n:#
|
||||
endif
|
||||
exe "setlocal tags+=" . vimwiki#tags#metadata_file_path()
|
||||
|
||||
" MISC }}}
|
||||
|
||||
" COMPLETION {{{
|
||||
function! Complete_wikifiles(findstart, base)
|
||||
if a:findstart == 1
|
||||
let column = col('.')-2
|
||||
let line = getline('.')[:column]
|
||||
let startoflink = match(line, '\[\[\zs[^\\[\]]*$')
|
||||
if startoflink != -1
|
||||
let s:line_context = '['
|
||||
return startoflink
|
||||
endif
|
||||
if VimwikiGet('syntax') ==? 'markdown'
|
||||
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
|
||||
if startofinlinelink != -1
|
||||
let s:line_context = '['
|
||||
return startofinlinelink
|
||||
endif
|
||||
endif
|
||||
let startoftag = match(line, ':\zs[^:[:space:]]*$')
|
||||
if startoftag != -1
|
||||
let s:line_context = ':'
|
||||
return startoftag
|
||||
endif
|
||||
let s:line_context = ''
|
||||
return -1
|
||||
else
|
||||
" Completion works for wikilinks/anchors, and for tags. s:line_content
|
||||
" tells us, which string came before a:base. There seems to be no easier
|
||||
" solution, because calling col('.') here returns garbage.
|
||||
if s:line_context == ''
|
||||
return []
|
||||
elseif s:line_context == ':'
|
||||
" Tags completion
|
||||
let tags = vimwiki#tags#get_tags()
|
||||
if a:base != ''
|
||||
call filter(tags,
|
||||
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
|
||||
endif
|
||||
return tags
|
||||
elseif a:base !~# '#'
|
||||
" we look for wiki files
|
||||
|
||||
if a:base =~# '^wiki\d:'
|
||||
let wikinumber = eval(matchstr(a:base, '^wiki\zs\d'))
|
||||
if wikinumber >= len(g:vimwiki_list)
|
||||
return []
|
||||
endif
|
||||
let prefix = matchstr(a:base, '^wiki\d:\zs.*')
|
||||
let scheme = matchstr(a:base, '^wiki\d:\ze')
|
||||
elseif a:base =~# '^diary:'
|
||||
let wikinumber = -1
|
||||
let prefix = matchstr(a:base, '^diary:\zs.*')
|
||||
let scheme = matchstr(a:base, '^diary:\ze')
|
||||
else " current wiki
|
||||
let wikinumber = g:vimwiki_current_idx
|
||||
let prefix = a:base
|
||||
let scheme = ''
|
||||
endif
|
||||
|
||||
let links = vimwiki#base#get_wikilinks(wikinumber, 1)
|
||||
let result = []
|
||||
for wikifile in links
|
||||
if wikifile =~ '^'.vimwiki#u#escape(prefix)
|
||||
call add(result, scheme . wikifile)
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
|
||||
else
|
||||
" we look for anchors in the given wikifile
|
||||
|
||||
let segments = split(a:base, '#', 1)
|
||||
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
|
||||
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
|
||||
let wikifile = link_infos.filename
|
||||
let syntax = VimwikiGet('syntax', link_infos.index)
|
||||
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
|
||||
|
||||
let filtered_anchors = []
|
||||
let given_anchor = join(segments[1:], '#')
|
||||
for anchor in anchors
|
||||
if anchor =~# '^'.vimwiki#u#escape(given_anchor)
|
||||
call add(filtered_anchors, segments[0].'#'.anchor)
|
||||
endif
|
||||
endfor
|
||||
return filtered_anchors
|
||||
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
setlocal omnifunc=Complete_wikifiles
|
||||
" COMPLETION }}}
|
||||
|
||||
" LIST STUFF {{{
|
||||
" settings necessary for the automatic formatting of lists
|
||||
setlocal autoindent
|
||||
setlocal nosmartindent
|
||||
setlocal nocindent
|
||||
setlocal comments=""
|
||||
setlocal formatoptions-=c
|
||||
setlocal formatoptions-=r
|
||||
setlocal formatoptions-=o
|
||||
setlocal formatoptions-=2
|
||||
setlocal formatoptions+=n
|
||||
|
||||
"Create 'formatlistpat'
|
||||
let &formatlistpat = g:vimwiki_rxListItem
|
||||
|
||||
if !empty(&langmap)
|
||||
" Valid only if langmap is a comma separated pairs of chars
|
||||
let l_o = matchstr(&langmap, '\C,\zs.\zeo,')
|
||||
if l_o
|
||||
exe 'nnoremap <buffer> '.l_o.' :call vimwiki#lst#kbd_oO("o")<CR>a'
|
||||
let s:l_o = matchstr(&langmap, '\C,\zs.\zeo,')
|
||||
if s:l_o
|
||||
exe 'nnoremap <silent> <buffer> '.s:l_o.' :call vimwiki#lst#kbd_o()<CR>a'
|
||||
endif
|
||||
|
||||
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
|
||||
if l_O
|
||||
exe 'nnoremap <buffer> '.l_O.' :call vimwiki#lst#kbd_oO("O")<CR>a'
|
||||
let s:l_O = matchstr(&langmap, '\C,\zs.\zeO,')
|
||||
if s:l_O
|
||||
exe 'nnoremap <silent> <buffer> '.s:l_O.' :call vimwiki#lst#kbd_O()<CR>a'
|
||||
endif
|
||||
endif
|
||||
|
||||
" COMMENTS }}}
|
||||
|
||||
" FOLDING for headers and list items using expr fold method. {{{
|
||||
|
||||
" Folding list items using expr fold method. {{{
|
||||
|
||||
function! s:get_base_level(lnum) "{{{
|
||||
let lnum = a:lnum - 1
|
||||
while lnum > 0
|
||||
if getline(lnum) =~ g:vimwiki_rxHeader
|
||||
return vimwiki#u#count_first_sym(getline(lnum))
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_forward(rx_item, lnum) "{{{
|
||||
let lnum = a:lnum + 1
|
||||
|
||||
while lnum <= line('$')
|
||||
let line = getline(lnum)
|
||||
if line =~ a:rx_item
|
||||
\ || line =~ '^\S'
|
||||
\ || line =~ g:vimwiki_rxHeader
|
||||
break
|
||||
endif
|
||||
let lnum += 1
|
||||
endwhile
|
||||
|
||||
return [lnum, getline(lnum)]
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_backward(rx_item, lnum) "{{{
|
||||
let lnum = a:lnum - 1
|
||||
|
||||
while lnum > 1
|
||||
let line = getline(lnum)
|
||||
if line =~ a:rx_item
|
||||
\ || line =~ '^\S'
|
||||
break
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
|
||||
return [lnum, getline(lnum)]
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_li_level(lnum) "{{{
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
let level = vimwiki#u#count_first_sym(getline(a:lnum))
|
||||
else
|
||||
let level = (indent(a:lnum) / &sw)
|
||||
endif
|
||||
return level
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_start_list(rx_item, lnum) "{{{
|
||||
let lnum = a:lnum
|
||||
while lnum >= 1
|
||||
let line = getline(lnum)
|
||||
if line !~ a:rx_item && line =~ '^\S'
|
||||
return nextnonblank(lnum + 1)
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
" LIST STUFF }}}
|
||||
|
||||
" FOLDING {{{
|
||||
" Folding list items {{{
|
||||
function! VimwikiFoldListLevel(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
|
||||
"" XXX Disabled: Header/section folding...
|
||||
"if line =~ g:vimwiki_rxHeader
|
||||
" return '>'.vimwiki#u#count_first_sym(line)
|
||||
"endif
|
||||
|
||||
"let nnline = getline(a:lnum+1)
|
||||
|
||||
"" Unnecessary?
|
||||
"if nnline =~ g:vimwiki_rxHeader
|
||||
" return '<'.vimwiki#u#count_first_sym(nnline)
|
||||
"endif
|
||||
"" Very slow when called on every single line!
|
||||
"let base_level = s:get_base_level(a:lnum)
|
||||
|
||||
"FIXME does not work correctly
|
||||
let base_level = 0
|
||||
|
||||
if line =~ g:vimwiki_rxListItem
|
||||
let [nnum, nline] = s:find_forward(g:vimwiki_rxListItem, a:lnum)
|
||||
let level = s:get_li_level(a:lnum)
|
||||
let leveln = s:get_li_level(nnum)
|
||||
let adj = s:get_li_level(s:get_start_list(g:vimwiki_rxListItem, a:lnum))
|
||||
|
||||
if leveln > level
|
||||
return ">".(base_level+leveln-adj)
|
||||
" check if multilined list item
|
||||
elseif (nnum-a:lnum) > 1
|
||||
\ && (nline =~ g:vimwiki_rxListItem || nnline !~ '^\s*$')
|
||||
return ">".(base_level+level+1-adj)
|
||||
else
|
||||
return (base_level+level-adj)
|
||||
endif
|
||||
else
|
||||
" process multilined list items
|
||||
let [pnum, pline] = s:find_backward(g:vimwiki_rxListItem, a:lnum)
|
||||
if pline =~ g:vimwiki_rxListItem
|
||||
if indent(a:lnum) >= indent(pnum) && line !~ '^\s*$'
|
||||
let level = s:get_li_level(pnum)
|
||||
let adj = s:get_li_level(s:get_start_list(g:vimwiki_rxListItem, pnum))
|
||||
return (base_level+level+1-adj)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
return base_level
|
||||
return vimwiki#lst#fold_level(a:lnum)
|
||||
endfunction "}}}
|
||||
" Folding list items }}}
|
||||
|
||||
" Folding sections and code blocks using expr fold method. {{{
|
||||
" Folding sections and code blocks {{{
|
||||
function! VimwikiFoldLevel(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
|
||||
" Header/section folding...
|
||||
if line =~ g:vimwiki_rxHeader
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
return '>'.vimwiki#u#count_first_sym(line)
|
||||
" Code block folding...
|
||||
elseif line =~ '^\s*'.g:vimwiki_rxPreStart
|
||||
elseif line =~# '^\s*'.g:vimwiki_rxPreStart
|
||||
return 'a1'
|
||||
elseif line =~ '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||
elseif line =~# '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||
return 's1'
|
||||
else
|
||||
return "="
|
||||
@ -213,15 +200,20 @@ endfunction "}}}
|
||||
" for long enough "text", the string's length is within s:tolerance of "len"
|
||||
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
|
||||
function! s:shorten_text(text, len) "{{{ returns [string, spare]
|
||||
let spare_len = a:len - strlen(a:text)
|
||||
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
|
||||
" trick here -- replace all non-spaces with dot, calculate lengths and
|
||||
" indexes on it, then use original string to break at selected index.
|
||||
let text_pattern = substitute(a:text, '\m\S', '.', 'g')
|
||||
let spare_len = a:len - strlen(text_pattern)
|
||||
if (spare_len + s:tolerance >= 0)
|
||||
return [a:text, spare_len]
|
||||
endif
|
||||
" try to break on a space; assumes a:len-s:ell_len >= s:tolerance
|
||||
let newlen = a:len - s:ell_len
|
||||
let idx = strridx(a:text, ' ', newlen + s:tolerance)
|
||||
let idx = strridx(text_pattern, ' ', newlen + s:tolerance)
|
||||
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
|
||||
return [a:text[0:break_idx].s:ellipsis, newlen - break_idx]
|
||||
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis,
|
||||
\ newlen - break_idx]
|
||||
endfunction "}}}
|
||||
|
||||
function! VimwikiFoldText() "{{{
|
||||
@ -229,7 +221,7 @@ function! VimwikiFoldText() "{{{
|
||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||
let fold_len = v:foldend - v:foldstart + 1
|
||||
let len_text = ' ['.fold_len.'] '
|
||||
if line !~ '^\s*'.g:vimwiki_rxPreStart
|
||||
if line !~# '^\s*'.g:vimwiki_rxPreStart
|
||||
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
||||
return main_text.len_text
|
||||
else
|
||||
@ -251,19 +243,23 @@ endfunction "}}}
|
||||
|
||||
" COMMANDS {{{
|
||||
command! -buffer Vimwiki2HTML
|
||||
\ silent w <bar>
|
||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||
\ <bar>
|
||||
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||
\ expand('%'))
|
||||
\<bar>
|
||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
|
||||
\ <bar>
|
||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '.expand(VimwikiGet('path_html')) | endif
|
||||
command! -buffer Vimwiki2HTMLBrowse
|
||||
\ silent w <bar>
|
||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||
\ <bar>
|
||||
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
|
||||
\ expand(VimwikiGet('path_html')),
|
||||
\ expand('%')))
|
||||
command! -buffer VimwikiAll2HTML
|
||||
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
|
||||
|
||||
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
|
||||
|
||||
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
|
||||
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
|
||||
command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
|
||||
@ -277,8 +273,6 @@ command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(
|
||||
|
||||
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
|
||||
|
||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
|
||||
|
||||
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
|
||||
|
||||
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
|
||||
@ -290,11 +284,23 @@ exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
|
||||
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
|
||||
command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("<args>")
|
||||
command! -buffer -nargs=+ -complete=custom,vimwiki#base#complete_links_escaped
|
||||
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
|
||||
|
||||
command! -buffer VimwikiCheckLinks call vimwiki#base#check_links()
|
||||
|
||||
" list commands
|
||||
command! -buffer -nargs=* VimwikiListChangeLevel call vimwiki#lst#change_level(<f-args>)
|
||||
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
|
||||
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
|
||||
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
|
||||
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call vimwiki#lst#change_marker_in_list(<f-args>)
|
||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
||||
command! -buffer -range -nargs=+ VimwikiListChangeLvl call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
||||
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
|
||||
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
|
||||
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
|
||||
command! -buffer VimwikiRenumberAllLists call vimwiki#lst#adjust_whole_buffer()
|
||||
command! -buffer VimwikiListToggle call vimwiki#lst#toggle_list_item()
|
||||
|
||||
" table commands
|
||||
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
|
||||
@ -307,6 +313,14 @@ command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right(
|
||||
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
||||
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
||||
|
||||
" tags commands
|
||||
command! -buffer -bang
|
||||
\ VimwikiRebuildTags call vimwiki#tags#update_tags(1, '<bang>')
|
||||
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
||||
\ VimwikiSearchTags VimwikiSearch /:<args>:/
|
||||
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
||||
\ VimwikiGenerateTags call vimwiki#tags#generate_tags(<f-args>)
|
||||
|
||||
" COMMANDS }}}
|
||||
|
||||
" KEYBINDINGS {{{
|
||||
@ -321,13 +335,13 @@ endif
|
||||
|
||||
|
||||
if !hasmapto('<Plug>Vimwiki2HTML')
|
||||
nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
|
||||
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'h <Plug>Vimwiki2HTML'
|
||||
endif
|
||||
nnoremap <script><buffer>
|
||||
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
||||
|
||||
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
|
||||
nmap <buffer> <Leader>whh <Plug>Vimwiki2HTMLBrowse
|
||||
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'hh <Plug>Vimwiki2HTMLBrowse'
|
||||
endif
|
||||
nnoremap <script><buffer>
|
||||
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
||||
@ -394,27 +408,17 @@ nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDeleteLink')
|
||||
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
|
||||
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'d <Plug>VimwikiDeleteLink'
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRenameLink')
|
||||
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
|
||||
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'r <Plug>VimwikiRenameLink'
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
|
||||
vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
|
||||
if has("unix")
|
||||
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
||||
endif
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
||||
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
||||
endif
|
||||
@ -427,42 +431,154 @@ endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
||||
|
||||
function! s:CR() "{{{
|
||||
let res = vimwiki#lst#kbd_cr()
|
||||
if res == "\<CR>" && g:vimwiki_table_mappings
|
||||
let res = vimwiki#tbl#kbd_cr()
|
||||
" List mappings
|
||||
if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
|
||||
vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
|
||||
if has("unix")
|
||||
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
||||
vmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
||||
endif
|
||||
return res
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||
vnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem', 'i')
|
||||
imap <silent><buffer> <C-D>
|
||||
\ <Plug>VimwikiDecreaseLvlSingleItem
|
||||
endif
|
||||
inoremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
|
||||
\ <C-O>:VimwikiListChangeLvl decrease 0<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiIncreaseLvlSingleItem', 'i')
|
||||
imap <silent><buffer> <C-T>
|
||||
\ <Plug>VimwikiIncreaseLvlSingleItem
|
||||
endif
|
||||
inoremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
|
||||
\ <C-O>:VimwikiListChangeLvl increase 0<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiListNextSymbol', 'i')
|
||||
imap <silent><buffer> <C-L><C-J>
|
||||
\ <Plug>VimwikiListNextSymbol
|
||||
endif
|
||||
inoremap <silent><script><buffer> <Plug>VimwikiListNextSymbol
|
||||
\ <C-O>:VimwikiListChangeSymbolI next<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiListPrevSymbol', 'i')
|
||||
imap <silent><buffer> <C-L><C-K>
|
||||
\ <Plug>VimwikiListPrevSymbol
|
||||
endif
|
||||
inoremap <silent><script><buffer> <Plug>VimwikiListPrevSymbol
|
||||
\ <C-O>:VimwikiListChangeSymbolI prev<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiListToggle', 'i')
|
||||
imap <silent><buffer> <C-L><C-M> <Plug>VimwikiListToggle
|
||||
endif
|
||||
inoremap <silent><script><buffer> <Plug>VimwikiListToggle <Esc>:VimwikiListToggle<CR>
|
||||
|
||||
nnoremap <silent> <buffer> o :call vimwiki#lst#kbd_o()<CR>
|
||||
nnoremap <silent> <buffer> O :call vimwiki#lst#kbd_O()<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRenumberList')
|
||||
nmap <silent><buffer> glr <Plug>VimwikiRenumberList
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRenumberList :VimwikiRenumberList<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRenumberAllLists')
|
||||
nmap <silent><buffer> gLr <Plug>VimwikiRenumberAllLists
|
||||
nmap <silent><buffer> gLR <Plug>VimwikiRenumberAllLists
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRenumberAllLists :VimwikiRenumberAllLists<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem')
|
||||
map <silent><buffer> glh <Plug>VimwikiDecreaseLvlSingleItem
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDecreaseLvlSingleItem :VimwikiListChangeLvl decrease 0<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiIncreaseLvlSingleItem')
|
||||
map <silent><buffer> gll <Plug>VimwikiIncreaseLvlSingleItem
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiIncreaseLvlSingleItem :VimwikiListChangeLvl increase 0<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDecreaseLvlWholeItem')
|
||||
map <silent><buffer> gLh <Plug>VimwikiDecreaseLvlWholeItem
|
||||
map <silent><buffer> gLH <Plug>VimwikiDecreaseLvlWholeItem
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDecreaseLvlWholeItem :VimwikiListChangeLvl decrease 1<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiIncreaseLvlWholeItem')
|
||||
map <silent><buffer> gLl <Plug>VimwikiIncreaseLvlWholeItem
|
||||
map <silent><buffer> gLL <Plug>VimwikiIncreaseLvlWholeItem
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiIncreaseLvlWholeItem :VimwikiListChangeLvl increase 1<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRemoveSingleCB')
|
||||
map <silent><buffer> gl<Space> <Plug>VimwikiRemoveSingleCB
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRemoveSingleCB :VimwikiRemoveSingleCB<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRemoveCBInList')
|
||||
map <silent><buffer> gL<Space> <Plug>VimwikiRemoveCBInList
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRemoveCBInList :VimwikiRemoveCBInList<CR>
|
||||
|
||||
for s:char in keys(g:vimwiki_bullet_types)
|
||||
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
|
||||
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
|
||||
endif
|
||||
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'<CR>')
|
||||
exe 'noremap <silent><buffer> gL'.s:char.' :VimwikiChangeSymbolInListTo '.s:char.'<CR>'
|
||||
endif
|
||||
endfor
|
||||
|
||||
for s:typ in g:vimwiki_number_types
|
||||
if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'<CR>')
|
||||
exe 'noremap <silent><buffer> gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'<CR>'
|
||||
endif
|
||||
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'<CR>')
|
||||
exe 'noremap <silent><buffer> gL'.s:typ[0].' :VimwikiChangeSymbolInListTo '.s:typ.'<CR>'
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
|
||||
function! s:CR(normal, just_mrkr) "{{{
|
||||
if g:vimwiki_table_mappings
|
||||
let res = vimwiki#tbl#kbd_cr()
|
||||
if res != ""
|
||||
exe "normal! " . res . "\<Right>"
|
||||
startinsert
|
||||
return
|
||||
endif
|
||||
endif
|
||||
call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr)
|
||||
endfunction "}}}
|
||||
|
||||
" List and Table <CR> mapping
|
||||
inoremap <buffer> <expr> <CR> <SID>CR()
|
||||
|
||||
" List mappings
|
||||
nnoremap <buffer> o :<C-U>call vimwiki#lst#kbd_oO('o')<CR>
|
||||
nnoremap <buffer> O :<C-U>call vimwiki#lst#kbd_oO('O')<CR>
|
||||
nnoremap <buffer> gll :VimwikiListChangeLevel <<<CR>
|
||||
nnoremap <buffer> glm :VimwikiListChangeLevel >><CR>
|
||||
nnoremap <buffer> gl* :VimwikiListChangeLevel *<CR>
|
||||
nnoremap <buffer> gl8 :VimwikiListChangeLevel *<CR>
|
||||
if VimwikiGet('syntax') == 'default'
|
||||
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
|
||||
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
|
||||
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
|
||||
elseif VimwikiGet('syntax') == 'markdown'
|
||||
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
|
||||
nnoremap <buffer> gl1 :VimwikiListChangeLevel 1.<CR>
|
||||
elseif VimwikiGet('syntax') == 'media'
|
||||
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
|
||||
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
|
||||
if maparg('<CR>', 'i') !~? '<Esc>:VimwikiReturn'
|
||||
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 5<CR>
|
||||
endif
|
||||
if maparg('<S-CR>', 'i') !~? '<Esc>:VimwikiReturn'
|
||||
inoremap <silent><buffer> <S-CR> <Esc>:VimwikiReturn 2 2<CR>
|
||||
endif
|
||||
|
||||
|
||||
" Table mappings
|
||||
if g:vimwiki_table_mappings
|
||||
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
|
||||
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
|
||||
endif
|
||||
"Table mappings
|
||||
if g:vimwiki_table_mappings
|
||||
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
|
||||
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
|
||||
endif
|
||||
|
||||
|
||||
|
||||
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
|
||||
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
|
||||
@ -498,6 +614,12 @@ vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
|
||||
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
|
||||
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> al :<C-U>call vimwiki#lst#TO_list_item(0, 0)<CR>
|
||||
vnoremap <silent><buffer> al :<C-U>call vimwiki#lst#TO_list_item(0, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 0)<CR>
|
||||
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
|
||||
@ -519,12 +641,25 @@ nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
|
||||
if VimwikiGet('auto_export')
|
||||
" Automatically generate HTML on page write.
|
||||
augroup vimwiki
|
||||
au BufWritePost <buffer>
|
||||
au BufWritePost <buffer>
|
||||
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||
\ expand('%'))
|
||||
augroup END
|
||||
endif
|
||||
|
||||
if VimwikiGet('auto_toc')
|
||||
" Automatically update the TOC *before* the file is written
|
||||
augroup vimwiki
|
||||
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
|
||||
augroup END
|
||||
endif
|
||||
|
||||
if VimwikiGet('auto_tags')
|
||||
" Automatically update tags metadata on page write.
|
||||
augroup vimwiki
|
||||
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
|
||||
augroup END
|
||||
endif
|
||||
" AUTOCOMMANDS }}}
|
||||
|
||||
" PASTE, CAT URL {{{
|
||||
|
@ -1,13 +1,12 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki plugin file
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
|
||||
|
||||
if exists("loaded_vimwiki") || &cp
|
||||
if exists("g:loaded_vimwiki") || &cp
|
||||
finish
|
||||
endif
|
||||
let loaded_vimwiki = 1
|
||||
let g:loaded_vimwiki = 1
|
||||
|
||||
let s:old_cpo = &cpo
|
||||
set cpo&vim
|
||||
@ -32,22 +31,36 @@ function! s:default(varname, value) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_wiki(path) "{{{
|
||||
" XXX: find_wiki() does not (yet) take into consideration the ext
|
||||
let path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(a:path))
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
let idx_path = expand(VimwikiGet('path', idx))
|
||||
let idx_path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(idx_path))
|
||||
if vimwiki#u#path_common_pfx(idx_path, path) == idx_path
|
||||
return idx
|
||||
endif
|
||||
let idx += 1
|
||||
endwhile
|
||||
return -1
|
||||
" an orphan page has been detected
|
||||
function! s:path_html(idx) "{{{
|
||||
let path_html = VimwikiGet('path_html', a:idx)
|
||||
if !empty(path_html)
|
||||
return path_html
|
||||
else
|
||||
let g:VimwikiLog.path_html += 1 "XXX
|
||||
let path = VimwikiGet('path', a:idx)
|
||||
return substitute(path, '[/\\]\+$', '', '').'_html/'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:normalize_path(path) "{{{
|
||||
let g:VimwikiLog.normalize_path += 1 "XXX
|
||||
" resolve doesn't work quite right with symlinks ended with / or \
|
||||
let path = substitute(a:path, '[/\\]\+$', '', '')
|
||||
if path !~# '^scp:'
|
||||
return resolve(expand(path)).'/'
|
||||
else
|
||||
return path.'/'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! Validate_wiki_options(idx) " {{{
|
||||
call VimwikiSet('path', s:normalize_path(VimwikiGet('path', a:idx)), a:idx)
|
||||
call VimwikiSet('path_html', s:normalize_path(s:path_html(a:idx)), a:idx)
|
||||
call VimwikiSet('template_path',
|
||||
\ s:normalize_path(VimwikiGet('template_path', a:idx)), a:idx)
|
||||
call VimwikiSet('diary_rel_path',
|
||||
\ s:normalize_path(VimwikiGet('diary_rel_path', a:idx)), a:idx)
|
||||
endfunction " }}}
|
||||
|
||||
function! s:vimwiki_idx() " {{{
|
||||
if exists('b:vimwiki_idx')
|
||||
@ -58,14 +71,14 @@ function! s:vimwiki_idx() " {{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:setup_buffer_leave() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
if g:vimwiki_debug == 3
|
||||
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
if &filetype == 'vimwiki'
|
||||
if &filetype ==? 'vimwiki'
|
||||
" cache global vars of current state XXX: SLOW!?
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endif
|
||||
if g:vimwiki_debug ==3
|
||||
if g:vimwiki_debug == 3
|
||||
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
@ -78,15 +91,14 @@ function! s:setup_buffer_leave() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_filetype() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
if g:vimwiki_debug == 3
|
||||
echom "Setup_filetype g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
let time0 = reltime() " start the clock "XXX
|
||||
" Find what wiki current buffer belongs to.
|
||||
let path = expand('%:p:h')
|
||||
" XXX: find_wiki() does not (yet) take into consideration the ext
|
||||
let idx = s:find_wiki(path)
|
||||
if g:vimwiki_debug ==3
|
||||
let idx = vimwiki#base#find_wiki(path)
|
||||
if g:vimwiki_debug == 3
|
||||
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
@ -108,8 +120,8 @@ function! s:setup_filetype() "{{{
|
||||
endif
|
||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
||||
let idx = len(g:vimwiki_list) - 1
|
||||
call Validate_wiki_options(idx)
|
||||
endif
|
||||
call vimwiki#base#validate_wiki_options(idx)
|
||||
" initialize and cache global vars of current state
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
if g:vimwiki_debug ==3
|
||||
@ -136,8 +148,7 @@ function! s:setup_buffer_enter() "{{{
|
||||
" buffer's path and ext.
|
||||
" Else set g:vimwiki_current_idx to that wiki index.
|
||||
let path = expand('%:p:h')
|
||||
" XXX: find_wiki() does not (yet) take into consideration the ext
|
||||
let idx = s:find_wiki(path)
|
||||
let idx = vimwiki#base#find_wiki(path)
|
||||
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
@ -161,8 +172,8 @@ function! s:setup_buffer_enter() "{{{
|
||||
endif
|
||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
||||
let idx = len(g:vimwiki_list) - 1
|
||||
call Validate_wiki_options(idx)
|
||||
endif
|
||||
call vimwiki#base#validate_wiki_options(idx)
|
||||
" initialize and cache global vars of current state
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
if g:vimwiki_debug ==3
|
||||
@ -180,7 +191,7 @@ function! s:setup_buffer_enter() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
elseif &syntax == 'vimwiki'
|
||||
elseif &syntax ==? 'vimwiki'
|
||||
" to force a rescan of the filesystem which may have changed
|
||||
" and update VimwikiLinks syntax group that depends on it;
|
||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
||||
@ -197,17 +208,20 @@ function! s:setup_buffer_enter() "{{{
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding == 'expr'
|
||||
if g:vimwiki_folding ==? 'expr'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding == 'list' || g:vimwiki_folding == 'lists'
|
||||
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding == 'syntax'
|
||||
elseif g:vimwiki_folding ==? 'syntax'
|
||||
setlocal fdm=syntax
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
else
|
||||
setlocal fdm=manual
|
||||
exe "normal zE"
|
||||
endif
|
||||
|
||||
" And conceal level too.
|
||||
@ -310,7 +324,7 @@ function! VimwikiSet(option, value, ...) "{{{
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
" Clear option for current wiki or if third parameter exists for
|
||||
" Clear option for current wiki or if second parameter exists for
|
||||
" wiki with a given index.
|
||||
" Currently, only works if option was previously saved in the buffer local
|
||||
" dictionary, that acts as a cache.
|
||||
@ -324,6 +338,23 @@ function! VimwikiClear(option, ...) "{{{
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
function! s:vimwiki_get_known_extensions() " {{{
|
||||
" Getting all extensions that different wikis could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for ext in keys(g:vimwiki_ext2syntax)
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
return keys(extensions)
|
||||
endfunction " }}}
|
||||
|
||||
" }}}
|
||||
|
||||
" CALLBACK functions "{{{
|
||||
@ -334,9 +365,15 @@ if !exists("*VimwikiLinkHandler") "{{{
|
||||
endfunction
|
||||
endif "}}}
|
||||
|
||||
if !exists("*VimwikiLinkConverter") "{{{
|
||||
function VimwikiLinkConverter(url, source, target)
|
||||
" Return the empty string when unable to process link
|
||||
return ''
|
||||
endfunction
|
||||
endif "}}}
|
||||
|
||||
if !exists("*VimwikiWikiIncludeHandler") "{{{
|
||||
function! VimwikiWikiIncludeHandler(value) "{{{
|
||||
" Return the empty string when unable to process link
|
||||
return ''
|
||||
endfunction "}}}
|
||||
endif "}}}
|
||||
@ -352,12 +389,13 @@ let s:vimwiki_defaults.ext = '.wiki'
|
||||
let s:vimwiki_defaults.maxhi = 0
|
||||
let s:vimwiki_defaults.syntax = 'default'
|
||||
|
||||
let s:vimwiki_defaults.template_path = ''
|
||||
let s:vimwiki_defaults.template_default = ''
|
||||
let s:vimwiki_defaults.template_ext = ''
|
||||
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
|
||||
let s:vimwiki_defaults.template_default = 'default'
|
||||
let s:vimwiki_defaults.template_ext = '.tpl'
|
||||
|
||||
let s:vimwiki_defaults.nested_syntaxes = {}
|
||||
let s:vimwiki_defaults.auto_export = 0
|
||||
let s:vimwiki_defaults.auto_toc = 0
|
||||
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
|
||||
" file.
|
||||
let s:vimwiki_defaults.temp = 0
|
||||
@ -376,11 +414,12 @@ let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
|
||||
let s:vimwiki_defaults.custom_wiki2html = ''
|
||||
"
|
||||
let s:vimwiki_defaults.list_margin = -1
|
||||
|
||||
let s:vimwiki_defaults.auto_tags = 0
|
||||
"}}}
|
||||
|
||||
" DEFAULT options {{{
|
||||
call s:default('list', [s:vimwiki_defaults])
|
||||
call s:default('auto_checkbox', 1)
|
||||
call s:default('use_mouse', 0)
|
||||
call s:default('folding', '')
|
||||
call s:default('menu', 'Vimwiki')
|
||||
@ -399,6 +438,7 @@ call s:default('dir_link', '')
|
||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
|
||||
call s:default('user_htmls', '')
|
||||
call s:default('autowriteall', 1)
|
||||
call s:default('toc_header', 'Contents')
|
||||
|
||||
call s:default('html_header_numbering', 0)
|
||||
call s:default('html_header_numbering_sym', '')
|
||||
@ -414,9 +454,12 @@ call s:default('diary_months',
|
||||
\ 10: 'October', 11: 'November', 12: 'December'
|
||||
\ })
|
||||
|
||||
call s:default('map_prefix', '<Leader>w')
|
||||
|
||||
call s:default('current_idx', 0)
|
||||
|
||||
call s:default('auto_chdir', 0)
|
||||
|
||||
" Scheme regexes should be defined even if syntax file is not loaded yet
|
||||
" cause users should be able to <leader>w<leader>w without opening any
|
||||
" vimwiki file first
|
||||
@ -426,20 +469,23 @@ call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'.
|
||||
\ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp')
|
||||
call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel')
|
||||
|
||||
let rxSchemes = '\%('.
|
||||
let s:rxSchemes = '\%('.
|
||||
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
|
||||
\ '\)'
|
||||
|
||||
call s:default('rxSchemeUrl', rxSchemes.':.*')
|
||||
call s:default('rxSchemeUrlMatchScheme', '\zs'.rxSchemes.'\ze:.*')
|
||||
call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
|
||||
call s:default('rxSchemeUrl', s:rxSchemes.':.*')
|
||||
call s:default('rxSchemeUrlMatchScheme', '\zs'.s:rxSchemes.'\ze:.*')
|
||||
call s:default('rxSchemeUrlMatchUrl', s:rxSchemes.':\zs.*\ze')
|
||||
" scheme regexes }}}
|
||||
|
||||
for s:idx in range(len(g:vimwiki_list))
|
||||
call Validate_wiki_options(s:idx)
|
||||
endfor
|
||||
"}}}
|
||||
|
||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||
let extensions = vimwiki#base#get_known_extensions()
|
||||
|
||||
augroup filetypedetect
|
||||
" clear FlexWiki's stuff
|
||||
@ -448,17 +494,17 @@ augroup end
|
||||
|
||||
augroup vimwiki
|
||||
autocmd!
|
||||
for ext in extensions
|
||||
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_reenter()'
|
||||
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
||||
exe 'autocmd BufNewFile,BufRead, *'.ext.' call s:setup_filetype()'
|
||||
exe 'autocmd ColorScheme *'.ext.' call s:setup_cleared_syntax()'
|
||||
for s:ext in s:vimwiki_get_known_extensions()
|
||||
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()'
|
||||
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'
|
||||
exe 'autocmd BufNewFile,BufRead, *'.s:ext.' call s:setup_filetype()'
|
||||
exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()'
|
||||
" Format tables when exit from insert mode. Do not use textwidth to
|
||||
" autowrap tables.
|
||||
if g:vimwiki_table_auto_fmt
|
||||
exe 'autocmd InsertLeave *'.ext.' call vimwiki#tbl#format(line("."))'
|
||||
exe 'autocmd InsertEnter *'.ext.' call vimwiki#tbl#reset_tw(line("."))'
|
||||
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
|
||||
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
|
||||
endif
|
||||
endfor
|
||||
augroup END
|
||||
@ -486,37 +532,37 @@ command! VimwikiDiaryGenerateLinks
|
||||
|
||||
" MAPPINGS {{{
|
||||
if !hasmapto('<Plug>VimwikiIndex')
|
||||
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'w <Plug>VimwikiIndex'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabIndex')
|
||||
nmap <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'t <Plug>VimwikiTabIndex'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiUISelect')
|
||||
nmap <silent><unique> <Leader>ws <Plug>VimwikiUISelect
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'s <Plug>VimwikiUISelect'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryIndex')
|
||||
nmap <silent><unique> <Leader>wi <Plug>VimwikiDiaryIndex
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'i <Plug>VimwikiDiaryIndex'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
|
||||
nmap <silent><unique> <Leader>w<Leader>i <Plug>VimwikiDiaryGenerateLinks
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
|
||||
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
||||
nmap <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
||||
\ :VimwikiTabMakeDiaryNote<CR>
|
||||
|
35
syntax/omnipresent_syntax.vim
Normal file
35
syntax/omnipresent_syntax.vim
Normal file
@ -0,0 +1,35 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Desc: Syntax definitions which are always available
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
|
||||
" Define Regexes of anchors for every syntax.
|
||||
" This has to be separated from vimwiki_default.vim, vimwiki_markdown.vim, etc.
|
||||
" because the latter are only loaded and available if the current wiki has the
|
||||
" corresponding syntax
|
||||
let g:vimwiki_default_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||
let g:vimwiki_default_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
||||
let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||
let g:vimwiki_default_tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||
let g:vimwiki_default_tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||
|
||||
let g:vimwiki_markdown_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
|
||||
let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
|
||||
let g:vimwiki_markdown_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_markdown_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_markdown_wikilink = g:vimwiki_default_wikilink "XXX plus markdown-style links
|
||||
let g:vimwiki_markdown_tag_search = g:vimwiki_default_tag_search
|
||||
let g:vimwiki_markdown_tag_match = g:vimwiki_default_tag_match
|
||||
|
||||
let g:vimwiki_media_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||
let g:vimwiki_media_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
||||
let g:vimwiki_media_bold_search = "'''\\zs[^']\\+\\ze'''"
|
||||
let g:vimwiki_media_bold_match = '''''''__Text__'''''''
|
||||
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
|
||||
" want to call escape() on this string, we must keep it in single quotes
|
||||
let g:vimwiki_media_wikilink = g:vimwiki_default_wikilink
|
||||
let g:vimwiki_media_tag_search = g:vimwiki_default_tag_search " XXX rework to mediawiki categories format?
|
||||
let g:vimwiki_media_tag_match = g:vimwiki_default_tag_match " XXX rework to mediawiki categories format?
|
@ -1,7 +1,6 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" Quit if syntax file is already loaded
|
||||
if version < 600
|
||||
@ -9,13 +8,16 @@ if version < 600
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
"TODO do nothing if ...? (?)
|
||||
let starttime = reltime() " start the clock
|
||||
let g:starttime = reltime() " start the clock
|
||||
if VimwikiGet('maxhi')
|
||||
let b:existing_wikifiles = vimwiki#base#get_links('*'.VimwikiGet('ext'))
|
||||
let b:existing_wikidirs = vimwiki#base#get_links('*/')
|
||||
let b:existing_wikifiles =
|
||||
\ vimwiki#base#get_wikilinks(g:vimwiki_current_idx, 1)
|
||||
let b:existing_wikidirs =
|
||||
\ vimwiki#base#get_wiki_directories(g:vimwiki_current_idx)
|
||||
endif
|
||||
let timescans = vimwiki#u#time(starttime) "XXX
|
||||
let s:timescans = vimwiki#u#time(g:starttime) "XXX
|
||||
"let b:xxx = 1
|
||||
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
|
||||
"if VimwikiGet('maxhi')
|
||||
@ -43,61 +45,70 @@ let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
|
||||
|
||||
" }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load concrete Wiki syntax: sets regexes and templates for headers and links
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
|
||||
" -------------------------------------------------------------------------
|
||||
let time0 = vimwiki#u#time(starttime) "XXX
|
||||
call vimwiki#u#reload_regexes()
|
||||
|
||||
let g:vimwiki_rxListItem = '\('.
|
||||
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
|
||||
\ '\)'
|
||||
let s:time0 = vimwiki#u#time(g:starttime) "XXX
|
||||
|
||||
" LINKS: setup of larger regexes {{{
|
||||
|
||||
" LINKS: setup wikilink regexps {{{
|
||||
let g:vimwiki_rxWikiLinkPrefix = '[['
|
||||
let g:vimwiki_rxWikiLinkSuffix = ']]'
|
||||
let g:vimwiki_rxWikiLinkSeparator = '|'
|
||||
let s:wikilink_prefix = '[['
|
||||
let s:wikilink_suffix = ']]'
|
||||
let s:wikilink_separator = '|'
|
||||
let s:rx_wikilink_prefix = vimwiki#u#escape(s:wikilink_prefix)
|
||||
let s:rx_wikilink_suffix = vimwiki#u#escape(s:wikilink_suffix)
|
||||
let s:rx_wikilink_separator = vimwiki#u#escape(s:wikilink_separator)
|
||||
|
||||
" templates for the creation of wiki links
|
||||
" [[URL]]
|
||||
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLinkSuffix
|
||||
let g:vimwiki_WikiLinkTemplate1 = s:wikilink_prefix . '__LinkUrl__'.
|
||||
\ s:wikilink_suffix
|
||||
" [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWikiLinkSuffix
|
||||
"
|
||||
let magic_chars = '.*[]\^$'
|
||||
let valid_chars = '[^\\\]]'
|
||||
let g:vimwiki_WikiLinkTemplate2 = s:wikilink_prefix . '__LinkUrl__'.
|
||||
\ s:wikilink_separator . '__LinkDescription__' . s:wikilink_suffix
|
||||
|
||||
let g:vimwiki_rxWikiLinkPrefix = escape(g:vimwiki_rxWikiLinkPrefix, magic_chars)
|
||||
let g:vimwiki_rxWikiLinkSuffix = escape(g:vimwiki_rxWikiLinkSuffix, magic_chars)
|
||||
let g:vimwiki_rxWikiLinkSeparator = escape(g:vimwiki_rxWikiLinkSeparator, magic_chars)
|
||||
let g:vimwiki_rxWikiLinkUrl = valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLinkDescr = valid_chars.'\{-}'
|
||||
" template for matching all wiki links with a given target file
|
||||
let g:vimwiki_WikiLinkMatchUrlTemplate =
|
||||
\ s:rx_wikilink_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_suffix .
|
||||
\ '\|' .
|
||||
\ s:rx_wikilink_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_separator .
|
||||
\ '.*' .
|
||||
\ s:rx_wikilink_suffix
|
||||
|
||||
let s:valid_chars = '[^\\\]]'
|
||||
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
|
||||
|
||||
" this regexp defines what can form a link when the user presses <CR> in the
|
||||
" buffer (and not on a link) to create a link
|
||||
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
|
||||
" non-Ascii characters
|
||||
let g:vimwiki_rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
||||
|
||||
let g:vimwiki_rxWord = '[^[:blank:]()\\]\+'
|
||||
|
||||
"
|
||||
" [[URL]], or [[URL|DESCRIPTION]]
|
||||
" a) match [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLinkPrefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.'\%('.g:vimwiki_rxWikiLinkSeparator.
|
||||
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
|
||||
let g:vimwiki_rxWikiLink = s:rx_wikilink_prefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.'\%('.s:rx_wikilink_separator.
|
||||
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
|
||||
" b) match URL within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLinkMatchUrl = g:vimwiki_rxWikiLinkPrefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. g:vimwiki_rxWikiLinkSeparator.
|
||||
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
|
||||
let g:vimwiki_rxWikiLinkMatchUrl = s:rx_wikilink_prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. s:rx_wikilink_separator.
|
||||
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
|
||||
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLinkMatchDescr = g:vimwiki_rxWikiLinkPrefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator.'\%('.
|
||||
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_rxWikiLinkSuffix
|
||||
let g:vimwiki_rxWikiLinkMatchDescr = s:rx_wikilink_prefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.s:rx_wikilink_separator.'\%('.
|
||||
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. s:rx_wikilink_suffix
|
||||
" }}}
|
||||
|
||||
" LINKS: Syntax helper {{{
|
||||
let g:vimwiki_rxWikiLinkPrefix1 = g:vimwiki_rxWikiLinkPrefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator
|
||||
let g:vimwiki_rxWikiLinkSuffix1 = g:vimwiki_rxWikiLinkSuffix
|
||||
let s:rx_wikilink_prefix1 = s:rx_wikilink_prefix . g:vimwiki_rxWikiLinkUrl .
|
||||
\ s:rx_wikilink_separator
|
||||
let s:rx_wikilink_suffix1 = s:rx_wikilink_suffix
|
||||
" }}}
|
||||
|
||||
|
||||
@ -114,13 +125,10 @@ let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
|
||||
\ '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWikiInclSuffix
|
||||
|
||||
let valid_chars = '[^\\\}]'
|
||||
|
||||
let g:vimwiki_rxWikiInclPrefix = escape(g:vimwiki_rxWikiInclPrefix, magic_chars)
|
||||
let g:vimwiki_rxWikiInclSuffix = escape(g:vimwiki_rxWikiInclSuffix, magic_chars)
|
||||
let g:vimwiki_rxWikiInclSeparator = escape(g:vimwiki_rxWikiInclSeparator, magic_chars)
|
||||
let g:vimwiki_rxWikiInclUrl = valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArg = valid_chars.'\{-}'
|
||||
let s:valid_chars = '[^\\\}]'
|
||||
let g:vimwiki_rxWikiInclUrl = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArg = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
|
||||
"
|
||||
"
|
||||
@ -151,7 +159,7 @@ let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
|
||||
" the whitespace.
|
||||
" Stuart, could you check it with markdown templated links? [](http://...), as
|
||||
" the last bracket is the part of URL now?
|
||||
let g:vimwiki_rxWeblink = '[[:alnum:]]\@<!'. g:vimwiki_rxWeblinkUrl . '\S*'
|
||||
let g:vimwiki_rxWeblink = '\<'. g:vimwiki_rxWeblinkUrl . '\S*'
|
||||
" 0a) match URL within URL
|
||||
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
|
||||
" 0b) match DESCRIPTION within URL
|
||||
@ -197,33 +205,40 @@ function! s:highlight_existing_links() "{{{
|
||||
" Conditional highlighting that depends on the existence of a wiki file or
|
||||
" directory is only available for *schemeless* wiki links
|
||||
" Links are set up upon BufEnter (see plugin/...)
|
||||
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
|
||||
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
|
||||
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
||||
" Wikilink Dirs set up upon BufEnter (see plugin/...)
|
||||
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
|
||||
|
||||
" match [[URL]]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
|
||||
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match [[URL|DESCRIPTION]]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
|
||||
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
|
||||
" match {{URL}}
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
|
||||
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match {{URL|...}}
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
|
||||
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match [[DIRURL]]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match [[DIRURL|DESCRIPTION]]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
endfunction "}}}
|
||||
@ -237,16 +252,16 @@ if VimwikiGet('maxhi')
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
|
||||
|
||||
" Subsequently, links verified on vimwiki's path are highlighted as existing
|
||||
let time01 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
call s:highlight_existing_links()
|
||||
let time02 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
else
|
||||
let time01 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
" Wikilink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
|
||||
" WikiIncl
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
|
||||
let time02 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
endif
|
||||
|
||||
" Weblink
|
||||
@ -254,83 +269,86 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
|
||||
|
||||
" WikiLink
|
||||
" All remaining schemes are highlighted automatically
|
||||
let rxSchemes = '\%('.
|
||||
let s:rxSchemes = '\%('.
|
||||
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
|
||||
\ '\):'
|
||||
|
||||
" a) match [[nonwiki-scheme-URL]]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
|
||||
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
|
||||
" a) match {{nonwiki-scheme-URL}}
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
|
||||
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
" b) match {{nonwiki-scheme-URL}[{...}]}
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
|
||||
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
|
||||
" }}}
|
||||
|
||||
|
||||
" generic headers "{{{
|
||||
if g:vimwiki_symH
|
||||
"" symmetric
|
||||
for i in range(1,6)
|
||||
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__ '.repeat(g:vimwiki_rxH, i)
|
||||
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
|
||||
let g:vimwiki_rxH{i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
|
||||
let g:vimwiki_rxH{i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{1,'.i.'}\s*$'
|
||||
for s:i in range(1,6)
|
||||
let g:vimwiki_rxH{s:i}_Template = repeat(g:vimwiki_rxH, s:i).' __Header__ '.repeat(g:vimwiki_rxH, s:i)
|
||||
let g:vimwiki_rxH{s:i} = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.s:i.'}\s*$'
|
||||
let g:vimwiki_rxH{s:i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.s:i.'}\s*$'
|
||||
let g:vimwiki_rxH{s:i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{1,'.s:i.'}\s*$'
|
||||
endfor
|
||||
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$'
|
||||
else
|
||||
" asymmetric
|
||||
for i in range(1,6)
|
||||
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__'
|
||||
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
let g:vimwiki_rxH{i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
let g:vimwiki_rxH{i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
for s:i in range(1,6)
|
||||
let g:vimwiki_rxH{s:i}_Template = repeat(g:vimwiki_rxH, s:i).' __Header__'
|
||||
let g:vimwiki_rxH{s:i} = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
let g:vimwiki_rxH{s:i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
let g:vimwiki_rxH{s:i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
endfor
|
||||
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$'
|
||||
endif
|
||||
|
||||
" Header levels, 1-6
|
||||
for i in range(1,6)
|
||||
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
|
||||
execute 'syntax region VimwikiH'.i.'Folding start=/'.g:vimwiki_rxH{i}_Start.
|
||||
\ '/ end=/'.g:vimwiki_rxH{i}_End.'/me=s-1 transparent fold'
|
||||
for s:i in range(1,6)
|
||||
execute 'syntax match VimwikiHeader'.s:i.' /'.g:vimwiki_rxH{s:i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
|
||||
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.g:vimwiki_rxH{s:i}_Start.
|
||||
\ '/ end=/'.g:vimwiki_rxH{s:i}_End.'/me=s-1 transparent fold'
|
||||
endfor
|
||||
|
||||
|
||||
" }}}
|
||||
|
||||
" possibly concealed chars " {{{
|
||||
let conceal = exists("+conceallevel") ? ' conceal' : ''
|
||||
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
|
||||
|
||||
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'.conceal
|
||||
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'.conceal
|
||||
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'.conceal
|
||||
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'.conceal
|
||||
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'.conceal
|
||||
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'.conceal
|
||||
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'.conceal
|
||||
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'.conceal
|
||||
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.conceal
|
||||
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'.s:conceal
|
||||
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'.s:conceal
|
||||
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'.s:conceal
|
||||
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'.s:conceal
|
||||
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'.s:conceal
|
||||
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'.s:conceal
|
||||
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'.s:conceal
|
||||
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'.s:conceal
|
||||
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.s:conceal
|
||||
" }}}
|
||||
|
||||
" concealed link parts " {{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix
|
||||
echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix
|
||||
echom 'WikiLink Prefix1: '.g:vimwiki_rxWikiLinkPrefix1
|
||||
echom 'WikiLink Suffix1: '.g:vimwiki_rxWikiLinkSuffix1
|
||||
echom 'WikiLink Prefix: '.s:rx_wikilink_prefix
|
||||
echom 'WikiLink Suffix: '.s:rx_wikilink_suffix
|
||||
echom 'WikiLink Prefix1: '.s:rx_wikilink_prefix1
|
||||
echom 'WikiLink Suffix1: '.s:rx_wikilink_suffix1
|
||||
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
|
||||
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
|
||||
endif
|
||||
@ -338,30 +356,30 @@ endif
|
||||
" define the conceal attribute for links only if Vim is new enough to handle it
|
||||
" and the user has g:vimwiki_url_maxsave > 0
|
||||
|
||||
let options = ' contained transparent contains=NONE'
|
||||
let s:options = ' contained transparent contains=NONE'
|
||||
"
|
||||
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
|
||||
" VimwikiLinkRest group is left undefined if link shortening is not desired
|
||||
if exists("+conceallevel") && g:vimwiki_url_maxsave > 0
|
||||
let options .= conceal
|
||||
let s:options .= s:conceal
|
||||
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
|
||||
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.options
|
||||
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.s:options
|
||||
endif
|
||||
|
||||
" VimwikiLinkChar is for syntax markers (and also URL when a description
|
||||
" is present) and may be concealed
|
||||
|
||||
" conceal wikilinks
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix1.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix1.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix1.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix1.'/'.s:options
|
||||
|
||||
" conceal wikiincls
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.s:options
|
||||
" }}}
|
||||
|
||||
" non concealed chars " {{{
|
||||
@ -405,25 +423,19 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
||||
syntax match VimwikiCellSeparator
|
||||
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
||||
|
||||
" List items
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
|
||||
" Lists
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/'
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
||||
" List item checkbox
|
||||
"syntax match VimwikiCheckBox /\[.\?\]/
|
||||
let g:vimwiki_rxCheckBox = '\s*\[['.g:vimwiki_listsyms.']\?\]\s'
|
||||
" Todo lists have a checkbox
|
||||
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListBullet.g:vimwiki_rxCheckBox.'/'
|
||||
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListNumber.g:vimwiki_rxCheckBox.'/'
|
||||
if g:vimwiki_hl_cb_checked
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.
|
||||
\ g:vimwiki_rxListBullet.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
|
||||
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.
|
||||
\ g:vimwiki_rxListNumber.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
|
||||
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
|
||||
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/'
|
||||
|
||||
if g:vimwiki_hl_cb_checked == 1
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '.
|
||||
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
elseif g:vimwiki_hl_cb_checked == 2
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
endif
|
||||
|
||||
|
||||
execute 'syntax match VimwikiEqIn /'.g:vimwiki_rxEqIn.'/ contains=VimwikiEqInChar'
|
||||
execute 'syntax match VimwikiEqInT /'.g:vimwiki_rxEqIn.'/ contained contains=VimwikiEqInCharT'
|
||||
|
||||
@ -462,7 +474,6 @@ execute 'syntax region VimwikiMath start=/^\s*'.g:vimwiki_rxMathStart.
|
||||
|
||||
|
||||
" placeholders
|
||||
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
|
||||
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||
@ -470,14 +481,18 @@ syntax match VimwikiPlaceholderParam /\s.*/ contained
|
||||
|
||||
" html tags
|
||||
if g:vimwiki_valid_html_tags != ''
|
||||
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
|
||||
let s:html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
|
||||
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
||||
|
||||
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
|
||||
endif
|
||||
|
||||
" tags
|
||||
execute 'syntax match VimwikiTag /'.g:vimwiki_rxTags.'/'
|
||||
|
||||
" }}}
|
||||
|
||||
" header groups highlighting "{{{
|
||||
@ -487,8 +502,8 @@ if g:vimwiki_hl_headers == 0
|
||||
if !exists("g:colors_name")
|
||||
hi Title cterm=bold
|
||||
endif
|
||||
for i in range(1,6)
|
||||
execute 'hi def link VimwikiHeader'.i.' Title'
|
||||
for s:i in range(1,6)
|
||||
execute 'hi def link VimwikiHeader'.s:i.' Title'
|
||||
endfor
|
||||
else
|
||||
" default colors when headers of different levels are highlighted differently
|
||||
@ -497,14 +512,12 @@ else
|
||||
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black']
|
||||
let g:vimwiki_hcolor_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
|
||||
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
|
||||
for i in range(1,6)
|
||||
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
|
||||
for s:i in range(1,6)
|
||||
execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[s:i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[s:i-1].' term=bold cterm=bold'
|
||||
endfor
|
||||
endif
|
||||
"}}}
|
||||
|
||||
|
||||
|
||||
" syntax group highlighting "{{{
|
||||
|
||||
hi def link VimwikiMarkers Normal
|
||||
@ -542,10 +555,10 @@ hi def link VimwikiLinkT VimwikiLink
|
||||
|
||||
hi def link VimwikiList Identifier
|
||||
hi def link VimwikiListTodo VimwikiList
|
||||
"hi def link VimwikiCheckBox VimwikiList
|
||||
hi def link VimwikiCheckBoxDone Comment
|
||||
hi def link VimwikiEmoticons Character
|
||||
hi def link VimwikiHR Identifier
|
||||
hi def link VimwikiTag Keyword
|
||||
|
||||
hi def link VimwikiDelText Constant
|
||||
hi def link VimwikiDelTextT VimwikiDelText
|
||||
@ -589,21 +602,19 @@ hi def link VimwikiLinkCharT VimwikiLinkT
|
||||
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
|
||||
"}}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific functionality
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
|
||||
" -------------------------------------------------------------------------
|
||||
call vimwiki#u#reload_regexes_custom()
|
||||
|
||||
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
|
||||
let b:current_syntax="vimwiki"
|
||||
|
||||
" EMBEDDED syntax setup "{{{
|
||||
let nested = VimwikiGet('nested_syntaxes')
|
||||
if !empty(nested)
|
||||
for [hl_syntax, vim_syntax] in items(nested)
|
||||
call vimwiki#base#nested_syntax(vim_syntax,
|
||||
let s:nested = VimwikiGet('nested_syntaxes')
|
||||
if !empty(s:nested)
|
||||
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
|
||||
call vimwiki#base#nested_syntax(s:vim_syntax,
|
||||
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
|
||||
endfor
|
||||
endif
|
||||
@ -617,5 +628,5 @@ call vimwiki#base#nested_syntax('tex',
|
||||
|
||||
syntax spell toplevel
|
||||
|
||||
let timeend = vimwiki#u#time(starttime) "XXX
|
||||
call VimwikiLog_extend('timing',['syntax:scans',timescans],['syntax:regexloaded',time0],['syntax:beforeHLexisting',time01],['syntax:afterHLexisting',time02],['syntax:end',timeend])
|
||||
let s:timeend = vimwiki#u#time(g:starttime) "XXX
|
||||
call VimwikiLog_extend('timing',['syntax:scans',s:timescans],['syntax:regexloaded',s:time0],['syntax:beforeHLexisting',s:time01],['syntax:afterHLexisting',s:time02],['syntax:end',s:timeend])
|
||||
|
@ -1,11 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Default syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" placeholder for math environments
|
||||
let b:vimwiki_mathEnv = ""
|
||||
" Desc: Defines default syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
@ -72,11 +68,19 @@ let g:vimwiki_rxHR = '^-----*$'
|
||||
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
|
||||
" List items start with optional whitespace(s) then '* ' or '# '
|
||||
let g:vimwiki_rxListBullet = '^\s*[*-]\s'
|
||||
let g:vimwiki_rxListNumber = '^\s*#\s'
|
||||
|
||||
" Lists
|
||||
"1 means multiple bullets, like * ** ***
|
||||
let g:vimwiki_bullet_types = { '-':0, '*':0, '#':0 }
|
||||
let g:vimwiki_number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
|
||||
"this should contain at least one element
|
||||
"it is used for i_<C-L><C-J> among other things
|
||||
let g:vimwiki_list_markers = ['-', '1.', '*', 'I)', 'a)']
|
||||
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
|
||||
call vimwiki#lst#setup_marker_infos()
|
||||
|
||||
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
|
||||
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '{{{'
|
||||
@ -87,3 +91,5 @@ let g:vimwiki_rxMathStart = '{{\$'
|
||||
let g:vimwiki_rxMathEnd = '}}\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
" see also g:vimwiki_default_tag_search
|
||||
|
@ -1,11 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Default syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" placeholder for math environments
|
||||
let b:vimwiki_mathEnv = ""
|
||||
" Desc: Defines markdown syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
@ -72,11 +68,16 @@ let g:vimwiki_rxHR = '^-----*$'
|
||||
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
|
||||
" List items start with optional whitespace(s) then '* ' or '1. ', '2. ', etc.
|
||||
let g:vimwiki_rxListBullet = '^\s*[*+-]\s'
|
||||
let g:vimwiki_rxListNumber = '^\s*[0-9]\+\.\s'
|
||||
|
||||
" Lists
|
||||
let g:vimwiki_bullet_types = { '-':0, '*':0, '+':0 }
|
||||
let g:vimwiki_number_types = ['1.']
|
||||
let g:vimwiki_list_markers = ['-', '*', '+', '1.']
|
||||
let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
|
||||
call vimwiki#lst#setup_marker_infos()
|
||||
|
||||
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
|
||||
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '```'
|
||||
@ -87,3 +88,4 @@ let g:vimwiki_rxMathStart = '\$\$'
|
||||
let g:vimwiki_rxMathEnd = '\$\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
|
@ -1,7 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Author: Stuart Andrews <stu.andrews@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" Desc: Special stuff for markdown syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" LINKS: assume this is common to all syntaxes "{{{
|
||||
|
||||
@ -30,60 +30,71 @@ let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
|
||||
" LINKS: setup wikilink1 regexps {{{
|
||||
" 1. [URL][], or [DESCRIPTION][URL]
|
||||
|
||||
let g:vimwiki_rxWikiLink1Prefix = '['
|
||||
let g:vimwiki_rxWikiLink1Suffix = ']'
|
||||
let g:vimwiki_rxWikiLink1Separator = ']['
|
||||
let s:wikilink_md_prefix = '['
|
||||
let s:wikilink_md_suffix = ']'
|
||||
let s:wikilink_md_separator = ']['
|
||||
let s:rx_wikilink_md_prefix = vimwiki#u#escape(s:wikilink_md_prefix)
|
||||
let s:rx_wikilink_md_suffix = vimwiki#u#escape(s:wikilink_md_suffix)
|
||||
let s:rx_wikilink_md_separator = vimwiki#u#escape(s:wikilink_md_separator)
|
||||
|
||||
" [URL][]
|
||||
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
|
||||
let g:vimwiki_WikiLink1Template1 = s:wikilink_md_prefix . '__LinkUrl__'.
|
||||
\ s:wikilink_md_separator. s:wikilink_md_suffix
|
||||
" [DESCRIPTION][URL]
|
||||
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLink1Suffix
|
||||
let g:vimwiki_WikiLink1Template2 = s:wikilink_md_prefix. '__LinkDescription__'.
|
||||
\ s:wikilink_md_separator. '__LinkUrl__'.
|
||||
\ s:wikilink_md_suffix
|
||||
"
|
||||
let magic_chars = '.*[]\^$'
|
||||
let valid_chars = '[^\\\[\]]'
|
||||
let g:vimwiki_WikiLinkMatchUrlTemplate .=
|
||||
\ '\|' .
|
||||
\ s:rx_wikilink_md_prefix .
|
||||
\ '.*' .
|
||||
\ s:rx_wikilink_md_separator .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_md_suffix .
|
||||
\ '\|' .
|
||||
\ s:rx_wikilink_md_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_md_separator .
|
||||
\ s:rx_wikilink_md_suffix
|
||||
|
||||
let g:vimwiki_rxWikiLink1Prefix = escape(g:vimwiki_rxWikiLink1Prefix, magic_chars)
|
||||
let g:vimwiki_rxWikiLink1Suffix = escape(g:vimwiki_rxWikiLink1Suffix, magic_chars)
|
||||
let g:vimwiki_rxWikiLink1Separator = escape(g:vimwiki_rxWikiLink1Separator, magic_chars)
|
||||
let g:vimwiki_rxWikiLink1Url = valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLink1Descr = valid_chars.'\{-}'
|
||||
let s:valid_chars = '[^\\\[\]]'
|
||||
let g:vimwiki_rxWikiLink1Url = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLink1Descr = s:valid_chars.'\{-}'
|
||||
|
||||
let g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
|
||||
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
|
||||
let g:vimwiki_rxWikiLink1Prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
|
||||
\ g:vimwiki_rxWikiLink1Prefix
|
||||
let g:vimwiki_rxWikiLink1Suffix = g:vimwiki_rxWikiLink1Suffix.
|
||||
let s:rx_wikilink_md_prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
|
||||
\ s:rx_wikilink_md_prefix
|
||||
let s:rx_wikilink_md_suffix = s:rx_wikilink_md_suffix.
|
||||
\ g:vimwiki_rxWikiLink1InvalidSuffix
|
||||
|
||||
"
|
||||
" 1. [URL][], [DESCRIPTION][URL]
|
||||
" 1a) match [URL][], [DESCRIPTION][URL]
|
||||
let g:vimwiki_rxWikiLink1 = g:vimwiki_rxWikiLink1Prefix.
|
||||
\ g:vimwiki_rxWikiLink1Url. g:vimwiki_rxWikiLink1Separator.
|
||||
\ g:vimwiki_rxWikiLink1Suffix.
|
||||
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
|
||||
\ g:vimwiki_rxWikiLink1Descr.g:vimwiki_rxWikiLink1Separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
|
||||
let g:vimwiki_rxWikiLink1 = s:rx_wikilink_md_prefix.
|
||||
\ g:vimwiki_rxWikiLink1Url. s:rx_wikilink_md_separator.
|
||||
\ s:rx_wikilink_md_suffix.
|
||||
\ '\|'. s:rx_wikilink_md_prefix.
|
||||
\ g:vimwiki_rxWikiLink1Descr.s:rx_wikilink_md_separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
|
||||
" 1b) match URL within [URL][], [DESCRIPTION][URL]
|
||||
let g:vimwiki_rxWikiLink1MatchUrl = g:vimwiki_rxWikiLink1Prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Separator.
|
||||
\ g:vimwiki_rxWikiLink1Suffix.
|
||||
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
|
||||
\ g:vimwiki_rxWikiLink1Descr. g:vimwiki_rxWikiLink1Separator.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Suffix
|
||||
let g:vimwiki_rxWikiLink1MatchUrl = s:rx_wikilink_md_prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_separator.
|
||||
\ s:rx_wikilink_md_suffix.
|
||||
\ '\|'. s:rx_wikilink_md_prefix.
|
||||
\ g:vimwiki_rxWikiLink1Descr. s:rx_wikilink_md_separator.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_suffix
|
||||
" 1c) match DESCRIPTION within [DESCRIPTION][URL]
|
||||
let g:vimwiki_rxWikiLink1MatchDescr = g:vimwiki_rxWikiLink1Prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. g:vimwiki_rxWikiLink1Separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
|
||||
let g:vimwiki_rxWikiLink1MatchDescr = s:rx_wikilink_md_prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. s:rx_wikilink_md_separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
|
||||
" }}}
|
||||
|
||||
" LINKS: Syntax helper {{{
|
||||
let g:vimwiki_rxWikiLink1Prefix1 = g:vimwiki_rxWikiLink1Prefix
|
||||
let g:vimwiki_rxWikiLink1Suffix1 = g:vimwiki_rxWikiLink1Separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
|
||||
let g:vimwiki_rxWikiLink1Prefix1 = s:rx_wikilink_md_prefix
|
||||
let g:vimwiki_rxWikiLink1Suffix1 = s:rx_wikilink_md_separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
|
||||
" }}}
|
||||
|
||||
" *. ANY wikilink {{{
|
||||
@ -125,14 +136,13 @@ let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription
|
||||
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWeblink1Suffix
|
||||
|
||||
let magic_chars = '.*[]\^$'
|
||||
let valid_chars = '[^\\]'
|
||||
let s:valid_chars = '[^\\]'
|
||||
|
||||
let g:vimwiki_rxWeblink1Prefix = escape(g:vimwiki_rxWeblink1Prefix, magic_chars)
|
||||
let g:vimwiki_rxWeblink1Suffix = escape(g:vimwiki_rxWeblink1Suffix, magic_chars)
|
||||
let g:vimwiki_rxWeblink1Separator = escape(g:vimwiki_rxWeblink1Separator, magic_chars)
|
||||
let g:vimwiki_rxWeblink1Url = valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWeblink1Descr = valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWeblink1Prefix = vimwiki#u#escape(g:vimwiki_rxWeblink1Prefix)
|
||||
let g:vimwiki_rxWeblink1Suffix = vimwiki#u#escape(g:vimwiki_rxWeblink1Suffix)
|
||||
let g:vimwiki_rxWeblink1Separator = vimwiki#u#escape(g:vimwiki_rxWeblink1Separator)
|
||||
let g:vimwiki_rxWeblink1Url = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWeblink1Descr = s:valid_chars.'\{-}'
|
||||
|
||||
"
|
||||
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
|
||||
@ -224,7 +234,7 @@ endfunction "}}}
|
||||
|
||||
function! s:existing_mkd_refs() "{{{
|
||||
call vimwiki#markdown_base#reset_mkd_refs()
|
||||
return "\n".join(keys(vimwiki#markdown_base#get_reflinks()), "\n")."\n"
|
||||
return keys(vimwiki#markdown_base#get_reflinks())
|
||||
endfunction "}}}
|
||||
|
||||
function! s:highlight_existing_links() "{{{
|
||||
@ -232,7 +242,8 @@ function! s:highlight_existing_links() "{{{
|
||||
" Conditional highlighting that depends on the existence of a wiki file or
|
||||
" directory is only available for *schemeless* wiki links
|
||||
" Links are set up upon BufEnter (see plugin/...)
|
||||
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
|
||||
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
|
||||
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
||||
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
|
||||
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
|
||||
" Ref links are cached
|
||||
@ -240,29 +251,35 @@ function! s:highlight_existing_links() "{{{
|
||||
|
||||
|
||||
" match [URL][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][URL]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [DIRURL][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][DIRURL]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [MKDREF][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][MKDREF]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
endfunction "}}}
|
||||
@ -274,14 +291,14 @@ if VimwikiGet('maxhi')
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
|
||||
|
||||
" Subsequently, links verified on vimwiki's path are highlighted as existing
|
||||
let time01 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
call s:highlight_existing_links()
|
||||
let time02 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
else
|
||||
let time01 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
" Wikilink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
|
||||
let time02 = vimwiki#u#time(starttime) "XXX
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
endif
|
||||
|
||||
" Weblink
|
||||
@ -289,27 +306,29 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
|
||||
|
||||
" WikiLink
|
||||
" All remaining schemes are highlighted automatically
|
||||
let rxSchemes = '\%('.
|
||||
let s:rxSchemes = '\%('.
|
||||
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
|
||||
\ '\):'
|
||||
|
||||
" a) match [nonwiki-scheme-URL]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||
" b) match [DESCRIPTION][nonwiki-scheme-URL]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||
" }}}
|
||||
|
||||
|
||||
" generic headers "{{{
|
||||
|
||||
" Header levels, 1-6
|
||||
for i in range(1,6)
|
||||
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
||||
for s:i in range(1,6)
|
||||
execute 'syntax match VimwikiHeader'.s:i.' /'.g:vimwiki_rxH{s:i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
||||
endfor
|
||||
|
||||
" }}}
|
||||
@ -330,16 +349,16 @@ endif
|
||||
|
||||
" VimwikiWikiLink1Char is for syntax markers (and also URL when a description
|
||||
" is present) and may be concealed
|
||||
let options = ' contained transparent contains=NONE'
|
||||
let s:options = ' contained transparent contains=NONE'
|
||||
" conceal wikilink1
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix.'/'.options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix.'/'.options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_prefix.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_suffix.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.s:options
|
||||
|
||||
" conceal weblink1
|
||||
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.options
|
||||
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.options
|
||||
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.s:options
|
||||
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.s:options
|
||||
|
||||
if exists("+conceallevel")
|
||||
syntax conceal off
|
||||
|
@ -1,11 +1,7 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" MediaWiki syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" placeholder for math environments
|
||||
let b:vimwiki_mathEnv = ""
|
||||
" Desc: Defines mediaWiki syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
@ -53,12 +49,16 @@ let g:vimwiki_rxHR = '^-----*$'
|
||||
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
|
||||
" Bulleted list items start with whitespace(s), then '*'
|
||||
" highlight only bullets and digits.
|
||||
let g:vimwiki_rxListBullet = '^\s*\*\+\s\%([^*]*$\)\@='
|
||||
let g:vimwiki_rxListNumber = '^\s*#\+\s'
|
||||
|
||||
" Lists
|
||||
let g:vimwiki_bullet_types = { '*':1, '#':1 }
|
||||
let g:vimwiki_number_types = []
|
||||
let g:vimwiki_list_markers = ['*', '#']
|
||||
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
|
||||
call vimwiki#lst#setup_marker_infos()
|
||||
|
||||
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
|
||||
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '<pre>'
|
||||
@ -69,3 +69,4 @@ let g:vimwiki_rxMathStart = '{{\$'
|
||||
let g:vimwiki_rxMathEnd = '}}\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
|
Reference in New Issue
Block a user