273 Commits
v2.1 ... v2.3

Author SHA1 Message Date
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
26 changed files with 5547 additions and 2744 deletions

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

131
README-cn.md Normal file
View File

@ -0,0 +1,131 @@
一个私人的维基——vim插件
==============================================================================
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png)
介绍
------------------------------------------------------------------------------
Vimwiki是私人维基的vim插件 -- 许多有自己代码高亮的text文件。
通过Vimwiki你可以:
* 组织笔记和想法
* 制作代办事项表
* 写文档
一个快速的开始,通常使用`<Leader>ww`(一般是`\ww`)然后创建你的index wiki文件。
通常,它在:
~/vimwiki/index.wiki
在这个文件,输入如下的例子:
= My knowledge base =
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
将你的光标放到`Tasks`(任务)上,并且按回车键去创建一个链接。一旦按下,`Task`将会
变成`[[Tasks]]` -- 一个vimwiki的链接。再按一次回车去打开它。编辑文件保存它
然后按backspace来返回你的index。
一个vimwiki链接可以一句话创建。只需要通过选择visual模式选择这个句子然后按回车。
你可以通过选择`Project Gutenberg`来尝试。结果像是这个样子:
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
基本标记
------------------------------------------------------------------------------
= Header1 =
== Header2 ==
=== Header3 ===
*bold* -- bold text
_italic_ -- italic text
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
列表:
* bullet list item 1
- bullet list item 2
- bullet list item 3
* bullet list item 4
* bullet list item 5
* bullet list item 6
* bullet list item 7
- bullet list item 8
- bullet list item 9
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
查看`:h vimwiki-syntax`
键位绑定
------------------------------------------------------------------------------
normal 模式:
* `<Leader>ww` -- 打开默认的wiki index文件
* `<Leader>wt` -- 通过tab实现上一个功能
* `<Leader>ws` -- 选择并且打开index文件
* `<Leader>wd` -- 删除进入的wiki文件
* `<Leader>wr` -- 重命名你进入的wiki文件
* `<Enter>` -- 进入/创建 wiki 链接
* `<Shift-Enter>` -- 通过分屏模式sp进入/创建wiki链接
* `<Ctrl-Enter>` -- 通过分屏模式vs进入/创建wiki链接
* `<Backspace>` -- 返回父节点
* `<Tab>` -- 寻找下一个wiki链接
* `<Shift-Tab>` -- 寻找上一个wiki链接
查看`:h vimwiki-mappings`
命令
------------------------------------------------------------------------------
* `:Vimwiki2HTML` -- 转换当前wiki成为html
* `:VimwikiAll2HTML` -- 转化你的全部wiki到html
* `:help vimwiki-commands` -- 显示全部命令
安装细节
==============================================================================
在安装之前,你需要做的
------------------------------------------------------------------------------
确定在`vimrc`中,你的设置是这样的。
set nocompatible
filetype plugin on
syntax on
如果没有他们Vimwiki将无法正常工作。
使用 pathogen (译者注:一个插件) (http://www.vim.org/scripts/script.php?script_id=2332 )
------------------------------------------------------------------------------
cd ~/.vim
mkdir bundle
cd bundle
git clone https://github.com/vimwiki/vimwiki.git
然后启动vim使用`:Helptags` 然后 `:help vimwiki`来确保他已经被安装了。

146
README.md
View File

@ -1,38 +1,25 @@
A Personal Wiki For Vim Plugin
A Personal Wiki For Vim
==============================================================================
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2226
Screenshots are available on http://code.google.com/p/vimwiki/
There are also zipped vimwiki files there in case you do not like vimball archives.
Prerequisites
==============================================================================
Make sure you have these settings in your vimrc file:
set nocompatible
filetype plugin on
syntax on
Without them Vimwiki will not work properly.
![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 +28,35 @@ Feed it with the following example:
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
Place your cursor on 'Tasks' and press Enter to create a link. Once pressed,
'Tasks' will become '[[Tasks]]' -- a vimwiki link. Press Enter again to
Place your cursor on `Tasks` and press Enter to create a link. Once pressed,
`Tasks` will become `[[Tasks]]` -- a Vimwiki link. Press Enter again to
open it. Edit the file, save it, and then press Backspace to jump back to your
index.
A vimwiki link can be constructed from more than one word. Just visually
select the words to be linked and press Enter. Try it with 'Project
Gutenberg'. The result should look something like:
A Vimwiki link can be constructed from more than one word. Just visually
select the words to be linked and press Enter. Try it with `Project Gutenberg`.
The result should look something like:
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
For the various options see `:h vimwiki-options`.
Basic Markup
==============================================================================
see `:h vimwiki-syntax`
------------------------------------------------------------------------------
*bold* -- bold
_italic_ -- italic
= Header1 =
== Header2 ==
=== Header3 ===
*bold* -- bold text
_italic_ -- italic text
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
[[wiki link]] -- link with spaces
[[wiki link|description]] -- link with description
Lists:
@ -80,50 +70,66 @@ Lists:
- bullet list item 8
- bullet list item 9
# numbered list item 1
# numbered list item 2
# numbered list item 3
# numbered list item 4
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
= Header1 =
== Header2 ==
=== Header3 ===
For other syntax elements, see `:h vimwiki-syntax`
Key bindings
==============================================================================
see `:h vimwiki-mappings`
------------------------------------------------------------------------------
normal mode:
normal mode:
* `<Leader>ww` -- Open default wiki index file.
* `<Leader>wt` -- Open default wiki index file in a new tab.
* `<Leader>ws` -- Select and open wiki index file.
* `<Leader>wd` -- Delete wiki file you are in.
* `<Leader>wr` -- Rename wiki file you are in.
* `<Enter>` -- Folow/Create wiki link
* `<Shift-Enter>` -- Split and folow/create wiki link
* `<Ctrl-Enter>` -- Vertical split and folow/create wiki link
* `<Backspace>` -- Go back to parent(previous) wiki link
* `<Tab>` -- Find next wiki link
* `<Shift-Tab>` -- Find previous wiki link
* `<Leader>ww` -- Open default wiki index file.
* `<Leader>wt` -- Open default wiki index file in a new tab.
* `<Leader>ws` -- Select and open wiki index file.
* `<Leader>wd` -- Delete wiki file you are in.
* `<Leader>wr` -- Rename wiki file you are in.
* `<Enter>` -- Follow/Create wiki link
* `<Shift-Enter>` -- Split and follow/create wiki link
* `<Ctrl-Enter>` -- Vertical split and follow/create wiki link
* `<Backspace>` -- Go back to parent(previous) wiki link
* `<Tab>` -- Find next wiki link
* `<Shift-Tab>` -- Find previous wiki link
For more keys, see `:h vimwiki-mappings`
Commands
==============================================================================
Commands
------------------------------------------------------------------------------
* `:Vimwiki2HTML` -- Convert current wiki link to HTML
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
* `:Vimwiki2HTML` -- Convert current wiki link to HTML
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
* `:help vimwiki-commands` -- list all commands
Install details
==============================================================================
Using pathogen (http://www.vim.org/scripts/script.php?script_id=2332)
Installation
==============================================================================
Prerequisites
------------------------------------------------------------------------------
Make sure you have these settings in your vimrc file:
set nocompatible
filetype plugin on
syntax on
Without them Vimwiki will not work properly.
Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
------------------------------------------------------------------------------
cd ~/.vim
mkdir bundle
cd bundle
git clone git://github.com/vim-scripts/vimwiki.git
git clone https://github.com/vimwiki/vimwiki.git
Then launch vim and run `:help vimwiki` to verify it was installed.
Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it in `~/.vim/bundle/`
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed.

File diff suppressed because it is too large Load Diff

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,8 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Handle diary notes
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Home: https://github.com/vimwiki/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_diary_auto") || &cp
@ -25,17 +24,6 @@ function! s:get_date_link(fmt) "{{{
return strftime(a:fmt)
endfunction "}}}
function! s:link_exists(lines, link) "{{{
let link_exists = 0
for line in a:lines
if line =~ escape(a:link, '[]\')
let link_exists = 1
break
endif
endfor
return link_exists
endfunction "}}}
function! s:diary_path(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
@ -54,7 +42,7 @@ endfunction "}}}
function! s:get_position_links(link) "{{{
let idx = -1
let links = []
if a:link =~ '^\d\{4}-\d\d-\d\d'
if a:link =~# '^\d\{4}-\d\d-\d\d'
let links = keys(s:get_diary_links())
" include 'today' into links
if index(links, s:diary_date_link()) == -1
@ -81,7 +69,7 @@ fun! s:read_captions(files) "{{{
if filereadable(fl)
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
if line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
if line =~# g:vimwiki_rxHeader && !has_key(result, fl_key)
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
endif
endfor
@ -95,18 +83,15 @@ fun! s:read_captions(files) "{{{
return result
endfun "}}}
fun! s:get_diary_links(...) "{{{
fun! s:get_diary_links() "{{{
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~ "'.escape(rx, '\').'"')
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
" remove backup files (.wiki~)
call filter(files, 'v:val !~ ''.*\~$''')
call filter(files, 'v:val !~# ''.*\~$''')
if a:0
call add(files, a:1)
endif
let links_with_captions = s:read_captions(files)
return links_with_captions
@ -133,36 +118,27 @@ fun! s:group_links(links) "{{{
return result
endfun "}}}
fun! s:sort(lst) "{{{
if VimwikiGet("diary_sort") == 'desc'
function! s:sort(lst) "{{{
if VimwikiGet("diary_sort") ==? 'desc'
return reverse(sort(a:lst))
else
return sort(a:lst)
endif
endfun "}}}
endfunction "}}}
fun! s:format_diary(...) "{{{
function! s:format_diary() "{{{
let result = []
call add(result, substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''))
let g_files = s:group_links(s:get_diary_links())
if a:0
let g_files = s:group_links(s:get_diary_links(a:1))
else
let g_files = s:group_links(s:get_diary_links())
endif
" for year in s:rev(sort(keys(g_files)))
for year in s:sort(keys(g_files))
call add(result, '')
call add(result, substitute(g:vimwiki_rxH2_Template, '__Header__', year , ''))
" for month in s:rev(sort(keys(g_files[year])))
for month in s:sort(keys(g_files[year]))
call add(result, '')
call add(result, substitute(g:vimwiki_rxH3_Template, '__Header__', s:get_month_name(month), ''))
" for [fl, cap] in s:rev(sort(items(g_files[year][month])))
for [fl, cap] in s:sort(items(g_files[year][month]))
if empty(cap)
let entry = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', fl, '')
@ -177,53 +153,15 @@ fun! s:format_diary(...) "{{{
endfor
endfor
call add(result, '')
return result
endfun "}}}
function! s:delete_diary_section() "{{{
" remove diary section
let old_pos = getpos('.')
let ln_start = -1
let ln_end = -1
call cursor(1, 1)
if search(substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''), 'Wc')
let ln_start = line('.')
if search(g:vimwiki_rxH1, 'W')
let ln_end = line('.') - 1
else
let ln_end = line('$')
endif
endif
if ln_start < 0 || ln_end < 0
call setpos('.', old_pos)
return
endif
if !&readonly
exe ln_start.",".ln_end."delete _"
endif
call setpos('.', old_pos)
endfunction "}}}
function! s:insert_diary_section() "{{{
if !&readonly
let ln = line('.')
call append(ln, s:format_diary())
if ln == 1 && getline(ln) == ''
1,1delete
endif
endif
endfunction "}}}
" Diary index stuff }}}
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!"
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
return
endif
@ -234,8 +172,7 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
let idx = 0
endif
call vimwiki#base#validate_wiki_options(idx)
call vimwiki#base#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
if a:0 && a:1 == 1
let cmd = 'tabedit'
@ -254,7 +191,7 @@ 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!"
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
return
endif
@ -265,8 +202,7 @@ function! vimwiki#diary#goto_diary_index(wnum) "{{{
let idx = 0
endif
call vimwiki#base#validate_wiki_options(idx)
call vimwiki#base#edit_file('e', s:diary_index(idx))
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
call vimwiki#base#setup_buffer_state(idx)
endfunction "}}}
@ -311,13 +247,14 @@ function! vimwiki#diary#goto_prev_day() "{{{
endfunction "}}}
function! vimwiki#diary#generate_diary_section() "{{{
let current_file = vimwiki#u#path_norm(expand("%:p"))
let diary_file = vimwiki#u#path_norm(s:diary_index())
if current_file == diary_file
call s:delete_diary_section()
call s:insert_diary_section()
let current_file = vimwiki#path#path_norm(expand("%:p"))
let diary_file = vimwiki#path#path_norm(s:diary_index())
if vimwiki#path#is_equal(current_file, diary_file)
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.g:vimwiki_rxHeader.'\)'
call vimwiki#base#update_listing_in_buffer(s:format_diary(),
\ VimwikiGet('diary_header'), content_rx, line('$')+1, 1)
else
echom "vimwiki: You can generate diary links only in a diary index page!"
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
endif
endfunction "}}}
@ -329,7 +266,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
let link = a:year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir == 'V'
if a:dir ==? 'V'
vsplit
else
split
@ -341,8 +278,8 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
endif
endif
" Create diary note for a selected date in default wiki.
call vimwiki#diary#make_note(1, 0, link)
" XXX: Well, +1 is for inconsistent index basing...
call vimwiki#diary#make_note(g:vimwiki_current_idx+1, 0, link)
endfunction "}}}
" Sign function.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Link functions for markdown syntax
" Author: Stuart Andrews <stu.andrews@gmail.com> (.. i.e. don't blame Maxim!)
" Home: http://code.google.com/p/vimwiki/
" Home: https://github.com/vimwiki/vimwiki/
" MISC helper functions {{{
@ -17,7 +16,8 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{
let mkd_refs = {}
" construct list of references using vimgrep
try
execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
" Why noautocmd? Because https://github.com/vimwiki/vimwiki/issues/121
noautocmd execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
"Ignore it, and move on to the next file
endtry
@ -66,48 +66,11 @@ function! vimwiki#markdown_base#open_reflink(link) " {{{
return 0
endif
endfunction " }}}
" s:normalize_path
" s:path_html
" vimwiki#base#apply_wiki_options
" vimwiki#base#read_wiki_options
" vimwiki#base#validate_wiki_options
" vimwiki#base#setup_buffer_state
" vimwiki#base#cache_buffer_state
" vimwiki#base#recall_buffer_state
" vimwiki#base#print_wiki_state
" vimwiki#base#mkdir
" vimwiki#base#file_pattern
" vimwiki#base#branched_pattern
" vimwiki#base#subdir
" vimwiki#base#current_subdir
" vimwiki#base#invsubdir
" vimwiki#base#resolve_scheme
" vimwiki#base#system_open_link
" vimwiki#base#open_link
" vimwiki#base#generate_links
" vimwiki#base#goto
" vimwiki#base#backlinks
" vimwiki#base#get_links
" vimwiki#base#edit_file
" vimwiki#base#search_word
" vimwiki#base#matchstr_at_cursor
" vimwiki#base#replacestr_at_cursor
" s:print_wiki_list
" s:update_wiki_link
" s:update_wiki_links_dir
" s:tail_name
" s:update_wiki_links
" s:get_wiki_buffers
" s:open_wiki_buffer
" vimwiki#base#nested_syntax
" }}}
" WIKI link following functions {{{
" vimwiki#base#find_next_link
" vimwiki#base#find_prev_link
" vimwiki#base#follow_link
" vimwiki#markdown_base#follow_link
function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
" to VimwikiLinkHandler, or failing that, the default open_link handler
" echom "markdown_base#follow_link"
@ -118,11 +81,11 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
" XXX: @Maxim: most likely! I am still working on a seemless way to
" integrate regexp's without complicating syntax/vimwiki.vim
else
if a:split == "split"
if a:split ==# "split"
let cmd = ":split "
elseif a:split == "vsplit"
elseif a:split ==# "vsplit"
let cmd = ":vsplit "
elseif a:split == "tabnew"
elseif a:split ==# "tabnew"
let cmd = ":tabnew "
else
let cmd = ":e "
@ -145,6 +108,8 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
if lnk != ""
if !VimwikiLinkHandler(lnk)
if !vimwiki#markdown_base#open_reflink(lnk)
" remove the extension from the filename if exists
let lnk = substitute(lnk, VimwikiGet('ext').'$', '', '')
call vimwiki#base#open_link(cmd, lnk)
endif
endif
@ -160,29 +125,7 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
endfunction " }}}
" vimwiki#base#go_back_link
" vimwiki#base#goto_index
" vimwiki#base#delete_link
" vimwiki#base#rename_link
" vimwiki#base#ui_select
" TEXT OBJECTS functions {{{
" vimwiki#base#TO_header
" vimwiki#base#TO_table_cell
" vimwiki#base#TO_table_col
" }}}
" HEADER functions {{{
" vimwiki#base#AddHeaderLevel
" vimwiki#base#RemoveHeaderLevel
"}}}
" LINK functions {{{
" vimwiki#base#apply_template
" s:clean_url
" vimwiki#base#normalize_link_helper
" vimwiki#base#normalize_imagelink_helper
" s:normalize_link_syntax_n
function! s:normalize_link_syntax_n() " {{{
@ -192,9 +135,6 @@ function! s:normalize_link_syntax_n() " {{{
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
if !empty(lnk)
" NO-OP !!
if g:vimwiki_debug > 1
echomsg "WikiIncl: ".lnk." Sub: ".lnk
endif
return
endif
@ -205,9 +145,6 @@ function! s:normalize_link_syntax_n() " {{{
\ 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
return
endif
@ -218,9 +155,6 @@ function! s:normalize_link_syntax_n() " {{{
\ 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
return
endif
@ -231,9 +165,6 @@ function! s:normalize_link_syntax_n() " {{{
\ 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
return
endif
@ -244,11 +175,8 @@ function! s:normalize_link_syntax_n() " {{{
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWord, '',
\ g:vimwiki_WikiLinkTemplate1)
\ g:vimwiki_Weblink1Template)
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
if g:vimwiki_debug > 1
echomsg "Word: ".lnk." Sub: ".sub
endif
return
endif
@ -266,9 +194,10 @@ function! s:normalize_link_syntax_v() " {{{
try
norm! gvy
let visual_selection = @"
let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
let link = substitute(g:vimwiki_Weblink1Template, '__LinkUrl__', '\='."'".visual_selection."'", '')
let link = substitute(link, '__LinkDescription__', '\='."'".visual_selection."'", '')
call setreg('"', visual_selection, 'v')
call setreg('"', link, 'v')
" paste result
norm! `>pgvd

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

@ -0,0 +1,169 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Path manipulation functions
" Home: https://github.com/vimwiki/vimwiki/
function! vimwiki#path#chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}}
" Define path-compare function, either case-sensitive or not, depending on OS.
"{{{ " function! vimwiki#path#is_equal(p1, p2)
if vimwiki#u#is_windows()
function! vimwiki#path#is_equal(p1, p2)
return a:p1 ==? a:p2
endfunction
else
function! vimwiki#path#is_equal(p1, p2)
return a:p1 ==# a:p2
endfunction
endif "}}}
" collapse sections like /a/b/../c to /a/c
function! vimwiki#path#normalize(path) "{{{
let path = a:path
while 1
let result = substitute(path, '/[^/]\+/\.\.', '', '')
if result ==# path
break
endif
let path = result
endwhile
return result
endfunction "}}}
function! vimwiki#path#path_norm(path) "{{{
" /-slashes
if a:path !~# '^scp:'
let path = substitute(a:path, '\', '/', 'g')
" treat multiple consecutive slashes as one path separator
let path = substitute(path, '/\+', '/', 'g')
" ensure that we are not fooled by a symbolic link
return resolve(path)
else
return a:path
endif
endfunction "}}}
function! vimwiki#path#is_link_to_dir(link) "{{{
" Check if link is to a directory.
" It should be ended with \ or /.
return a:link =~# '\m[/\\]$'
endfunction "}}}
function! vimwiki#path#abs_path_of_link(link) "{{{
return vimwiki#path#normalize(expand("%:p:h").'/'.a:link)
endfunction "}}}
" return longest common path prefix of 2 given paths.
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
function! vimwiki#path#path_common_pfx(path1, path2) "{{{
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
let idx = 0
let minlen = min([len(p1), len(p2)])
while (idx < minlen) && vimwiki#path#is_equal(p1[idx], p2[idx])
let idx = idx + 1
endwhile
if idx == 0
return ''
else
return join(p1[: idx-1], '/')
endif
endfunction "}}}
function! vimwiki#path#wikify_path(path) "{{{
let result = resolve(expand(a:path, ':p'))
if vimwiki#u#is_windows()
let result = substitute(result, '\\', '/', 'g')
endif
let result = vimwiki#path#chomp_slash(result)
return result
endfunction "}}}
" Returns: the relative path from a:dir to a:file
function! vimwiki#path#relpath(dir, file) "{{{
let result = []
let dir = split(a:dir, '/')
let file = split(a:file, '/')
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
call remove(dir, 0)
call remove(file, 0)
endwhile
if empty(dir) && empty(file)
return './'
endif
for segment in dir
let result += ['..']
endfor
for segment in file
let result += [segment]
endfor
let result_path = join(result, '/')
if a:file =~ '\m/$'
let result_path .= '/'
endif
return result_path
endfunction "}}}
" If the optional argument provided and nonzero,
" it will ask before creating a directory
" Returns: 1 iff directory exists or successfully created
function! vimwiki#path#mkdir(path, ...) "{{{
let path = expand(a:path)
if path =~# '^scp:'
" we can not do much, so let's pretend everything is ok
return 1
endif
if isdirectory(path)
return 1
else
if !exists("*mkdir")
return 0
endif
let path = vimwiki#path#chomp_slash(path)
if vimwiki#u#is_windows() && !empty(g:vimwiki_w32_dir_enc)
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
endif
if a:0 && a:1 && input("Vimwiki: Make new directory: "
\ .path."\n [y]es/[N]o? ") !~? '^y'
return 0
endif
call mkdir(path, "p")
return 1
endif
endfunction " }}}
function! vimwiki#path#is_absolute(path) "{{{
if vimwiki#u#is_windows()
return a:path =~? '\m^\a:'
else
return a:path =~# '\m^/\|\~/'
endif
endfunction "}}}
" 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,6 +24,7 @@ del {text-decoration: line-through; color: #777777;}
.justright {text-align: right;}
.justcenter {text-align: center;}
.center {margin-left: auto; margin-right: auto;}
.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;}
/* classes for items of todo lists */
.done0 {
@ -31,35 +32,30 @@ del {text-decoration: line-through; color: #777777;}
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .2em;
margin-left: -2em;
padding-left: 1.5em;
}
.done1 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done2 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done3 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done4 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}

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

@ -0,0 +1,342 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
let s:TAGS_METADATA_FILE_NAME = '.tags'
" Tags metadata in-memory format:
" metadata := { 'pagename': [entries, ...] }
" entry := { 'tagname':..., 'lineno':..., 'link':... }
" Tags metadata in-file format:
"
" Is based on CTags format (see |tags-file-format|).
"
" {tagaddress} is set to lineno. We'll let vim search by exact line number; we
" can afford that, we assume metadata file is always updated before use.
"
" Pagename and link are not saved in standard ctags fields, so we'll add
" an optional field, "vimwiki:". In this field, we encode tab-separated values
" of missing parameters -- "pagename" and "link".
" vimwiki#tags#update_tags
" Update tags metadata.
" a:full_rebuild == 1: re-scan entire wiki
" a:full_rebuild == 0: only re-scan current page
" a:all_files == '': only if the file is newer than .tags
function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
let all_files = a:all_files != ''
if !a:full_rebuild
" Updating for one page (current)
let page_name = VimwikiGet('subdir') . expand('%:t:r')
" Collect tags in current file
let tags = s:scan_tags(getline(1, '$'), page_name)
" Load metadata file
let metadata = s:load_tags_metadata()
" Drop old tags
let metadata = s:remove_page_from_tags(metadata, page_name)
" Merge in the new ones
let metadata = s:merge_tags(metadata, page_name, tags)
" Save
call s:write_tags_metadata(metadata)
else " full rebuild
let files = vimwiki#base#find_files(g:vimwiki_current_idx, 0)
let wiki_base_dir = VimwikiGet('path', g:vimwiki_current_idx)
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 " }}}
" s:scan_tags
" Scans the list of text lines (argument) and produces tags metadata as a
" list of tag entries.
function! s:scan_tags(lines, page_name) "{{{
let entries = []
" Code wireframe to scan for headers -- borrowed from
" vimwiki#base#get_anchors(), with minor modifications.
let rxheader = g:vimwiki_{VimwikiGet('syntax')}_header_search
let rxtag = g:vimwiki_{VimwikiGet('syntax')}_tag_search
let anchor_level = ['', '', '', '', '', '', '']
let current_complete_anchor = ''
let PROXIMITY_LINES_NR = 2
let header_line_nr = - (2 * PROXIMITY_LINES_NR)
for line_nr in range(1, len(a:lines))
let line = a:lines[line_nr - 1]
" process headers
let h_match = matchlist(line, rxheader)
if !empty(h_match) " got a header
let header_line_nr = line_nr
let header = vimwiki#u#trim(h_match[2])
let level = len(h_match[1])
let anchor_level[level-1] = header
for l in range(level, 6)
let anchor_level[l] = ''
endfor
if level == 1
let current_complete_anchor = header
else
let current_complete_anchor = ''
for l in range(level-1)
if anchor_level[l] != ''
let current_complete_anchor .= anchor_level[l].'#'
endif
endfor
let current_complete_anchor .= header
endif
continue " tags are not allowed in headers
endif
" TODO ignore verbatim blocks
" Scan line for tags. There can be many of them.
let str = line
while 1
let tag_group = matchstr(str, rxtag)
if tag_group == ''
break
endif
let tagend = matchend(str, rxtag)
let str = str[(tagend):]
for tag in split(tag_group, ':')
" Create metadata entry
let entry = {}
let entry.tagname = tag
let entry.lineno = line_nr
if line_nr <= PROXIMITY_LINES_NR && header_line_nr < 0
" Tag appeared at the top of the file
let entry.link = a:page_name
elseif line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
" Tag appeared right below a header
let entry.link = a:page_name . '#' . current_complete_anchor
else
" Tag stands on its own
let entry.link = a:page_name . '#' . tag
endif
call add(entries, entry)
endfor
endwhile
endfor " loop over lines
return entries
endfunction " }}}
" vimwiki#tags#metadata_file_path
" Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort "{{{
return fnamemodify(vimwiki#path#join_path(VimwikiGet('path'), s:TAGS_METADATA_FILE_NAME), ':p')
endfunction " }}}
" s:load_tags_metadata
" Loads tags metadata from file, returns a dictionary
function! s:load_tags_metadata() abort "{{{
let metadata_path = vimwiki#tags#metadata_file_path()
if !filereadable(metadata_path)
return {}
endif
let metadata = {}
for line in readfile(metadata_path)
if line =~ '^!_TAG_FILE_'
continue
endif
let parts = matchlist(line, '^\(.\{-}\);"\(.*\)$')
if parts[0] == '' || parts[1] == '' || parts[2] == ''
throw 'VimwikiTags1: Metadata file corrupted'
endif
let std_fields = split(parts[1], '\t')
if len(std_fields) != 3
throw 'VimwikiTags2: Metadata file corrupted'
endif
let vw_part = parts[2]
if vw_part[0] != "\t"
throw 'VimwikiTags3: Metadata file corrupted'
endif
let vw_fields = split(vw_part[1:], "\t")
if len(vw_fields) != 1 || vw_fields[0] !~ '^vimwiki:'
throw 'VimwikiTags4: Metadata file corrupted'
endif
let vw_data = substitute(vw_fields[0], '^vimwiki:', '', '')
let vw_data = substitute(vw_data, '\\n', "\n", 'g')
let vw_data = substitute(vw_data, '\\r', "\r", 'g')
let vw_data = substitute(vw_data, '\\t', "\t", 'g')
let vw_data = substitute(vw_data, '\\\\', "\\", 'g')
let vw_fields = split(vw_data, "\t")
if len(vw_fields) != 2
throw 'VimwikiTags5: Metadata file corrupted'
endif
let pagename = vw_fields[0]
let entry = {}
let entry.tagname = std_fields[0]
let entry.lineno = std_fields[2]
let entry.link = vw_fields[1]
if has_key(metadata, pagename)
call add(metadata[pagename], entry)
else
let metadata[pagename] = [entry]
endif
endfor
return metadata
endfunction " }}}
" s:remove_page_from_tags
" Removes all entries for given page from metadata in-place. Returns updated
" metadata (just in case).
function! s:remove_page_from_tags(metadata, page_name) "{{{
if has_key(a:metadata, a:page_name)
call remove(a:metadata, a:page_name)
return a:metadata
else
return a:metadata
endif
endfunction " }}}
" s:merge_tags
" Merges metadata of one file into a:metadata
function! s:merge_tags(metadata, pagename, file_metadata) "{{{
let metadata = a:metadata
let metadata[a:pagename] = a:file_metadata
return metadata
endfunction " }}}
" s:tags_entry_cmp
" 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 " }}}
" s:write_tags_metadata
" Saves metadata object into a file. Throws exceptions in case of problems.
function! s:write_tags_metadata(metadata) "{{{
let metadata_path = vimwiki#tags#metadata_file_path()
let tags = []
for pagename in keys(a:metadata)
for entry in a:metadata[pagename]
let entry_data = pagename . "\t" . entry.link
let entry_data = substitute(entry_data, "\\", '\\\\', 'g')
let entry_data = substitute(entry_data, "\t", '\\t', 'g')
let entry_data = substitute(entry_data, "\r", '\\r', 'g')
let entry_data = substitute(entry_data, "\n", '\\n', 'g')
call add(tags,
\ entry.tagname . "\t"
\ . pagename . VimwikiGet('ext') . "\t"
\ . entry.lineno
\ . ';"'
\ . "\t" . "vimwiki:" . entry_data
\)
endfor
endfor
call sort(tags, "s:tags_entry_cmp")
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
call writefile(tags, metadata_path)
endfunction " }}}
" vimwiki#tags#get_tags
" Returns list of unique tags found in the .tags file
function! vimwiki#tags#get_tags() "{{{
let metadata = s:load_tags_metadata()
let tags = {}
for entries in values(metadata)
for entry in entries
let tags[entry.tagname] = 1
endfor
endfor
return keys(tags)
endfunction " }}}
" vimwiki#tags#generate_tags
" Similar to vimwiki#base#generate_links. In the current buffer, appends
" tags and references to all their instances. If no arguments (tags) are
" specified, outputs all tags.
function! vimwiki#tags#generate_tags(...) abort "{{{
let need_all_tags = (a:0 == 0)
let specific_tags = a:000
let metadata = s:load_tags_metadata()
" make a dictionary { tag_name: [tag_links, ...] }
let tags_entries = {}
for entries in values(metadata)
for entry in entries
if has_key(tags_entries, entry.tagname)
call add(tags_entries[entry.tagname], entry.link)
else
let tags_entries[entry.tagname] = [entry.link]
endif
endfor
endfor
let lines = []
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
\ vimwiki#lst#default_symbol().' '
for tagname in sort(keys(tags_entries))
if need_all_tags || index(specific_tags, tagname) != -1
call extend(lines, [
\ '',
\ substitute(g:vimwiki_rxH2_Template, '__Header__', tagname, ''),
\ '' ])
for taglink in sort(tags_entries[tagname])
call add(lines, bullet .
\ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', taglink, ''))
endfor
endif
endfor
let links_rx = '\m\%(^\s*$\)\|\%('.g:vimwiki_rxH2.'\)\|\%(^\s*'
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
\ .g:vimwiki_rxWikiLink.'$\)'
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx,
\ line('$')+1, 1)
endfunction " }}}
" vimwiki#tags#complete_tags
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort " {{{
" We can safely ignore args if we use -custom=complete option, Vim engine
" will do the job of filtering.
let taglist = vimwiki#tags#get_tags()
return join(taglist, "\n")
endfunction " }}}

View File

@ -5,8 +5,7 @@
" |--------|------------|-------|--------|---------|
" | Have | fun! | Drink | tea | Period. |
"
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Home: https://github.com/vimwiki/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_tbl_auto") || &cp
@ -54,28 +53,28 @@ function! s:sep_splitter() "{{{
endfunction "}}}
function! s:is_table(line) "{{{
return s:is_separator(a:line) || (a:line !~ s:rxSep().s:rxSep() && a:line =~ '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
return s:is_separator(a:line) || (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
endfunction "}}}
function! s:is_separator_tail(line) "{{{
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), a:cnum - 1)
"echomsg "DEBUG is_last_column> ".(line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$')
return line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$'
"echomsg "DEBUG is_last_column> ".(line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$')
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
endfunction "}}}
function! s:is_first_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
"echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
"echomsg "DEBUG is_first_column> ".(line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
return line =~# '^\s*$' || (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction "}}}
function! s:count_separators_up(lnum) "{{{
@ -134,11 +133,11 @@ function! vimwiki#tbl#get_cells(line) "{{{
for idx in range(strlen(a:line))
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state == 'NONE'
if state ==# 'NONE'
if ch == '|'
let state = 'CELL'
endif
elseif state == 'CELL'
elseif state ==# 'CELL'
if ch == '[' || ch == '{'
let state = 'BEFORE_QUOTE_START'
let quote = ch
@ -148,7 +147,7 @@ function! vimwiki#tbl#get_cells(line) "{{{
else
let cell .= ch
endif
elseif state == 'BEFORE_QUOTE_START'
elseif state ==# 'BEFORE_QUOTE_START'
if ch == '[' || ch == '{'
let state = 'QUOTE'
let quote .= ch
@ -157,12 +156,12 @@ function! vimwiki#tbl#get_cells(line) "{{{
let cell .= quote.ch
let quote = ''
endif
elseif state == 'QUOTE'
elseif state ==# 'QUOTE'
if ch == ']' || ch == '}'
let state = 'BEFORE_QUOTE_END'
endif
let quote .= ch
elseif state == 'BEFORE_QUOTE_END'
elseif state ==# 'BEFORE_QUOTE_END'
if ch == ']' || ch == '}'
let state = 'CELL'
endif
@ -235,13 +234,13 @@ function! s:get_rows(lnum) "{{{
return upper_rows + lower_rows
endfunction "}}}
function! s:get_cell_max_lens(lnum) "{{{
function! s:get_cell_max_lens(lnum, ...) "{{{
let max_lens = {}
for [lnum, row] in s:get_rows(a:lnum)
if s:is_separator(row)
continue
endif
let cells = vimwiki#tbl#get_cells(row)
let cells = a:0 > 1 ? a:1[lnum - a:2] : vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let value = cells[idx]
if has_key(max_lens, idx)
@ -255,17 +254,23 @@ function! s:get_cell_max_lens(lnum) "{{{
endfunction "}}}
function! s:get_aligned_rows(lnum, col1, col2) "{{{
let max_lens = s:get_cell_max_lens(a:lnum)
let rows = []
for [lnum, row] in s:get_rows(a:lnum)
let rows = s:get_rows(a:lnum)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row))
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum)
let result = []
for [lnum, row] in rows
if s:is_separator(row)
let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
else
let new_row = s:fmt_row(row, max_lens, a:col1, a:col2)
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, a:col1, a:col2)
endif
call add(rows, [lnum, new_row])
call add(result, [lnum, new_row])
endfor
return rows
return result
endfunction "}}}
" Number of the current column. Starts from 0.
@ -303,20 +308,19 @@ function! s:fmt_cell(cell, max_len) "{{{
return cell
endfunction "}}}
function! s:fmt_row(line, max_lens, col1, col2) "{{{
function! s:fmt_row(cells, max_lens, col1, col2) "{{{
let new_line = s:rxSep()
let cells = vimwiki#tbl#get_cells(a:line)
for idx in range(len(cells))
for idx in range(len(a:cells))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
let value = cells[idx]
let value = a:cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep()
endfor
let idx = len(cells)
let idx = len(a:cells)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep()
let idx += 1
@ -411,7 +415,6 @@ function! vimwiki#tbl#goto_prev_col() "{{{
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
@ -447,7 +450,7 @@ endfunction "}}}
function! vimwiki#tbl#kbd_cr() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<CR>"
return ""
endif
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
@ -490,7 +493,7 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
endfunction "}}}
function! vimwiki#tbl#format(lnum, ...) "{{{
if !(&filetype == 'vimwiki')
if !(&filetype ==? 'vimwiki')
return
endif
let line = getline(a:lnum)
@ -507,9 +510,14 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
endif
let indent = s:get_indent(a:lnum)
if &expandtab
let indentstring = repeat(' ', indent)
else
let indentstring = repeat(' ', indent / &tabstop) . repeat(' ', indent % &tabstop)
endif
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
let row = repeat(' ', indent).row
let row = indentstring.row
call setline(lnum, row)
endfor
@ -560,7 +568,7 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
endfunction "}}}
function! vimwiki#tbl#reset_tw(lnum) "{{{
if !(&filetype == 'vimwiki')
if !(&filetype ==? 'vimwiki')
return
endif
let line = getline(a:lnum)

View File

@ -1,8 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Utility functions
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Desc: Utility functions
" Home: https://github.com/vimwiki/vimwiki/
function! vimwiki#u#trim(string, ...) "{{{
let chars = ''
@ -14,7 +13,6 @@ function! vimwiki#u#trim(string, ...) "{{{
return res
endfunction "}}}
" Builtin cursor doesn't work right with unicode characters.
function! vimwiki#u#cursor(lnum, cnum) "{{{
exe a:lnum
@ -25,53 +23,46 @@ function! vimwiki#u#is_windows() "{{{
return has("win32") || has("win64") || has("win95") || has("win16")
endfunction "}}}
function! vimwiki#u#chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}}
function! vimwiki#u#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) "{{{
let first_sym = matchstr(a:line, '\S')
return len(matchstr(a:line, first_sym.'\+'))
endfunction "}}}
" return longest common path prefix of 2 given paths.
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
function! vimwiki#u#path_common_pfx(path1, path2) "{{{
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
let idx = 0
let minlen = min([len(p1), len(p2)])
while (idx < minlen) && (p1[idx] ==? p2[idx])
let idx = idx + 1
endwhile
if idx == 0
return ''
else
return join(p1[: idx-1], '/')
endif
function! vimwiki#u#escape(string) "{{{
return escape(a:string, '~.*[]\^$')
endfunction "}}}
" Load concrete Wiki syntax: sets regexes and templates for headers and links
function vimwiki#u#reload_regexes() "{{{
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
endfunction "}}}
" Load omnipresent Wiki syntax
function vimwiki#u#reload_omni_regexes() "{{{
execute 'runtime! syntax/omnipresent_syntax.vim'
endfunction "}}}
" Load syntax-specific functionality
function vimwiki#u#reload_regexes_custom() "{{{
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
endfunction "}}}
" Backward compatible version of the built-in function shiftwidth()
if exists('*shiftwidth') "{{{
func vimwiki#u#sw()
return shiftwidth()
endfunc
else
func vimwiki#u#sw()
return &sw
endfunc
endif "}}}

BIN
doc/screenshot_1.png Normal file

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,17 +1,19 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki filetype plugin file
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Home: https://github.com/vimwiki/vimwiki/
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
call vimwiki#u#reload_regexes()
call vimwiki#u#reload_omni_regexes()
" UNDO list {{{
" Reset the following options to undo this plugin.
let b:undo_ftplugin = "setlocal ".
\ "suffixesadd< isfname< comments< ".
\ "suffixesadd< isfname< formatlistpat< ".
\ "formatoptions< foldtext< ".
\ "foldmethod< foldexpr< commentstring< "
" UNDO }}}
@ -24,171 +26,156 @@ if g:vimwiki_conceallevel && exists("+conceallevel")
let &l:conceallevel = g:vimwiki_conceallevel
endif
" MISC }}}
" GOTO FILE: gf {{{
execute 'setlocal suffixesadd='.VimwikiGet('ext')
setlocal isfname-=[,]
" gf}}}
" Autocreate list items {{{
" for list items, and list items with checkboxes
setlocal formatoptions+=tnro
setlocal formatoptions-=cq
if VimwikiGet('syntax') == 'default'
setl comments=b:*,b:#,b:-
setl formatlistpat=^\\s*[*#-]\\s*
elseif VimwikiGet('syntax') == 'markdown'
setlocal comments=fb:*,fb:-,fb:+,nb:> commentstring=\ >\ %s
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+j
else
setl comments=n:*,n:#
endif
exe "setlocal tags+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"')
" MISC }}}
" COMPLETION {{{
function! Complete_wikifiles(findstart, base)
if a:findstart == 1
let column = col('.')-2
let line = getline('.')[:column]
let startoflink = match(line, '\[\[\zs[^\\[\]]*$')
if startoflink != -1
let s:line_context = '['
return startoflink
endif
if VimwikiGet('syntax') ==? 'markdown'
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
if startofinlinelink != -1
let s:line_context = '['
return startofinlinelink
endif
endif
let startoftag = match(line, ':\zs[^:[:space:]]*$')
if startoftag != -1
let s:line_context = ':'
return startoftag
endif
let s:line_context = ''
return -1
else
" Completion works for wikilinks/anchors, and for tags. s:line_content
" tells us, which string came before a:base. There seems to be no easier
" solution, because calling col('.') here returns garbage.
if s:line_context == ''
return []
elseif s:line_context == ':'
" Tags completion
let tags = vimwiki#tags#get_tags()
if a:base != ''
call filter(tags,
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
endif
return tags
elseif a:base !~# '#'
" we look for wiki files
if a:base =~# '^wiki\d:'
let wikinumber = eval(matchstr(a:base, '^wiki\zs\d'))
if wikinumber >= len(g:vimwiki_list)
return []
endif
let prefix = matchstr(a:base, '^wiki\d:\zs.*')
let scheme = matchstr(a:base, '^wiki\d:\ze')
elseif a:base =~# '^diary:'
let wikinumber = -1
let prefix = matchstr(a:base, '^diary:\zs.*')
let scheme = matchstr(a:base, '^diary:\ze')
else " current wiki
let wikinumber = g:vimwiki_current_idx
let prefix = a:base
let scheme = ''
endif
let links = vimwiki#base#get_wikilinks(wikinumber, 1)
let result = []
for wikifile in links
if wikifile =~ '^'.vimwiki#u#escape(prefix)
call add(result, scheme . wikifile)
endif
endfor
return result
else
" we look for anchors in the given wikifile
let segments = split(a:base, '#', 1)
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
let wikifile = link_infos.filename
let syntax = VimwikiGet('syntax', link_infos.index)
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
let filtered_anchors = []
let given_anchor = join(segments[1:], '#')
for anchor in anchors
if anchor =~# '^'.vimwiki#u#escape(given_anchor)
call add(filtered_anchors, segments[0].'#'.anchor)
endif
endfor
return filtered_anchors
endif
endif
endfunction
setlocal omnifunc=Complete_wikifiles
" COMPLETION }}}
" LIST STUFF {{{
" settings necessary for the automatic formatting of lists
setlocal autoindent
setlocal nosmartindent
setlocal nocindent
setlocal comments=""
setlocal formatoptions-=c
setlocal formatoptions-=r
setlocal formatoptions-=o
setlocal formatoptions-=2
setlocal formatoptions+=n
"Create 'formatlistpat'
let &formatlistpat = g:vimwiki_rxListItem
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
let l_o = matchstr(&langmap, '\C,\zs.\zeo,')
if l_o
exe 'nnoremap <buffer> '.l_o.' :call vimwiki#lst#kbd_oO("o")<CR>a'
let s:l_o = matchstr(&langmap, '\C,\zs.\zeo,')
if s:l_o
exe 'nnoremap <silent> <buffer> '.s:l_o.' :call vimwiki#lst#kbd_o()<CR>a'
endif
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
if l_O
exe 'nnoremap <buffer> '.l_O.' :call vimwiki#lst#kbd_oO("O")<CR>a'
let s:l_O = matchstr(&langmap, '\C,\zs.\zeO,')
if s:l_O
exe 'nnoremap <silent> <buffer> '.s:l_O.' :call vimwiki#lst#kbd_O()<CR>a'
endif
endif
" COMMENTS }}}
" FOLDING for headers and list items using expr fold method. {{{
" Folding list items using expr fold method. {{{
function! s:get_base_level(lnum) "{{{
let lnum = a:lnum - 1
while lnum > 0
if getline(lnum) =~ g:vimwiki_rxHeader
return vimwiki#u#count_first_sym(getline(lnum))
endif
let lnum -= 1
endwhile
return 0
endfunction "}}}
function! s:find_forward(rx_item, lnum) "{{{
let lnum = a:lnum + 1
while lnum <= line('$')
let line = getline(lnum)
if line =~ a:rx_item
\ || line =~ '^\S'
\ || line =~ g:vimwiki_rxHeader
break
endif
let lnum += 1
endwhile
return [lnum, getline(lnum)]
endfunction "}}}
function! s:find_backward(rx_item, lnum) "{{{
let lnum = a:lnum - 1
while lnum > 1
let line = getline(lnum)
if line =~ a:rx_item
\ || line =~ '^\S'
break
endif
let lnum -= 1
endwhile
return [lnum, getline(lnum)]
endfunction "}}}
function! s:get_li_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
let level = vimwiki#u#count_first_sym(getline(a:lnum))
else
let level = (indent(a:lnum) / &sw)
endif
return level
endfunction "}}}
function! s:get_start_list(rx_item, lnum) "{{{
let lnum = a:lnum
while lnum >= 1
let line = getline(lnum)
if line !~ a:rx_item && line =~ '^\S'
return nextnonblank(lnum + 1)
endif
let lnum -= 1
endwhile
return 0
endfunction "}}}
" LIST STUFF }}}
" FOLDING {{{
" Folding list items {{{
function! VimwikiFoldListLevel(lnum) "{{{
let line = getline(a:lnum)
"" XXX Disabled: Header/section folding...
"if line =~ g:vimwiki_rxHeader
" return '>'.vimwiki#u#count_first_sym(line)
"endif
"let nnline = getline(a:lnum+1)
"" Unnecessary?
"if nnline =~ g:vimwiki_rxHeader
" return '<'.vimwiki#u#count_first_sym(nnline)
"endif
"" Very slow when called on every single line!
"let base_level = s:get_base_level(a:lnum)
"FIXME does not work correctly
let base_level = 0
if line =~ g:vimwiki_rxListItem
let [nnum, nline] = s:find_forward(g:vimwiki_rxListItem, a:lnum)
let level = s:get_li_level(a:lnum)
let leveln = s:get_li_level(nnum)
let adj = s:get_li_level(s:get_start_list(g:vimwiki_rxListItem, a:lnum))
if leveln > level
return ">".(base_level+leveln-adj)
" check if multilined list item
elseif (nnum-a:lnum) > 1
\ && (nline =~ g:vimwiki_rxListItem || nnline !~ '^\s*$')
return ">".(base_level+level+1-adj)
else
return (base_level+level-adj)
endif
else
" process multilined list items
let [pnum, pline] = s:find_backward(g:vimwiki_rxListItem, a:lnum)
if pline =~ g:vimwiki_rxListItem
if indent(a:lnum) >= indent(pnum) && line !~ '^\s*$'
let level = s:get_li_level(pnum)
let adj = s:get_li_level(s:get_start_list(g:vimwiki_rxListItem, pnum))
return (base_level+level+1-adj)
endif
endif
endif
return base_level
return vimwiki#lst#fold_level(a:lnum)
endfunction "}}}
" Folding list items }}}
" Folding sections and code blocks using expr fold method. {{{
" Folding sections and code blocks {{{
function! VimwikiFoldLevel(lnum) "{{{
let line = getline(a:lnum)
" Header/section folding...
if line =~ g:vimwiki_rxHeader
if line =~# g:vimwiki_rxHeader
return '>'.vimwiki#u#count_first_sym(line)
" Code block folding...
elseif line =~ '^\s*'.g:vimwiki_rxPreStart
elseif line =~# g:vimwiki_rxPreStart
return 'a1'
elseif line =~ '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
elseif line =~# g:vimwiki_rxPreEnd
return 's1'
else
return "="
@ -213,15 +200,20 @@ endfunction "}}}
" for long enough "text", the string's length is within s:tolerance of "len"
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
function! s:shorten_text(text, len) "{{{ returns [string, spare]
let spare_len = a:len - strlen(a:text)
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
" trick here -- replace all non-spaces with dot, calculate lengths and
" indexes on it, then use original string to break at selected index.
let text_pattern = substitute(a:text, '\m\S', '.', 'g')
let spare_len = a:len - strlen(text_pattern)
if (spare_len + s:tolerance >= 0)
return [a:text, spare_len]
endif
" try to break on a space; assumes a:len-s:ell_len >= s:tolerance
let newlen = a:len - s:ell_len
let idx = strridx(a:text, ' ', newlen + s:tolerance)
let idx = strridx(text_pattern, ' ', newlen + s:tolerance)
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
return [a:text[0:break_idx].s:ellipsis, newlen - break_idx]
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis,
\ newlen - break_idx]
endfunction "}}}
function! VimwikiFoldText() "{{{
@ -229,7 +221,7 @@ function! VimwikiFoldText() "{{{
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
let fold_len = v:foldend - v:foldstart + 1
let len_text = ' ['.fold_len.'] '
if line !~ '^\s*'.g:vimwiki_rxPreStart
if line !~# g:vimwiki_rxPreStart
let [main_text, spare_len] = s:shorten_text(main_text, 50)
return main_text.len_text
else
@ -251,19 +243,23 @@ endfunction "}}}
" COMMANDS {{{
command! -buffer Vimwiki2HTML
\ silent w <bar>
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
\<bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
\ <bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '.expand(VimwikiGet('path_html')) | endif
command! -buffer Vimwiki2HTMLBrowse
\ silent w <bar>
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(VimwikiGet('path_html')),
\ expand('%')))
command! -buffer VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
@ -277,8 +273,6 @@ command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
@ -290,11 +284,23 @@ exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("<args>")
command! -buffer -nargs=+ -complete=custom,vimwiki#base#complete_links_escaped
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
command! -buffer VimwikiCheckLinks call vimwiki#base#check_links()
" list commands
command! -buffer -nargs=* VimwikiListChangeLevel call vimwiki#lst#change_level(<f-args>)
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call vimwiki#lst#change_marker_in_list(<f-args>)
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
command! -buffer -range -nargs=+ VimwikiListChangeLvl call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
command! -buffer VimwikiRenumberAllLists call vimwiki#lst#adjust_whole_buffer()
command! -buffer VimwikiListToggle call vimwiki#lst#toggle_list_item()
" table commands
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
@ -307,6 +313,14 @@ command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right(
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
" tags commands
command! -buffer -bang
\ VimwikiRebuildTags call vimwiki#tags#update_tags(1, '<bang>')
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
\ VimwikiSearchTags VimwikiSearch /:<args>:/
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
\ VimwikiGenerateTags call vimwiki#tags#generate_tags(<f-args>)
" COMMANDS }}}
" KEYBINDINGS {{{
@ -321,13 +335,13 @@ endif
if !hasmapto('<Plug>Vimwiki2HTML')
nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'h <Plug>Vimwiki2HTML'
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
nmap <buffer> <Leader>whh <Plug>Vimwiki2HTMLBrowse
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'hh <Plug>Vimwiki2HTMLBrowse'
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
@ -394,27 +408,17 @@ nnoremap <silent><script><buffer>
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
if !hasmapto('<Plug>VimwikiDeleteLink')
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'d <Plug>VimwikiDeleteLink'
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
if !hasmapto('<Plug>VimwikiRenameLink')
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'r <Plug>VimwikiRenameLink'
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
if !hasmapto('<Plug>VimwikiToggleListItem')
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
if has("unix")
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
endif
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
if !hasmapto('<Plug>VimwikiDiaryNextDay')
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
endif
@ -427,42 +431,154 @@ endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
function! s:CR() "{{{
let res = vimwiki#lst#kbd_cr()
if res == "\<CR>" && g:vimwiki_table_mappings
let res = vimwiki#tbl#kbd_cr()
" List mappings
if !hasmapto('<Plug>VimwikiToggleListItem')
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
if has("unix")
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
vmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
endif
return res
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
vnoremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem', 'i')
imap <silent><buffer> <C-D>
\ <Plug>VimwikiDecreaseLvlSingleItem
endif
inoremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
\ <C-O>:VimwikiListChangeLvl decrease 0<CR>
if !hasmapto('<Plug>VimwikiIncreaseLvlSingleItem', 'i')
imap <silent><buffer> <C-T>
\ <Plug>VimwikiIncreaseLvlSingleItem
endif
inoremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
\ <C-O>:VimwikiListChangeLvl increase 0<CR>
if !hasmapto('<Plug>VimwikiListNextSymbol', 'i')
imap <silent><buffer> <C-L><C-J>
\ <Plug>VimwikiListNextSymbol
endif
inoremap <silent><script><buffer> <Plug>VimwikiListNextSymbol
\ <C-O>:VimwikiListChangeSymbolI next<CR>
if !hasmapto('<Plug>VimwikiListPrevSymbol', 'i')
imap <silent><buffer> <C-L><C-K>
\ <Plug>VimwikiListPrevSymbol
endif
inoremap <silent><script><buffer> <Plug>VimwikiListPrevSymbol
\ <C-O>:VimwikiListChangeSymbolI prev<CR>
if !hasmapto('<Plug>VimwikiListToggle', 'i')
imap <silent><buffer> <C-L><C-M> <Plug>VimwikiListToggle
endif
inoremap <silent><script><buffer> <Plug>VimwikiListToggle <Esc>:VimwikiListToggle<CR>
nnoremap <silent> <buffer> o :call vimwiki#lst#kbd_o()<CR>
nnoremap <silent> <buffer> O :call vimwiki#lst#kbd_O()<CR>
if !hasmapto('<Plug>VimwikiRenumberList')
nmap <silent><buffer> glr <Plug>VimwikiRenumberList
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiRenumberList :VimwikiRenumberList<CR>
if !hasmapto('<Plug>VimwikiRenumberAllLists')
nmap <silent><buffer> gLr <Plug>VimwikiRenumberAllLists
nmap <silent><buffer> gLR <Plug>VimwikiRenumberAllLists
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiRenumberAllLists :VimwikiRenumberAllLists<CR>
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem')
map <silent><buffer> glh <Plug>VimwikiDecreaseLvlSingleItem
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiDecreaseLvlSingleItem :VimwikiListChangeLvl decrease 0<CR>
if !hasmapto('<Plug>VimwikiIncreaseLvlSingleItem')
map <silent><buffer> gll <Plug>VimwikiIncreaseLvlSingleItem
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiIncreaseLvlSingleItem :VimwikiListChangeLvl increase 0<CR>
if !hasmapto('<Plug>VimwikiDecreaseLvlWholeItem')
map <silent><buffer> gLh <Plug>VimwikiDecreaseLvlWholeItem
map <silent><buffer> gLH <Plug>VimwikiDecreaseLvlWholeItem
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiDecreaseLvlWholeItem :VimwikiListChangeLvl decrease 1<CR>
if !hasmapto('<Plug>VimwikiIncreaseLvlWholeItem')
map <silent><buffer> gLl <Plug>VimwikiIncreaseLvlWholeItem
map <silent><buffer> gLL <Plug>VimwikiIncreaseLvlWholeItem
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiIncreaseLvlWholeItem :VimwikiListChangeLvl increase 1<CR>
if !hasmapto('<Plug>VimwikiRemoveSingleCB')
map <silent><buffer> gl<Space> <Plug>VimwikiRemoveSingleCB
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiRemoveSingleCB :VimwikiRemoveSingleCB<CR>
if !hasmapto('<Plug>VimwikiRemoveCBInList')
map <silent><buffer> gL<Space> <Plug>VimwikiRemoveCBInList
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiRemoveCBInList :VimwikiRemoveCBInList<CR>
for s:char in keys(g:vimwiki_bullet_types)
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
endif
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'<CR>')
exe 'noremap <silent><buffer> gL'.s:char.' :VimwikiChangeSymbolInListTo '.s:char.'<CR>'
endif
endfor
for s:typ in g:vimwiki_number_types
if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'<CR>')
exe 'noremap <silent><buffer> gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'<CR>'
endif
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'<CR>')
exe 'noremap <silent><buffer> gL'.s:typ[0].' :VimwikiChangeSymbolInListTo '.s:typ.'<CR>'
endif
endfor
function! s:CR(normal, just_mrkr) "{{{
if g:vimwiki_table_mappings
let res = vimwiki#tbl#kbd_cr()
if res != ""
exe "normal! " . res . "\<Right>"
startinsert
return
endif
endif
call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr)
endfunction "}}}
" List and Table <CR> mapping
inoremap <buffer> <expr> <CR> <SID>CR()
" List mappings
nnoremap <buffer> o :<C-U>call vimwiki#lst#kbd_oO('o')<CR>
nnoremap <buffer> O :<C-U>call vimwiki#lst#kbd_oO('O')<CR>
nnoremap <buffer> gll :VimwikiListChangeLevel <<<CR>
nnoremap <buffer> glm :VimwikiListChangeLevel >><CR>
nnoremap <buffer> gl* :VimwikiListChangeLevel *<CR>
nnoremap <buffer> gl8 :VimwikiListChangeLevel *<CR>
if VimwikiGet('syntax') == 'default'
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
elseif VimwikiGet('syntax') == 'markdown'
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
nnoremap <buffer> gl1 :VimwikiListChangeLevel 1.<CR>
elseif VimwikiGet('syntax') == 'media'
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
if maparg('<CR>', 'i') !~? '<Esc>:VimwikiReturn'
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 5<CR>
endif
if maparg('<S-CR>', 'i') !~? '<Esc>:VimwikiReturn'
inoremap <silent><buffer> <S-CR> <Esc>:VimwikiReturn 2 2<CR>
endif
" Table mappings
if g:vimwiki_table_mappings
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif
"Table mappings
if g:vimwiki_table_mappings
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
@ -498,6 +614,12 @@ vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
onoremap <silent><buffer> al :<C-U>call vimwiki#lst#TO_list_item(0, 0)<CR>
vnoremap <silent><buffer> al :<C-U>call vimwiki#lst#TO_list_item(0, 1)<CR>
onoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 0)<CR>
vnoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif
@ -519,12 +641,25 @@ nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
if VimwikiGet('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer>
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
augroup END
endif
if VimwikiGet('auto_toc')
" Automatically update the TOC *before* the file is written
augroup vimwiki
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
augroup END
endif
if VimwikiGet('auto_tags')
" Automatically update tags metadata on page write.
augroup vimwiki
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
augroup END
endif
" AUTOCOMMANDS }}}
" PASTE, CAT URL {{{

View File

@ -1,29 +1,16 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki plugin file
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Home: https://github.com/vimwiki/vimwiki/
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
if exists("loaded_vimwiki") || &cp
if exists("g:loaded_vimwiki") || &cp
finish
endif
let loaded_vimwiki = 1
let g:loaded_vimwiki = 1
let s:old_cpo = &cpo
set cpo&vim
" 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) "{{{
@ -32,22 +19,34 @@ function! s:default(varname, value) "{{{
endif
endfunction "}}}
function! s:find_wiki(path) "{{{
" XXX: find_wiki() does not (yet) take into consideration the ext
let path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(a:path))
let idx = 0
while idx < len(g:vimwiki_list)
let idx_path = expand(VimwikiGet('path', idx))
let idx_path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(idx_path))
if vimwiki#u#path_common_pfx(idx_path, path) == idx_path
return idx
endif
let idx += 1
endwhile
return -1
" an orphan page has been detected
function! s:path_html(idx) "{{{
let path_html = VimwikiGet('path_html', a:idx)
if !empty(path_html)
return path_html
else
let path = VimwikiGet('path', a:idx)
return substitute(path, '[/\\]\+$', '', '').'_html/'
endif
endfunction "}}}
function! s:normalize_path(path) "{{{
" resolve doesn't work quite right with symlinks ended with / or \
let path = substitute(a:path, '[/\\]\+$', '', '')
if path !~# '^scp:'
return resolve(expand(path)).'/'
else
return path.'/'
endif
endfunction "}}}
function! Validate_wiki_options(idx) " {{{
call VimwikiSet('path', s:normalize_path(VimwikiGet('path', a:idx)), a:idx)
call VimwikiSet('path_html', s:normalize_path(s:path_html(a:idx)), a:idx)
call VimwikiSet('template_path',
\ s:normalize_path(VimwikiGet('template_path', a:idx)), a:idx)
call VimwikiSet('diary_rel_path',
\ s:normalize_path(VimwikiGet('diary_rel_path', a:idx)), a:idx)
endfunction " }}}
function! s:vimwiki_idx() " {{{
if exists('b:vimwiki_idx')
@ -58,16 +57,10 @@ function! s:vimwiki_idx() " {{{
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'
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
@ -78,17 +71,9 @@ function! s:setup_buffer_leave() "{{{
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
let idx = vimwiki#base#find_wiki(path)
if idx == -1 && g:vimwiki_global_ext == 0
return
@ -108,40 +93,24 @@ function! s:setup_filetype() "{{{
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
call Validate_wiki_options(idx)
endif
call vimwiki#base#validate_wiki_options(idx)
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
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)
let idx = vimwiki#base#find_wiki(path)
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
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
@ -161,13 +130,10 @@ function! s:setup_buffer_enter() "{{{
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
call Validate_wiki_options(idx)
endif
call vimwiki#base#validate_wiki_options(idx)
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
endif
@ -177,37 +143,33 @@ function! s:setup_buffer_enter() "{{{
" 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'
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'
if g:vimwiki_folding ==? 'expr'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif g:vimwiki_folding == 'list' || g:vimwiki_folding == 'lists'
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif g:vimwiki_folding == 'syntax'
elseif g:vimwiki_folding ==? 'syntax'
setlocal fdm=syntax
setlocal foldtext=VimwikiFoldText()
else
setlocal fdm=manual
normal! zE
endif
" And conceal level too.
@ -219,21 +181,13 @@ function! s:setup_buffer_enter() "{{{
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
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
@ -310,7 +264,7 @@ function! VimwikiSet(option, value, ...) "{{{
endfunction "}}}
" Clear option for current wiki or if third parameter exists for
" Clear option for current wiki or if second parameter exists for
" wiki with a given index.
" Currently, only works if option was previously saved in the buffer local
" dictionary, that acts as a cache.
@ -324,6 +278,23 @@ function! VimwikiClear(option, ...) "{{{
endfunction "}}}
" }}}
function! s:vimwiki_get_known_extensions() " {{{
" Getting all extensions that different wikis could have
let extensions = {}
for wiki in g:vimwiki_list
if has_key(wiki, 'ext')
let extensions[wiki.ext] = 1
else
let extensions['.wiki'] = 1
endif
endfor
" append map g:vimwiki_ext2syntax
for ext in keys(g:vimwiki_ext2syntax)
let extensions[ext] = 1
endfor
return keys(extensions)
endfunction " }}}
" }}}
" CALLBACK functions "{{{
@ -334,9 +305,15 @@ if !exists("*VimwikiLinkHandler") "{{{
endfunction
endif "}}}
if !exists("*VimwikiLinkConverter") "{{{
function VimwikiLinkConverter(url, source, target)
" Return the empty string when unable to process link
return ''
endfunction
endif "}}}
if !exists("*VimwikiWikiIncludeHandler") "{{{
function! VimwikiWikiIncludeHandler(value) "{{{
" Return the empty string when unable to process link
return ''
endfunction "}}}
endif "}}}
@ -352,12 +329,14 @@ let s:vimwiki_defaults.ext = '.wiki'
let s:vimwiki_defaults.maxhi = 0
let s:vimwiki_defaults.syntax = 'default'
let s:vimwiki_defaults.template_path = ''
let s:vimwiki_defaults.template_default = ''
let s:vimwiki_defaults.template_ext = ''
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
let s:vimwiki_defaults.template_default = 'default'
let s:vimwiki_defaults.template_ext = '.tpl'
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.automatic_nested_syntaxes = 1
let s:vimwiki_defaults.auto_export = 0
let s:vimwiki_defaults.auto_toc = 0
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
" file.
let s:vimwiki_defaults.temp = 0
@ -376,11 +355,12 @@ let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
let s:vimwiki_defaults.custom_wiki2html = ''
"
let s:vimwiki_defaults.list_margin = -1
let s:vimwiki_defaults.auto_tags = 0
"}}}
" DEFAULT options {{{
call s:default('list', [s:vimwiki_defaults])
call s:default('auto_checkbox', 1)
call s:default('use_mouse', 0)
call s:default('folding', '')
call s:default('menu', 'Vimwiki')
@ -399,12 +379,12 @@ call s:default('dir_link', '')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
call s:default('user_htmls', '')
call s:default('autowriteall', 1)
call s:default('toc_header', 'Contents')
call s:default('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 2)
call s:default('url_maxsave', 15)
call s:default('debug', 0)
call s:default('diary_months',
\ {
@ -414,9 +394,12 @@ call s:default('diary_months',
\ 10: 'October', 11: 'November', 12: 'December'
\ })
call s:default('map_prefix', '<Leader>w')
call s:default('current_idx', 0)
call s:default('auto_chdir', 0)
" Scheme regexes should be defined even if syntax file is not loaded yet
" cause users should be able to <leader>w<leader>w without opening any
" vimwiki file first
@ -426,20 +409,23 @@ call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'.
\ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp')
call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel')
let rxSchemes = '\%('.
let s:rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
\ '\)'
call s:default('rxSchemeUrl', rxSchemes.':.*')
call s:default('rxSchemeUrlMatchScheme', '\zs'.rxSchemes.'\ze:.*')
call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
call s:default('rxSchemeUrl', s:rxSchemes.':.*')
call s:default('rxSchemeUrlMatchScheme', '\zs'.s:rxSchemes.'\ze:.*')
call s:default('rxSchemeUrlMatchUrl', s:rxSchemes.':\zs.*\ze')
" scheme regexes }}}
for s:idx in range(len(g:vimwiki_list))
call Validate_wiki_options(s:idx)
endfor
"}}}
" AUTOCOMMANDS for all known wiki extensions {{{
let extensions = vimwiki#base#get_known_extensions()
augroup filetypedetect
" clear FlexWiki's stuff
@ -448,17 +434,17 @@ augroup end
augroup vimwiki
autocmd!
for ext in extensions
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_reenter()'
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
exe 'autocmd BufNewFile,BufRead, *'.ext.' call s:setup_filetype()'
exe 'autocmd ColorScheme *'.ext.' call s:setup_cleared_syntax()'
for s:ext in s:vimwiki_get_known_extensions()
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()'
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'
exe 'autocmd BufNewFile,BufRead, *'.s:ext.' call s:setup_filetype()'
exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
if g:vimwiki_table_auto_fmt
exe 'autocmd InsertLeave *'.ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.ext.' call vimwiki#tbl#reset_tw(line("."))'
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
endfor
augroup END
@ -479,6 +465,8 @@ command! -count=1 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1)
command! -count=1 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1, 1)
command! -count=1 VimwikiMakeYesterdayDiaryNote
\ call vimwiki#diary#make_note(v:count1, 0, strftime(VimwikiGet('diary_link_fmt', v:count1 - 1), localtime() - 60*60*24))
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
@ -486,41 +474,47 @@ command! VimwikiDiaryGenerateLinks
" MAPPINGS {{{
if !hasmapto('<Plug>VimwikiIndex')
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'w <Plug>VimwikiIndex'
endif
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabIndex')
nmap <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'t <Plug>VimwikiTabIndex'
endif
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect')
nmap <silent><unique> <Leader>ws <Plug>VimwikiUISelect
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'s <Plug>VimwikiUISelect'
endif
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
if !hasmapto('<Plug>VimwikiDiaryIndex')
nmap <silent><unique> <Leader>wi <Plug>VimwikiDiaryIndex
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'i <Plug>VimwikiDiaryIndex'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
nmap <silent><unique> <Leader>w<Leader>i <Plug>VimwikiDiaryGenerateLinks
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
nmap <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :VimwikiMakeYesterdayDiaryNote<CR>
"}}}
" MENU {{{

View File

@ -0,0 +1,35 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Desc: Syntax definitions which are always available
" Home: https://github.com/vimwiki/vimwiki/
" Define Regexes of anchors for every syntax.
" This has to be separated from vimwiki_default.vim, vimwiki_markdown.vim, etc.
" because the latter are only loaded and available if the current wiki has the
" corresponding syntax
let g:vimwiki_default_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let g:vimwiki_default_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let g:vimwiki_default_tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
let g:vimwiki_default_tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
let g:vimwiki_markdown_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
let g:vimwiki_markdown_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_markdown_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_markdown_wikilink = g:vimwiki_default_wikilink "XXX plus markdown-style links
let g:vimwiki_markdown_tag_search = g:vimwiki_default_tag_search
let g:vimwiki_markdown_tag_match = g:vimwiki_default_tag_match
let g:vimwiki_media_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let g:vimwiki_media_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let g:vimwiki_media_bold_search = "'''\\zs[^']\\+\\ze'''"
let g:vimwiki_media_bold_match = '''''''__Text__'''''''
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
" want to call escape() on this string, we must keep it in single quotes
let g:vimwiki_media_wikilink = g:vimwiki_default_wikilink
let g:vimwiki_media_tag_search = g:vimwiki_default_tag_search " XXX rework to mediawiki categories format?
let g:vimwiki_media_tag_match = g:vimwiki_default_tag_match " XXX rework to mediawiki categories format?

View File

@ -1,7 +1,6 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Home: https://github.com/vimwiki/vimwiki/
" Quit if syntax file is already loaded
if version < 600
@ -9,13 +8,14 @@ if version < 600
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('*/')
let b:existing_wikifiles =
\ vimwiki#base#get_wikilinks(g:vimwiki_current_idx, 1)
let b:existing_wikidirs =
\ vimwiki#base#get_wiki_directories(g:vimwiki_current_idx)
endif
let timescans = vimwiki#u#time(starttime) "XXX
"let b:xxx = 1
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
"if VimwikiGet('maxhi')
@ -43,61 +43,68 @@ let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
" }}}
" -------------------------------------------------------------------------
" Load concrete Wiki syntax: sets regexes and templates for headers and links
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" -------------------------------------------------------------------------
let time0 = vimwiki#u#time(starttime) "XXX
let g:vimwiki_rxListItem = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
\ '\)'
call vimwiki#u#reload_regexes()
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
let g:vimwiki_rxWikiLinkPrefix = '[['
let g:vimwiki_rxWikiLinkSuffix = ']]'
let g:vimwiki_rxWikiLinkSeparator = '|'
let s:wikilink_prefix = '[['
let s:wikilink_suffix = ']]'
let s:wikilink_separator = '|'
let s:rx_wikilink_prefix = vimwiki#u#escape(s:wikilink_prefix)
let s:rx_wikilink_suffix = vimwiki#u#escape(s:wikilink_suffix)
let s:rx_wikilink_separator = vimwiki#u#escape(s:wikilink_separator)
" templates for the creation of wiki links
" [[URL]]
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_WikiLinkTemplate1 = s:wikilink_prefix . '__LinkUrl__'.
\ s:wikilink_suffix
" [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
\ g:vimwiki_rxWikiLinkSuffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\\]]'
let g:vimwiki_WikiLinkTemplate2 = s:wikilink_prefix . '__LinkUrl__'.
\ s:wikilink_separator . '__LinkDescription__' . s:wikilink_suffix
let g:vimwiki_rxWikiLinkPrefix = escape(g:vimwiki_rxWikiLinkPrefix, magic_chars)
let g:vimwiki_rxWikiLinkSuffix = escape(g:vimwiki_rxWikiLinkSuffix, magic_chars)
let g:vimwiki_rxWikiLinkSeparator = escape(g:vimwiki_rxWikiLinkSeparator, magic_chars)
let g:vimwiki_rxWikiLinkUrl = valid_chars.'\{-}'
let g:vimwiki_rxWikiLinkDescr = valid_chars.'\{-}'
" template for matching all wiki links with a given target file
let g:vimwiki_WikiLinkMatchUrlTemplate =
\ s:rx_wikilink_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ s:rx_wikilink_suffix .
\ '\|' .
\ s:rx_wikilink_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ s:rx_wikilink_separator .
\ '.*' .
\ s:rx_wikilink_suffix
let s:valid_chars = '[^\\\]]'
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
" this regexp defines what can form a link when the user presses <CR> in the
" buffer (and not on a link) to create a link
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
" non-Ascii characters
let g:vimwiki_rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
let g:vimwiki_rxWord = '[^[:blank:]()\\]\+'
"
" [[URL]], or [[URL|DESCRIPTION]]
" a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.'\%('.g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_rxWikiLink = s:rx_wikilink_prefix.
\ g:vimwiki_rxWikiLinkUrl.'\%('.s:rx_wikilink_separator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
" b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchUrl = g:vimwiki_rxWikiLinkPrefix.
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_rxWikiLinkMatchUrl = s:rx_wikilink_prefix.
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. s:rx_wikilink_separator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchDescr = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_rxWikiLinkMatchDescr = s:rx_wikilink_prefix.
\ g:vimwiki_rxWikiLinkUrl.s:rx_wikilink_separator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. s:rx_wikilink_suffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLinkPrefix1 = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator
let g:vimwiki_rxWikiLinkSuffix1 = g:vimwiki_rxWikiLinkSuffix
let s:rx_wikilink_prefix1 = s:rx_wikilink_prefix . g:vimwiki_rxWikiLinkUrl .
\ s:rx_wikilink_separator
let s:rx_wikilink_suffix1 = s:rx_wikilink_suffix
" }}}
@ -114,13 +121,10 @@ let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ '__LinkDescription__'.
\ g:vimwiki_rxWikiInclSuffix
let valid_chars = '[^\\\}]'
let g:vimwiki_rxWikiInclPrefix = escape(g:vimwiki_rxWikiInclPrefix, magic_chars)
let g:vimwiki_rxWikiInclSuffix = escape(g:vimwiki_rxWikiInclSuffix, magic_chars)
let g:vimwiki_rxWikiInclSeparator = escape(g:vimwiki_rxWikiInclSeparator, magic_chars)
let g:vimwiki_rxWikiInclUrl = valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArg = valid_chars.'\{-}'
let s:valid_chars = '[^\\\}]'
let g:vimwiki_rxWikiInclUrl = s:valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArg = s:valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
"
"
@ -151,7 +155,7 @@ let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
" the whitespace.
" Stuart, could you check it with markdown templated links? [](http://...), as
" the last bracket is the part of URL now?
let g:vimwiki_rxWeblink = '[[:alnum:]]\@<!'. g:vimwiki_rxWeblinkUrl . '\S*'
let g:vimwiki_rxWeblink = '\<'. g:vimwiki_rxWeblinkUrl . '\S*'
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
" 0b) match DESCRIPTION within URL
@ -169,9 +173,6 @@ let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
" 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
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
@ -181,9 +182,6 @@ function! s:add_target_syntax_ON(target, type) " {{{
endfunction "}}}
function! s:add_target_syntax_OFF(target) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
@ -197,33 +195,40 @@ function! s:highlight_existing_links() "{{{
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
\ '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" match [[URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction "}}}
@ -237,16 +242,12 @@ if VimwikiGet('maxhi')
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
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')
" WikiIncl
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
let time02 = vimwiki#u#time(starttime) "XXX
endif
" Weblink
@ -254,114 +255,115 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
let s:rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" }}}
" generic headers "{{{
if g:vimwiki_symH
"" symmetric
for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__ '.repeat(g:vimwiki_rxH, i)
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
let g:vimwiki_rxH{i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
let g:vimwiki_rxH{i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{1,'.i.'}\s*$'
for s:i in range(1,6)
let g:vimwiki_rxH{s:i}_Template = repeat(g:vimwiki_rxH, s:i).' __Header__ '.repeat(g:vimwiki_rxH, s:i)
let g:vimwiki_rxH{s:i} = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.s:i.'}\s*$'
let g:vimwiki_rxH{s:i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.s:i.'}\s*$'
let g:vimwiki_rxH{s:i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{1,'.s:i.'}\s*$'
endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$'
else
" asymmetric
for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__'
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
let g:vimwiki_rxH{i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
let g:vimwiki_rxH{i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.i.'}[^'.g:vimwiki_rxH.'].*$'
for s:i in range(1,6)
let g:vimwiki_rxH{s:i}_Template = repeat(g:vimwiki_rxH, s:i).' __Header__'
let g:vimwiki_rxH{s:i} = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
let g:vimwiki_rxH{s:i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
let g:vimwiki_rxH{s:i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$'
endif
" Header levels, 1-6
for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
execute 'syntax region VimwikiH'.i.'Folding start=/'.g:vimwiki_rxH{i}_Start.
\ '/ end=/'.g:vimwiki_rxH{i}_End.'/me=s-1 transparent fold'
for s:i in range(1,6)
execute 'syntax match VimwikiHeader'.s:i.' /'.g:vimwiki_rxH{s:i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.g:vimwiki_rxH{s:i}_Start.
\ '/ end=/'.g:vimwiki_rxH{s:i}_End.'/me=s-1 transparent fold'
endfor
" }}}
" possibly concealed chars " {{{
let conceal = exists("+conceallevel") ? ' conceal' : ''
let g:vimwiki_rxPreStart = '^\s*'.g:vimwiki_rxPreStart
let g:vimwiki_rxPreEnd = '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
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
let g:vimwiki_rxMathStart = '^\s*'.g:vimwiki_rxMathStart
let g:vimwiki_rxMathEnd = '^\s*'.g:vimwiki_rxMathEnd.'\s*$'
" possibly concealed chars " {{{
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'.s:conceal
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'.s:conceal
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'.s:conceal
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'.s:conceal
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'.s:conceal
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'.s:conceal
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'.s:conceal
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'.s:conceal
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.s:conceal
" }}}
" concealed link parts " {{{
if g:vimwiki_debug > 1
echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix
echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix
echom 'WikiLink Prefix1: '.g:vimwiki_rxWikiLinkPrefix1
echom 'WikiLink Suffix1: '.g:vimwiki_rxWikiLinkSuffix1
echom '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
let s:options .= s:conceal
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.options
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.s:options
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix1.'/'.options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix1.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix1.'/'.s:options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.s:options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.s:options
" }}}
" non concealed chars " {{{
@ -405,25 +407,19 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" List items
execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
" Lists
execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
" List item checkbox
"syntax match VimwikiCheckBox /\[.\?\]/
let g:vimwiki_rxCheckBox = '\s*\[['.g:vimwiki_listsyms.']\?\]\s'
" Todo lists have a checkbox
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListBullet.g:vimwiki_rxCheckBox.'/'
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListNumber.g:vimwiki_rxCheckBox.'/'
if g:vimwiki_hl_cb_checked
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListBullet.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListNumber.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/'
if g:vimwiki_hl_cb_checked == 1
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '.
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
elseif g:vimwiki_hl_cb_checked == 2
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
endif
execute 'syntax match VimwikiEqIn /'.g:vimwiki_rxEqIn.'/ contains=VimwikiEqInChar'
execute 'syntax match VimwikiEqInT /'.g:vimwiki_rxEqIn.'/ contained contains=VimwikiEqInCharT'
@ -454,15 +450,14 @@ execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=Vim
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
execute 'syntax region VimwikiPre start=/'.g:vimwiki_rxPreStart.
\ '/ end=/'.g:vimwiki_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=/'.g:vimwiki_rxMathStart.
\ '/ end=/'.g:vimwiki_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
@ -470,14 +465,18 @@ syntax match VimwikiPlaceholderParam /\s.*/ contained
" html tags
if g:vimwiki_valid_html_tags != ''
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
let s:html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
endif
" tags
execute 'syntax match VimwikiTag /'.g:vimwiki_rxTags.'/'
" }}}
" header groups highlighting "{{{
@ -487,8 +486,8 @@ if g:vimwiki_hl_headers == 0
if !exists("g:colors_name")
hi Title cterm=bold
endif
for i in range(1,6)
execute 'hi def link VimwikiHeader'.i.' Title'
for s:i in range(1,6)
execute 'hi def link VimwikiHeader'.s:i.' Title'
endfor
else
" default colors when headers of different levels are highlighted differently
@ -497,14 +496,12 @@ else
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black']
let g:vimwiki_hcolor_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
for s:i in range(1,6)
execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[s:i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[s:i-1].' term=bold cterm=bold'
endfor
endif
"}}}
" syntax group highlighting "{{{
hi def link VimwikiMarkers Normal
@ -542,10 +539,10 @@ hi def link VimwikiLinkT VimwikiLink
hi def link VimwikiList Identifier
hi def link VimwikiListTodo VimwikiList
"hi def link VimwikiCheckBox VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiEmoticons Character
hi def link VimwikiHR Identifier
hi def link VimwikiTag Keyword
hi def link VimwikiDelText Constant
hi def link VimwikiDelTextT VimwikiDelText
@ -589,33 +586,31 @@ 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')
let s:nested = VimwikiGet('nested_syntaxes')
if VimwikiGet('automatic_nested_syntaxes')
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax())
endif
if !empty(s:nested)
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
call vimwiki#base#nested_syntax(s:vim_syntax,
\ g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ g:vimwiki_rxPreEnd, 'VimwikiPre')
endfor
endif
" LaTeX
call vimwiki#base#nested_syntax('tex',
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ '\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
\ g:vimwiki_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,11 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" Desc: Defines default syntax
" Home: https://github.com/vimwiki/vimwiki/
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
@ -72,11 +68,19 @@ let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '# '
let g:vimwiki_rxListBullet = '^\s*[*-]\s'
let g:vimwiki_rxListNumber = '^\s*#\s'
" Lists
"1 means multiple bullets, like * ** ***
let g:vimwiki_bullet_types = { '-':0, '*':0, '#':0 }
let g:vimwiki_number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
"this should contain at least one element
"it is used for i_<C-L><C-J> among other things
let g:vimwiki_list_markers = ['-', '1.', '*', 'I)', 'a)']
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
call vimwiki#lst#setup_marker_infos()
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text
let g:vimwiki_rxPreStart = '{{{'
@ -87,3 +91,5 @@ let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\)\@='
" see also g:vimwiki_default_tag_search

View File

@ -1,11 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" Desc: Defines markdown syntax
" Home: https://github.com/vimwiki/vimwiki/
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
@ -72,11 +68,16 @@ let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '1. ', '2. ', etc.
let g:vimwiki_rxListBullet = '^\s*[*+-]\s'
let g:vimwiki_rxListNumber = '^\s*[0-9]\+\.\s'
" Lists
let g:vimwiki_bullet_types = { '-':0, '*':0, '+':0 }
let g:vimwiki_number_types = ['1.']
let g:vimwiki_list_markers = ['-', '*', '+', '1.']
let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
call vimwiki#lst#setup_marker_infos()
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text
let g:vimwiki_rxPreStart = '```'
@ -87,3 +88,4 @@ let g:vimwiki_rxMathStart = '\$\$'
let g:vimwiki_rxMathEnd = '\$\$'
let g:vimwiki_rxComment = '^\s*%%.*$'
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='

View File

@ -1,7 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Author: Stuart Andrews <stu.andrews@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Desc: Special stuff for markdown syntax
" Home: https://github.com/vimwiki/vimwiki/
" LINKS: assume this is common to all syntaxes "{{{
@ -30,60 +30,71 @@ let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
" LINKS: setup wikilink1 regexps {{{
" 1. [URL][], or [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1Prefix = '['
let g:vimwiki_rxWikiLink1Suffix = ']'
let g:vimwiki_rxWikiLink1Separator = ']['
let s:wikilink_md_prefix = '['
let s:wikilink_md_suffix = ']'
let s:wikilink_md_separator = ']['
let s:rx_wikilink_md_prefix = vimwiki#u#escape(s:wikilink_md_prefix)
let s:rx_wikilink_md_suffix = vimwiki#u#escape(s:wikilink_md_suffix)
let s:rx_wikilink_md_separator = vimwiki#u#escape(s:wikilink_md_separator)
" [URL][]
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_WikiLink1Template1 = s:wikilink_md_prefix . '__LinkUrl__'.
\ s:wikilink_md_separator. s:wikilink_md_suffix
" [DESCRIPTION][URL]
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_WikiLink1Template2 = s:wikilink_md_prefix. '__LinkDescription__'.
\ s:wikilink_md_separator. '__LinkUrl__'.
\ s:wikilink_md_suffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\\[\]]'
let g:vimwiki_WikiLinkMatchUrlTemplate .=
\ '\|' .
\ s:rx_wikilink_md_prefix .
\ '.*' .
\ s:rx_wikilink_md_separator .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ s:rx_wikilink_md_suffix .
\ '\|' .
\ s:rx_wikilink_md_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ s:rx_wikilink_md_separator .
\ s:rx_wikilink_md_suffix
let g:vimwiki_rxWikiLink1Prefix = escape(g:vimwiki_rxWikiLink1Prefix, magic_chars)
let g:vimwiki_rxWikiLink1Suffix = escape(g:vimwiki_rxWikiLink1Suffix, magic_chars)
let g:vimwiki_rxWikiLink1Separator = escape(g:vimwiki_rxWikiLink1Separator, magic_chars)
let g:vimwiki_rxWikiLink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1Descr = valid_chars.'\{-}'
let s:valid_chars = '[^\\\[\]]'
let g:vimwiki_rxWikiLink1Url = s:valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1Descr = s:valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
let g:vimwiki_rxWikiLink1Prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix = g:vimwiki_rxWikiLink1Suffix.
let s:rx_wikilink_md_prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ s:rx_wikilink_md_prefix
let s:rx_wikilink_md_suffix = s:rx_wikilink_md_suffix.
\ g:vimwiki_rxWikiLink1InvalidSuffix
"
" 1. [URL][], [DESCRIPTION][URL]
" 1a) match [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1 = g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Url. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr.g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1 = s:rx_wikilink_md_prefix.
\ g:vimwiki_rxWikiLink1Url. s:rx_wikilink_md_separator.
\ s:rx_wikilink_md_suffix.
\ '\|'. s:rx_wikilink_md_prefix.
\ g:vimwiki_rxWikiLink1Descr.s:rx_wikilink_md_separator.
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
" 1b) match URL within [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchUrl = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr. g:vimwiki_rxWikiLink1Separator.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1MatchUrl = s:rx_wikilink_md_prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_separator.
\ s:rx_wikilink_md_suffix.
\ '\|'. s:rx_wikilink_md_prefix.
\ g:vimwiki_rxWikiLink1Descr. s:rx_wikilink_md_separator.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_suffix
" 1c) match DESCRIPTION within [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchDescr = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1MatchDescr = s:rx_wikilink_md_prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. s:rx_wikilink_md_separator.
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLink1Prefix1 = g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix1 = g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1Prefix1 = s:rx_wikilink_md_prefix
let g:vimwiki_rxWikiLink1Suffix1 = s:rx_wikilink_md_separator.
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
" }}}
" *. ANY wikilink {{{
@ -125,14 +136,13 @@ let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWeblink1Suffix
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\]'
let s:valid_chars = '[^\\]'
let g:vimwiki_rxWeblink1Prefix = escape(g:vimwiki_rxWeblink1Prefix, magic_chars)
let g:vimwiki_rxWeblink1Suffix = escape(g:vimwiki_rxWeblink1Suffix, magic_chars)
let g:vimwiki_rxWeblink1Separator = escape(g:vimwiki_rxWeblink1Separator, magic_chars)
let g:vimwiki_rxWeblink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWeblink1Descr = valid_chars.'\{-}'
let g:vimwiki_rxWeblink1Prefix = vimwiki#u#escape(g:vimwiki_rxWeblink1Prefix)
let g:vimwiki_rxWeblink1Suffix = vimwiki#u#escape(g:vimwiki_rxWeblink1Suffix)
let g:vimwiki_rxWeblink1Separator = vimwiki#u#escape(g:vimwiki_rxWeblink1Separator)
let g:vimwiki_rxWeblink1Url = s:valid_chars.'\{-}'
let g:vimwiki_rxWeblink1Descr = s:valid_chars.'\{-}'
"
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
@ -194,9 +204,6 @@ let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)
" 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
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
@ -206,9 +213,6 @@ function! s:add_target_syntax_ON(target, type) " {{{
endfunction "}}}
function! s:add_target_syntax_OFF(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
@ -224,7 +228,7 @@ endfunction "}}}
function! s:existing_mkd_refs() "{{{
call vimwiki#markdown_base#reset_mkd_refs()
return "\n".join(keys(vimwiki#markdown_base#get_reflinks()), "\n")."\n"
return keys(vimwiki#markdown_base#get_reflinks())
endfunction "}}}
function! s:highlight_existing_links() "{{{
@ -232,7 +236,8 @@ function! s:highlight_existing_links() "{{{
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
\ '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" Ref links are cached
@ -240,29 +245,35 @@ function! s:highlight_existing_links() "{{{
" match [URL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DIRURL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][DIRURL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [MKDREF][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][MKDREF]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
endfunction "}}}
@ -274,14 +285,10 @@ if VimwikiGet('maxhi')
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
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
endif
" Weblink
@ -289,27 +296,29 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
let s:rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):'
" a) match [nonwiki-scheme-URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" b) match [DESCRIPTION][nonwiki-scheme-URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" }}}
" generic headers "{{{
" Header levels, 1-6
for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
for s:i in range(1,6)
execute 'syntax match VimwikiHeader'.s:i.' /'.g:vimwiki_rxH{s:i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endfor
" }}}
@ -321,25 +330,18 @@ 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 /'.s:rx_wikilink_md_prefix.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_suffix.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.s:options
" conceal weblink1
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.options
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.options
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.s:options
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.s:options
if exists("+conceallevel")
syntax conceal off

View File

@ -1,11 +1,7 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" MediaWiki syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" Desc: Defines mediaWiki syntax
" Home: https://github.com/vimwiki/vimwiki/
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
@ -53,12 +49,16 @@ let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" Bulleted list items start with whitespace(s), then '*'
" highlight only bullets and digits.
let g:vimwiki_rxListBullet = '^\s*\*\+\s\%([^*]*$\)\@='
let g:vimwiki_rxListNumber = '^\s*#\+\s'
" Lists
let g:vimwiki_bullet_types = { '*':1, '#':1 }
let g:vimwiki_number_types = []
let g:vimwiki_list_markers = ['*', '#']
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
call vimwiki#lst#setup_marker_infos()
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*'
" Preformatted text
let g:vimwiki_rxPreStart = '<pre>'
@ -69,3 +69,4 @@ let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='