515 Commits

Author SHA1 Message Date
5553cef249 Update version number 2019-03-21 23:09:36 +01:00
7fbeea2c1e Update the changelog 2019-03-21 23:06:01 +01:00
57385b29bb Update list of contributors 2019-03-21 21:52:59 +01:00
d0e14dd11c Merge branch 'master' into rel-2.4-pre 2019-03-21 21:12:44 +01:00
a5ef478750 Improverize issue template per #513 2019-03-20 06:24:16 -06:00
605604fc23 Create an issue template 2019-03-17 22:24:51 -06:00
7f98bfbe4b Create a pull request template. 2019-03-17 22:06:10 -06:00
54d1a997d9 Update Contributing.md 2019-03-11 21:24:19 +01:00
5ab8f8672e Add call for help and note about Riot 2019-03-09 14:49:01 +01:00
1b2643ea19 Clarify the description of hl_cb_checked in the doc
Ref #605
2019-02-04 21:48:18 +01:00
e16dc41a50 The recommended branch to use is master, not dev 2019-02-01 17:51:41 +01:00
19f1d36229 Revert "Initial commit"
This reverts commit 7699967a99.
Reason: It's wrong. In markdown, opposed to mediawiki, list items can be indented, e.g. when a
list contains a list.
2019-02-01 17:48:48 +01:00
b8d0cf377d doc: Fix spelling for <Leader> 2019-02-01 17:43:05 +01:00
a7160310c9 Patch for issue #585 - implement suggested improvements 2019-02-01 17:43:05 +01:00
0f38192b03 Patch for issue #585, fix anchor links for multiple extensions 2019-02-01 17:43:05 +01:00
41199e6e3b Update Chinese readme & add links to each readme 2019-02-01 17:43:05 +01:00
69aa609941 Don't include trailing period in link 2019-02-01 17:43:05 +01:00
72bbb1b740 fixed writing error 2019-02-01 17:43:05 +01:00
7699967a99 Initial commit 2019-02-01 17:43:05 +01:00
394efe4312 Add a command that shows the version or commit
Ref #512
2019-02-01 17:43:05 +01:00
ea13b0e848 Make master the recommended branch to use
Discussed in #505
2019-02-01 17:43:05 +01:00
daee3b4796 Fix a typo 2019-01-30 21:46:03 +01:00
bda3a59f91 Made headings link to themselves.
Made each heading link to itself, by placing an <a> tag inside each
<h[1-6]> tag.

Also adds class="header" to each header, allowing for the CSS rule
    .header a { ...  }
to remove all styling from the inner links, allowing the outputed
document to look like before.
2019-01-30 21:13:29 +01:00
417490f30b doc: Fix spelling for <Leader> 2019-01-29 21:49:28 +01:00
1cffbdbf3d Fix: Don't double a ' character in header in TOC
When building the TOC, every ' in a header got doubled. According to git blame, I did this doubling explicitely, but I have no idea why I did this.
2019-01-25 16:45:11 +01:00
Ben
28675698ad Added syntax documentation to README.md
Currently, there is no easy way for a new user of this plugin to discover how to change the syntax. Markdown is favored by many in the community because it is more widely used than Vimwiki's default syntax and is therefore a more portable option. This configuration should be presented much more openly.
2019-01-20 19:55:14 +01:00
4e6db92d2c Patch for issue #585 - implement suggested improvements 2019-01-20 19:10:10 +01:00
aca8c2b8cc Patch for issue #585, fix anchor links for multiple extensions 2019-01-20 19:10:10 +01:00
fdc367f725 Check all user settings for correct type, range etc. 2019-01-19 21:05:27 +01:00
6257c8fa54 Revert "Allow to specify additional chars for lists"
This reverts commit 75819ca23a.
2019-01-17 21:57:42 +01:00
35d1f23b92 Revert "Allow list symbols to be configured per wiki"
This reverts commit 79c295a92f.
2019-01-17 21:57:40 +01:00
05de247f36 Revert "Update documentation"
This reverts commit 7ea136dd0b.
2019-01-17 21:57:39 +01:00
54e064f5c4 Revert "Fix bug"
This reverts commit 2346b7e299.
2019-01-17 21:57:28 +01:00
65b0c97c6d Revert "Update the links when renaming markdown wikis"
This reverts commit 599a0e9083.

Sorry, we can't simply change the syntax of something as basic as a
link, even if the old syntax is wrong. We need to keep Vimwiki
reasonably backwards compatible.
2019-01-16 20:56:49 +01:00
2346b7e299 Fix bug 2019-01-04 01:19:26 +01:00
7ea136dd0b Update documentation 2019-01-03 21:02:21 +01:00
79c295a92f Allow list symbols to be configured per wiki 2019-01-03 21:02:21 +01:00
75819ca23a Allow to specify additional chars for lists
See also #390 and #479 for earlier attempts
2019-01-03 21:02:21 +01:00
f9b8906985 Fix section number for anchor, closes #597 2019-01-03 17:20:31 +01:00
24f33e3e3f Clarify toggling of todo list items in visual mode 2019-01-03 17:20:31 +01:00
599a0e9083 Update the links when renaming markdown wikis
Two reasons whey the links in markdown wikis are not updated:
1. The markdown link pattern is wrong, should be []() rather than [][];
2. The logic of getting wiki local var cannot get correct wiki index as:
    a. the renamed file's buffer is removed and %:p would return empty
    b. the function that gets the wiki local var depends on buffer's %:p
    value to find the wiki it belongs to and it would always return -1
    and result in the default option values instead the user's option

The fix is
1. fix the markdown link pattern regex;
2. keep the renamed file's buffer open during the period of updating the link
2019-01-03 13:00:19 +01:00
2366523001 Fixed updation of links when renaming wiki files in subdirectories 2018-12-21 11:08:14 +01:00
d9b6d77e90 Accept '.foo' and 'foo' as value for the ext option 2018-12-17 20:27:15 +01:00
645ae61dc3 Fix error when trying to make a link out of '-'
Fix #582
2018-12-14 21:03:46 +01:00
a72c14da1c More reasonable behavior for [-] and [X] list items
A parent [-] list item should have only [-] items as children.
2018-12-08 21:13:04 +01:00
c398f5cd81 Remove code duplicate 2018-12-08 21:06:30 +01:00
fa36bf3838 Don't check a [-] list item when its parent is [X] checked 2018-11-30 17:02:38 +01:00
a653e2d8c2 HTML converter: trim strings correctly
The old version didn't remove trailing spaces.
2018-11-25 17:56:43 +01:00
349d551181 Diary: make + in visual mode work correctly 2018-11-25 17:55:43 +01:00
dcd1c0a364 Make gl* work again
The problem was that map() also changed the given list in-place, that's
not what was intended.
2018-11-19 21:02:37 +01:00
2fb0e17adb glx on a list item creates a checked checkbox
... instead of an unchecked one.
2018-11-17 20:07:48 +01:00
12349b8cb6 Remove duplicated code 2018-11-17 20:07:09 +01:00
2e523b308f Check if there is a TOC header before trying to update it 2018-11-17 20:05:58 +01:00
6f6023610c Don't jump to the TOC on C-o etc.
Before, the cursor would jump to the TOC a lot when pressing <C-o> etc.,
because it is changed every time the buffer is saved.
Use :keepjumps to make it less intrusive. Sadly, the cursor still jumps
to the TOC when you press u and C-r, but it seems there is no way around
it.
2018-11-12 21:54:52 +01:00
bddd644fbb Use $HOME instead of ~/ in paths
Apparently, the latter doesn't work on all platforms.
Ref #565
2018-11-07 22:02:30 +01:00
675ff23ed1 Fix a few regexes
Without this, things would go wrong if the user has >= 10 Wikis.
2018-11-05 22:36:25 +01:00
90722a4703 Make an error message more clear 2018-11-01 21:12:14 +01:00
6a6aeff013 Fix losing the highlight of headers when switching colorschemes
Funnily, the code to fix this was there for over 8 years now, but didn't
work.
2018-10-28 21:04:24 +01:00
7969810b49 Fix losing highlighting after VimwikiAll2HTML
Apparently, switching buffers in connection with disabled events caused
the highlighting to disappear. Solution: use the :wa command to save all
buffers. A disadvantage is that now also non-Vimwiki buffers are saved,
but I think that is bearable.
2018-10-27 17:01:52 +02:00
a32a06f3b8 Follow up to 5f76208 2018-10-25 23:39:45 +02:00
a244246641 Merge branch 'dev' of github.com:vimwiki/vimwiki into dev 2018-10-25 23:27:15 +02:00
5f762082d2 Fix bug: change links when renaming pages 2018-10-25 23:26:35 +02:00
7668985b43 Fixed system file handlers for windows
Fixes #560
Opening external files containing spaces should now work on cmd and powershell.
2018-10-22 21:25:56 +02:00
bd88ea968b Better error handling when opening a file of which a swapfile exists
Ref #569
2018-10-16 22:25:33 +02:00
76f51f1dba Nicer error message when linking to not registered wiki 2018-10-15 07:36:41 +02:00
7ffc295094 Update Chinese readme & add links to each readme 2018-10-12 23:44:36 +02:00
e6d0678b54 Add CONTRIBUTING.md 2018-10-09 21:54:02 +02:00
d7d94e2160 Initial commit 2018-09-29 20:23:26 +02:00
f639c0a342 Clean URLs that don't have slashes
Will fix normalization of links like [[local:./foo.txt]]
Also, allow schemes to end with a number, so that e.g. [[wiki1:foo]]
will normalize as expected.
2018-09-19 12:12:32 +02:00
f882cf0152 Don't include trailing period in link 2018-09-17 15:22:04 +02:00
f55ec31675 fixed writing error 2018-09-03 18:42:27 +02:00
5605f285c1 Fix messing up folding when Vim is in diff mode 2018-08-07 21:39:54 +02:00
2185815b00 Fix problem with open swap-file 2018-07-27 02:49:47 +02:00
9f797f6ad9 Initial commit 2018-07-21 02:04:13 +02:00
44a1f3a6f3 Add a note to the doc about setting Vimwiki settings
Ref #510
2018-07-05 14:11:37 +02:00
51017f6b5e Update changelog
Ref #504
2018-07-05 14:00:18 +02:00
786aa470e3 Remove the user-mappable function and use commands instead. 2018-06-26 21:38:55 +02:00
50c95f1bef Remove all protocols and tlds on URL-cleaning
Also make removal of protocol, tld and 'www' more robust against
fails-positives by considering the position in the url.
2018-06-17 16:10:44 +02:00
4d4e88bfa2 Improve heuristic for cleaning urls in link descr. 2018-06-17 15:31:57 +02:00
9f8b0082db Add a command that shows the version or commit
Ref #512
2018-06-12 20:55:56 +02:00
f60923eaa3 Make master the recommended branch to use
Discussed in #505
2018-06-06 21:27:25 +02:00
7ad365e142 Add Installation-Guide for Vim-plug
Installation-note for vim-plug is important since vimplug defaults to master branch. See #503
2018-05-30 20:17:54 +02:00
966a94bd47 Diary links should use markdown syntax when appropriate (#500)
When markdown syntax is enabled, generated links should use markdown
link syntax.

Fix #499
2018-05-28 21:24:29 +02:00
d5c6cee5eb Make VimwikiMakeDiaryNote etc work outside a wiki buffer
Fix #497
2018-05-23 18:28:03 +02:00
9a8854756e Refactoring: simplify and remove some regexes 2018-05-20 15:18:05 +02:00
946b3feb12 Fix one-off error when opening a wiki via the menu 2018-05-17 21:47:50 +02:00
c5b39a12b4 Add a help section to the readme
Ref #490
2018-05-17 20:18:53 +02:00
057fa39303 :VimwikiMakeDiaryNote makes a new note in the current wiki
... like the doc says, instead of always using the first wiki.
Also, fix the menu entry, which always led to the wrong diary.

Fix #482
2018-05-17 20:06:27 +02:00
c08a9f8c71 Add a note to the doc on how to use :VWS case insensitively
Fix #480
2018-05-16 20:14:36 +02:00
7c5935b9ba Do init s:vimwiki_autowriteall_saved, but perhaps with the default value
Ref #492
2018-05-15 21:48:58 +02:00
f96d0c26d3 Add section to doc about getting help via IRC
Fix #490
2018-05-15 21:26:05 +02:00
ed58049dbe Revert "set script variable for autowrite_all"
This reverts commit 818fe930c3.
2018-05-14 10:50:41 +02:00
818fe930c3 set script variable for autowrite_all
Ref #492
2018-05-13 15:43:47 +02:00
9b744b42b1 Fix bug when creating a temporary wiki
Fix #488
2018-05-09 22:03:24 +02:00
d73c1e4ed6 Remove useless statement 2018-05-08 10:56:10 +02:00
b5dcd1ebeb Allow wikis in subfolders of other wikis 2018-05-08 10:56:10 +02:00
c8b02e4bc5 Use markdown link syntax for the TOC
Ref #483
Fix #200
2018-05-01 21:22:07 +02:00
66a565d388 Merge branch 'mMontu-dev' into dev 2018-04-22 21:25:09 +02:00
503bc11dd9 Merge branch 'dev' of https://github.com/mMontu/vimwiki into mMontu-dev
Conflicts:
	plugin/vimwiki.vim
2018-04-22 21:24:28 +02:00
1176f60ec6 Allow any visual mode to be used to create a link
The only real condition we care about is whether the selection is
contained within a single line.  It is practical to do something like
V<CR> to link a whole line, and AFAIK there is no reason for why that
doesn't work.
2018-04-22 20:58:39 +02:00
3f8bb1261f Make some functions script-local 2018-04-20 07:13:21 +02:00
c6e87ab661 Remove already deactivated emoticons highlighting 2018-04-20 07:06:59 +02:00
c1dbf90c29 Remove foldmarkers; general reformatting 2018-04-20 07:03:53 +02:00
90dc1e5871 Make ]] work when cursor is above first header
Ref #462
2018-04-17 08:53:08 +02:00
3556de54e1 Small refactorings 2018-04-17 07:15:23 +02:00
cdc37162a9 Escape only '"' in links
Fix #467
Ref #474
2018-04-16 20:40:18 +02:00
7036561446 Add VimwikiMakeTomorrowDiaryNote
This change introduces a new global diary command "VimwikiMakeTomorrowDiaryNote". The purpose is the
same as VimwikiMakeYesterdayDiaryNote, except it allows
you to create a diary note in the future.

I find this useful when trying to plan my day the night before.
2018-04-14 00:06:51 +02:00
65c4ffacca fix missing custom_wiki2html_args default key
Ref #475
2018-04-13 11:03:21 +02:00
86a8604c4e Remove recently introduced code duplication 2018-04-08 20:41:27 +02:00
bf2039555a Allow Powershell to open links in Windows 2018-04-08 18:41:17 +02:00
2941913ccc Add keys for motions between headers
Fix #462
Inspired by #23
2018-04-06 21:11:40 +02:00
a3b100ccaa Update the documentation for header text objects 2018-04-06 09:58:28 +02:00
a144be2a30 Improve header text objects
- make it work for markdown and media syntax as well
- don't find headers in preformatted text or headers of the form = foo ==
- introduce iH and aH text objects for headers plus subheaders
- add a count to include parent headers

Inspired by #462
2018-04-06 09:58:28 +02:00
ec516cfdbd Once again 2018-04-04 17:03:49 +02:00
9b5e4b445a Revert previous changes 2018-04-04 16:54:41 +02:00
5ad702cce6 Revert 89d28a7
This was committed by accident. Since 53745e8 had to be done by machine
this it not a real revert, but a redo of 53745e8. Due to the matter of
53745e8 it's slightly different.
2018-04-04 03:31:54 +02:00
53745e89e0 Fix newlineformat (issue #465)
The file contained carriage return characters leading to issues on some
systems. Removing them all should solve this.
2018-04-04 03:00:55 +02:00
89d28a72c5 Merge branch 'beta' into dev 2018-04-04 02:27:27 +02:00
13271541a6 Highlight done and rejected list item the same way 2018-04-03 19:45:19 +02:00
a2a9f2e6ca Fix path resolution of diary notes (#442) 2018-04-02 21:34:21 +02:00
1c4a9bb1af HTML comments and better TODO
* Allow HTML-style comment syntax

Allow <!-- HTML comments --> in vimwiki's highlight for markdown.

* Avoid matching "TODO" on word boundaries

Do not match e.g. "xTODO:" as if it were "TODO:".
This also lifts the requirement of ":" after these keywords
(it is more flexible to just require a word boundary regardless of what).
2018-04-01 21:45:15 +02:00
52f3bf7c3b Don't throw errors when the user presses 123\ww
This reverts commit 5a00028e6a.
2018-03-25 21:51:08 +02:00
16b9e45b03 fix diary list, indent according to list_margin
The list of diary entries now is not indented according to the vim
`shiftwidth` setting, but gets the indentation from list_margin (as is
the case for `vimwiki#base#generate_links`).
2018-03-18 21:05:11 +01:00
8009e5c7cf Handle all combinations of 'autowriteall' and 'hidden'
Ref #445
2018-03-16 21:39:24 +01:00
4bacbe0000 Force vimwiki filetype
Else, Vim decides the filetype according to the file extension.
Ref #440
2018-02-26 07:20:14 +01:00
02e8fb3108 Fix: register a default wiki if the user hasn't
Ref #440
Ref #441
2018-02-23 17:39:50 +01:00
5a00028e6a Don't exit if there are no registered wikis
Vimwiki can handle that.
Ref #440
2018-02-22 20:56:30 +01:00
b016eab91a Set 'tw' to 99 in all source files. We're not in the middle ages anymore. 2018-02-21 07:11:51 +01:00
46a5be9b3b Fix regression: some variables are global, not syntax-local
Ref #256
2018-02-20 17:42:13 +01:00
f8ee21aa64 Merge branch 'refactor-internal-state-handling' into dev
Conflicts:
	autoload/vimwiki/base.vim
	autoload/vimwiki/diary.vim
	autoload/vimwiki/html.vim
	autoload/vimwiki/lst.vim
	autoload/vimwiki/markdown_base.vim
	doc/vimwiki.txt
	ftplugin/vimwiki.vim
	plugin/vimwiki.vim
	syntax/vimwiki.vim
	syntax/vimwiki_default.vim
	syntax/vimwiki_markdown.vim
	syntax/vimwiki_media.vim
2018-02-19 17:56:17 +01:00
2757a7826a Cherry-pick the changes from dev -- part8 2018-02-19 07:44:19 +01:00
1e858b50cb Cherry-pick the changes from dev -- part7 2018-02-19 07:07:22 +01:00
4c940cd5bb Cherry-pick the changes from dev -- part6 2018-02-17 21:30:01 +01:00
f60993249a Cherry-pick the changes from dev -- part5 2018-02-17 21:05:06 +01:00
3756c6258b Cherry-pick the changes from dev -- part4 2018-02-16 21:42:32 +01:00
73bda6b9ab Cherry-pick the changes from dev -- part3 2018-02-16 18:11:49 +01:00
7d4254a75d Cherry-pick the changes from dev -- part2 2018-02-16 17:47:32 +01:00
19f398c73e Cherry-pick the changes from dev -- part 1 2018-02-16 07:26:42 +01:00
5419fad3f7 Formatting and small refactorings 2018-02-15 18:38:39 +01:00
f48dce6f1d Refactor then updating of the known wiki pages
for the 'maxhi' option.
2018-02-14 06:53:46 +01:00
967b342b23 Formatting 2018-02-10 22:04:37 +01:00
68ad4675a3 Remove b:undo_ftplugin to speed up buffer loading
If this variable is present, then for some reason the complete ftplugin
file is sourced everytime a Vimwiki buffer is entered, even if the
buffer has been entered before, i.e. the guard b:did_ftplugin has no
effect. (See /usr/share/vimXX/ftplugin.vim)
Deleting these lines. I don't think undoing the settings is a common use
case, anyway.
2018-02-10 21:41:07 +01:00
75fe1d4f00 Fix bug: unknown function SafeSubstitute 2017-12-04 16:26:59 +01:00
533c103748 Merge pull request #7 from Nudin/dev
Merge from upstream
2017-11-15 16:37:35 +01:00
aff1b639df Merge pull request #6 from vimwiki/dev
Merge from upstream
2017-11-15 16:35:28 +01:00
c94af4b3f1 Update argument handling in diary#make_note
Fix an "Undefined variable: a:3" error that occurs when attempting to open
a diary page with Calendar.vim.
2017-11-15 16:33:59 +01:00
0df94e47a8 Merge pull request #5 from vimwiki/dev
Merge upstream patches
2017-11-15 16:32:54 +01:00
164b760d3b Merge pull request #411 from Nudin/safesubst
Use a safe substitution-function everywhere
2017-11-14 00:43:49 -05:00
4e16db926f Fix more regression bugs 2017-11-11 21:52:07 +01:00
074d882762 Allow Backtick in Link 2017-11-10 22:47:57 +01:00
91c382a034 Use a safe substitution-function everywhere 2017-11-10 22:32:29 +01:00
b6d47e894d Give vimwiki#diary#make_note similar functionality 2017-11-10 21:26:58 +01:00
02e32489d7 Added the option to open vimwiki in a pane.
1       tabedit
2       split
3       vsplit

Similar to opening a tab,::

vimwiki#base#goto_index(v:count1, 1)

we can now open a split with::

vimwiki#base#goto_index(v:count1, 2)

and a vertical split with::

vimwiki#base#goto_index(v:count1, 3)
2017-11-10 21:26:58 +01:00
95d4c095d0 Added the option to open vimwiki in a pane.
1       tabedit
2       split
3       vsplit

Similar to opening a tab,::

vimwiki#base#goto_index(v:count1, 1)

we can now open a split with::

vimwiki#base#goto_index(v:count1, 2)

and a vertical split with::

vimwiki#base#goto_index(v:count1, 3)
2017-11-10 21:26:58 +01:00
734d014367 Added the option to open vimwiki in a pane.
1       tabedit
2       split
3       vsplit

Similar to opening a tab,::

vimwiki#base#goto_index(1, 1)

we can now open a split with::

vimwiki#base#goto_index(1, 2)

and a vertical split with::

vimwiki#base#goto_index(1, 3)
2017-11-10 21:26:58 +01:00
293e1f51ee Added the option to open vimwiki in a pane.
1       tabedit
2       split
3       vsplit

Similar to opening a tab,::

vimwiki#base#goto_index(v:count1, 1)

we can now open a split with::

vimwiki#base#goto_index(v:count1, 2)

and a vertical split with::

vimwiki#base#goto_index(v:count1, 3)
2017-11-10 21:26:58 +01:00
7c2ae8a714 Merge pull request #373 from Nudin/wontdo
"Won't-do" state for checkbox list items
2017-11-04 14:23:50 -04:00
eed4ceff1a Escape the 'dot' in extension substitution
This escapes the `.` preceding an extension (e.g. `.wiki`) so that it doesn't accidentally match any character.

For example: `[vimwiki](vimwiki)` was opening the `vi.wiki` page, because of this rule.
2017-11-03 23:06:10 +01:00
bc6acf5103 Merge pull request #403 from dpc/dev
Fix diary index generation with custom file extensions
2017-10-26 19:34:38 -04:00
d9a73b7117 Fix diary index generation with custom file extensions
Fix #302
2017-10-25 16:02:48 -07:00
cf8e3e7319 Unified spelling Licence -> License 2017-10-25 19:02:12 +02:00
ec3d554c0b Update list of contributers 2017-10-25 19:02:12 +02:00
742fc99692 Add Copyright-attribution to Daniel Schemala 2017-10-25 19:02:12 +02:00
37e4dfc288 Add License-File
Vimwiki currently has not License-File, and the license is only mentioned in the help-file. We should change this.
2017-10-25 19:02:12 +02:00
3cbc505fba Update Documentation to reflect EOL of MathJax CDN 2017-10-24 14:35:40 +02:00
d4240083f7 Merge pull request #3 from Nudin/individualli
Allow to specify additional chars for lists
2017-09-16 17:09:41 +02:00
0f64032127 Merge pull request #2 from Nudin/wontdo
Wontdo
2017-09-16 16:54:59 +02:00
bb0bbb8133 Merge pull request #1 from Nudin/individualli
Allow to specify additional chars for lists
2017-09-16 16:54:19 +02:00
41e653718e Allow to specify additional chars for lists 2017-09-16 16:30:22 +02:00
97ae634b9f Renamed command
Common prefix causes serious delays
2017-09-16 15:36:10 +02:00
d772a14d43 Fix bug with keybinding 2017-08-05 22:18:56 +02:00
413b9ca04f Add default keybinding glx for toggling disabled 2017-08-05 17:32:15 +02:00
0136039306 Documented VimwikiToggleListItemRejected 2017-08-05 16:45:35 +02:00
f917b01998 Html-export: Add support of rejected Todo-listentry 2017-08-05 16:45:35 +02:00
6b9df766bb Remove duplicated code 2017-08-05 16:45:35 +02:00
f888773767 New feature reject a item form todo-list
Based on patches of davidlmontgomery.
2017-08-05 16:45:35 +02:00
976cbbcd23 Add notes for gln and glp to the doc
Ref #369
2017-07-15 20:27:32 +02:00
46653f48a9 Switch to gln/glp as default keybindings 2017-07-15 15:48:47 +02:00
38efe2c2f1 Change key binding vimwiki#lst#increment_cb to gl+
As well as gl- for vimwiki#lst#decrement_cb.
2017-07-15 15:48:47 +02:00
7fe98bd20c Clean up code by reusing code 2017-07-15 15:48:47 +02:00
20afe48edd Add comment & binding for in-/decrease Todo-status 2017-07-15 15:48:47 +02:00
s
0178114c7f add documentation entry for custom_wiki2html_args 2017-07-11 21:52:41 +02:00
s
3ecf9c544a set additional custom arguments in g:vimwiki_list
(custom_wiki2html_args) which will then be passed to the appropriate
custom_wiki2html script.
2017-07-11 21:52:41 +02:00
4a7d9a286f Merge pull request #326 from salazar/dev
Fix issue in Markdown visual mode link creation
2017-07-09 18:20:54 +02:00
d5df4c7726 Merge pull request #346 from trnila/data-scheme
Support for data scheme
2017-07-09 14:46:48 +02:00
f6437ebdf5 Fix regexps of placeholders
- the highlighting was wrong when the placeholder is indented
- %titleBla was wrongly recongnized as placeholder
- make them more robust by prepending \m
2017-07-08 22:08:41 +02:00
2369fd73aa Add documentation for the %date placeholder
Ref #360
2017-07-08 22:02:44 +02:00
28177c33e3 Added date placeholder. (#360)
* added date placeholder.

* made today the default.
2017-07-08 21:04:54 +02:00
b25b2283e0 Link: support data scheme 2017-05-11 17:33:57 +02:00
8cdc1c1538 Don't throw an error when typing <count>o
Ref #255
2017-04-15 21:22:21 +02:00
39745ebcd3 Don't open all diary files when going to next day
This is unnecessary and can be very slow when the user has many diary
files.
Ref #328
2017-04-15 10:49:53 +02:00
ca95b3fc73 Add some remarks about nested syntaxes to the doc
Ref #329
2017-04-15 10:09:24 +02:00
f54f72981d Add a clarifying note to the doc
Ref #332
2017-04-13 20:33:56 +02:00
30ab7dbff0 fix issue in Markdown visual mode link creation 2017-04-04 20:20:36 -03:00
13f82dbaac Add option for enabling local folding settings
Ref #321
2017-03-31 21:38:32 +02:00
013f699de8 Merge pull request #320 from sqlwwx/dev
doc for install by Vim packages
2017-03-31 21:11:58 +02:00
dd4b9e1276 doc install by Vim packages 2017-03-27 20:47:48 +08:00
065b7cbac0 Small fix to the doc
Don't use arbitrary tags, but always use the prefix 'vimwiki'.
Ref #316
2017-03-19 10:26:25 +01:00
e4fe5ce09d Add possibility to reuse a split when opening a link
Also, refactor and simplify the corresponding functions (and finally
remove the chat between long inactive developers in the comments!)

Fix #316
2017-03-19 10:17:21 +01:00
56cb06e73e Fix <BS> under Windows
It didn't do anything after you hit a link which jumps inside a buffer.
This makes me realize that there are probably a lot more issues under
Windows.
2017-03-01 21:38:14 +01:00
88405934f1 Merge pull request #270 from priomsrb/patch-1
Fix example mapping for decreasing list item level
2017-02-21 21:05:23 +01:00
e0fea20fa6 Merge pull request #266 from NullInfinity/dev
Fix typo in docs
2017-02-21 21:01:44 +01:00
ed7230707d Merge branch 'dev' of https://github.com/vimwiki/vimwiki into dev 2017-02-19 21:53:34 +01:00
2eed86813d Update folding documentation to match current behaviour
Ref #297
Ref #117
2017-02-19 21:50:35 +01:00
d5ed58f763 Fix a few regression bugs
Ref #256
Fix #301
2017-02-16 21:54:10 +01:00
be79f68a92 Merge pull request #285 from MichaelThessel/dev
Added config option to allow for newlines in text when exporting to HTML
2017-01-30 20:43:26 +01:00
c857be2f87 Allow g:vimwiki_listsyms be larger than 5 elements (Issue #275) (#279)
* Allow g:vimwiki_listsyms to be of arbitrary size

* Update documentation

* Add support for arbitrary size listsyms to vimwikihtml
2017-01-22 20:16:10 +01:00
31760a7ef7 Fix a few regression bugs
Ref #256
2017-01-16 22:10:28 +01:00
fea76ace23 Use new access functions for buffer-local variables
Ref #256
2017-01-13 16:33:41 +01:00
ce5c822072 Start refactoring the rest -- part 6
Ref #256
2017-01-12 21:45:09 +01:00
b61ff8b5ee Start refactoring the rest -- part 6
Ref #256
2017-01-11 22:12:33 +01:00
1806d3edfa Start refactoring the rest -- part 5
Ref #256
2017-01-07 21:51:15 +01:00
8507c95716 Added config option to allow for newlines in text when exporting to HTML 2017-01-05 22:17:37 -08:00
4a96eb4d32 Remove two undocumented and probably buggy features 2017-01-04 22:10:10 +01:00
203fb5b430 Start refactoring the rest -- part 4
Ref #256
2017-01-04 21:53:03 +01:00
b82245b09e Start refactoring the rest -- part 3
Ref #256
2016-12-31 20:47:19 +01:00
7c98ce3934 Start refactoring the rest -- part 2
Ref #256
2016-12-28 22:17:08 +01:00
c9104fc2c1 Start refactoring the rest -- part 1
Ref #256
2016-12-25 21:35:56 +01:00
250fd3c47b Use new access functions for wiki-local variables -- part 5
Ref #256
2016-12-23 20:05:53 +01:00
2329d602a7 Use new access functions for wiki-local variables -- part 4
Ref #256
2016-12-22 21:00:19 +01:00
f497a4abc7 Use new access functions for wiki-local variables -- part 3
Ref #256
2016-12-22 19:55:20 +01:00
61910cd93a Use new access functions for wiki-local variables -- part 2
Ref #256
2016-12-22 19:12:03 +01:00
6221861957 Use new access functions for wiki-local variables -- part 1
Ref #256
2016-12-22 18:16:05 +01:00
23ee20887a Use new access functions for global variables -- part 3
Ref #256
2016-12-21 22:11:44 +01:00
49bdf7fa47 Use new access functions for global variables -- part 2
Ref #256
2016-12-21 21:28:48 +01:00
e6d997867a Use new access functions for global variables -- part 1
Ref #256
2016-12-21 19:43:34 +01:00
6b34e954e8 Add new functions for variable access
Ref #256
2016-12-21 17:09:25 +01:00
3a87437005 Merge pull request #276 from bcicen/add-vundle-install-steps
Add vundle install steps to readme
2016-12-18 21:43:33 +01:00
690936ec97 add vundle install steps to readme 2016-12-18 06:23:14 -06:00
febf716bf5 Fix example mapping for decreasing list item level 2016-12-13 10:30:51 +11:00
4c5b0fec6b Fix typo in docs 2016-12-12 22:20:52 +00:00
bb75ec6deb Merge pull request #264 from christianrondeau/check-before-imap-cr
Prevent imap of `<CR>` if already mapped
2016-12-06 08:42:28 +01:00
3b96f8ffeb Prevent imap of <CR> if already mapped 2016-12-05 18:17:38 -05:00
0966031234 Highlight math not using TeX but TeX math
Fix #236
2016-11-24 16:46:56 +01:00
2c9df65644 Merge pull request #251 from jconroy77/markdown_nested_syntax
Automatic detection of nested syntaxes in markdown
2016-11-23 21:49:37 +01:00
8534219694 Automatic detection of nested syntaxes in markdown 2016-10-31 15:35:57 -04:00
777569f95f Workaround for slow folding methods (issue #225) 2016-07-12 11:41:44 -03:00
3f66117894 When sorting tags, always match case because Vim expects it 2016-05-23 22:02:03 +02:00
4831384ab9 Merge branch 'dev' 2016-05-18 22:07:49 +02:00
3a5a5ef0ad Prefer the value of nested_syntaxes over detected syntax 2016-05-17 20:29:59 +02:00
f567009329 Merge pull request #201 from irfansharif/patch-1
fix a tag in the doc
2016-04-25 08:52:40 +02:00
7e3234e0bf fix vimwiki.txt intro tag
previously redirected to `CONTENTS` page, changed to redirect to `Intro` page
2016-04-24 16:45:21 -04:00
129c281810 Update changelog 2016-03-31 12:10:27 +02:00
722d6e4b9a '+' on a raw url surrounds it with brackets
Fix #188
2016-03-21 09:02:22 +01:00
0001b3cda9 Copy CSS file also with :Vimwiki2HTML 2016-03-19 22:01:25 +01:00
68cdfe36df Unify all messages to the user 2016-03-19 21:29:42 +01:00
4956976bb6 Some fixes in the doc 2016-03-19 19:55:08 +01:00
4c2e13a284 Skip preformatted and math text while scanning for headers
Fix #191
2016-03-18 15:18:23 +01:00
4bd0690a52 Simplify some regexes 2016-03-18 15:16:59 +01:00
128581babc Merge remote-tracking branch 'optik-aper/master' into dev 2016-03-01 10:46:29 +01:00
c2d1869227 Escape tilde (~) in path names otherwise regex comparison gets upset 2016-02-29 16:12:56 -05:00
6f579711ab Merge pull request #186 from lotabout/master
fix #64: markdown style link support
2016-02-22 11:42:42 +01:00
6d96516ab4 enhance #64: generate same link type for visual mode and normal mode 2016-02-22 16:00:37 +08:00
0ea8d85b7f Sort links in the list generated by VimwikiGenerateTags
Fix #192
2016-02-19 11:32:58 +01:00
5f9dbca89c Small cleanup of the merged PR
Ref #187
2016-01-28 10:52:40 +01:00
2aeaea5f0d Merge pull request #187 from mMontu/nested
Dynamically detect nested syntaxes (fix #128)
2016-01-28 10:29:53 +01:00
a2888692fd Option for automatic detection of nested syntaxes 2016-01-27 13:30:30 -02:00
fc947523b0 Dynamically detect nested syntaxes (fix #128) 2016-01-27 10:14:49 -02:00
91a004bc23 Remove superfluous debug message 2016-01-25 13:47:41 +01:00
78cef05fa3 Fix HTML conversion of headers containing links
Fix #183
2016-01-22 13:32:01 +01:00
1db5924271 Update the changelog 2016-01-21 13:27:43 +01:00
ff90e980de Locate the .tags file correctly on windows
Ref #184
2016-01-21 13:27:08 +01:00
bb3026dba8 Include subdir in wiki page name when rebuilding tags
Ref #184
2016-01-21 13:25:04 +01:00
b0cc6ff0de fix #64: markdown style link support 2016-01-18 16:51:08 +08:00
949b29b694 Fix tags file path when 'path' contains spaces
Fix #176
2015-12-14 10:36:16 +01:00
f31550badb Merge pull request #165 from Tomsod/dev
Add command for opening yesterday's diary
2015-12-11 11:49:45 +01:00
3bd3d9b860 Update changelog 2015-12-10 16:19:26 +01:00
e0d72759a6 Remember kids: always use :normal! with the bang in plugins
Fix #175
2015-12-10 16:07:36 +01:00
f9045a40e0 Merge pull request #169 from t7ko/bugfix/tags-sorted-in-wrong-order
Fix sorting order of tags.
2015-12-08 16:31:01 +03:00
9be96884ba Remove g:VimwikiLog and the timing stuff
For profiling, there is Vim's :profile command
2015-12-07 12:29:25 +01:00
2a70e1517e Remove g:vimwiki_debug, which probably nobody used 2015-12-07 12:27:32 +01:00
c565b38bb6 Remove some unreachable code 2015-12-07 12:25:17 +01:00
37aae9c3ce Merge pull request #170 from t7ko/bugfix/cursor-moves-on-toc-update
Bugfix: cursor moves on TOC update, TOC fold gets closed.
2015-12-04 14:36:26 +03:00
c2b0fd843b Fix bug: saving a page would err out trying to open fold if folds are disabled or are configured differently. 2015-12-04 15:33:03 +04:00
77fca9080c Fix code review notes on 'norm zo':
- Only issue 'zo' if there is any fold at all.
        - Correct possible bug, code was using 'start_lnum' var, but it
          was changed/incremented which could lead to wrong results.
        - Use bang with norm, to prevent user re-mapping interfere with
          standard ones.
2015-12-01 22:41:50 +03:00
3eb20a6c98 Fix regression bug: Normalize paths if settings changed after startup
Fix #171
2015-11-30 13:33:22 +01:00
7124a9be97 Add a note to the change log
Hopefully not too late.
Ref #173
2015-11-30 13:13:06 +01:00
5247de4a0b Prevent scrolling of large folds while filesave updates TOC.
During TOC update, screen sometimes scrolls -- most often I've seen this
when I'm working inside large enough fold (does not fit in one screen).

Fix uses winsaveview()/winrestview() instead of getpos()/setpos().
Winview pair would also manage scroll position on screen, not just
cursor position in text.
2015-11-27 03:20:44 +03:00
0d3f526a88 Preserve fold open/close status of the TOC on save.
Since TOC is completely recreated, Vim loses its fold open/close status.
If your TOC was open, after you save it gets closed.

Fix will save fold status, and restore it after TOC is updated.
2015-11-27 03:13:25 +03:00
d265df42f5 Prevent cursor moving up/down when TOC changes.
getpos()/setpos() combination does not account for changes of lines
count.  So if you do getpos, then remove lines _above_ it, then do
setpos -- it's going to be off.

The fix calculates the "diff", and adjusts saved position for that diff
(if any).
2015-11-27 03:05:39 +03:00
7df0405c4e Fix sorting order of tags.
Before the fix, tags file sorting was done alphabetically.  That would
treat line numbers as strings, and so, for example, if the same tag was
placed on the same page on lines, say, 9 and 114, the order you would
get, 114 would go first, instead of 9.

Fix adds proper entries comparison to the sort function.
2015-11-27 01:50:41 +03:00
8231433bad Merge pull request #168 from hiberabyss/macurl
follow url silently in mac
2015-11-26 09:32:51 +01:00
399e9a4512 follow url silently in mac 2015-11-26 11:54:32 +08:00
2f95a6a651 Clean up the help file (part 4) 2015-11-25 10:43:26 +01:00
c799d61b19 Clean up the help file (part 3)
Notably, put my name in the list of contributors. Well, and some other
names, too.
2015-11-23 13:10:46 +01:00
da899311c7 Clean up the help file (part 2)
Notably, complete the changelog.
2015-11-22 20:42:21 +01:00
b794a3bd3b Restrict the distance of tag to header to two lines
Suffices, I think.
Also, clean the code a bit and correct the help file.

Ref #85
2015-11-21 21:20:33 +01:00
debd308eea Clean up the help file (part 1)
Notably, integrate the parts about schemes, transclusion and thumbnails
into the part about links. I hope that makes things more clear.
2015-11-20 13:51:19 +01:00
ad4a12612c When doing VimwikiCheckLinks, check if index files exist
Also, clean the code a bit
2015-11-20 11:50:31 +01:00
82c435c1e4 Some cosmetic changes to the readme 2015-11-17 15:58:01 +01:00
2c0e6ebfd9 Add two screenshots 2015-11-17 15:52:02 +01:00
3901b7566b Fix uneven indentation of list items with checkboxes in HTML 2015-11-13 14:40:55 +01:00
0931685ba2 Merge branch 'tags' into dev
Ref #85
2015-11-12 11:56:03 +01:00
e8164bb58a Add description of :VimwikiRebuildTags! to the help file
Ref #85
2015-11-11 13:18:09 +01:00
a043e7d973 Don't allow ' in tags
Ref #85
2015-11-11 12:56:28 +01:00
977f234f6d Allow tags in markdown and mediawiki syntax as well
Ref #85
2015-11-11 12:01:01 +01:00
52634a6753 add HTML processing for tags
Ref #85
2015-11-10 14:37:25 +01:00
642a94ffae :VimwikiGenerateTags now updates a potentially existing listing
instead of adding it to the end.
Ref #85
2015-11-09 15:45:56 +01:00
64f71bc785 Add :VimwikiMakeYesterdayDiaryNote command
Opens diary for yesterday.
For when you stay up past midnight.
2015-10-29 01:00:00 +03:00
2afff4c411 Detect the OS correctly
Fix #158
2015-09-14 15:11:14 +02:00
854219f42e Merge pull request #144 from t7ko/bugfix/fold-shortening-bug-on-utf8
Fix bug with folds shortening on multibyte characters.
2015-07-08 11:54:25 +02:00
d7becafbdd Fix bug with folds shortening on multibyte characters.
If section title contains multibyte chars, the fold shortening function
often fails, because it works with text as array of bytes, not
characters (see strlen() doc for example).

This commit fixes this issue.
2015-07-07 22:54:57 +03:00
3142e08095 Fix some links in the doc from the latest commit
Ref #142
2015-07-03 14:21:13 +02:00
5e382fe079 Merge pull request #142 from JohnKaul/dev
.gitignore and vimwiki.txt changes
2015-07-03 14:14:38 +02:00
d502d653f7 vimwiki.txt:
1. I corrected the webpage links to the github site instead of the old
   code.google.com.
2. Added note the changelog section
2015-06-26 13:47:28 -05:00
477d54ca51 .gitignore:
1. Added sections and comments to gitignore file for better readability.
2. Added more entries to the Vim list (there was already two entries
   for Vim.)
3. Added entries for the following sections/areas: OS &
   Package formats.

jlk
2015-06-26 13:28:40 -05:00
7aa273fd7c A file tag must be at the very top of the file
Ref #85
2015-06-10 22:08:40 +02:00
b808dcfdc1 Simplify a function call 2015-06-10 22:00:07 +02:00
d28b615286 two small things
Ref #85
2015-05-15 11:20:44 +02:00
a2a28a2d91 Make <BS> work also when the user jumped to a tag
Ref #85
2015-05-15 11:04:53 +02:00
3a333881d8 When jumping to anchor, tags have highest precedence
Otherwise, in the list generated by VimwikiGenerateTags, Vimwiki would
jump to the header of the concerning tag rather than to the tag

Ref #85
2015-05-15 11:03:14 +02:00
8bbe0408f9 Set the 'tags' option correctly
Ref #85
2015-05-15 11:01:55 +02:00
6c77fd9101 :VimwikiRebuildTags! only reads files newer than .tags file
Ref #85
2015-05-15 10:56:46 +02:00
f7725fb506 Clarify use of links to directories
Fix #138
2015-05-13 11:10:25 +02:00
6846459255 Fix regression bug: correctly convert links like [[http:...]]
Ref #123
2015-05-12 15:54:53 +02:00
b53dd48429 Merge remote-tracking branch 'upstream/dev' into upstream/tags
Conflicts:
	doc/vimwiki.txt
2015-05-06 17:27:25 +04:00
b5da4ffc8a auto complete absolute wiki links 2015-04-30 13:53:25 +02:00
baf3be038a Fix wrong highlight of directories when maxhi is set 2015-04-30 13:52:33 +02:00
41b40374f9 Finish doc for absolute/relative link stuff 2015-04-30 13:50:58 +02:00
77607f635a slightly change the semantics of file: and local: scheme 2015-04-29 14:59:10 +02:00
4617576c20 Fix bug: tags would not work in subfolders ('tags file not found') 2015-04-26 22:13:03 +03:00
fd66db5551 Merge remote-tracking branch 'upstream/dev' into upstream/tags 2015-04-15 22:44:58 +03:00
99494655c2 Support for absolute links when converting to HTML
Also, Fix #124
2015-04-09 14:48:26 +02:00
62da755350 Fix for #122, don't claim ownership over directories 2015-04-09 14:29:50 +02:00
6607a3f641 Force wiki files to have filetype=vimwiki
Fix #122
2015-03-31 14:31:58 +02:00
c543f8cfb1 Fixed issue with tags in subfolders not being saved in tags file properly (subdir name lost) 2015-03-25 21:44:44 +03:00
28114d8c85 Merge remote-tracking branch 'upstream/dev' into 'upstream/tags'
Conflicts:
	autoload/vimwiki/base.vim
2015-03-25 21:33:19 +03:00
4ab0bdf3da Don't trigger QuickFixCmdPost autocmd unnecessarily
Fix #121
2015-03-23 13:25:39 +01:00
f823589076 make VimwikiCheckLinks also find nonexisting directories
Fix #120
2015-03-19 13:22:28 +01:00
d20e03d660 Make absolute wiki links work with wikiN: scheme
Ref #105
2015-03-19 09:05:19 +01:00
4511bf09e6 Don't highlight absolute links when 'maxhi' is on
Ref #105
2015-03-17 10:33:43 +01:00
6922836a0c Wiki links starting with / are always relative to the wiki root
Also, links with the file: scheme are absolute iff they start with / or
drive letter

Ref #105
2015-03-13 16:31:15 +01:00
55adfca6a1 Rename a function, fixes previous commit 2015-02-24 09:39:03 +01:00
8d7d568214 Clean up all file headers
- remove author names. There's git blame for this job
- change home from code.google to github
- add short descriptions
2015-02-23 12:10:42 +01:00
7e87e92954 Move tags-related functions to extra file
also rename some functions from vimwiki#tags#bla() to s:bla()
2015-02-23 11:29:02 +01:00
8055ef8608 Fix highlighting of tags
in some circumstances, e.g.

- :Tag:

the tag wasn't highlighted. Don't know why.
2015-02-16 12:53:32 +01:00
7bc2fcb3a7 Merge remote-tracking branch 'vimwiki/dev' into 'vimwiki/tags'
Conflicts:
	doc/vimwiki.txt
	ftplugin/vimwiki.vim
2015-02-12 22:20:16 +03:00
3a39498604 Add .gitignore 2015-02-10 13:46:44 +01:00
df5e49c7fd Fix completion in some circumstances 2015-02-09 21:56:28 +01:00
ac4f66586a col('.') inside the omnicompletion function returns garbage
so use a workaround
2015-02-09 21:40:17 +01:00
41bce9ae42 Remove apparently unused function 2015-02-09 21:06:04 +01:00
e4de62b7d5 turn all =~ into =~# or =~?; !~ analogically 2015-02-09 20:58:05 +01:00
6716ba709f turn all != into !=# or !=? when comparing strings 2015-02-09 20:24:18 +01:00
9ada4d2041 turn all == into ==# or ==? when comparing strings
or vimwiki#path#is_equal, if the strings are file names
2015-02-09 20:05:25 +01:00
b240b52a3f Small fix for #112
Ref #111
2015-02-09 09:20:30 +01:00
bf1eb62c32 Merge pull request #112 from t7ko/completion-fix-issue111
Use case sensitive/insensitive path comparison depending on the OS
2015-02-09 09:18:21 +01:00
827b3a8974 Unify yes/no question 2015-02-07 22:12:32 +01:00
68b82a15c6 Adjust case sensitivity of path comparison depending on the OS 2015-02-07 01:50:04 +03:00
42f427e718 Fix issue with tags completion not working right after the colon 2015-02-05 00:05:04 +03:00
13bdb43a54 Merge pull request #113 from t7ko/auto-cd
Option to enable auto-change-dir when opening a wiki index page with <Leader>ww
2015-02-04 23:58:04 +03:00
e34e160a34 Merge pull request #104 from t7ko/autoload-fix
Don't source base.vim at Vim startup
2015-02-04 14:36:23 +01:00
3d3586417d Remove an option that is written but never read 2015-02-03 13:53:56 +01:00
10293f60d7 Use case insensitive path comparison for vimwiki#path#relpath() 2015-02-03 13:34:07 +04:00
556f686431 Make VimwikiGetKnownExtensions into script-local function s:vimwiki_get_known_extensions 2015-02-02 22:07:17 +03:00
de11957fca Use script local variable instead of buffer local 2015-02-02 10:35:32 +01:00
d2ff96717e Encapsulate tag path into a function; expand paths in it to make them absolute 2015-01-29 13:48:15 +04:00
be9667cfa6 Documented the fix in ChangeLog 2015-01-24 10:55:22 +03:00
0511b51a5f Implement auto-chdir option 2015-01-24 10:49:20 +03:00
17cfd6e613 Modify patterns and code -- tag colons must be either at line boundary, or surrounded with white spaces 2015-01-23 23:13:27 +03:00
f5e1cbe721 Move get-known-sytaxes back into base.vim 2015-01-23 22:41:36 +03:00
13e76aed2e <CR> to create a link ignores most punctuation characters now
Fix #99
2015-01-14 13:34:33 +01:00
43cad87426 Merge pull request #106 from t7ko/get_anchors-bugfix
Bold anchors were duplicated in get_anchors() results
2015-01-12 10:06:09 +01:00
8f24644967 Remove unused function parameter 2015-01-12 09:34:59 +01:00
918b07342d Add default values to some options like the doc says
Fix #102
2015-01-12 09:32:05 +01:00
22ab2bfd9b Merge pull request #103 from t7ko/misprint-fix
Fix misprint in documentation
2015-01-12 09:09:11 +01:00
b912e4e3c7 Update :VimikiGenerateTags -- use tags as anchors in links 2015-01-10 17:10:18 +03:00
d72ef4dd70 Treat tags as anchors (wikilink completion, jumping to) 2015-01-10 16:39:11 +03:00
28af35bcfe Fix collecting anchors -- bold anchors were added to the list twice 2015-01-10 16:12:40 +03:00
b99a3dc988 Convert file format to CTAGS. Update docs 2015-01-10 01:44:25 +03:00
8a0433dec5 Fix error 'metadata file not found' when tag functions are called first time 2015-01-10 00:51:37 +03:00
66626ad415 Move two helper functions to plugin file out of autoload. Plugin would have called them at startup anyway, defeating the whole purpose of autoload file. 2015-01-10 00:23:21 +03:00
e6f6fdd359 Mention tags in ChangeLog 2015-01-10 00:06:02 +03:00
e44b188a49 :VimwikiGenerateTags 2015-01-10 00:05:58 +03:00
a62bebceb2 Implement :VimwikiSearchTags to look up tag instances in a wiki 2015-01-10 00:05:11 +03:00
df91772d7e Implement :VimwikiRebuildTags to rebuild metadata for all pages in current wiki 2015-01-10 00:01:18 +03:00
4f639cebee Syntax definitions 2015-01-10 00:01:15 +03:00
a01290160c Support for omni completion of tags 2015-01-10 00:01:12 +03:00
c7436a44cf Reading metadata file; filtering by page name 2015-01-10 00:01:09 +03:00
6cafc97c9c Implement saving metadata to file 2015-01-10 00:01:05 +03:00
2d0616343d Implemented tags scan function (go over range of lines and compose list of tag entries and their metadata 2015-01-10 00:00:57 +03:00
19cc1b873a Added placeholders for tags on-page-save analysis 2015-01-10 00:00:53 +03:00
7f5e517162 Default value for auto-tags option 2015-01-10 00:00:49 +03:00
91b73c2aac Basic documentation 2015-01-10 00:00:26 +03:00
37dafcf8c7 Fix misprint in documentation 2015-01-09 23:36:42 +03:00
6b0be58392 Merge pull request #98 from mMontu/dev
Use shiftwidth() instead of &shiftwidth
2015-01-09 09:21:13 +01:00
edb72680a1 Use backward compatible version of shiftwidth() 2015-01-08 14:14:16 -02:00
b89c22fe03 Use shiftwidth() instead of &shiftwidth
Using &shiftwidth makes VimwikiListChangeLvl misbehave when this option is set
to 0, which is a default configuration of [DetectIndent](https://github.com/roryokane/detectindent).
2015-01-08 11:20:34 -02:00
2804a4495d Don't process placeholders inside preformatted text
Fixes #93
2014-12-16 15:52:53 +01:00
37ef87b930 Suppress an annoying error message when it's not the right time 2014-12-14 14:49:06 +01:00
f419b04346 :VimwikiBacklinks now considers subdirs and other wikis 2014-12-07 11:59:56 +01:00
53ecfdcc68 Fix and clean resolution of links 2014-12-07 11:58:08 +01:00
e5c5a1420d :VimwikiGenerateLinks also generates links for subdirectories 2014-12-04 21:27:02 +01:00
931b40ade1 New command :VimwikiCheckLinks
while we are at it, refactor the code to search through files
2014-12-04 21:26:19 +01:00
eb02e0be9a Move some file system related functions to path.vim 2014-12-04 21:12:04 +01:00
a091bd5a76 Remove some pointless comments 2014-12-04 21:03:49 +01:00
c7366625a3 Remove the grammar based HTML converter -- too slow 2014-12-04 21:00:25 +01:00
b990ed1966 Merge remote-tracking branch 'Svtter/master' into dev 2014-11-27 10:30:02 +01:00
eb254c9573 add chinese Readme 2014-11-27 12:45:53 +08:00
19465760b4 Fix the menu entries which are sometimes not shown correctly 2014-11-26 14:35:38 +01:00
a3e06e4e8d Disable updating of TOC while in diff mode 2014-11-12 11:13:14 +01:00
9fa06803d6 Merge pull request #83 from t7ko/autocompletion
Autocompletion for VimwikiGoto command.
2014-11-12 09:11:00 +01:00
f47f3c4e26 Removed unused functions; added a few more comments 2014-11-11 23:12:03 +03:00
bc0f310889 Update the TOC *before* the file is written, not after
otherwise, Vim behaves strange
2014-11-11 13:52:18 +01:00
d8853c5a34 Fix and simplify the collection of anchors 2014-11-11 13:43:44 +01:00
3906294180 Small doc fix 2014-11-11 13:27:19 +01:00
6b9edefecc Fixed misprint in comments; corrected completion to escape filenames properly; add documentation. 2014-11-10 23:04:06 +03:00
a579e258a1 Merge pull request #77 from lervag/issue66
Improved normalize links in diary (fixes #66)
2014-11-10 09:14:23 +01:00
f7df798b25 Support autocompletion of link argument for VimwikiGoto command 2014-11-07 00:02:37 +03:00
395cfec299 Extract links list generation to an individual function 2014-11-06 23:52:26 +03:00
bb815bcdd8 Replaced all ¦¦ by | 2014-11-06 20:01:16 +01:00
f7bacc3e75 Merge pull request #82 from t7ko/custom-map
Allow users to override <Leader>w prefix via config option
2014-11-06 12:12:16 +01:00
7d07397a98 Enable customization of <Leader>w prefix for global mappings (allow users choose their own prefix). 2014-11-06 01:12:21 +03:00
39b6239820 Vim gets stuck when converting a read-only file
because it tries to write it beforehand.
Fix #81
2014-10-23 12:18:28 +02:00
fb5ea2886b Merge remote-tracking branch 'patrickdavey/check_for_binary' into dev 2014-10-16 11:42:38 +02:00
c1a5bb51ad Checks if custom_wiki2html is executable on PATH 2014-10-14 15:39:46 +13:00
f02fbffaf1 Fixed more issues. 2014-09-17 23:26:16 +02:00
ec4066ad83 Solved some minor issues 2014-09-17 23:10:49 +02:00
24d690f32d Use relative paths in omnicomplete
Fix #70
Ref #72
2014-09-16 10:18:40 +02:00
e8ad164fb0 Improved normalize links in diary (fixes #66) 2014-09-15 21:44:32 +02:00
21b3f63a47 Merge remote-tracking branch 'chelmertz/dev-doctype-html5' into dev 2014-09-12 12:16:41 +02:00
fb8bbef69b Merge remote-tracking branch 'chelmertz/dev-echo-export-location' into dev
Conflicts:
	ftplugin/vimwiki.vim
2014-09-12 12:09:40 +02:00
4da4f19611 HTML5 doctype for HTML output
Signed-off-by: Carl Helmertz <chelmertz@op5.com>
2014-09-12 11:31:06 +02:00
d7488e3291 html export: Let the user know where to find the output
This works both for :Vimwiki2HTML and :VimwikiAll2HTML.

Signed-off-by: Carl Helmertz <chelmertz@op5.com>
2014-09-12 11:25:07 +02:00
3e480e9e3f Add a syntax example for windows users to the doc
Ref #71
2014-09-11 15:45:59 +02:00
f109e0e488 Fix regression bug: opening URLs didn't work
Fix #68 and #73
2014-09-11 10:36:44 +02:00
b954923cbf Fix jumping to an anchor in the very first line 2014-08-18 09:38:45 +02:00
2dd9a153bc Remove option 2 of 'auto_toc'
It doesn't really work for :VimwikiAll2HTML
2014-08-18 09:35:52 +02:00
502212b58d process links of the form [[#anchor]] correctly
when typing :VimwikiAll2HTML
2014-08-18 09:30:22 +02:00
1b6b50a3b7 Don't break after bold text in HTML output 2014-08-14 13:49:45 +02:00
41ddc28c9e Don't interpret autocomplete start string as regexp 2014-08-14 13:08:24 +02:00
fcd908791b Function names must start with s: or capital letter 2014-07-30 21:46:22 +02:00
77bc1b709b Remove nonascii bullet symbol because of encoding probs 2014-07-30 21:26:07 +02:00
a099a2cf3c Disable 'shellslash' on Windows to avoid problems
Probably fix #54
2014-07-04 11:23:28 +02:00
aeaa994fb6 Merge remote-tracking branch 'dan/master' into dev
Ref #56
2014-07-01 09:29:00 +02:00
bd1fb39f6c Update README.md
Fix typos in README: "folow" -> "follow"
2014-06-25 14:01:03 -04:00
8d0e49272b Add a note about how to integrate Tagbar 2014-06-24 14:19:22 +02:00
57143c2c74 Fix highlight of anchor links when maxhi is on 2014-06-22 17:43:26 +02:00
aa32fc2ba5 Fix wrong creation of links caused by previous commit 2014-06-22 16:26:40 +02:00
4a04fc7519 Recognize markdown links when renaming wiki file
Fix #52
2014-06-19 15:36:11 +02:00
c0ead893b4 Merge remote-tracking branch 'af/patch-1' into dev
Fix #51
2014-06-10 09:14:33 +02:00
d33c64f791 Fix <leader>ww text in README 2014-06-07 21:21:25 -07:00
ab36532f75 Tables can now be embedded in lists
Solves #50
2014-06-05 09:42:59 +02:00
9f92a375c1 Faster formatting of large tables
Ref #44
2014-04-30 12:15:51 +02:00
88b61f4e30 Fix jumping to anchor sometimes not working 2014-04-14 13:11:26 +02:00
8167c65499 Fix appending '#' to links
Ref #40
2014-03-13 16:33:39 +01:00
93ca39202c Fix unimportant error message
Partly revert commit 44436f4581
2014-03-13 13:21:50 +01:00
3dbac3a8b7 Don't htmlize stuff inside pre tags
Ref #39
2014-03-10 10:01:32 +01:00
a036ca54c6 Fix 424: External links with #, % don't work under Linux
Use the additional parameter for shellescape() only for system calls of
the form execute '!...', not for system(...).
2014-03-03 09:19:59 +01:00
ddab77bb8f Fix spontaneous change of list symbol 2014-03-03 09:15:38 +01:00
2eccebc7ea Fix list item containing only preformatted text behaving not properly 2014-03-03 09:13:41 +01:00
29fa46f0c5 Restore line deleted in previous commit
apparently, it's not as useless as it seemed to me yesterday...
2014-02-25 15:05:28 +01:00
44436f4581 Do some cleaning using vim-vimlint
Mostly turning global variables into script variables
2014-02-24 12:16:23 +01:00
2c03d82a0e Small updates to README.md 2014-02-21 14:19:55 +01:00
81b7ee0327 Two tags appear two times which produces errors
Fix #35
2014-02-18 16:12:04 +01:00
b1362ac161 VimwikiBacklinks finds only links to the current file
But doesn't take into account markdown style links
Ref #25
2014-02-18 14:52:35 +01:00
8f6768d7e6 Update the doc and make some fixes regarding anchors
Solve #10
2014-02-18 14:47:42 +01:00
8097083f46 Add anchors, jumping to anchors, TOC and completion
Ref #10
2014-02-13 12:42:24 +01:00
cec6acd2f0 Rename :VimwikiToggleCheckbox back to :VimwikiToggleListItem
the name is a little confusing, since there is also a command
:VimwikiListToggle, but it's backwards compatible
2014-02-04 10:40:14 +01:00
1e4f4eb39a Add changelog to the doc 2014-02-04 10:34:19 +01:00
e6735215ed Reactivate and fix html.vim to make it work with lists 2014-02-03 11:41:55 +01:00
23db33ed17 Merge branch 'dev' of https://github.com/vimwiki/vimwiki into dev 2014-01-09 09:28:36 +01:00
b68eb77648 Small additions and fixes to the doc 2014-01-09 09:27:11 +01:00
1762492469 Merge pull request #33 from harciga/dev
Fix for visual mode link creation
2014-01-09 00:06:43 -08:00
69c17a5fec Fix for visual mode link creation 2014-01-08 19:10:20 -06:00
976c39140a Cleanup of the documentation. Mostly superfluous whitespaces 2014-01-06 14:16:37 +01:00
74c3372c44 Finally introduce commands for all list keys
and update the documentation
2014-01-06 14:11:16 +01:00
41d46eb42a Fix CR not working in one circumstance 2014-01-06 13:56:10 +01:00
68ae7d57fb Some more small cleanups 2014-01-06 13:54:11 +01:00
9810ff1c55 g:vimwiki_listsyms is a string again, not a list
this is to be backwards compatible
we still need to split it into a list internally, because indexing
doesn't work for unicode symbols
2014-01-06 13:49:29 +01:00
96dfabb03b When pressing S-Tab, always jump to prev link
not to the start of the link the cursor is on
2014-01-06 13:37:33 +01:00
f5634c92e1 fold also multiline items (folding is still slow) 2014-01-06 13:32:45 +01:00
072ba175f7 More functions moved around 2014-01-06 13:30:33 +01:00
19e4cf90ef Fix cursor misplacement after CR in front of space 2014-01-06 13:07:56 +01:00
ea95f3fc36 Indent after colon only if at end of line
because there are problems otherwise
2014-01-06 13:06:31 +01:00
373ad1cee5 clean up lst.vim, move functions around
no actual change in behavior or so
2014-01-06 13:03:07 +01:00
9821aaf528 (not complete) integration of peggi for html conversion 2014-01-06 12:54:34 +01:00
3be4ba8fd2 Of course, I forgot the a: again
References #24
2013-11-06 13:46:12 +01:00
b37db4e109 Basic support for remote drectories via netrw
References #24
2013-11-06 13:34:45 +01:00
140d32fcdd Add text objects for list items
I put the function in lst.vim, not base.vim because it uses some
functions from lst.vim and because it's list stuff.
2013-10-30 10:53:34 +01:00
e9b1b66807 Prevent the cursor from jumping around on gl* 2013-10-29 13:10:16 +01:00
a389d7ebd7 Make i_<c-t> work in an empty line 2013-10-29 13:06:02 +01:00
0be8924759 Insert new item at the right level on <S-CR> 2013-10-29 13:03:10 +01:00
eb44af27c2 clear a [.] or [o] or [O] item if it has no more children after moving 2013-10-29 12:58:03 +01:00
c036ac34c9 Merge branch 'larryhynes-patch-1' into dev 2013-10-25 09:43:00 +02:00
5038b319a2 Added ` around <leader> to make it visible, added l to folow. 2013-10-24 17:21:50 +01:00
c09d31d1a8 a new list item is inserted at the right level
when pressing i_<c-l><c-m>
2013-10-16 12:20:08 +02:00
391cbd827d Refactor ugly functions
to more ugly ones ;)
2013-10-16 12:18:50 +02:00
3eaaf12b2d Merge branch 'new-lists' of github.com:vimwiki/vimwiki into new-lists 2013-09-08 14:53:42 +04:00
8a46108ef6 Issue #13: VimwikiRenameLink don't update links with dot. 2013-08-17 20:10:00 +04:00
b09077c908 Issue #12: multiple diary with calendar
Unfortunatly there is no way to update calendar signs when wiki is
changed. We could convince calendar mainteiner to provide a hook.
2013-08-15 19:21:08 +04:00
a4e168fb6e Fix a regexp that is matched really slow in Vim 7.4
This is a bug in Vim's new regexp engine I already reported.
It causes a remarkable slowdown.
2013-08-13 09:11:59 +02:00
b170eb52f3 Fix <CR> in a table leaving insert mode 2013-07-30 09:56:33 +02:00
a3a499080b Further update for the documentation 2013-07-29 10:57:07 +02:00
b61b74d037 Fix computation of level of items when using Media syntax 2013-07-29 10:51:50 +02:00
c3ba10ca12 Fix weird behavior when pressing CR and Spaces follow
That's because Vim silently deletes the trailing whitespaces when
pressing enter
2013-07-29 10:42:13 +02:00
6317912520 Fix checkboxes not getting updated in some cases 2013-07-29 10:36:43 +02:00
911f2d4a8c Never alter a checkbox if it has no children with checkboxes 2013-07-24 13:07:42 +02:00
c6e110a368 Code clean up
Remove unused list functions from ftplugin.
2013-07-24 11:30:29 +04:00
e30aa56722 Issue 4: List folding doesn't work
Using new list functions to determine list fold level.
As a regression there is no folds for multilined list item's text.

1. item 1
2. item 2
   multilined
	 that is not
	 folded now
3. item 3

Previous method was able to fold item 2. I am not sure if we should fix
it or not.
2013-07-24 11:09:41 +04:00
b26591437b Revert more of my earlier commit in order to fix #6 2013-07-22 12:54:03 +02:00
5b2f01094b normal behavior of i_<C-T> and i_<C-D> when not on list item 2013-07-22 10:33:32 +02:00
0822759ac3 Clean up messy function and fix i_<S-CR> sometimes not working 2013-07-22 10:30:30 +02:00
8c5760ae98 Simplify detection if two markers have same kind
Ref #5
2013-07-22 10:19:54 +02:00
58e072fa92 Do not load whole syntax file for a buffer twice.
Load twice only regexes for a concrete syntax.
2013-07-18 09:55:24 +04:00
79b78dc9ee Move around and simplify the code for initialization 2013-07-17 15:57:35 +02:00
6805438779 Change some list mappings to have prefix <C-L>.
Remove <C-B>, <C-S> and <C-A> mappings. Use <C-L><C-M>, <C-L><C-K>,
<C-L><C-J> instead.
2013-07-16 11:27:44 +04:00
d873113118 Typo. 2013-07-14 22:19:22 +04:00
aa6849082c Update list mappings. 2013-07-14 22:16:16 +04:00
6d15d32652 Issue 2: g:vimwiki_rxListBullet is not defined
Move g:vimwiki_rxListBullet definition to corresponding syntax files.

Restore multiple bullets (*, **, ***) functionality, set up vimwiki
default lists have only one bullet.
2013-07-14 20:58:46 +04:00
a405c7317a Do not add multiple * on gll
Lists in default vimwiki syntax has no multiple * as bullet point.
This behaviour could be implemented for media syntax.
2013-07-11 23:23:47 +04:00
a36bbbb54a Add some list bindings. 2013-07-11 19:04:18 +04:00
2e3883c851 Level decrease binding was wrong. 2013-07-11 18:24:28 +04:00
813b3bb5a3 Fix marker adjustment on gll 2013-07-09 13:02:37 +02:00
8744a31031 support for numbered lists and much other list stuff 2013-07-08 11:37:35 +02:00
1c88deeee0 Issue 415: No-folding configuration ignored.
When g:vimwiki_folding is set to '' there should be no folding no matter
what foldmethod you have in your .vimrc.
2013-06-18 18:43:03 +04:00
30 changed files with 8621 additions and 4654 deletions

11
.github/issue_template.md vendored Normal file
View File

@ -0,0 +1,11 @@
# Issue Checks
Prior to submitting a new issue make sure to complete these steps:
1. Checkout the `dev` branch and confirm the issue is present there as well.
The `dev` branch contains fixes that may not have been merged to `master` yet.
2. Post the syntax you are using (default/mediawiki/markdown) **and** your vimwiki settings from your `.vimrc`
3. Provide a detailed description of the problem including **steps to reproduce the issue**.
4. Include the output of `:VimwikiShowVersion`.
**DELETE THIS TEMPLATE TEXT PRIOR TO SUBMITTING THE ISSUE**

9
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,9 @@
# Pull Request Checks
1. **ALL** pull requests should be made against the `dev` branch!
2. Take a look at [CONTRIBUTING.MD](https://github.com/vimwiki/vimwiki/blob/dev/CONTRIBUTING.md)
3. Reference any related issues.
4. Provide a description of the proposed changes and any testing that was done.
5. Make sure to update the documentation in `doc/vimwiki.txt` if applicable.
**DELETE THIS TEMPLATE TEXT PRIOR TO SUBMITTING YOUR PULL REQUEST**

22
.gitignore vendored Normal file
View 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

55
CONTRIBUTING.md Normal file
View File

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

22
LICENSE Normal file
View File

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

161
README-cn.md Normal file
View File

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

197
README.md
View File

@ -1,38 +1,27 @@
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.
[中文](README-cn.md)
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) *
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 +30,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 +72,117 @@ 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
==============================================================================
* `:help vimwiki` -- General vimwiki help docs
Using pathogen (http://www.vim.org/scripts/script.php?script_id=2332)
Changing Wiki Syntax
------------------------------------------------------------------------------
Vimwiki currently ships with 3 syntaxes: Vimwiki (default), Markdown (markdown), and MediaWiki (media)
If you would prefer to use either Markdown or MediaWiki syntaxes, set the following option in your .vimrc:
```
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
Installation
==============================================================================
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 [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528)
------------------------------------------------------------------------------
git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
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.
Installation using [Vim-Plug](https://github.com/junegunn/vim-plug)
------------------------------------------------------------------------------
Add the following to the plugin-configuration in your vimrc:
Plug 'vimwiki/vimwiki'
Then run `:PlugInstall`.
Installation using [Vundle](https://github.com/VundleVim/Vundle.vim)
------------------------------------------------------------------------------
Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run
vim +PluginInstall +qall
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.
Getting help
==============================================================================
Have a question? Visit the IRC channel `#vimwiki` on Freenode ([webchat](https://webchat.freenode.net/?channels=#vimwiki), also synced to Matrix/Riot: `#freenode_#vimwiki:matrix.org`) or post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki).
Helping Vimwiki
==============================================================================
Vimwiki has a lot of users but only very few recurring developers or people helping the community. Your help is therefore appreciated. Everyone can help! See [#625](https://github.com/vimwiki/vimwiki/issues/625) for information on how you can help.
----
\* Screenshots made with the [solarized colorscheme](https://github.com/altercation/vim-colors-solarized)
and [lightline](https://github.com/itchyny/lightline.vim)

File diff suppressed because it is too large Load Diff

View File

@ -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.

View File

@ -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%">

View File

@ -1,88 +1,80 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Desc: Handle diary notes
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Description: Handle diary notes
" Home: https://github.com/vimwiki/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_diary_auto") || &cp
finish
endif
let g:loaded_vimwiki_diary_auto = 1
"}}}
let s:vimwiki_max_scan_for_caption = 5
" Helpers {{{
function! s:prefix_zero(num) "{{{
function! s:prefix_zero(num)
if a:num < 10
return '0'.a:num
endif
return a:num
endfunction "}}}
endfunction
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 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
endfunction
function! s:diary_path(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
endfunction "}}}
function! s:diary_index(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return s:diary_path(idx).VimwikiGet('diary_index', idx).VimwikiGet('ext', idx)
endfunction "}}}
function! s:diary_index(...)
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).
\ vimwiki#vars#get_wikilocal('ext', idx)
endfunction
function! s:diary_date_link(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return s:get_date_link(VimwikiGet('diary_link_fmt', idx))
endfunction "}}}
function! s:get_position_links(link) "{{{
function! vimwiki#diary#diary_date_link(...)
if a:0
return strftime('%Y-%m-%d', a:1)
else
return strftime('%Y-%m-%d')
endif
endfunction
function! s:get_position_links(link)
let idx = -1
let links = []
if a:link =~ '^\d\{4}-\d\d-\d\d'
let links = keys(s:get_diary_links())
if a:link =~# '^\d\{4}-\d\d-\d\d'
let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")')
" include 'today' into links
if index(links, s:diary_date_link()) == -1
call add(links, s:diary_date_link())
if index(links, vimwiki#diary#diary_date_link()) == -1
call add(links, vimwiki#diary#diary_date_link())
endif
call sort(links)
let idx = index(links, a:link)
endif
return [idx, links]
endfunction "}}}
endfunction
fun! s:get_month_name(month) "{{{
return g:vimwiki_diary_months[str2nr(a:month)]
endfun "}}}
" Helpers }}}
function! s:get_month_name(month)
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
endfunction
" Diary index stuff {{{
fun! s:read_captions(files) "{{{
function! s:read_captions(files)
let result = {}
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
for fl in a:files
" remove paths and extensions
let fl_key = fnamemodify(fl, ':t:r')
let fl_key = substitute(fnamemodify(fl, ':t'), vimwiki#vars#get_wikilocal('ext').'$', '', '')
if filereadable(fl)
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
if line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
if line =~# rx_header && !has_key(result, fl_key)
let result[fl_key] = vimwiki#u#trim(matchstr(line, rx_header))
endif
endfor
endif
@ -93,26 +85,24 @@ fun! s:read_captions(files) "{{{
endfor
return result
endfun "}}}
endfunction
fun! s:get_diary_links(...) "{{{
function! s:get_diary_files()
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
let s_files = glob(vimwiki#vars#get_wikilocal('path').
\ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~ "'.escape(rx, '\').'"')
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)
endif
let links_with_captions = s:read_captions(files)
return files
endfunction
return links_with_captions
endfun "}}}
fun! s:group_links(links) "{{{
function! s:group_links(links)
let result = {}
let p_year = 0
let p_month = 0
@ -131,130 +121,105 @@ fun! s:group_links(links) "{{{
let p_month = month
endfor
return result
endfun "}}}
endfunction
fun! s:sort(lst) "{{{
if VimwikiGet("diary_sort") == 'desc'
function! s:sort(lst)
if vimwiki#vars#get_wikilocal('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'), ''))
let links_with_captions = s:read_captions(s:get_diary_files())
let g_files = s:group_links(links_with_captions)
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 , ''))
call add(result,
\ substitute(vimwiki#vars#get_syntaxlocal('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), ''))
call add(result, substitute(vimwiki#vars#get_syntaxlocal('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, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', &sw).'* '.entry)
else
let entry = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', &sw).'* '.entry)
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
if empty(cap) " When using markdown syntax, we should ensure we always have a link description.
let cap = fl
endif
elseif empty(cap)
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
endif
let entry = substitute(link_tpl, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry)
endfor
endfor
endfor
call add(result, '')
return result
endfun "}}}
endfunction
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('$')
" The given wiki number a:wnum is 1 for the first wiki, 2 for the second and so on. This is in
" contrast to most other places, where counting starts with 0. When a:wnum is 0, the current wiki
" is used.
function! vimwiki#diary#make_note(wnum, ...)
if a:wnum == 0
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
if wiki_nr < 0 " this happens when e.g. VimwikiMakeDiaryNote was called outside a wiki buffer
let wiki_nr = 0
endif
else
let wiki_nr = a:wnum - 1
endif
if 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 }}}
function! vimwiki#diary#make_note(wnum, ...) "{{{
if a:wnum > len(g:vimwiki_list)
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
if wiki_nr >= vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.wiki_nr.' is not registered in g:vimwiki_list!'
return
endif
" TODO: refactor it. base#goto_index uses the same
if a:wnum > 0
let idx = a:wnum - 1
else
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(vimwiki#vars#get_wikilocal('path', wiki_nr).
\ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr))
if a:0 && a:1 == 1
let cmd = 'tabedit'
else
let cmd = 'edit'
let cmd = 'edit'
if a:0
if a:1 == 1
let cmd = 'tabedit'
elseif a:1 == 2
let cmd = 'split'
elseif a:1 == 3
let cmd = 'vsplit'
endif
endif
if a:0>1
let link = 'diary:'.a:2
else
let link = 'diary:'.s:diary_date_link(idx)
let link = 'diary:'.vimwiki#diary#diary_date_link()
endif
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
call vimwiki#base#setup_buffer_state(idx)
endfunction "}}}
call vimwiki#base#open_link(cmd, link, s:diary_index(wiki_nr))
endfunction
function! vimwiki#diary#goto_diary_index(wnum) "{{{
if a:wnum > len(g:vimwiki_list)
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
function! vimwiki#diary#goto_diary_index(wnum)
if a:wnum > vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
return
endif
@ -265,12 +230,16 @@ 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#setup_buffer_state(idx)
endfunction "}}}
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
function! vimwiki#diary#goto_next_day() "{{{
if vimwiki#vars#get_wikilocal('auto_diary_index')
call vimwiki#diary#generate_diary_section()
write! " save changes
endif
endfunction
function! vimwiki#diary#goto_next_day()
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
@ -282,15 +251,16 @@ function! vimwiki#diary#goto_next_day() "{{{
let link = 'diary:'.links[idx+1]
else
" goto today
let link = 'diary:'.s:diary_date_link()
let link = 'diary:'.vimwiki#diary#diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
endfunction
function! vimwiki#diary#goto_prev_day() "{{{
function! vimwiki#diary#goto_prev_day()
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
@ -302,34 +272,36 @@ function! vimwiki#diary#goto_prev_day() "{{{
let link = 'diary:'.links[idx-1]
else
" goto today
let link = 'diary:'.s:diary_date_link()
let link = 'diary:'.vimwiki#diary#diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
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()
function! vimwiki#diary#generate_diary_section()
let current_file = vimwiki#path#path_norm(expand("%:p"))
let diary_file = vimwiki#path#path_norm(s:diary_index())
if vimwiki#path#is_equal(current_file, diary_file)
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)'
call vimwiki#base#update_listing_in_buffer(s:format_diary(),
\ vimwiki#vars#get_wikilocal('diary_header'), content_rx, line('$')+1, 1)
else
echom "vimwiki: You can generate diary links only in a diary index page!"
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
endif
endfunction "}}}
endfunction
" Calendar.vim {{{
" Callback function.
function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
" Callback function for Calendar.vim
function! vimwiki#diary#calendar_action(day, month, year, week, dir)
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let link = a:year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir == 'V'
if a:dir ==? 'V'
vsplit
else
split
@ -341,18 +313,15 @@ 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)
endfunction "}}}
call vimwiki#diary#make_note(0, 0, link)
endfunction
" Sign function.
function vimwiki#diary#calendar_sign(day, month, year) "{{{
function vimwiki#diary#calendar_sign(day, month, year)
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
\ a:year.'-'.month.'-'.day.VimwikiGet('ext')
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction "}}}
" Calendar.vim }}}
endfunction

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,44 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" 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/
" Description: Link functions for markdown syntax
" Home: https://github.com/vimwiki/vimwiki/
" MISC helper functions {{{
function! s:safesubstitute(text, search, replace, mode)
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
return substitute(a:text, a:search, escaped, a:mode)
endfunction
" vimwiki#markdown_base#reset_mkd_refs
function! vimwiki#markdown_base#reset_mkd_refs() "{{{
call VimwikiClear('markdown_refs')
endfunction "}}}
" vimwiki#markdown_base#scan_reflinks
function! vimwiki#markdown_base#scan_reflinks() " {{{
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 #'.vimwiki#vars#get_syntaxlocal('rxMkdRef').'#j %'
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
"Ignore it, and move on to the next file
endtry
"
for d in getqflist()
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl)
let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr'))
let url = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchUrl'))
if descr != '' && url != ''
let mkd_refs[descr] = url
endif
endfor
call VimwikiSet('markdown_refs', mkd_refs)
call vimwiki#vars#set_bufferlocal('markdown_refs', mkd_refs)
return mkd_refs
endfunction "}}}
endfunction
" vimwiki#markdown_base#get_reflinks
function! vimwiki#markdown_base#get_reflinks() " {{{
let done = 1
try
let mkd_refs = VimwikiGet('markdown_refs')
catch
" work-around hack
let done = 0
" ... the following command does not work inside catch block !?
" > let mkd_refs = vimwiki#markdown_base#scan_reflinks()
endtry
if !done
let mkd_refs = vimwiki#markdown_base#scan_reflinks()
endif
return mkd_refs
endfunction "}}}
" vimwiki#markdown_base#open_reflink
" try markdown reference links
function! vimwiki#markdown_base#open_reflink(link) " {{{
function! vimwiki#markdown_base#open_reflink(link)
" echom "vimwiki#markdown_base#open_reflink"
let link = a:link
let mkd_refs = vimwiki#markdown_base#get_reflinks()
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
if has_key(mkd_refs, link)
let url = mkd_refs[link]
call vimwiki#base#system_open_link(url)
@ -65,197 +46,68 @@ function! vimwiki#markdown_base#open_reflink(link) " {{{
else
return 0
endif
endfunction " }}}
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
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"
if 0
" Syntax-specific links
" XXX: @Stuart: do we still need it?
" 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"
let cmd = ":split "
elseif a:split == "vsplit"
let cmd = ":vsplit "
elseif a:split == "tabnew"
let cmd = ":tabnew "
else
let cmd = ":e "
endif
" try WikiLink
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
\ g:vimwiki_rxWikiLinkMatchUrl)
" try WikiIncl
if lnk == ""
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
\ g:vimwiki_rxWikiInclMatchUrl)
endif
" try Weblink
if lnk == ""
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
\ g:vimwiki_rxWeblinkMatchUrl)
endif
if lnk != ""
if !VimwikiLinkHandler(lnk)
if !vimwiki#markdown_base#open_reflink(lnk)
call vimwiki#base#open_link(cmd, lnk)
endif
endif
return
endif
if a:0 > 0
execute "normal! ".a:1
else
call vimwiki#base#normalize_link(0)
endif
endif
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() " {{{
function! s:normalize_link_syntax_n()
let lnum = line('.')
" try WikiIncl
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl'))
if !empty(lnk)
" NO-OP !!
if g:vimwiki_debug > 1
echomsg "WikiIncl: ".lnk." Sub: ".lnk
endif
return
endif
" try WikiLink0: replace with WikiLink1
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
\ g:vimwiki_WikiLink1Template2)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
if g:vimwiki_debug > 1
echomsg "WikiLink: ".lnk." Sub: ".sub
endif
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
\ vimwiki#vars#get_syntaxlocal('WikiLink1Template2'))
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'), sub)
return
endif
" try WikiLink1: replace with WikiLink0
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
\ g:vimwiki_WikiLinkTemplate2)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
if g:vimwiki_debug > 1
echomsg "WikiLink: ".lnk." Sub: ".sub
endif
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), sub)
return
endif
" try Weblink
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
\ g:vimwiki_Weblink1Template)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
if g:vimwiki_debug > 1
echomsg "WebLink: ".lnk." Sub: ".sub
endif
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'),
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchDescr'),
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'), sub)
return
endif
" try Word (any characters except separators)
" rxWord is less permissive than rxWikiLinkUrl which is used in
" normalize_link_syntax_v
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWord'))
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWord, '',
\ g:vimwiki_WikiLinkTemplate1)
\ vimwiki#vars#get_global('rxWord'), '',
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
if g:vimwiki_debug > 1
echomsg "Word: ".lnk." Sub: ".sub
endif
return
endif
endfunction " }}}
endfunction
" s:normalize_link_syntax_v
function! s:normalize_link_syntax_v() " {{{
function! s:normalize_link_syntax_v()
let lnum = line('.')
let sel_save = &selection
let &selection = "old"
@ -266,37 +118,33 @@ function! s:normalize_link_syntax_v() " {{{
try
norm! gvy
let visual_selection = @"
let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
let link = s:safesubstitute(vimwiki#vars#get_syntaxlocal('Weblink1Template'),
\ '__LinkUrl__', visual_selection, '')
let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
call setreg('"', visual_selection, 'v')
call setreg('"', substitute(link, '\n', '', ''), visualmode())
" paste result
norm! `>pgvd
norm! `>""pgvd
finally
call setreg('"', rv, rt)
let &selection = sel_save
endtry
endfunction " }}}
endfunction
" vimwiki#base#normalize_link
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
function! vimwiki#markdown_base#normalize_link(is_visual_mode)
if 0
" Syntax-specific links
else
if !a:is_visual_mode
call s:normalize_link_syntax_n()
elseif visualmode() ==# 'v' && line("'<") == line("'>")
" action undefined for 'line-wise' or 'multi-line' visual mode selections
elseif line("'<") == line("'>")
" action undefined for multi-line visual mode selections
call s:normalize_link_syntax_v()
endif
endif
endfunction "}}}
" }}}
" -------------------------------------------------------------------------
" Load syntax-specific Wiki functionality
" -------------------------------------------------------------------------
endfunction

183
autoload/vimwiki/path.vim Normal file
View File

@ -0,0 +1,183 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Description: Path manipulation functions
" Home: https://github.com/vimwiki/vimwiki/
function! vimwiki#path#chomp_slash(str)
return substitute(a:str, '[/\\]\+$', '', '')
endfunction
" Define path-compare function, either case-sensitive or not, depending on OS.
if vimwiki#u#is_windows()
function! vimwiki#path#is_equal(p1, p2)
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(fnamemodify(a:path, ':p'))
if vimwiki#u#is_windows()
let result = substitute(result, '\\', '/', 'g')
endif
let result = vimwiki#path#chomp_slash(result)
return result
endfunction
function! vimwiki#path#current_wiki_file()
return vimwiki#path#wikify_path(expand('%:p'))
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(vimwiki#vars#get_global('w32_dir_enc'))
let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc'))
endif
if a:0 && a:1 && input("Vimwiki: Make new directory: ".path."\n [y]es/[N]o? ") !~? '^y'
return 0
endif
call mkdir(path, "p")
return 1
endif
endfunction
function! vimwiki#path#is_absolute(path)
if vimwiki#u#is_windows()
return a:path =~? '\m^\a:'
else
return a:path =~# '\m^/\|\~/'
endif
endfunction
" Combine a directory and a file into one path, doesn't generate duplicate
" path separator in case the directory is also having an ending / or \. This
" is because on windows ~\vimwiki//.tags is invalid but ~\vimwiki/.tags is a
" valid path.
if vimwiki#u#is_windows()
function! vimwiki#path#join_path(directory, file)
let directory = vimwiki#path#chomp_slash(a:directory)
let file = substitute(a:file, '\m^[\\/]\+', '', '')
return directory . '/' . file
endfunction
else
function! vimwiki#path#join_path(directory, file)
let directory = substitute(a:directory, '\m/\+$', '', '')
let file = substitute(a:file, '\m^/\+', '', '')
return directory . '/' . file
endfunction
endif

View File

@ -24,42 +24,46 @@ 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;}
.header a {text-decoration: none; color: inherit;}
/* classes for items of todo lists */
.rejected {
/* list-style: none; */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAAACXBIWXMAAADFAAAAxQEdzbqoAAAAB3RJTUUH4QgEFhAtuWgv9wAAAPZQTFRFmpqam5iYnJaWnJeXnpSUn5OTopCQpoqKpouLp4iIqIiIrYCAt3V1vW1tv2xsmZmZmpeXnpKS/x4e/x8f/yAg/yIi/yQk/yUl/yYm/ygo/ykp/yws/zAw/zIy/zMz/zQ0/zU1/zY2/zw8/0BA/0ZG/0pK/1FR/1JS/1NT/1RU/1VV/1ZW/1dX/1pa/15e/19f/2Zm/2lp/21t/25u/3R0/3p6/4CA/4GB/4SE/4iI/46O/4+P/52d/6am/6ur/66u/7Oz/7S0/7e3/87O/9fX/9zc/93d/+Dg/+vr/+3t/+/v//Dw//Ly//X1//f3//n5//z8////gzaKowAAAA90Uk5T/Pz8/Pz8/Pz8/Pz8/f39ppQKWQAAAAFiS0dEEnu8bAAAAACuSURBVAhbPY9ZF4FQFEZPSKbIMmWep4gMGTKLkIv6/3/GPbfF97b3w17rA0kQOPgvAeHW6uJ6+5h7HqLdwowgOzejXRXBdx6UdSru216xuOMBHHNU0clTzeSUA6EhF8V8kqroluMiU6HKcuf4phGPr1o2q9kYZWwNq1qfRRmTaXpqsyjj17KkWCxKBUBgXWueHIyiAIg18gsse4KHkLF5IKIY10WQgv7fOy4ST34BRiopZ8WLNrgAAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: 0 .2em;
padding-left: 1.5em;
}
.done0 {
/* list-style: none; */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .2em;
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;
}

342
autoload/vimwiki/tags.vim Normal file
View File

@ -0,0 +1,342 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" 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".
" 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 = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r')
" Collect tags in current file
let tags = s:scan_tags(getline(1, '$'), page_name)
" Load metadata file
let metadata = s:load_tags_metadata()
" Drop old tags
let metadata = s:remove_page_from_tags(metadata, page_name)
" Merge in the new ones
let metadata = s:merge_tags(metadata, page_name, tags)
" Save
call s:write_tags_metadata(metadata)
else " full rebuild
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let tags_file_last_modification = getftime(vimwiki#tags#metadata_file_path())
let metadata = s:load_tags_metadata()
for file in files
if all_files || getftime(file) >= tags_file_last_modification
let subdir = vimwiki#base#subdir(wiki_base_dir, file)
let page_name = subdir . fnamemodify(file, ':t:r')
let tags = s:scan_tags(readfile(file), page_name)
let metadata = s:remove_page_from_tags(metadata, page_name)
let metadata = s:merge_tags(metadata, page_name, tags)
endif
endfor
call s:write_tags_metadata(metadata)
endif
endfunction
" 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 = vimwiki#vars#get_syntaxlocal('header_search')
let rxtag = vimwiki#vars#get_syntaxlocal('tag_search')
let anchor_level = ['', '', '', '', '', '', '']
let current_complete_anchor = ''
let PROXIMITY_LINES_NR = 2
let header_line_nr = - (2 * PROXIMITY_LINES_NR)
for line_nr in range(1, len(a:lines))
let line = a:lines[line_nr - 1]
" 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
" Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'),
\ s:TAGS_METADATA_FILE_NAME), ':p')
endfunction
" Loads tags metadata from file, returns a dictionary
function! s:load_tags_metadata() abort
let metadata_path = vimwiki#tags#metadata_file_path()
if !filereadable(metadata_path)
return {}
endif
let metadata = {}
for line in readfile(metadata_path)
if line =~ '^!_TAG_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
" 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
" 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
" Compares two actual lines from tags file. Return value is in strcmp style.
" See help on sort() -- that's what this function is going to be used for.
" See also s:write_tags_metadata below -- that's where we compose these tags
" file lines.
"
" This function is needed for tags sorting, since plain sort() compares line
" numbers as strings, not integers, and so, for example, tag at line 14
" preceeds the same tag on the same page at line 9. (Because string "14" is
" alphabetically 'less than' string "9".)
function! s:tags_entry_cmp(i1, i2)
let items = []
for orig_item in [a:i1, a:i2]
let fields = split(orig_item, "\t")
let item = {}
let item.text = fields[0]."\t".fields[1]
let item.lineno = 0 + matchstr(fields[2], '\m\d\+')
call add(items, item)
endfor
if items[0].text ># items[1].text
return 1
elseif items[0].text <# items[1].text
return -1
elseif items[0].lineno > items[1].lineno
return 1
elseif items[0].lineno < items[1].lineno
return -1
else
return 0
endif
endfunction
" Saves metadata object into a file. Throws exceptions in case of problems.
function! s:write_tags_metadata(metadata)
let metadata_path = vimwiki#tags#metadata_file_path()
let tags = []
for pagename in keys(a:metadata)
for entry in a:metadata[pagename]
let entry_data = pagename . "\t" . entry.link
let entry_data = substitute(entry_data, "\\", '\\\\', 'g')
let entry_data = substitute(entry_data, "\t", '\\t', 'g')
let entry_data = substitute(entry_data, "\r", '\\r', 'g')
let entry_data = substitute(entry_data, "\n", '\\n', 'g')
call add(tags,
\ entry.tagname . "\t"
\ . pagename . vimwiki#vars#get_wikilocal('ext') . "\t"
\ . entry.lineno
\ . ';"'
\ . "\t" . "vimwiki:" . entry_data
\)
endfor
endfor
call sort(tags, "s:tags_entry_cmp")
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
call writefile(tags, metadata_path)
endfunction
" 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
" 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(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''),
\ '' ])
for taglink in sort(tags_entries[tagname])
call add(lines, bullet . substitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
\ '__LinkUrl__', taglink, ''))
endfor
endif
endfor
let links_rx = '\m\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH2').'\)\|\%(^\s*'
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
\ .vimwiki#vars#get_syntaxlocal('rxWikiLink').'$\)'
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx, line('$')+1, 1)
endfunction
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort
" We can safely ignore args if we use -custom=complete option, Vim engine
" will do the job of filtering.
let taglist = vimwiki#tags#get_tags()
return join(taglist, "\n")
endfunction

View File

@ -1,36 +1,36 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Desc: Tables
" Description: Tables
" | Easily | manageable | text | tables | ! |
" |--------|------------|-------|--------|---------|
" | 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
finish
endif
let g:loaded_vimwiki_tbl_auto = 1
"}}}
let s:textwidth = &tw
" Misc functions {{{
function! s:rxSep() "{{{
return g:vimwiki_rxTableSep
endfunction "}}}
function! s:rxSep()
return vimwiki#vars#get_syntaxlocal('rxTableSep')
endfunction
function! s:wide_len(str) "{{{
function! s:wide_len(str)
" vim73 has new function that gives correct string width.
if exists("*strdisplaywidth")
return strdisplaywidth(a:str)
endif
" get str display width in vim ver < 7.2
if !g:vimwiki_CJK_length
if !vimwiki#vars#get_global('CJK_length')
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
else
let savemodified = &modified
@ -43,42 +43,49 @@ function! s:wide_len(str) "{{{
let &modified = savemodified
endif
return ret
endfunction "}}}
endfunction
function! s:cell_splitter() "{{{
function! s:cell_splitter()
return '\s*'.s:rxSep().'\s*'
endfunction "}}}
endfunction
function! s:sep_splitter() "{{{
function! s:sep_splitter()
return '-'.s:rxSep().'-'
endfunction "}}}
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*$')
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
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*$')
endfunction
function! s:is_separator_tail(line) "{{{
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
function! s:is_separator(line)
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*$'
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*$'
endfunction "}}}
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
endfunction
function! s:is_first_column(lnum, cnum) "{{{
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())
endfunction "}}}
return line =~# '^\s*$' ||
\ (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction
function! s:count_separators_up(lnum) "{{{
function! s:count_separators_up(lnum)
let lnum = a:lnum - 1
while lnum > 1
if !s:is_separator(getline(lnum))
@ -88,9 +95,10 @@ function! s:count_separators_up(lnum) "{{{
endwhile
return (a:lnum-lnum)
endfunction "}}}
endfunction
function! s:count_separators_down(lnum) "{{{
function! s:count_separators_down(lnum)
let lnum = a:lnum + 1
while lnum < line('$')
if !s:is_separator(getline(lnum))
@ -100,9 +108,10 @@ function! s:count_separators_down(lnum) "{{{
endwhile
return (lnum-a:lnum)
endfunction "}}}
endfunction
function! s:create_empty_row(cols) "{{{
function! s:create_empty_row(cols)
let row = s:rxSep()
let cell = " ".s:rxSep()
@ -111,9 +120,10 @@ function! s:create_empty_row(cols) "{{{
endfor
return row
endfunction "}}}
endfunction
function! s:create_row_sep(cols) "{{{
function! s:create_row_sep(cols)
let row = s:rxSep()
let cell = "---".s:rxSep()
@ -122,9 +132,10 @@ function! s:create_row_sep(cols) "{{{
endfor
return row
endfunction "}}}
endfunction
function! vimwiki#tbl#get_cells(line) "{{{
function! vimwiki#tbl#get_cells(line)
let result = []
let cell = ''
let quote = ''
@ -134,11 +145,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 +159,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 +168,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
@ -175,13 +186,15 @@ function! vimwiki#tbl#get_cells(line) "{{{
call add(result, vimwiki#u#trim(cell.quote, '|'))
endif
return result
endfunction "}}}
endfunction
function! s:col_count(lnum) "{{{
function! s:col_count(lnum)
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
endfunction "}}}
endfunction
function! s:get_indent(lnum) "{{{
function! s:get_indent(lnum)
if !s:is_table(getline(a:lnum))
return
endif
@ -199,9 +212,10 @@ function! s:get_indent(lnum) "{{{
endwhile
return indent
endfunction " }}}
endfunction
function! s:get_rows(lnum) "{{{
function! s:get_rows(lnum)
if !s:is_table(getline(a:lnum))
return
endif
@ -233,15 +247,16 @@ function! s:get_rows(lnum) "{{{
endwhile
return upper_rows + lower_rows
endfunction "}}}
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)
@ -252,24 +267,32 @@ function! s:get_cell_max_lens(lnum) "{{{
endfor
endfor
return max_lens
endfunction "}}}
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)
function! s:get_aligned_rows(lnum, col1, col2)
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
endfunction "}}}
return result
endfunction
" Number of the current column. Starts from 0.
function! s:cur_column() "{{{
function! s:cur_column()
let line = getline('.')
if !s:is_table(line)
return -1
@ -286,12 +309,10 @@ function! s:cur_column() "{{{
endif
endwhile
return col
endfunction "}}}
endfunction
" }}}
" Format functions {{{
function! s:fmt_cell(cell, max_len) "{{{
function! s:fmt_cell(cell, max_len)
let cell = ' '.a:cell.' '
let diff = a:max_len - s:wide_len(a:cell)
@ -301,38 +322,40 @@ function! s:fmt_cell(cell, max_len) "{{{
let cell .= repeat(' ', diff)
return cell
endfunction "}}}
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
endwhile
return new_line
endfunction "}}}
endfunction
function! s:fmt_cell_sep(max_len) "{{{
function! s:fmt_cell_sep(max_len)
if a:max_len == 0
return repeat('-', 3)
else
return repeat('-', a:max_len+2)
endif
endfunction "}}}
endfunction
function! s:fmt_sep(max_lens, col1, col2) "{{{
function! s:fmt_sep(max_lens, col1, col2)
let new_line = s:rxSep()
for idx in range(len(a:max_lens))
if idx == a:col1
@ -343,11 +366,10 @@ function! s:fmt_sep(max_lens, col1, col2) "{{{
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
endfor
return new_line
endfunction "}}}
"}}}
endfunction
" Keyboard functions "{{{
function! s:kbd_create_new_row(cols, goto_first) "{{{
function! s:kbd_create_new_row(cols, goto_first)
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>0"
@ -360,26 +382,29 @@ function! s:kbd_create_new_row(cols, goto_first) "{{{
let cmd .= "a"
return cmd
endfunction "}}}
endfunction
function! s:kbd_goto_next_row() "{{{
function! s:kbd_goto_next_row()
let cmd = "\<ESC>j"
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
endfunction
function! s:kbd_goto_prev_row() "{{{
function! s:kbd_goto_prev_row()
let cmd = "\<ESC>k"
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
endfunction
" Used in s:kbd_goto_next_col
function! vimwiki#tbl#goto_next_col() "{{{
function! vimwiki#tbl#goto_next_col()
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
@ -392,9 +417,10 @@ function! vimwiki#tbl#goto_next_col() "{{{
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
endfunction
function! s:kbd_goto_next_col(jumpdown) "{{{
function! s:kbd_goto_next_col(jumpdown)
let cmd = "\<ESC>"
if a:jumpdown
let seps = s:count_separators_down(line('.'))
@ -402,16 +428,16 @@ function! s:kbd_goto_next_col(jumpdown) "{{{
endif
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
return cmd
endfunction "}}}
endfunction
" Used in s:kbd_goto_prev_col
function! vimwiki#tbl#goto_prev_col() "{{{
function! vimwiki#tbl#goto_prev_col()
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
let prev_cell_len = 0
echom string(max_lens)
for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
if newcol + delta > curcol-1
@ -425,9 +451,10 @@ function! vimwiki#tbl#goto_prev_col() "{{{
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
endfunction
function! s:kbd_goto_prev_col(jumpup) "{{{
function! s:kbd_goto_prev_col(jumpup)
let cmd = "\<ESC>"
if a:jumpup
let seps = s:count_separators_up(line('.'))
@ -439,15 +466,13 @@ function! s:kbd_goto_prev_col(jumpup) "{{{
" let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd
endfunction "}}}
endfunction
"}}}
" Global functions {{{
function! vimwiki#tbl#kbd_cr() "{{{
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))
@ -456,9 +481,10 @@ function! vimwiki#tbl#kbd_cr() "{{{
else
return s:kbd_goto_next_row()
endif
endfunction "}}}
endfunction
function! vimwiki#tbl#kbd_tab() "{{{
function! vimwiki#tbl#kbd_tab()
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<Tab>"
@ -472,9 +498,10 @@ function! vimwiki#tbl#kbd_tab() "{{{
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(is_sep || last)
endfunction "}}}
endfunction
function! vimwiki#tbl#kbd_shift_tab() "{{{
function! vimwiki#tbl#kbd_shift_tab()
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<S-Tab>"
@ -487,10 +514,11 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
return ""
endif
return s:kbd_goto_prev_col(is_sep || first)
endfunction "}}}
endfunction
function! vimwiki#tbl#format(lnum, ...) "{{{
if !(&filetype == 'vimwiki')
function! vimwiki#tbl#format(lnum, ...)
if !(&filetype ==? 'vimwiki')
return
endif
let line = getline(a:lnum)
@ -507,16 +535,22 @@ 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
let &tw = s:textwidth
endfunction "}}}
function! vimwiki#tbl#create(...) "{{{
let &tw = s:textwidth
endfunction
function! vimwiki#tbl#create(...)
if a:0 > 1
let cols = a:1
let rows = a:2
@ -547,34 +581,36 @@ function! vimwiki#tbl#create(...) "{{{
for r in range(rows - 1)
call add(lines, row)
endfor
call append(line('.'), lines)
endfunction "}}}
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
call append(line('.'), lines)
endfunction
function! vimwiki#tbl#align_or_cmd(cmd)
if s:is_table(getline('.'))
call vimwiki#tbl#format(line('.'))
else
exe 'normal! '.a:cmd
endif
endfunction "}}}
endfunction
function! vimwiki#tbl#reset_tw(lnum) "{{{
if !(&filetype == 'vimwiki')
function! vimwiki#tbl#reset_tw(lnum)
if !(&filetype ==? 'vimwiki')
return
endif
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let s:textwidth = &tw
let &tw = 0
endfunction "}}}
endfunction
" TODO: move_column_left and move_column_right are good candidates to be
" refactored.
function! vimwiki#tbl#move_column_left() "{{{
" TODO: move_column_left and move_column_right are good candidates to be refactored.
function! vimwiki#tbl#move_column_left()
"echomsg "DEBUG move_column_left: "
@ -590,7 +626,7 @@ function! vimwiki#tbl#move_column_left() "{{{
endif
if cur_col > 0
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep().'\).\zs'
@ -600,16 +636,16 @@ function! vimwiki#tbl#move_column_left() "{{{
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
else
break
endif
endwhile
endif
endfunction
endfunction "}}}
function! vimwiki#tbl#move_column_right() "{{{
function! vimwiki#tbl#move_column_right()
let line = getline('.')
@ -623,7 +659,7 @@ function! vimwiki#tbl#move_column_right() "{{{
endif
if cur_col < s:col_count(line('.'))-1
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep().'\).\zs'
@ -633,33 +669,35 @@ function! vimwiki#tbl#move_column_right() "{{{
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
else
break
endif
endwhile
endif
endfunction
endfunction "}}}
function! vimwiki#tbl#get_rows(lnum) "{{{
function! vimwiki#tbl#get_rows(lnum)
return s:get_rows(a:lnum)
endfunction "}}}
endfunction
function! vimwiki#tbl#is_table(line) "{{{
function! vimwiki#tbl#is_table(line)
return s:is_table(a:line)
endfunction "}}}
endfunction
function! vimwiki#tbl#is_separator(line) "{{{
function! vimwiki#tbl#is_separator(line)
return s:is_separator(a:line)
endfunction "}}}
endfunction
function! vimwiki#tbl#cell_splitter() "{{{
function! vimwiki#tbl#cell_splitter()
return s:cell_splitter()
endfunction "}}}
endfunction
function! vimwiki#tbl#sep_splitter() "{{{
function! vimwiki#tbl#sep_splitter()
return s:sep_splitter()
endfunction "}}}
endfunction
"}}}

View File

@ -1,10 +1,9 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Utility functions
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Description: Utility functions
" Home: https://github.com/vimwiki/vimwiki/
function! vimwiki#u#trim(string, ...) "{{{
function! vimwiki#u#trim(string, ...)
let chars = ''
if a:0 > 0
let chars = a:1
@ -12,66 +11,62 @@ function! vimwiki#u#trim(string, ...) "{{{
let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
return res
endfunction "}}}
endfunction
" Builtin cursor doesn't work right with unicode characters.
function! vimwiki#u#cursor(lnum, cnum) "{{{
function! vimwiki#u#cursor(lnum, cnum)
exe a:lnum
exe 'normal! 0'.a:cnum.'|'
endfunction "}}}
endfunction
function! vimwiki#u#is_windows() "{{{
function! vimwiki#u#is_windows()
return has("win32") || has("win64") || has("win95") || has("win16")
endfunction "}}}
endfunction
function! vimwiki#u#chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '')
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 =~ '.\+[/\\]$'
function! vimwiki#u#is_macos()
if has("mac") || has("macunix") || has("gui_mac")
return 1
endif
return 0
endfunction " }}}
" that still doesn't mean we are not on Mac OS
let os = substitute(system('uname'), '\n', '', '')
return os == 'Darwin' || os == 'Mac'
endfunction
function! vimwiki#u#count_first_sym(line) "{{{
function! vimwiki#u#count_first_sym(line)
let first_sym = matchstr(a:line, '\S')
return len(matchstr(a:line, first_sym.'\+'))
endfunction "}}}
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
endfunction "}}}
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_'.vimwiki#vars#get_wikilocal('syntax').'.vim'
endfunction
" Load syntax-specific functionality
function vimwiki#u#reload_regexes_custom()
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('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

850
autoload/vimwiki/vars.vim Normal file
View File

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

BIN
doc/screenshot_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
doc/screenshot_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,235 +1,217 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" 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
" UNDO list {{{
" Reset the following options to undo this plugin.
let b:undo_ftplugin = "setlocal ".
\ "suffixesadd< isfname< comments< ".
\ "formatoptions< foldtext< ".
\ "foldmethod< foldexpr< commentstring< "
" UNDO }}}
" MISC STUFF {{{
setlocal commentstring=%%%s
if g:vimwiki_conceallevel && exists("+conceallevel")
let &l:conceallevel = g:vimwiki_conceallevel
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
endif
" MISC }}}
" GOTO FILE: gf {{{
execute 'setlocal suffixesadd='.VimwikiGet('ext')
" This is for GOTO FILE: gf
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('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+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"')
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 vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
if startofinlinelink != -1
let s:line_context = '['
return startofinlinelink
endif
endif
let startoftag = match(line, ':\zs[^:[:space:]]*$')
if startoftag != -1
let s:line_context = ':'
return startoftag
endif
let s:line_context = ''
return -1
else
" Completion works for wikilinks/anchors, and for tags. s:line_content
" tells us which string came before a:base. There seems to be no easier
" solution, because calling col('.') here returns garbage.
if s:line_context == ''
return []
elseif s:line_context == ':'
" Tags completion
let tags = vimwiki#tags#get_tags()
if a:base != ''
call filter(tags,
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
endif
return tags
elseif a:base !~# '#'
" we look for wiki files
if a:base =~# '\m^wiki\d\+:'
let wikinumber = eval(matchstr(a:base, '\m^wiki\zs\d\+'))
if wikinumber >= vimwiki#vars#number_of_wikis()
return []
endif
let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*')
let scheme = matchstr(a:base, '\m^wiki\d\+:\ze')
elseif a:base =~# '^diary:'
let wikinumber = -1
let prefix = matchstr(a:base, '^diary:\zs.*')
let scheme = matchstr(a:base, '^diary:\ze')
else " current wiki
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
let prefix = a:base
let scheme = ''
endif
let links = vimwiki#base#get_wikilinks(wikinumber, 1)
let result = []
for wikifile in links
if wikifile =~ '^'.vimwiki#u#escape(prefix)
call add(result, scheme . wikifile)
endif
endfor
return result
else
" we look for anchors in the given wikifile
let segments = split(a:base, '#', 1)
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
let wikifile = link_infos.filename
let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index)
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
let filtered_anchors = []
let given_anchor = join(segments[1:], '#')
for anchor in anchors
if anchor =~# '^'.vimwiki#u#escape(given_anchor)
call add(filtered_anchors, segments[0].'#'.anchor)
endif
endfor
return filtered_anchors
endif
endif
endfunction
setlocal omnifunc=Complete_wikifiles
" settings necessary for the automatic formatting of lists
setlocal autoindent
setlocal nosmartindent
setlocal nocindent
setlocal comments=""
setlocal formatoptions-=c
setlocal formatoptions-=r
setlocal formatoptions-=o
setlocal formatoptions-=2
setlocal formatoptions+=n
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
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. {{{
" ------------------------------------------------
" Folding stuff
" ------------------------------------------------
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! VimwikiFoldListLevel(lnum)
return vimwiki#lst#fold_level(a:lnum)
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 "}}}
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
endfunction "}}}
" Folding list items }}}
" Folding sections and code blocks using expr fold method. {{{
function! VimwikiFoldLevel(lnum) "{{{
function! VimwikiFoldLevel(lnum)
let line = getline(a:lnum)
" Header/section folding...
if line =~ g:vimwiki_rxHeader
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader')
return '>'.vimwiki#u#count_first_sym(line)
" Code block folding...
elseif line =~ '^\s*'.g:vimwiki_rxPreStart
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
return 'a1'
elseif line =~ '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
return 's1'
else
return "="
endif
endfunction
endfunction "}}}
" Constants used by VimwikiFoldText {{{
" Constants used by VimwikiFoldText
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
let s:ellipsis = (&enc ==? 'utf-8') ? "\u2026" : "..."
let s:ell_len = strlen(s:ellipsis)
let s:newline = (&enc ==? 'utf-8') ? "\u21b2 " : " "
let s:tolerance = 5
" }}}
function! s:shorten_text_simple(text, len) "{{{ unused
" unused
function! s:shorten_text_simple(text, len)
let spare_len = a:len - len(a:text)
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
endfunction "}}}
endfunction
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
" for long enough "text", the string's length is within s:tolerance of "len"
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
function! s:shorten_text(text, len) "{{{ returns [string, spare]
let spare_len = a:len - strlen(a:text)
function! s:shorten_text(text, len)
" returns [string, spare]
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
" trick here -- replace all non-spaces with dot, calculate lengths and
" indexes on it, then use original string to break at selected index.
let text_pattern = substitute(a:text, '\m\S', '.', 'g')
let spare_len = a:len - strlen(text_pattern)
if (spare_len + s:tolerance >= 0)
return [a:text, spare_len]
endif
" try to break on a space; assumes a:len-s:ell_len >= s:tolerance
let newlen = a:len - s:ell_len
let idx = strridx(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]
endfunction "}}}
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis, newlen - break_idx]
endfunction
function! VimwikiFoldText() "{{{
function! VimwikiFoldText()
let line = getline(v:foldstart)
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
let fold_len = v:foldend - v:foldstart + 1
let len_text = ' ['.fold_len.'] '
if line !~ '^\s*'.g:vimwiki_rxPreStart
if line !~# vimwiki#vars#get_syntaxlocal('rxPreStart')
let [main_text, spare_len] = s:shorten_text(main_text, 50)
return main_text.len_text
else
@ -244,40 +226,45 @@ function! VimwikiFoldText() "{{{
endif
return main_text.len_text.content_text
endif
endfunction "}}}
endfunction
" Folding sections and code blocks }}}
" FOLDING }}}
" COMMANDS {{{
" ------------------------------------------------
" Commands
" ------------------------------------------------
command! -buffer Vimwiki2HTML
\ silent w <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
\<bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
\ <bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
\ . expand(vimwiki#vars#get_wikilocal('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(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%')))
command! -buffer VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('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()
command! -buffer VimwikiRenameLink call vimwiki#base#rename_link()
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit')
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1)
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split')
command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit')
command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', <f-args>)
command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', <f-args>)
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tab', 0, 1)
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
@ -285,16 +272,36 @@ command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('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 VimwikiToggleRejectedListItem
\ call vimwiki#lst#toggle_rejected_cb(<line1>, <line2>)
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
command! -buffer -range -nargs=+ VimwikiListChangeLvl
\ call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
command! -buffer VimwikiRenumberAllLists call vimwiki#lst#adjust_whole_buffer()
command! -buffer VimwikiListToggle call vimwiki#lst#toggle_list_item()
" table commands
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
@ -307,13 +314,26 @@ 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()
" COMMANDS }}}
" 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>)
" KEYBINDINGS {{{
if g:vimwiki_use_mouse
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
" ------------------------------------------------
" Keybindings
" ------------------------------------------------
if vimwiki#vars#get_global('use_mouse')
nmap <buffer> <S-LeftMouse> <NOP>
nmap <buffer> <C-LeftMouse> <NOP>
nnoremap <silent><buffer> <2-LeftMouse> :call vimwiki#base#follow_link("nosplit", "\<lt>2-LeftMouse>")<CR>
nnoremap <silent><buffer> <2-LeftMouse>
\ :call vimwiki#base#follow_link('nosplit', 0, 1, "\<lt>2-LeftMouse>")<CR>
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
@ -321,46 +341,39 @@ endif
if !hasmapto('<Plug>Vimwiki2HTML')
nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'h <Plug>Vimwiki2HTML'
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
nnoremap <script><buffer> <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
nmap <buffer> <Leader>whh <Plug>Vimwiki2HTMLBrowse
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'hh <Plug>Vimwiki2HTMLBrowse'
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
nnoremap <script><buffer> <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
if !hasmapto('<Plug>VimwikiFollowLink')
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
if !hasmapto('<Plug>VimwikiSplitLink')
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
if !hasmapto('<Plug>VimwikiVSplitLink')
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
if !hasmapto('<Plug>VimwikiNormalizeLink')
nmap <silent><buffer> + <Plug>VimwikiNormalizeLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLink :VimwikiNormalizeLink 0<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLink :VimwikiNormalizeLink 0<CR>
if !hasmapto('<Plug>VimwikiNormalizeLinkVisual')
vmap <silent><buffer> + <Plug>VimwikiNormalizeLinkVisual
endif
vnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLinkVisual :<C-U>VimwikiNormalizeLink 1<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisual :<C-U>VimwikiNormalizeLink 1<CR>
if !hasmapto('<Plug>VimwikiNormalizeLinkVisualCR')
vmap <silent><buffer> <CR> <Plug>VimwikiNormalizeLinkVisualCR
@ -372,105 +385,209 @@ if !hasmapto('<Plug>VimwikiTabnewLink')
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
if !hasmapto('<Plug>VimwikiGoBackLink')
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
if !hasmapto('<Plug>VimwikiNextLink')
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiNextLink :VimwikiNextLink<CR>
if !hasmapto('<Plug>VimwikiPrevLink')
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
if !hasmapto('<Plug>VimwikiDeleteLink')
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'d <Plug>VimwikiDeleteLink'
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
if !hasmapto('<Plug>VimwikiRenameLink')
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'r <Plug>VimwikiRenameLink'
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
if !hasmapto('<Plug>VimwikiDiaryNextDay')
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
endif
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
endif
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<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
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
if !hasmapto('<Plug>VimwikiDiaryNextDay')
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
if !hasmapto('<Plug>VimwikiToggleRejectedListItem')
nmap <silent><buffer> glx <Plug>VimwikiToggleRejectedListItem
vmap <silent><buffer> glx <Plug>VimwikiToggleRejectedListItem
endif
nnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
\ <Plug>VimwikiToggleRejectedListItem :VimwikiToggleRejectedListItem<CR>
vnoremap <silent><script><buffer>
\ <Plug>VimwikiToggleRejectedListItem :VimwikiToggleRejectedListItem<CR>
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
if !hasmapto('<Plug>VimwikiIncrementListItem')
nmap <silent><buffer> gln <Plug>VimwikiIncrementListItem
vmap <silent><buffer> gln <Plug>VimwikiIncrementListItem
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
if !hasmapto('<Plug>VimwikiDecrementListItem')
nmap <silent><buffer> glp <Plug>VimwikiDecrementListItem
vmap <silent><buffer> glp <Plug>VimwikiDecrementListItem
endif
nnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
vnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
function! s:CR() "{{{
let res = vimwiki#lst#kbd_cr()
if res == "\<CR>" && g:vimwiki_table_mappings
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 :<C-U>call vimwiki#lst#kbd_o()<CR>
nnoremap <silent> <buffer> O :<C-U>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 vimwiki#vars#get_syntaxlocal('bullet_types')
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
endif
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'<CR>')
exe 'noremap <silent><buffer> gL'.s:char.' :VimwikiChangeSymbolInListTo '.s:char.'<CR>'
endif
endfor
for s:typ in vimwiki#vars#get_syntaxlocal('number_types')
if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'<CR>')
exe 'noremap <silent><buffer> gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'<CR>'
endif
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'<CR>')
exe 'noremap <silent><buffer> gL'.s:typ[0].' :VimwikiChangeSymbolInListTo '.s:typ.'<CR>'
endif
endfor
function! s:CR(normal, just_mrkr)
if vimwiki#vars#get_global('table_mappings')
let res = vimwiki#tbl#kbd_cr()
if res != ""
exe "normal! " . res . "\<Right>"
startinsert
return
endif
endif
return res
endfunction "}}}
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 !hasmapto('VimwikiReturn', 'i')
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
endif
"Table mappings
if vimwiki#vars#get_global('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>
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
nnoremap <silent><script><buffer> <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
if !hasmapto('<Plug>VimwikiTableMoveColumnRight')
nmap <silent><buffer> <A-Right> <Plug>VimwikiTableMoveColumnRight
endif
@ -479,12 +596,21 @@ nnoremap <silent><script><buffer>
" Text objects {{{
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0)<CR>
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 1)<CR>
" ------------------------------------------------
" Text objects
" ------------------------------------------------
onoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 0)<CR>
vnoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 1)<CR>
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
onoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 0, v:count1)<CR>
vnoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 0, v:count1)<CR>
onoremap <silent><buffer> aH :<C-U>call vimwiki#base#TO_header(0, 1, v:count1)<CR>
vnoremap <silent><buffer> aH :<C-U>call vimwiki#base#TO_header(0, 1, v:count1)<CR>
onoremap <silent><buffer> iH :<C-U>call vimwiki#base#TO_header(1, 1, v:count1)<CR>
vnoremap <silent><buffer> iH :<C-U>call vimwiki#base#TO_header(1, 1, v:count1)<CR>
onoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 0)<CR>
vnoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 1)<CR>
@ -498,11 +624,16 @@ 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
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
\<C-U>call vimwiki#base#AddHeaderLevel()<CR>
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :<C-U>call vimwiki#base#AddHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
@ -510,30 +641,59 @@ endif
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
\<C-U>call vimwiki#base#RemoveHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiGoToParentHeader')
nmap <silent><buffer> ]u <Plug>VimwikiGoToParentHeader
nmap <silent><buffer> [u <Plug>VimwikiGoToParentHeader
endif
nnoremap <silent><buffer> <Plug>VimwikiGoToParentHeader :
\<C-u>call vimwiki#base#goto_parent_header()<CR>
" }}}
if !hasmapto('<Plug>VimwikiGoToNextHeader')
nmap <silent><buffer> ]] <Plug>VimwikiGoToNextHeader
endif
nnoremap <silent><buffer> <Plug>VimwikiGoToNextHeader :
\<C-u>call vimwiki#base#goto_next_header()<CR>
" KEYBINDINGS }}}
if !hasmapto('<Plug>VimwikiGoToPrevHeader')
nmap <silent><buffer> [[ <Plug>VimwikiGoToPrevHeader
endif
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevHeader :
\<C-u>call vimwiki#base#goto_prev_header()<CR>
" AUTOCOMMANDS {{{
if VimwikiGet('auto_export')
if !hasmapto('<Plug>VimwikiGoToNextSiblingHeader')
nmap <silent><buffer> ]= <Plug>VimwikiGoToNextSiblingHeader
endif
nnoremap <silent><buffer> <Plug>VimwikiGoToNextSiblingHeader :
\<C-u>call vimwiki#base#goto_sibling(+1)<CR>
if !hasmapto('<Plug>VimwikiGoToPrevSiblingHeader')
nmap <silent><buffer> [= <Plug>VimwikiGoToPrevSiblingHeader
endif
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader :
\<C-u>call vimwiki#base#goto_sibling(-1)<CR>
if vimwiki#vars#get_wikilocal('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
augroup END
endif
" AUTOCOMMANDS }}}
if vimwiki#vars#get_wikilocal('auto_toc')
" Automatically update the TOC *before* the file is written
augroup vimwiki
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
augroup END
endif
" PASTE, CAT URL {{{
" html commands
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
" }}}
if vimwiki#vars#get_wikilocal('auto_tags')
" Automatically update tags metadata on page write.
augroup vimwiki
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
augroup END
endif
" DEBUGGING {{{
command! VimwikiPrintWikiState call vimwiki#base#print_wiki_state()
command! VimwikiReadLocalOptions call vimwiki#base#read_wiki_options(1)
" }}}

View File

@ -1,473 +1,287 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" 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
" Set to version number for release, otherwise -1 for dev-branch
let s:plugin_vers = 2.4
" Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h')
let s:old_cpo = &cpo
set cpo&vim
" Logging and performance instrumentation "{{{
let g:VimwikiLog = {}
let g:VimwikiLog.path = 0 " # of calls to VimwikiGet with path or path_html
let g:VimwikiLog.path_html = 0 " # of calls to path_html()
let g:VimwikiLog.normalize_path = 0 " # of calls to normalize_path()
let g:VimwikiLog.subdir = 0 " # of calls to vimwiki#base#subdir()
let g:VimwikiLog.timing = [] " various timing measurements
let g:VimwikiLog.html = [] " html conversion timing
function! VimwikiLog_extend(what,...) "{{{
call extend(g:VimwikiLog[a:what],a:000)
endfunction "}}}
"}}}
" HELPER functions {{{
function! s:default(varname, value) "{{{
if !exists('g:vimwiki_'.a:varname)
let g:vimwiki_{a:varname} = a: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
endfunction "}}}
if exists('g:vimwiki_autowriteall')
let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall
else
let s:vimwiki_autowriteall_saved = 1
endif
function! s:vimwiki_idx() " {{{
if exists('b:vimwiki_idx')
return b:vimwiki_idx
else
return -1
endif
endfunction " }}}
function! s:setup_buffer_leave() "{{{
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'
" cache global vars of current state XXX: SLOW!?
call vimwiki#base#cache_buffer_state()
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let &autowriteall = s:vimwiki_autowriteall
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
endif
endfunction "}}}
function! s:setup_filetype() "{{{
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
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
endif
if idx == -1 && g:vimwiki_global_ext == 0
" this is called when the cursor leaves the buffer
function! s:setup_buffer_leave()
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
"XXX when idx = -1? (an orphan page has been detected)
"TODO: refactor (same code in setup_buffer_enter)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
let &autowriteall = s:vimwiki_autowriteall_saved
if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
" create a new temporary wiki for the current buffer
function! s:create_temporary_wiki()
let path = expand('%:p:h')
let ext = '.'.expand('%:e')
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
if has_key(syntax_mapping, ext)
let syntax = syntax_mapping[ext]
else
let syntax = vimwiki#vars#get_wikilocal_default('syntax')
endif
let new_temp_wiki_settings = {'path': path,
\ 'ext': ext,
\ 'syntax': syntax,
\ }
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
" Update the wiki number of the current buffer, because it may have changed when adding this
" temporary wiki.
call vimwiki#vars#set_bufferlocal('wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
endfunction
" This function is called when Vim opens a new buffer with a known wiki
" extension. Both when the buffer has never been opened in this session and
" when it has.
function! s:setup_new_wiki_buffer()
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
if wiki_nr == -1 " it's not in a known wiki directory
if vimwiki#vars#get_global('global_ext')
call s:create_temporary_wiki()
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
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
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
unlet! b:vimwiki_fs_rescan
set filetype=vimwiki
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (set ft=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
let time1 = vimwiki#u#time(time0) "XXX
call VimwikiLog_extend('timing',['plugin:setup_filetype:time1',time1])
endfunction "}}}
function! s:setup_buffer_enter() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let time0 = reltime() " start the clock "XXX
if !vimwiki#base#recall_buffer_state()
" Find what wiki current buffer belongs to.
" If wiki does not exist in g:vimwiki_list -- add new wiki there with
" 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)
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().""
endif
" The buffer's file is not in the path and user *does NOT* want his wiki
" extension to be global -- Do not add new wiki.
if idx == -1 && g:vimwiki_global_ext == 0
" the user does not want a temporary wiki, so do nothing
return
endif
"TODO: refactor (same code in setup_filetype)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
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
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
endif
" If you have
" au GUIEnter * VimwikiIndex
" Then change it to
" au GUIEnter * nested VimwikiIndex
if &filetype == ''
set filetype=vimwiki
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'
" 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
if exists("b:vimwiki_fs_rescan") && VimwikiGet('maxhi')
set syntax=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set syntax=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
endif
let b:vimwiki_fs_rescan = 1
endif
let time1 = vimwiki#u#time(time0) "XXX
" 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'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
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'
setlocal fdm=syntax
setlocal foldtext=VimwikiFoldText()
if vimwiki#vars#get_wikilocal('maxhi')
call vimwiki#vars#set_bufferlocal('existing_wikifiles', vimwiki#base#get_wikilinks(wiki_nr, 1))
call vimwiki#vars#set_bufferlocal('existing_wikidirs',
\ vimwiki#base#get_wiki_directories(wiki_nr))
endif
" And conceal level too.
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
" sourced
setfiletype vimwiki
endfunction
" this is called when the cursor enters the buffer
function! s:setup_buffer_enter()
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
if &filetype != 'vimwiki'
setfiletype vimwiki
endif
"let time2 = vimwiki#u#time(time0) "XXX
call VimwikiLog_extend('timing',['plugin:setup_buffer_enter:time1',time1])
endfunction "}}}
function! s:setup_buffer_reenter() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if !vimwiki#base#recall_buffer_state()
" Do not repeat work of s:setup_buffer_enter() and s:setup_filetype()
" Once should be enough ...
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if !exists("s:vimwiki_autowriteall")
let s:vimwiki_autowriteall = &autowriteall
endif
let &autowriteall = g:vimwiki_autowriteall
endfunction "}}}
call s:set_global_options()
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
call s:set_windowlocal_options()
endfunction
function! s:setup_cleared_syntax()
" highlight groups that get cleared
" on colorscheme change because they are not linked to Vim-predefined groups
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def VimwikiUnderline gui=underline
if g:vimwiki_hl_headers == 1
if vimwiki#vars#get_global('hl_headers') == 1
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'
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='
\ . vimwiki#vars#get_global('hcolor_guifg_'.&bg)[i-1]
\ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[i-1]
\ .' term=bold cterm=bold'
endfor
endif
endfunction "}}}
endfunction
" OPTION get/set functions {{{
" return complete list of options
function! VimwikiGetOptionNames() "{{{
return keys(s:vimwiki_defaults)
endfunction "}}}
function! VimwikiGetOptions(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
let option_dict = {}
for kk in keys(s:vimwiki_defaults)
let option_dict[kk] = VimwikiGet(kk, idx)
function! s:vimwiki_get_known_extensions()
" Getting all extensions that different wikis could have
let extensions = {}
for idx in range(vimwiki#vars#number_of_wikis())
let ext = vimwiki#vars#get_wikilocal('ext', idx)
let extensions[ext] = 1
endfor
return option_dict
endfunction "}}}
" append extensions from g:vimwiki_ext2syntax
for ext in keys(vimwiki#vars#get_global('ext2syntax'))
let extensions[ext] = 1
endfor
return keys(extensions)
endfunction
" Return value of option for current wiki or if second parameter exists for
" wiki with a given index.
" If the option is not found, it is assumed to have been previously cached in a
" buffer local dictionary, that acts as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiGet(option, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(g:vimwiki_list[idx], a:option)
let val = g:vimwiki_list[idx][a:option]
elseif has_key(s:vimwiki_defaults, a:option)
let val = s:vimwiki_defaults[a:option]
let g:vimwiki_list[idx][a:option] = val
" Set settings which are global for Vim, but should only be executed for
" Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer
" and reset when the cursor leaves the buffer.
function! s:set_global_options()
let s:vimwiki_autowriteall_saved = &autowriteall
let &autowriteall = vimwiki#vars#get_global('autowriteall')
if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
" Set settings which are local to a window. In a new tab they would be reset to
" Vim defaults. So we enforce our settings here when the cursor enters a
" Vimwiki buffer.
function! s:set_windowlocal_options()
if !&diff " if Vim is currently in diff mode, don't interfere with its folding
let foldmethod = vimwiki#vars#get_global('folding')
if foldmethod =~? '^expr.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^syntax.*'
setlocal foldmethod=syntax
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^custom.*'
" do nothing
else
setlocal foldmethod=manual
normal! zE
endif
endif
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
let &conceallevel = vimwiki#vars#get_global('conceallevel')
endif
if vimwiki#vars#get_global('auto_chdir')
exe 'lcd' vimwiki#vars#get_wikilocal('path')
endif
endfunction
function! s:get_version()
if s:plugin_vers != -1
echo "Stable version: " . s:plugin_vers
else
let val = b:vimwiki_list[a:option]
let a:plugin_rev = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD")
let a:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD")
let a:plugin_date = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci")
if v:shell_error == 0
echo "Branch: " . a:plugin_branch
echo "Revision: " . a:plugin_rev
echo "Date: " . a:plugin_date
else
echo "Unknown version"
endif
endif
endfunction
" XXX no call to vimwiki#base here or else the whole autoload/base gets loaded!
return val
endfunction "}}}
" Set option for current wiki or if third parameter exists for
" wiki with a given index.
" If the option is not found or recognized (i.e. does not exist in
" s:vimwiki_defaults), it is saved in a buffer local dictionary, that acts
" as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiSet(option, value, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(s:vimwiki_defaults, a:option) ||
\ has_key(g:vimwiki_list[idx], a:option)
let g:vimwiki_list[idx][a:option] = a:value
elseif exists('b:vimwiki_list')
let b:vimwiki_list[a:option] = a:value
else
let b:vimwiki_list = {}
let b:vimwiki_list[a:option] = a:value
endif
" Initialization of Vimwiki starts here. Make sure everything below does not
" cause autoload/vimwiki/base.vim to be loaded
endfunction "}}}
call vimwiki#vars#init()
" Clear option for current wiki or if third 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.
function! VimwikiClear(option, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if exists('b:vimwiki_list') && has_key(b:vimwiki_list, a:option)
call remove(b:vimwiki_list, a:option)
endif
endfunction "}}}
" }}}
" }}}
" CALLBACK functions "{{{
" User can redefine it.
if !exists("*VimwikiLinkHandler") "{{{
" Define callback functions which the user can redefine
if !exists("*VimwikiLinkHandler")
function VimwikiLinkHandler(url)
return 0
endfunction
endif "}}}
endif
if !exists("*VimwikiWikiIncludeHandler") "{{{
function! VimwikiWikiIncludeHandler(value) "{{{
if !exists("*VimwikiLinkConverter")
function VimwikiLinkConverter(url, source, target)
" Return the empty string when unable to process link
return ''
endfunction "}}}
endif "}}}
" CALLBACK }}}
endfunction
endif
" DEFAULT wiki {{{
let s:vimwiki_defaults = {}
let s:vimwiki_defaults.path = '~/vimwiki/'
let s:vimwiki_defaults.path_html = '' " '' is replaced by derived path.'_html/'
let s:vimwiki_defaults.css_name = 'style.css'
let s:vimwiki_defaults.index = 'index'
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.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
" file.
let s:vimwiki_defaults.temp = 0
" diary
let s:vimwiki_defaults.diary_rel_path = 'diary/'
let s:vimwiki_defaults.diary_index = 'diary'
let s:vimwiki_defaults.diary_header = 'Diary'
let s:vimwiki_defaults.diary_sort = 'desc'
" Do not change this! Will wait till vim become more datetime awareable.
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
" NEW! in v2.0
" custom_wiki2html
let s:vimwiki_defaults.custom_wiki2html = ''
"
let s:vimwiki_defaults.list_margin = -1
"}}}
" 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')
call s:default('global_ext', 1)
call s:default('ext2syntax', {}) " syntax map keyed on extension
call s:default('hl_headers', 0)
call s:default('hl_cb_checked', 0)
call s:default('list_ignore_newline', 1)
call s:default('listsyms', ' .oOX')
call s:default('use_calendar', 1)
call s:default('table_mappings', 1)
call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('CJK_length', 0)
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('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 2)
call s:default('url_maxsave', 15)
call s:default('debug', 0)
call s:default('diary_months',
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ })
if !exists("*VimwikiWikiIncludeHandler")
function! VimwikiWikiIncludeHandler(value)
return ''
endfunction
endif
call s:default('current_idx', 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
" Scheme regexes {{{
call s:default('schemes', 'wiki\d\+,diary,local')
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')
" Define autocommands for all known wiki extensions
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
\ '\)'
let s:known_extensions = s:vimwiki_get_known_extensions()
call s:default('rxSchemeUrl', rxSchemes.':.*')
call s:default('rxSchemeUrlMatchScheme', '\zs'.rxSchemes.'\ze:.*')
call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
" scheme regexes }}}
"}}}
" AUTOCOMMANDS for all known wiki extensions {{{
let extensions = vimwiki#base#get_known_extensions()
augroup filetypedetect
" clear FlexWiki's stuff
au! * *.wiki
augroup end
if index(s:known_extensions, '.wiki') > -1
augroup filetypedetect
" clear FlexWiki's stuff
au! * *.wiki
augroup end
endif
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()'
autocmd ColorScheme * call s:setup_cleared_syntax()
for s:ext in s:known_extensions
exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()'
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()'
" 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("."))'
if vimwiki#vars#get_global('table_auto_fmt')
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
if vimwiki#vars#get_global('folding') =~? ':quick$'
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
" Don't screw up folds when inserting text that might affect them, until
" leaving insert mode. Foldmethod is local to the window. Protect against
" screwing up folding when switching between windows.
exe 'autocmd InsertEnter *'.s:ext.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'.
\ ' | setlocal foldmethod=manual | endif'
exe 'autocmd InsertLeave,WinLeave *'.s:ext.' if exists("w:last_fdm") |'.
\ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
endif
endfor
augroup END
"}}}
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#base#ui_select()
" XXX: why not using <count> instead of v:count1?
" See Issue 324.
" why not using <count> instead of v:count1?
" See https://github.com/vimwiki-backup/vimwiki/issues/324
command! -count=1 VimwikiIndex
\ call vimwiki#base#goto_index(v:count1)
command! -count=1 VimwikiTabIndex
@ -476,65 +290,85 @@ command! -count=1 VimwikiTabIndex
command! -count=1 VimwikiDiaryIndex
\ call vimwiki#diary#goto_diary_index(v:count1)
command! -count=1 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1)
\ call vimwiki#diary#make_note(v:count)
command! -count=1 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1, 1)
\ call vimwiki#diary#make_note(v:count, 1)
command! -count=1 VimwikiMakeYesterdayDiaryNote
\ call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
command! -count=1 VimwikiMakeTomorrowDiaryNote
\ call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
"}}}
" MAPPINGS {{{
command! VimwikiShowVersion call s:get_version()
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
if !hasmapto('<Plug>VimwikiIndex')
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
exe 'nmap <silent><unique> '.s: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> '.s: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> '.s: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> '.s: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> '.s: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> '.s: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> '.s:map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
"}}}
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote')
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :VimwikiMakeYesterdayDiaryNote<CR>
if !hasmapto('<Plug>VimwikiMakeTomorrowDiaryNote')
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>m <Plug>VimwikiMakeTomorrowDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeTomorrowDiaryNote
\ :VimwikiMakeTomorrowDiaryNote<CR>
" MENU {{{
function! s:build_menu(topmenu)
let idx = 0
while idx < len(g:vimwiki_list)
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
for idx in range(vimwiki#vars#number_of_wikis())
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ \.')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#base#goto_index('.(idx + 1).')<CR>'
\ ' :call vimwiki#base#goto_index('.(idx+1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
let idx += 1
endwhile
\ ' :call vimwiki#diary#make_note('.(idx+1).')<CR>'
endfor
endfunction
function! s:build_table_menu(topmenu)
@ -542,23 +376,23 @@ function! s:build_table_menu(topmenu)
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
exe 'nmenu '.a:topmenu.
\ '.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
exe 'nmenu disable '.a:topmenu.'.Table'
endfunction
"XXX make sure anything below does not cause autoload/base to be loaded
if !empty(g:vimwiki_menu)
call s:build_menu(g:vimwiki_menu)
call s:build_table_menu(g:vimwiki_menu)
endif
" }}}
" CALENDAR Hook "{{{
if g:vimwiki_use_calendar
if !empty(vimwiki#vars#get_global('menu'))
call s:build_menu(vimwiki#vars#get_global('menu'))
call s:build_table_menu(vimwiki#vars#get_global('menu'))
endif
" Hook for calendar.vim
if vimwiki#vars#get_global('use_calendar')
let g:calendar_action = 'vimwiki#diary#calendar_action'
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
endif
"}}}
let &cpo = s:old_cpo

View File

@ -1,396 +1,242 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" 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
if v:version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
"TODO do nothing if ...? (?)
let 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('*/')
endif
let timescans = vimwiki#u#time(starttime) "XXX
"let b:xxx = 1
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
"if VimwikiGet('maxhi')
" ...
"endif
" LINKS: assume this is common to all syntaxes "{{{
" LINKS: WebLinks {{{
" match URL for common protocols;
" see http://en.wikipedia.org/wiki/URI_scheme http://tools.ietf.org/html/rfc3986
let g:vimwiki_rxWebProtocols = ''.
\ '\%('.
\ '\%('.
\ '\%('.join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\):'.
\ '\%(//\)'.
\ '\)'.
\ '\|'.
\ '\%('.join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').'\):'.
\ '\)'
"
let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
\ '\S\{-1,}'. '\%(([^ \t()]*)\)\='
" }}}
" }}}
" -------------------------------------------------------------------------
" 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
let g:vimwiki_rxListItem = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
\ '\)'
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
let g:vimwiki_rxWikiLinkPrefix = '[['
let g:vimwiki_rxWikiLinkSuffix = ']]'
let g:vimwiki_rxWikiLinkSeparator = '|'
" [[URL]]
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSuffix
" [[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_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.'\{-}'
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
" 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
" 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
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLinkPrefix1 = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator
let g:vimwiki_rxWikiLinkSuffix1 = g:vimwiki_rxWikiLinkSuffix
" }}}
" LINKS: setup of wikiincl regexps {{{
let g:vimwiki_rxWikiInclPrefix = '{{'
let g:vimwiki_rxWikiInclSuffix = '}}'
let g:vimwiki_rxWikiInclSeparator = '|'
"
" '{{__LinkUrl__}}'
let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}'
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 g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
"
"
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]}
let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]}
let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix.
\ '\zs'. g:vimwiki_rxWikiInclUrl. '\ze'.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiInclPrefix1 = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.g:vimwiki_rxWikiInclSeparator
let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
\ g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Setup weblink regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
" Maxim:
" Simplify free-standing links: URL starts with non(letter|digit)scheme till
" 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*'
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr = ''
" }}}
let s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
" LINKS: highlighting is complicated due to "nonexistent" links feature
function! s:add_target_syntax_ON(target, type)
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
endfunction
function! s:add_target_syntax_OFF(target) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
function! s:add_target_syntax_OFF(target)
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
endfunction
function! s:highlight_existing_links() "{{{
function! s:highlight_existing_links()
" Wikilink
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
let safe_links = '\%('.vimwiki#base#file_pattern(
\ vimwiki#vars#get_bufferlocal('existing_wikifiles')) . '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
" match [[URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction "}}}
endfunction
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
if vimwiki#vars#get_wikilocal('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink)
call s:add_target_syntax_OFF(vimwiki#vars#get_syntaxlocal('rxWikiLink'))
" WikiIncl
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
call s:add_target_syntax_OFF(vimwiki#vars#get_global('rxWikiIncl'))
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
call s:highlight_existing_links()
let time02 = vimwiki#u#time(starttime) "XXX
else
let time01 = vimwiki#u#time(starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink'), 'VimwikiLink')
" WikiIncl
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
let time02 = vimwiki#u#time(starttime) "XXX
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiIncl'), 'VimwikiLink')
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiLink')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ '\):'
" 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(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let 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(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let 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(vimwiki#vars#get_global('WikiInclTemplate1')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let 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(vimwiki#vars#get_global('WikiInclTemplate2')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" 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*$'
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.'].*$'
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
\ . ' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
\ 'VimwikiLink,@Spell'
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).'/ end=/'.
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).
\ '/me=s-1 transparent fold'
endfor
" }}}
" possibly concealed chars " {{{
let conceal = exists("+conceallevel") ? ' conceal' : ''
" possibly concealed chars
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 /'.
\ vimwiki#vars#get_syntaxlocal('char_eqin').'/'.s:conceal
execute 'syn match VimwikiBoldChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_bold').'/'.s:conceal
execute 'syn match VimwikiItalicChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_italic').'/'.s:conceal
execute 'syn match VimwikiBoldItalicChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'.s:conceal
execute 'syn match VimwikiItalicBoldChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_italicbold').'/'.s:conceal
execute 'syn match VimwikiCodeChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_code').'/'.s:conceal
execute 'syn match VimwikiDelTextChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_deltext').'/'.s:conceal
execute 'syn match VimwikiSuperScript contained /'.
\ vimwiki#vars#get_syntaxlocal('char_superscript').'/'.s:conceal
execute 'syn match VimwikiSubScript contained /'.
\ vimwiki#vars#get_syntaxlocal('char_subscript').'/'.s:conceal
" 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 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
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
if exists("+conceallevel") && vimwiki#vars#get_global('url_maxsave') > 0
let s:options .= s:conceal
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.options
\.'\%([/#?]\w\|\S\{'.vimwiki#vars#get_global('url_maxsave').'}\)`'.' cchar=~'.s:options
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.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 /'.vimwiki#vars#get_global('rx_wikilink_prefix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix1').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix1').'/'.s:options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.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 /'.vimwiki#vars#get_global('rxWikiInclPrefix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix1').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1').'/'.s:options
" non concealed chars " {{{
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.g:vimwiki_rxH.'\+\)\|\%('.g:vimwiki_rxH.'\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldCharT contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeCharT contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
" Emoticons
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
" non concealed chars
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.
\ vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH').
\ '\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_eqin').'/'
execute 'syn match VimwikiBoldCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_bold').'/'
execute 'syn match VimwikiItalicCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_italic').'/'
execute 'syn match VimwikiBoldItalicCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'
execute 'syn match VimwikiItalicBoldCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_italicbold').'/'
execute 'syn match VimwikiCodeCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_code').'/'
execute 'syn match VimwikiDelTextCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_deltext').'/'
execute 'syn match VimwikiSuperScriptT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_superscript').'/'
execute 'syn match VimwikiSubScriptT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_subscript').'/'
execute 'syntax match VimwikiTodo /'. vimwiki#vars#get_global('rxTodo') .'/'
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
@ -405,108 +251,127 @@ 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.'/'
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'
" Lists
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
if vimwiki#vars#get_global('hl_cb_checked') == 1
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
\ . '\s*\[['.vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ']\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
execute 'syntax match VimwikiCheckBoxDone /'
\ . vimwiki#vars#get_syntaxlocal('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'
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
execute 'syntax match VimwikiEqIn /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
\ '/ contains=VimwikiEqInChar'
execute 'syntax match VimwikiEqInT /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
\ '/ contained contains=VimwikiEqInCharT'
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT,@Spell'
execute 'syntax match VimwikiBold /'.vimwiki#vars#get_syntaxlocal('rxBold').
\ '/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.vimwiki#vars#get_syntaxlocal('rxBold').
\ '/ contained contains=VimwikiBoldCharT,@Spell'
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiItalic /'.vimwiki#vars#get_syntaxlocal('rxItalic').
\ '/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /'.vimwiki#vars#get_syntaxlocal('rxItalic').
\ '/ contained contains=VimwikiItalicCharT,@Spell'
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiBoldItalic /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
\ '/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiItalicBold /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
\ '/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT,@Spell'
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contained contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT,@Spell'
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contained contains=VimwikiSuperScriptCharT,@Spell'
execute 'syntax match VimwikiSubScript /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
\ '/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
\ '/ contained contains=VimwikiSubScriptCharT,@Spell'
execute 'syntax match VimwikiCode /'.vimwiki#vars#get_syntaxlocal('rxCode').
\ '/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').
\ '/ contained contains=VimwikiCodeCharT'
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
execute 'syntax region VimwikiPre start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell'
execute 'syntax region VimwikiMath start=/^\s*'.g:vimwiki_rxMathStart.
\ '/ end=/^\s*'.g:vimwiki_rxMathEnd.'\s*$/ contains=@Spell'
execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@Spell'
" 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
syntax match VimwikiPlaceholderParam /\s.*/ contained
syntax match VimwikiPlaceholder
\ /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder
\ /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder
\ /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholderParam /.*/ contained
" html tags
if 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*/\?>#'
if vimwiki#vars#get_global('valid_html_tags') != ''
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').
\ '/ contains=@Spell,VimwikiTodo'
endif
" }}}
" header groups highlighting "{{{
" tags
execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
if g:vimwiki_hl_headers == 0
" header groups highlighting
if vimwiki#vars#get_global('hl_headers') == 0
" Strangely in default colorscheme Title group is not set to bold for cterm...
if !exists("g:colors_name")
hi Title cterm=bold
endif
for 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
" not making it yet another option; needed by ColorScheme autocommand
let g:vimwiki_hcolor_guifg_light = ['#aa5858','#507030','#1030a0','#103040','#505050','#636363']
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='
\ .vimwiki#vars#get_global('hcolor_guifg_'.&bg)[s:i-1].' gui=bold ctermfg='
\ .vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold'
endfor
endif
"}}}
" syntax group highlighting "{{{
hi def link VimwikiMarkers Normal
hi def link VimwikiEqIn Number
@ -542,10 +407,9 @@ 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
@ -587,35 +451,37 @@ hi def link VimwikiCodeCharT VimwikiMarkers
hi def link VimwikiHeaderCharT VimwikiMarkers
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,
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
" EMBEDDED syntax setup
let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes')
if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes')
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), "keep")
endif
if !empty(s:nested)
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
call vimwiki#base#nested_syntax(s:vim_syntax,
\ vimwiki#vars#get_syntaxlocal('rxPreStart').'\%(.*[[:blank:][:punct:]]\)\?'.
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ vimwiki#vars#get_syntaxlocal('rxPreEnd'), 'VimwikiPre')
endfor
endif
" LaTeX
call vimwiki#base#nested_syntax('tex',
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
\ '\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
"}}}
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
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])

View File

@ -1,89 +1,110 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Description: Defines default syntax
" Home: https://github.com/vimwiki/vimwiki/
" s:default_syntax is kind of a reference to the dict in
" g:vimwiki_syntax_variables['default']. It is used here simply as an
" abbreviation for the latter.
let s:default_syntax = g:vimwiki_syntax_variables['default']
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
let s:default_syntax.rxEqIn = '\$[^$`]\+\$'
let s:default_syntax.char_eqin = '\$'
" text: *strong*
" let g:vimwiki_rxBold = '\*[^*]\+\*'
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
" let s:default_syntax.rxBold = '\*[^*]\+\*'
let s:default_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bold = '*'
let s:default_syntax.char_bold = '*'
" text: _emphasis_
" let g:vimwiki_rxItalic = '_[^_]\+_'
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
" let s:default_syntax.rxItalic = '_[^_]\+_'
let s:default_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italic = '_'
let s:default_syntax.char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
let s:default_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bolditalic = '\*_'
let s:default_syntax.char_bolditalic = '\*_'
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
let s:default_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italicbold = '_\*'
let s:default_syntax.char_italicbold = '_\*'
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
let s:default_syntax.rxCode = '`[^`]\+`'
let s:default_syntax.char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
let s:default_syntax.rxDelText = '\~\~[^~`]\+\~\~'
let s:default_syntax.char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
let g:vimwiki_char_superscript = '^'
let s:default_syntax.rxSuperScript = '\^[^^`]\+\^'
let s:default_syntax.char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
let s:default_syntax.rxSubScript = ',,[^,`]\+,,'
let s:default_syntax.char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '='
let g:vimwiki_symH = 1
let s:default_syntax.rxH = '='
let s:default_syntax.symH = 1
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
let s:default_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
let s:default_syntax.rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '# '
let g:vimwiki_rxListBullet = '^\s*[*-]\s'
let g:vimwiki_rxListNumber = '^\s*#\s'
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
" Lists
let s:default_syntax.bullet_types = ['-', '*', '#']
" 1 means the bullets can be repeatet to indicate the level, like * ** ***
" 0 means the bullets stand on their own and the level is indicated by the indentation
let s:default_syntax.recurring_bullets = 0
let s:default_syntax.number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
"this should contain at least one element
"it is used for i_<C-L><C-J> among other things
let s:default_syntax.list_markers = ['-', '1.', '*', 'I)', 'a)']
let s:default_syntax.rxListDefine = '::\(\s\|$\)'
" Preformatted text
let g:vimwiki_rxPreStart = '{{{'
let g:vimwiki_rxPreEnd = '}}}'
let s:default_syntax.rxPreStart = '{{{'
let s:default_syntax.rxPreEnd = '}}}'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let s:default_syntax.rxMathStart = '{{\$'
let s:default_syntax.rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'
let s:default_syntax.rxComment = '^\s*%%.*$'
let s:default_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\)\@='
let s:default_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let s:default_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let s:default_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*'.
\ '[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
\ '\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let s:default_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let s:default_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'

View File

@ -1,89 +1,104 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Description: Defines markdown syntax
" Home: https://github.com/vimwiki/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" see the comments in vimwiki_default.vim for some info about this file
let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$'
let s:markdown_syntax.char_eqin = '\$'
" text: *strong*
" let g:vimwiki_rxBold = '\*[^*]\+\*'
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
" let s:markdown_syntax.rxBold = '\*[^*]\+\*'
let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bold = '*'
let s:markdown_syntax.char_bold = '*'
" text: _emphasis_
" let g:vimwiki_rxItalic = '_[^_]\+_'
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
" let s:markdown_syntax.rxItalic = '_[^_]\+_'
let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italic = '_'
let s:markdown_syntax.char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bolditalic = '\*_'
let s:markdown_syntax.char_bolditalic = '\*_'
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italicbold = '_\*'
let s:markdown_syntax.char_italicbold = '_\*'
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
let s:markdown_syntax.rxCode = '`[^`]\+`'
let s:markdown_syntax.char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
let s:markdown_syntax.rxDelText = '\~\~[^~`]\+\~\~'
let s:markdown_syntax.char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
let g:vimwiki_char_superscript = '^'
let s:markdown_syntax.rxSuperScript = '\^[^^`]\+\^'
let s:markdown_syntax.char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
let s:markdown_syntax.rxSubScript = ',,[^,`]\+,,'
let s:markdown_syntax.char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '#'
let g:vimwiki_symH = 0
let s:markdown_syntax.rxH = '#'
let s:markdown_syntax.symH = 0
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
let s:markdown_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
let s:markdown_syntax.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'
let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
" Lists
let s:markdown_syntax.bullet_types = ['-', '*', '+']
let s:markdown_syntax.recurring_bullets = 0
let s:markdown_syntax.number_types = ['1.']
let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
" Preformatted text
let g:vimwiki_rxPreStart = '```'
let g:vimwiki_rxPreEnd = '```'
let s:markdown_syntax.rxPreStart = '```'
let s:markdown_syntax.rxPreEnd = '```'
" Math block
let g:vimwiki_rxMathStart = '\$\$'
let g:vimwiki_rxMathEnd = '\$\$'
let s:markdown_syntax.rxMathStart = '\$\$'
let s:markdown_syntax.rxMathEnd = '\$\$'
let g:vimwiki_rxComment = '^\s*%%.*$'
let s:markdown_syntax.rxComment = '^\s*%%.*$\|<!--[^>]*-->'
let s:markdown_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
let s:markdown_syntax.header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
let s:markdown_syntax.header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
let s:markdown_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs'.
\ '\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
\ '\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let s:markdown_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let s:markdown_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'

View File

@ -1,355 +1,168 @@
" 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/
" LINKS: assume this is common to all syntaxes "{{{
" }}}
" -------------------------------------------------------------------------
" Load concrete Wiki syntax: sets regexes and templates for headers and links
" -------------------------------------------------------------------------
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink0 regexps {{{
" 0. [[URL]], or [[URL|DESCRIPTION]]
" 0a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0 = g:vimwiki_rxWikiLink
" 0b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0MatchUrl = g:vimwiki_rxWikiLinkMatchUrl
" 0c) match DESCRIPTION within [[URL|DESCRIPTION]]
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 = ']['
" [URL][]
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
" [DESCRIPTION][URL]
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Suffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\\[\]]'
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 g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
let g:vimwiki_rxWikiLink1Prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix = g:vimwiki_rxWikiLink1Suffix.
\ 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
" 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
" 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
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLink1Prefix1 = g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix1 = g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" }}}
" *. ANY wikilink {{{
" *a) match ANY wikilink
let g:vimwiki_rxWikiLink = ''.
\ g:vimwiki_rxWikiLink0.'\|'.
\ g:vimwiki_rxWikiLink1
" *b) match URL within ANY wikilink
let g:vimwiki_rxWikiLinkMatchUrl = ''.
\ g:vimwiki_rxWikiLink0MatchUrl.'\|'.
\ g:vimwiki_rxWikiLink1MatchUrl
" *c) match DESCRIPTION within ANY wikilink
let g:vimwiki_rxWikiLinkMatchDescr = ''.
\ g:vimwiki_rxWikiLink0MatchDescr.'\|'.
\ g:vimwiki_rxWikiLink1MatchDescr
" }}}
" LINKS: setup of wikiincl regexps {{{
" }}}
" LINKS: Syntax helper {{{
" }}}
" LINKS: Setup weblink0 regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
let g:vimwiki_rxWeblink0 = g:vimwiki_rxWeblink
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl0 = g:vimwiki_rxWeblinkMatchUrl
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr0 = g:vimwiki_rxWeblinkMatchDescr
" }}}
" LINKS: Setup weblink1 regexps {{{
let g:vimwiki_rxWeblink1Prefix = '['
let g:vimwiki_rxWeblink1Suffix = ')'
let g:vimwiki_rxWeblink1Separator = ']('
" [DESCRIPTION](URL)
let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWeblink1Suffix
let magic_chars = '.*[]\^$'
let 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.'\{-}'
"
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
" 1. [DESCRIPTION](URL)
" 1a) match [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1 = g:vimwiki_rxWeblink1Prefix.
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Descr.g:vimwiki_rxWeblink1Suffix
" 1b) match URL within [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1MatchUrl = g:vimwiki_rxWeblink1Prefix.
\ g:vimwiki_rxWeblink1Descr. g:vimwiki_rxWeblink1Separator.
\ '\zs'.g:vimwiki_rxWeblink1Url.'\ze'. g:vimwiki_rxWeblink1Suffix
" 1c) match DESCRIPTION within [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1MatchDescr = g:vimwiki_rxWeblink1Prefix.
\ '\zs'.g:vimwiki_rxWeblink1Descr.'\ze'. g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Url. g:vimwiki_rxWeblink1Suffix
" }}}
" Syntax helper {{{
" TODO: image links too !!
" let g:vimwiki_rxWeblink1Prefix1 = '!\?'. g:vimwiki_rxWeblink1Prefix
let g:vimwiki_rxWeblink1Prefix1 = g:vimwiki_rxWeblink1Prefix
let g:vimwiki_rxWeblink1Suffix1 = g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Suffix
" }}}
" *. ANY weblink {{{
" *a) match ANY weblink
let g:vimwiki_rxWeblink = ''.
\ g:vimwiki_rxWeblink1.'\|'.
\ g:vimwiki_rxWeblink0
" *b) match URL within ANY weblink
let g:vimwiki_rxWeblinkMatchUrl = ''.
\ g:vimwiki_rxWeblink1MatchUrl.'\|'.
\ g:vimwiki_rxWeblinkMatchUrl0
" *c) match DESCRIPTION within ANY weblink
let g:vimwiki_rxWeblinkMatchDescr = ''.
\ g:vimwiki_rxWeblink1MatchDescr.'\|'.
\ g:vimwiki_rxWeblinkMatchDescr0
" }}}
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
" LINKS: setup wikilink1 reference link definitions {{{
let g:vimwiki_rxMkdRef = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
\ g:vimwiki_rxWeblink0
let g:vimwiki_rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'.
\ g:vimwiki_rxWeblink0
let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
\ g:vimwiki_rxWeblink0.'\ze'
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
function! s:add_target_syntax_ON(target, type)
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
endfunction
function! s:add_target_syntax_OFF(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
function! s:add_target_syntax_OFF(target, type)
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
endfunction
function! s:wrap_wikilink1_rx(target) "{{{
return g:vimwiki_rxWikiLink1InvalidPrefix.a:target.
\ g:vimwiki_rxWikiLink1InvalidSuffix
endfunction "}}}
function! s:existing_mkd_refs() "{{{
call vimwiki#markdown_base#reset_mkd_refs()
return "\n".join(keys(vimwiki#markdown_base#get_reflinks()), "\n")."\n"
endfunction "}}}
function! s:wrap_wikilink1_rx(target)
return vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidPrefix') . a:target.
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidSuffix')
endfunction
function! s:highlight_existing_links() "{{{
function! s:existing_mkd_refs()
return keys(vimwiki#markdown_base#scan_reflinks())
endfunction
function! s:highlight_existing_links()
" Wikilink1
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
let safe_links = '\%('.
\ vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
\ '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
" Ref links are cached
let safe_reflinks = vimwiki#base#file_pattern(s:existing_mkd_refs())
" match [URL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ safe_links, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ safe_links, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DIRURL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ safe_dirs, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][DIRURL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ safe_dirs, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [MKDREF][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][MKDREF]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
endfunction "}}}
endfunction
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
if vimwiki#vars#get_wikilocal('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
call s:add_target_syntax_OFF(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
call s:highlight_existing_links()
let time02 = vimwiki#u#time(starttime) "XXX
else
let time01 = vimwiki#u#time(starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
let time02 = vimwiki#u#time(starttime) "XXX
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink1'), 'VimwikiWeblink1')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ '\):'
" 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(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" b) match [DESCRIPTION][nonwiki-scheme-URL]
let 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(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'),
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" 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.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i).
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
\ 'VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endfor
" }}}
" concealed chars " {{{
" concealed chars
if exists("+conceallevel")
syntax conceal on
endif
syntax spell toplevel
if g:vimwiki_debug > 1
echom 'WikiLink1 Prefix: '.g:vimwiki_rxWikiLink1Prefix1
echom 'WikiLink1 Suffix: '.g:vimwiki_rxWikiLink1Suffix1
echom 'Weblink1 Prefix: '.g:vimwiki_rxWeblink1Prefix1
echom 'Weblink1 Suffix: '.g:vimwiki_rxWeblink1Suffix1
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 /'.
\ vimwiki#vars#get_syntaxlocal('rx_wikilink_md_prefix').'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rx_wikilink_md_suffix').'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Prefix1').'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Suffix1').'/'.s:options
" conceal weblink1
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.options
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.options
execute 'syn match VimwikiWeblink1Char "'.
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Prefix1').'"'.s:options
execute 'syn match VimwikiWeblink1Char "'.
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options
if exists("+conceallevel")
syntax conceal off
endif
" }}}
" non concealed chars " {{{
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
@ -358,7 +171,6 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ VimwikiWeblink1T,
\ VimwikiWikiLink1T,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
@ -371,22 +183,12 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ VimwikiEqInT,
\ @Spell
" }}}
" header groups highlighting "{{{
"}}}
" syntax group highlighting "{{{
" syntax group highlighting
hi def link VimwikiWeblink1 VimwikiLink
hi def link VimwikiWeblink1T VimwikiLink
hi def link VimwikiWikiLink1 VimwikiLink
hi def link VimwikiWikiLink1T VimwikiLink
"}}}
" EMBEDDED syntax setup "{{{
"}}}
"

View File

@ -1,71 +1,85 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" MediaWiki syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Description: Defines mediaWiki syntax
" Home: https://github.com/vimwiki/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" see the comments in vimwiki_default.vim for some info about this file
let s:media_syntax = g:vimwiki_syntax_variables['media']
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
let s:media_syntax.rxEqIn = '\$[^$`]\+\$'
let s:media_syntax.char_eqin = '\$'
" text: '''strong'''
let g:vimwiki_rxBold = "'''[^']\\+'''"
let g:vimwiki_char_bold = "'''"
let s:media_syntax.rxBold = "'''[^']\\+'''"
let s:media_syntax.char_bold = "'''"
" text: ''emphasis''
let g:vimwiki_rxItalic = "''[^']\\+''"
let g:vimwiki_char_italic = "''"
let s:media_syntax.rxItalic = "''[^']\\+''"
let s:media_syntax.char_italic = "''"
" text: '''''strong italic'''''
let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''"
let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic
let g:vimwiki_char_bolditalic = "'''''"
let g:vimwiki_char_italicbold = g:vimwiki_char_bolditalic
let s:media_syntax.rxBoldItalic = "'''''[^']\\+'''''"
let s:media_syntax.rxItalicBold = s:media_syntax.rxBoldItalic
let s:media_syntax.char_bolditalic = "'''''"
let s:media_syntax.char_italicbold = s:media_syntax.char_bolditalic
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
let s:media_syntax.rxCode = '`[^`]\+`'
let s:media_syntax.char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
let s:media_syntax.rxDelText = '\~\~[^~]\+\~\~'
let s:media_syntax.char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^]\+\^'
let g:vimwiki_char_superscript = '^'
let s:media_syntax.rxSuperScript = '\^[^^]\+\^'
let s:media_syntax.char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,]\+,,'
let g:vimwiki_char_subscript = ',,'
let s:media_syntax.rxSubScript = ',,[^,]\+,,'
let s:media_syntax.char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '='
let g:vimwiki_symH = 1
let s:media_syntax.rxH = '='
let s:media_syntax.symH = 1
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
let s:media_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
let s:media_syntax.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'
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
" Lists
let s:media_syntax.bullet_types = ['*', '#']
let s:media_syntax.recurring_bullets = 1
let s:media_syntax.number_types = []
let s:media_syntax.list_markers = ['*', '#']
let s:media_syntax.rxListDefine = '^\%(;\|:\)\s'
" Preformatted text
let g:vimwiki_rxPreStart = '<pre>'
let g:vimwiki_rxPreEnd = '<\/pre>'
let s:media_syntax.rxPreStart = '<pre>'
let s:media_syntax.rxPreEnd = '<\/pre>'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let s:media_syntax.rxMathStart = '{{\$'
let s:media_syntax.rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'
let s:media_syntax.rxComment = '^\s*%%.*$'
let s:media_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
let s:media_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let s:media_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let s:media_syntax.bold_search = "'''\\zs[^']\\+\\ze'''"
let s:media_syntax.bold_match = '''''''__Text__'''''''
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
" want to call escape() on this string, we must keep it in single quotes
let s:media_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let s:media_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let s:media_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'