Compare commits

...

555 Commits
v2.2 ... master

Author SHA1 Message Date
Marcin Woźniak a17b1bc6d4 Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-08-30 21:52:26 +02:00
Michael F. Schönitzer 619f04f898 Bump version number – release 2.5 2020-05-26 23:39:31 +02:00
Michael F. Schönitzer 96b139253d Merge branch 'dev' 2020-05-26 23:37:46 +02:00
Michael F. Schönitzer c9e6afe856 Prepare for release 2.5
- Format Changelog
- Update version number in docs
- Update list of Contributers
- Update version number in tests
- Update link in README
2020-05-26 23:09:58 +02:00
Tinmarino 36fa81c059 Fix: get_wikilinks arguments: add pattern 2020-05-26 14:06:17 -04:00
Michael F. Schönitzer 1eb74dcf2f
Rename three commands, deprecate their old names (#887)
The following commands have been renamed to better describe their
function and avoid confusion.
:VimwikiDeleteLink → :VimwikiDeletePage
:VimwikiRenameLink → :VimwikiRenamePage
:VimwikiGenerateTags → :VimwikiGenerateTagLinks (was already renamed in 3b5537f)

Calling the old commands still works but displays a warning message.
2020-05-24 23:49:28 +02:00
Michael F. Schönitzer 57dc48d686
Fix grammar in help file (#888) 2020-05-24 23:49:10 +02:00
Michael F. Schönitzer 306efbcdf3 Fix test for mediawiki syntax 2020-05-23 01:23:28 +02:00
Tinmarino f54b94a38f Lint tipo 2020-05-20 14:43:56 -04:00
Tinmarino e83173c7c8 Test remove commented nvim from Dockerfile 2020-05-20 14:41:07 -04:00
Tinmarino 972594829e Lazy: Link with only '-' do not work 2020-05-18 21:23:38 -04:00
Michael F. Schönitzer b4cb7f7ab6 Preciser description for VimwikiGenerateLinks
Preciser and easier understandable description for VimwikiGenerateLinks.
2020-05-18 12:10:53 -04:00
Tinmarino f49a91501b Fix: Command [count]o can't repeat in vimwiki
Issue #776
2020-05-17 14:07:43 -04:00
Tinmarino 077467877d Util: count_exe 2020-05-17 14:06:41 -04:00
Tinmarino f4c983b6b5 Feature: VimwikiGenerateLink take pattern optional argument
Issue #803
2020-05-17 13:14:08 -04:00
Tinmarino 3b5537f15a Fix: Link containing only '-'
Issue #835 #876
2020-05-17 12:31:32 -04:00
Tinmarino c6564119b0 Doc: g:vimwiki_auto_chdir, emphasis __root__ wiki path
and not current file path as Issue #802
2020-05-14 00:17:31 -04:00
Tinmarino ee38764480 Add: ShowVersion: os and vim version for easyer issue debug 2020-05-13 22:43:41 -04:00
Tinmarino e850cb8562 Add travis tests 2020-05-13 11:35:22 -04:00
Tinmarino 0850ce13ad Fix: retrocompatibility and Vint 2020-05-13 11:35:22 -04:00
Tinmarino d86685f350 Test: comment non working -> All tests green 2020-05-13 11:35:22 -04:00
Tinmarino 1852c6c542 Fix: clean_url removing Chinese character
Issue: <Enter> create link bug with Chinese characters #849
Thank: @BSDxxxx
2020-05-13 11:35:22 -04:00
Tinmarino 39812e5c96 Fix: renaming tipo: s:get_diary_file -> vimwiki#diary#get_diary_files() 2020-05-13 11:35:22 -04:00
flex 76af17a872 fix base#find_files so that it works for filenames with whitespaces 2020-05-11 22:14:35 -04:00
Hugo 46025fb0fb Update MathJax local loading instructions
The MathJax.js file doesn't exist anymore in the MathJax repository and
the script that should be loaded is tex-chtml.js.
This update the helpfile to reflect this change.
2020-05-11 21:24:04 -04:00
Patrick Stockwell ab301801b0 Improve path normalisation with separate substitutions
This change reverts the original regex and simply adds a second regex
which is called on the result. '/\./' is one literal forward slash, one
literal fullstop (escaped with a leading backslash), and one literal
forward slash. In plain text, `/./` will be replaced with `/`.
2020-05-11 21:08:54 -04:00
Patrick Stockwell 73527d3f14 Update changelog and contributors list 2020-05-11 21:08:54 -04:00
Patrick Stockwell b96e82d6cc Generate links when diary & wiki dir are the same
When generating links, we first check that the file is not a diary file
as we don't want to include those in the list. That work is delegated to
the `is_diary_file` function. Prior to this change, the function always
returned true if the file was in the diary directory.
This approach gives false positives for a wiki which has a flat structure
and the wiki files and diary files share a directory. eg:

let wiki.diary_rel_path = './'

This change reuses existing diary functions from the diary.vim module to
get an exact list of diary files to check against.
2020-05-11 21:08:54 -04:00
Tinmarino 1020ac51bf Prettify: Special case in diary not so special
Same as generic case within this PR
2020-04-22 11:22:53 -04:00
Stefan Lehmann c73107dc10 Fix for Issue #807
creating a new link to an existing page in the diary path now uses the full page name instead of just the first word.
2020-04-22 11:22:53 -04:00
kaphula 35af13c1ef Moved safe_line_html call after the %plainhtml check so it does not convert essential html characters such as < and > to ampersand form. 2020-04-20 22:11:40 -04:00
Tinmarino f9b9b5a768 Test: plaintext html magic 2020-04-18 14:10:05 -04:00
kaphula 867d81a50c Added new feature to insert plaintext to the final html conversion file. 2020-04-18 13:04:55 -04:00
Mauro Morales 6a0210c644 Update changelog and contributors 2020-04-17 19:02:59 -04:00
Mauro Morales a4738f31d6 Add viewport meta tag to make it responsive 2020-04-17 19:02:59 -04:00
Tinmarino 614287a42b Comment: tipo 2020-04-17 19:01:03 -04:00
Rane Brown dee6a88929
Merge pull request #850 from ubitux/remove-extra-echom-idx
Remove unecessary echom idx cruft
2020-04-06 08:50:47 -06:00
Clément Bœsch 7ae02bb4e6 Remove unnecessary echom idx cruft
This was introduced in 3396e87db for debugging and probably forgotten.
2020-04-06 16:50:26 +02:00
Rane Brown 78a41b79c6 Merge branch 'multi_ft' into dev
This allows setting multiple filetypes at the same time e.g. 'vimwiki.md'
Closes #817, resolves #830, resolves #461.
2020-04-03 13:31:36 -06:00
Rane Brown ca28174dcc Add shell command to install helptags #836 2020-03-23 05:53:15 -06:00
Rane Brown 53301fdf4d Add install notes when using vim packages.
Closes #836
2020-03-23 05:30:13 -06:00
Rane Brown 64c9f3d36d Remove extra checkbox 2020-01-12 21:13:51 -07:00
Rane Brown 75c557bcbc Disable syntax for indented code blocks.
The behavior within lists is not correct.
2020-01-08 06:03:40 -07:00
Tinmarino d9412218e3 Fix relative paths for VimwikiRenameLink. Merge PR #787.
Fixes #90 

__Problem__: VimwikiRenameLink does not rename dir1/toto url in dir2/tata
because the dirs (dir2 and .) were well crossed but badly inspected.
__Solution__: `blob(.ext*)` -> `glob(**/*.ext)` + find the relative URL

* Fasten: VimwikiRenameLink goes faster with cache
More: To compute old_url regex, use a cache dict because it is the same
for files in the same directories

* Util DeleteHiddenBuffer -> do not delete Vader buffer

* Test: Prettify: Util: teardown delete defined function

* Remove unnecessary trailing spaces
Note: list_VimwikiReturn.vader has some necessary trailing spaces
2020-01-04 21:21:52 -07:00
Rane Brown b90e6f2e33 Use checkboxes for templates 2020-01-03 19:51:17 -07:00
Rane Brown c7aa3cc122 Update issue and PR templates 2020-01-03 19:35:28 -07:00
Rane Brown 8ccfeb4fdb Add min Vim version, add missing header 2020-01-03 15:34:29 -07:00
Rane Brown 87c13f570a Ignore verbatim blocks when scanning tags.
Merge pull request #672.
2020-01-03 15:24:47 -07:00
Rane Brown 270f542292 Improve detection of code blocks 2020-01-03 15:14:45 -07:00
Rane Brown 3ec0c9cd91 Add markdown syntax support for indented code blocks. 2020-01-03 07:10:02 -07:00
Rane Brown 59e1229da6 Update call to VimwikiGenerateTagLinks 2020-01-03 07:08:54 -07:00
Rane Brown 5126967d09 Rename VimwikiGenerateTags -> VimwikiGenerateTagLinks
Closes #796
2020-01-02 20:53:48 -07:00
Rane Brown 5cdeb9a682 Improve markdown syntax for fenced code blocks. Closes #764 2020-01-01 10:58:56 -07:00
Rane Brown 2c50f710b8 Update changelog 2019-12-30 10:25:02 -07:00
Rane Brown cf072ebdf2 Update how tags are written to file.
Ensures older vims are still supported.
2019-12-30 10:24:52 -07:00
Rane Brown b4e0f738a3 Allow markdown syntax to have tags at top of file.
Previously tags that did not fall under a header caused errors because
the generation code expected an anchor.

Update tags test case.

Closes #790
2019-12-30 10:09:04 -07:00
Rane Brown b9eec79cc6 Update tags file format. Closes #779. 2019-12-30 10:07:20 -07:00
Rane Brown 719036b011 Add ability to select individual tests to run. 2019-12-30 05:58:20 -07:00
Rane Brown 19f913429f Don't overwrite user setting of list_margin.
Closes #789
2019-12-23 13:35:31 -07:00
Rane Brown 3cc6fa71f6 Update default list_margin value 2019-12-21 09:16:48 -07:00
Rane Brown e66464cda0 Remove ft=conf -> Vader is a ft 2019-12-21 09:11:17 -07:00
Rane Brown f18bb6bc57 Add function to print a command output to the buffer 2019-12-21 09:10:39 -07:00
Rane Brown 7ad0ad36dc Set default list_margin=0 for markdown 2019-12-21 09:09:16 -07:00
Rane Brown cd3e3d238b Update changelog 2019-12-20 20:41:08 -07:00
Rane Brown 1a4e1ed1ae Stylistic changes to pass vint tests.
Two non-stylistic errors were also fixed:
  1. Removed duplicate function with invalid argument usage
  2. Added missing quotes to a function call argument
2019-12-20 20:41:03 -07:00
Rane Brown 68e33e37e5 Add info about testing with vader and vint.
Stylistic fixes.
2019-12-20 20:40:59 -07:00
Rane Brown 7c892e2516 Add link to Vimwikiwiki and more info on contributing.
Adds note that only the default syntax has a built in HTML converter.
Also incorporates a few stylistic changes.
2019-12-20 20:40:55 -07:00
Rane Brown b6ea14d3f8 Pin versions for everything 2019-12-20 20:40:48 -07:00
Rane Brown 2526547db2 Cleanup, add link to vim-testbed on DockerHub 2019-12-20 20:40:43 -07:00
Rane Brown 6a047cb067
Merge pull request #785 from tinmarino/merge_goto_nested
VimwikiGoto completion works with part of filename and in nested directories
2019-12-15 19:47:54 -07:00
tinmarino 8db9d4b387 VimwikiGoto: Enable VimwikiGoBackLink after 2019-12-15 19:23:50 -03:00
tinmarino 80013f457d Feature: VimwikiGoto completion works with only part of filename
Problem: Could not complete when the user argument was not the begining
of the filepath
Solution: use custom smartcase filter and customlist instead of custom
2019-12-15 02:27:11 -03:00
tinmarino 64eea36b1e Feature: VimwikiGoto completion get also link of files nested in directories
Before: VimwikiGoto <Tab> -> completed only files in current dir
After: complete also files in nested dirs
Changes: glob(*) -> glob(**/*)
2019-12-15 02:27:11 -03:00
Rane Brown 2a51d83397
Merge pull request #780 from rattletat/dev
Only echo message with custom_wiki2html call if the output isn't empty.
2019-12-14 21:56:09 -07:00
Rane Brown 36faec1de9 Merge tinmarino-dev_vader. Add new vader tests.
Adds tests for the commands:
VimwikiTOC, VimwikiGenerateLinks, VimwikiDiaryGenerateLinks,
VimwikiRebuildTags, VimwikiGenerateTags, VimwikiGoto

Add syntax tests, key mapping tests and table auto format tests.

New helper function in vader setup file.

The default wikis setup in the test vimrc are now mapped to the Docker
containers test user's home directory. The test user does not have
access to write to other locations.
2019-12-14 21:44:19 -07:00
Rane Brown 58331993c7 Update changelog 2019-12-14 21:08:32 -07:00
Rane Brown c58d5da049 Set default ext2syntax values for markdown and mediawiki.
Closes #769.

Also fixes an error when adding missing '.' to mapped extensions. The
previous behavior tried to access a value after it was removed from the
dictionary.
2019-12-14 20:31:59 -07:00
Rane Brown fb5d2f3f82 Move notes about vim patches to readme.
Add some info on additonal patches.
2019-12-14 20:31:59 -07:00
Rane Brown 4f648b6567 Modify how tests are run to improve overall speed.
A Vader issue causes problems with the test results when using the
location list. Because of this the tests were modified to run 1 test
file per vim instance instead of running all tests in a single vim
instance. This resulted in signficant slow down in test execution time.
To speed up execution time only specific tests are run individually now.
2019-12-14 10:41:22 -07:00
Rane Brown eb26a66be5 Add check to generate_tags() to ensure a header is present.
Prior to this fix a file with tags present before any header would
result in vim errors. Now a single Vimwiki message is printed to alert
the user of the issue.
2019-12-14 10:41:22 -07:00
Rane Brown 460fcb692e Make generation functions compatible with older vims.
PR #634, PR #635, and PR #636 introduced new features that broke
compatibility with older version of Vim. This modifies those changes to
ensure compatibility. Closes #781.

Removes usage of funcref(), closure. Fixes filter() call.
Made globpath calls not use the list argument.
Unlet a variable that is reused (sticky type checking)

v7.4.1989 modified filter() to accept a Funcref
v7.4.2120 Added function "closure" argument
v7.4.2137 add funcref()
2019-12-14 10:31:30 -07:00
Michael Brauweiler c48637fd99
Add better echoing of custom wiki2html script
This commit adds a check to the call of the wiki2html script,
so that it is only echoed if it actually produces output.
2019-12-08 12:05:25 +08:00
Rane Brown c8bb658360
Merge pull request #766 from tinmarino/fix_multiple_link_back
Allow VimwikiGoBackLink to store multiple jumps per page (links to headers) Fix #691
2019-11-19 20:50:52 -07:00
tinmarino ce4074aeb9 Test: Add vader tests for fixing going back links on same file 2019-10-28 19:14:50 +01:00
Rane Brown 241126631d
Merge pull request #768 from tessarin/update-mathjax-cdn
Update MathJax CDN Loading Instructions
2019-10-28 05:05:03 -06:00
Cesar Tessarin 16998af36d
Update MathJax CDN loading instructions
The instructions to loading MathJax from a CDN were outdated and not
working for some users.

This commit updates those links to conform with the instructions from:
https://www.mathjax.org/#gettingstarted
2019-10-25 16:13:52 -02:00
tinmarino c4a40e7fc7 Fix: VimwikiGoBackLink does not go back to links on the same page #691 2019-10-24 23:24:17 +02:00
tinmarino 53ba047a18 Clean code: : mutualise bash: is_wiki_link: command not found in a script function 2019-10-24 23:24:17 +02:00
Rane Brown 839a5bf608 Merge branch 'ratfactor-issue-420' into dev 2019-10-20 20:54:35 -06:00
Rane Brown 85b220bae1 Merge branch 'issue-420' of https://github.com/ratfactor/vimwiki into ratfactor-issue-420 2019-10-20 20:27:25 -06:00
Rane Brown 141d1aa081 Treat math blocks in the same manner as code blocks 2019-10-19 10:45:45 -06:00
Rane Brown 4bc6ff4547 Exclude code block comments from header folding.
This makes sure comment characters that match markdown folding are not
recognized as a header and folder. Fixes #212, Fixes #756.
2019-10-16 22:31:42 -06:00
Rane Brown a42cd58636 Don't insert marker character with o or O within a code block.
Previously if a code block was part of a list and o or O was used a new
list marker would be inserted. Also moved the is_codeblock check
function to utils file for use elsewhere.
2019-10-16 22:27:26 -06:00
Rane Brown 1f85a3c855
Merge pull request #735 from simias/fix-407
Fix off-by-one error in get_next_line and get_prev_line
2019-10-15 12:15:14 -06:00
Dave Gauer ad95e3463f Add error handling to VimwikiSearch per issue #420
- Create function wrapper around lvimgrep for input checking, pattern
   quoting, and error handling.
 - Add Vader tests for VimwikiSearch.
 - Change syntax loading from try/catch to explicit file check (to
   prevent Vader test bug).
 - Update doc/vimwiki.txt for changes.
 - Change test script to run Vader tests separately
2019-10-12 18:31:43 -04:00
Rane Brown ba84981b5a Merge branch 'abhinav-dev' into dev
This commit changes the autocmd registration in vimwiki so that
registration happens once rather than once per extension. PR #742
2019-08-28 03:51:51 -06:00
Rane Brown f6a99569bd Merge abhinav-dev
autocmd registration simplification
2019-08-28 03:50:30 -06:00
Rane Brown 0ce3c87a2e
Merge pull request #744 from defau1t/dev
Fixed typo and paragraph formatting in vimwiki help.
2019-08-28 03:36:01 -06:00
defau1t 3cf10e8ddc
Added name to contributors and changelog. 2019-08-26 12:18:59 -06:00
defau1t 515155038f
Fixed typo and paragraph formatting in vimwiki help. 2019-08-26 12:14:33 -06:00
Rane Brown 4458216760 <leader>ww opens the currently active wiki.
The previous behavior was to open the index of the first wiki. This
change makes the command more consistent with similar mappings.
Closes #741.
2019-08-25 14:25:31 -06:00
Rane Brown a17a9826bd Fix 'VimwikiReturn 3 5' behavior within code blocks.
Previously a new list marker would get added when working within a code
block that was part of a list. This change excludes code blocks from
list marker creation.
2019-08-23 14:42:07 -06:00
Rane Brown e814c6ad93 Add test cases for VimwikiReturn command 2019-08-22 05:52:54 -06:00
Rane Brown 4f674f68b4 Fix the method for changing the Vimwiki syntax for tests.
This change ensures the syntax is properly changed when running multiple
tests by removing the previously created temporary wiki and then
creating a new one.
2019-08-22 05:52:54 -06:00
Rane Brown 5ce7c14a3d Properly handle lists with hard wraps. Fixes #443.
This change modifies the behavior of VimwikiReturn to not insert a new
list marker if not within a list. Mostly useful when mapping <CR> to
VimwikiReturn 3 5 or similar. The behavior of 'o' was also modified to
properly insert a marker in a list with hard line wraps.
2019-08-22 05:52:54 -06:00
Rane Brown b5d808b440 Don't use <Plug> definitions for VimwikiReturn mappings.
This is necessary to properly allow the user to remap these since there
are different arguments to the command. The documentation regarding this
command was also updated to be more clear.
2019-08-22 05:52:54 -06:00
Abhinav Gupta 152a7bfdf1 Register autocmds once
This commit changes the autocmd registration in vimwiki so that
registration happens once rather than once per extension.

Instead of the following,

    autocmd BufEnter *.md call s:setup_buffer_enter()
    autocmd BufEnter *.mdown call s:setup_buffer_enter()

We'll now only run,

    autocmd BufEnter *.md,*.mdown call s:setup_buffer_enter()

This probably has no effect on performance but it makes for a simpler
implementation.
2019-08-20 19:24:28 -07:00
Shaedil 28d78b0d39 Update grammar and Pathogen link in readme. 2019-08-19 21:59:08 -07:00
Michael F. Schönitzer 57d23fa763
Fix syntax
It is Vimwiki2HTML with a small w.
2019-08-08 13:53:09 +02:00
Rane Brown 45025fa4f0 Fix docker build command syntax. Closes #736. 2019-08-01 05:19:39 -06:00
Lionel Flandrin dcd68a6781 Fix off-by-one error in get_next_line and get_prev_line
The functions stopped at the end/start block marker (respectively)
instead of returning the following line. This caused issues when the
function was subsequently called in markdown mode since the start and
end block markers are the same.

This fixes #407
2019-07-31 17:56:08 +01:00
Michael F. Schönitzer 0c561e5341 Add note about Telegram group 2019-07-28 15:34:19 +02:00
Rane Brown 594ac7dbe1 Update test script and documentation. 2019-07-24 21:57:01 -06:00
Rane Brown fcb5850c28 Use updated key_mappings variable to check if table_mappings is set 2019-07-20 22:14:48 -06:00
Rane Brown 0678df38e9 Support getbufvar for vim < v7.3.831 2019-07-20 22:13:48 -06:00
Rane Brown 3180209c6f Use python3, update vim versions 2019-07-20 22:13:03 -06:00
Rane Brown 0d0b9a7492 Add script to automate running tests 2019-07-20 22:12:27 -06:00
Rane Brown 0c145c7604 Move helper files so they don't get run with test/* 2019-07-20 22:12:07 -06:00
Rane Brown fbec80b7d9 Remove control characters. Fixes #598 2019-07-17 07:15:06 -06:00
Rane Brown e68592b8ef Create a function fo reload the plugin. Fix setting of mediwiki syntax.
Also adds a few additional link creation tests.
2019-07-17 07:13:36 -06:00
Rane Brown 86cad979e5 Better handling of extensions when normalizing links.
For markdown syntax the extension was added to the url multiple times if
the option g:vimwiki_markdown_link_ext was set which is now fixed.
Normalizing links no longer adds the extension to the description field.
2019-07-17 07:10:47 -06:00
Rane Brown 86926b7212 Update documentation for local key mappings.
Original updates from PR #704.
2019-07-15 08:13:17 -06:00
Rane Brown 8ec1cccb36 Update documentation for intro and folding sections.
Originals modifications from PR #694.
2019-07-15 07:28:12 -06:00
Rane Brown 585a9fd16b Fix paths and add some additional settings 2019-07-14 21:50:49 -06:00
Rane Brown d536fa1117 Basic tests for creating links 2019-07-14 21:50:22 -06:00
Rane Brown fb7d2881d7 Ignore temp test directory 2019-07-14 07:33:25 -06:00
Rane Brown 94d62ad7f2 Add vader tests and docker setup 2019-07-14 07:32:38 -06:00
Rane Brown 0441be5e34 Rename folder 2019-07-13 21:50:35 -06:00
Rane Brown 466bdcd4e8 Don't reuse variable in s:clean_url (sticky type checking)
Versions of Vim prior to 7.4.1546 had sticky type checking which
prevented a variables type from changing. Fixes #715.
2019-07-12 13:52:23 -06:00
Rane Brown af12065e92 Update changelog 2019-07-12 06:26:45 -06:00
Rane Brown c58268df3f Make normalized links in diary pages use relative path.
A previous PR added this feature to the default syntax. This add the
same functionality to markdown syntax. Fixes #729
2019-07-10 21:06:33 -06:00
Rane Brown b997e687c3
Merge pull request #698 from jpmor/dev
Remove awa check triggering silent file edits.
2019-06-05 06:04:41 -06:00
James Moriarty 8914b14e24 Remove awa check triggering silent file edits. 2019-06-04 21:30:52 -04:00
Rane Brown 6ec85cd0e8 Allow buffer local mappings to overwrite existing mappings.
If the fileype is vimwiki then the vimwiki mappings take precedence.
Global mappings will not be overwritten. Closes #699
2019-05-24 20:41:12 -06:00
Rane Brown d045ad4db0 Modify horizontal rule (thematic-breaks) syntax for markdown.
This change makes the horizontal rule syntax more closely match the
commonmark spec https://spec.commonmark.org/0.29/#thematic-breaks. The
number of characters required was changed to 3 and '___' and '***' where
added as valid sequences. The space rules were not added becuase it adds
extra complexity for little benefit. Issue #664.
2019-05-23 21:59:13 -06:00
Rane Brown 42a1f08ffa Disable spell check in code and math inline/blocks.
For nested syntaxes the default spell behavior will still be used e.g.
spelling in comments will still be checked.
2019-05-23 21:47:14 -06:00
Rane Brown 68233c51eb Handle markdown image links '![]()'. 2019-05-23 21:23:53 -06:00
Rane Brown 6755068152 Fix #415, expand iabbrev entries on <CR>. 2019-05-23 21:22:29 -06:00
Rane Brown 70a4852f3c
Merge pull request #711 from gpanders/dev
Allow forcing VimwikiAll2HTML with !
2019-05-22 06:37:58 -06:00
Greg Anders 8bfdf54d10 Update changelog 2019-05-22 06:28:03 -06:00
Greg Anders 12df0bddb2 Update documentation 2019-05-20 08:29:12 -06:00
Greg Anders ddf7e5e0ff Allow forcing VimwikiAll2HTML with ! 2019-05-20 08:22:15 -06:00
Rane Brown efe5f648de Convert path to use '\' for windows in backlinks function.
Fixes #413
2019-05-16 20:47:17 -06:00
Rane Brown 3ba65a671f
Merge pull request #710
Fix in readme - use a lowercase 'w' for Vimwiki commands
2019-05-15 21:35:04 -06:00
AresMegaGlobal b1c009c1df
VimWiki2HTML -> lowercase 'w' in readme 2019-05-15 23:08:46 -04:00
Steve Dondley cf8a16c5c7 Fix list folding bug (PR #705)
Closes #680
2019-05-11 14:01:45 -06:00
Steve Dondley 8c6bc81756 Improve documentation on global key mappings (#703) 2019-05-11 12:55:26 -06:00
Rane Brown c05037a490 Allow escaped characters in markdown links.
Fixes #619
2019-05-08 21:30:06 -06:00
Rane Brown cde4703354 Modify regex pattern for markdown links.
Fixes #240. Also fixes a related issue where markdown links where not
correctly highlighted in todo lists. Adds concealment for markdown links
in todo lists.
2019-05-08 20:55:56 -06:00
Rane Brown 0d8fbebcb8 Print the correct help message for global or wikilocal options.
Fixes #685
2019-05-04 06:31:13 -06:00
Rane Brown 61a6862f8e Update changelog 2019-05-03 22:25:09 -06:00
Rane Brown fd8832cfa1 Fixes #237 VimwikiRenameLink now works for markdown syntax. 2019-05-03 21:19:05 -06:00
Rane Brown 61d93fde7f Exclude '>' from url regex, including tables. Issue #481 2019-04-30 06:11:51 -06:00
Rane Brown 50a3c78c87 Ensure key mappings defined in ftplugin are buffer specific.
The changes made with #686 did not ensure the ftplugin mappings were
specific to the buffer containing a Vimwiki file. This resulted in
undesired keymappings with no defined behavior since the <Plug>
definition was buffer specific.
2019-04-29 23:03:00 -06:00
Rane Brown bb15cd1aff Exclude '>' from url regex.
Fixes #481
2019-04-29 22:09:38 -06:00
Steven Stallion ad4d43abfe Add :VimwikiGoto key maping 2019-04-27 11:10:32 -05:00
Rane Brown 4106cb7bc7 New option g:vimwiki_key_mappings to enable/disable key mappings.
All key mappings have the option of being disabled but the <Plug>
definitions are still available for user customization. Key sequences
are no longer overwritten if a mapping already exists. Fixes #671,
fixes #425.
2019-04-26 21:17:35 -06:00
Jonny Bylsma e84dcbfa25 Prevent sticky type checking (E706) errors with older Vims (#681)
Vim used to throw the E706 error if you tried to change a variable's
type. This error can be triggered by vimwiki if, during the user
settings loop in `read_global_settings_from_user()`, the variable type
for `users_value` changes.

The vim error was removed in v7.4.1546 as part of
f6f32c38bf.
2019-04-26 11:06:09 -06:00
Alexander Gude 6787e0fb7e Change diary_rel_path minimum length to 0 (#689)
Changing this option to allow empty strings places the diary files in the same directory as the main wiki files. This is more backwards compatible with previous releases.
2019-04-26 06:23:45 -06:00
Steve Dondley 1e5c93ea91 Improve documentation of key bindings in README (#687) 2019-04-25 08:18:41 -06:00
Marcelo D Montu 2b6fa274a8 Speed improvement with folding enabled
The 'foldmethod' was being reset every time the cursor entered a vimwiki, causing an unnecessary large delay. So it was changed to set it only the first time the buffer is loaded into a window. This greatly improves performance when switching between vim tabs. Fold settings are also reapplied after using 'diffoff'. Added test/ directory with sample file and instructions for testing this change.

Fixes #580
2019-04-22 07:39:11 -07:00
Rane Brown 510c149512 Add wikilocal option to assign a name to each wiki.
Names can be used for interwiki links in the format wn.name:link.
Additionally, :VimwikiUISelect and the menu created in GVim utilize the
wiki name. Fixes #612, closes #477.
2019-04-21 13:05:01 -06:00
Rane Brown 37f020d21a Omnicompletion fix for Windows (#660)
* Temporary fix for omnicomplete of vimwiki links - #456.

This fixes the omnicomplete of wiki links under Windows which were
not working since paths on Windows use '\' instead of '/'. This is
a temporary fix until path refactoring is done.

* Update changelog with description of fix for #456
2019-04-20 17:28:32 +02:00
Rane Brown 13adbe3510
Merge pull request #670 from monkinco/dev
New Logo, Screenshots & CSS
2019-04-20 08:09:13 -07:00
Michael F. Schönitzer be793e28be Update matrix-address to new canonical address 2019-04-20 14:13:17 +02:00
Michael F. Schönitzer 79d6a1a4e2 Update version number to 2.4.1 2019-04-20 14:01:11 +02:00
Michael F. Schönitzer f105819c48 Add screen shots provided by @monkinco in PR #670
I cut the screen shots to only show features of vimwiki.
2019-04-20 13:51:15 +02:00
Monkin 3d076f01c8
New Logo and Screenshots
Update CSS Styles

Add Splash Image

Compress PNG

Remove header

Change headings sizes

Add background colors to code blocks and use HEX

Update fonts and put back old screenshots

Change font-size in code blocks
2019-04-19 21:01:02 +02:00
Rane Brown d1cc873809 Ignore .tags files 2019-04-15 08:36:26 -06:00
Rane Brown 9d10610c4a Add option g:vimwiki_auto_header to automatically generate H1.
A level 1 header will automatically be generated for new files. The
title used in the header is based on the filename. Closes #245.
2019-04-13 07:00:06 -06:00
Rane Brown aff0258d03
Merge pull request #665 from patrickdavey/dev
Add html_filename_parameterization option.
2019-04-13 06:42:04 -06:00
Rane Brown 750b3171b3 Prevent table formatting mappings from overwriting user mappings.
Closes #425
2019-04-12 20:38:23 -06:00
Patrick Davey 5f01182468 Add html_filename_parameterization option.
This adds the vimwiki_local `html_filename_parameterization` option (0|1)
which performs the same sanitization of filenames as does the
vimwiki_markdown gem.

For example, if your file is called "My File.md" it will be written out
as "my-file.html".

If the html_filename_parameterization options is enabled, we also _do
not delete_ non-matching html files when the VimwikiAllToHtml command is
run.

Closes #129
2019-04-13 10:07:51 +12:00
Rane Brown 1e74443b5a Allow additional filetypes to be registered to vimwiki files.
This options allow third party plugins to register and enable additonal
functionality by setting the filetype to vimwiki.other_ft.other_ft2 etc.
This option should be used with care since vimwiki functionality can be
overwritten by other plugins. See Issue #461 for an example use case.
2019-04-12 07:42:49 -06:00
Rane Brown ae67790ad5
Merge pull request #663 from padowi/vimwiki_315
Add option to not conceal one-character markers
2019-04-11 21:32:49 -06:00
Rane Brown 4a9f81c54b Add info to include in help file. Issue #652 2019-04-10 21:31:23 +02:00
Rane Brown d3aade7349 Fix VimwikiShowVersion function. Closes #654.
Change a:xxx variable to l:xxx since argument variables are immutable as
of Vim patch 888. Convert the stable version number to a string prior to
printing.
2019-04-10 21:31:15 +02:00
Monkin 62d71b832a Update and format README.md 2019-04-10 21:31:02 +02:00
Rane Brown b90fbc70d9 Fix missing 'T' in syntax definition of VimwikiDelTextT
The missing 'T' character was causing strikethrough ~ characters to be
hidden within tables which is not the desired behavior. Closes #404.
2019-04-10 21:28:47 +02:00
Henry Qin 048f2eb34a Remove redundant layer of branching in get_cell_aligns_fast 2019-04-10 11:06:05 -07:00
Henry Qin 63985a52e8 Rename get_cell_fast_aligns --> get_cell_aligns_fast 2019-04-10 11:02:13 -07:00
Henry Qin 08dcae9630 Merge branch 'dev' of https://github.com/lyokha/vimwiki into lyokha-dev 2019-04-10 10:48:42 -07:00
Patrik Willard b172db23d3
Add changelog entry 2019-04-10 16:00:50 +02:00
Patrik Willard 8fbe51d614
Update with review comments 2019-04-09 22:31:41 +02:00
Patrik Willard a5bda652d0
Add option to not conceal one-character markers
Adds new configuration variable, "conceal_onechar_markers", defaulting
to on (preserving default behaviour)

Adds if-statement around relevant parts of code (as suggested in the
issue), which uses the new configuration variable.

Fix #315 - Don't conceal one-character markers
2019-04-09 08:17:56 +02:00
Rane Brown 82ba1e99bf Move variable declaration outside of for loop 2019-04-08 22:18:07 -06:00
Rane Brown 3bf389bf99 Don't replace spaces in link description for markdown syntax.
The option 'links_space_char' replaces spaces with the specified
character when creating a link from a visual selection. This modifies
the behavior to not replace spaces in the link description but to still
replace spaces in the filename.
2019-04-08 20:54:21 -06:00
Rane Brown 848feb43e1 Add v2.5 release info. Issue #652 2019-04-07 09:04:46 -06:00
Rane Brown b77473960a Add info to include in help file. Issue #652 2019-04-07 09:03:58 -06:00
Rane e7f5ce6046 Fix VimwikiBackLinks on Windows. See Issue #413.
This is a temporary fix until refactoring of path handling is complete.
2019-04-06 10:43:09 -06:00
Alexey Radkov d040a4bd7d
Merge branch 'dev' into dev 2019-04-04 21:34:34 +03:00
lyokha 0303021abd Fast aligns check
The optimized table formatting algorithm was still O(n) because
calculating aligns required traversal to the separator line on the top
of a table. This heuristic algorithm calculates aligns in O(1) in the
best case by looking at cells in two rows above.

Say, if two above rows are

|      uau | uauyaya         | ya      |
|       ua | uaua            | uaaua   |
| <cursor> |                 |         |

then the aligns can be figured out without need to find the separator
line. If aligns cannot be figured out after this fast check then the
algorithm falls back to O(n) with searching for the separator line.
2019-04-04 21:30:14 +03:00
Лёха ae3db7a079 Do not format current table line directly in get_rows()
This formatting is needed in the optimized table formatting algorithm
for shrinking the current table line to try the best to avoid
re-formatting the whole table. However, this breaks cursor motion and
may also affect other table related behaviors. The fix is to move this
formatting to get_aligned_rows(). Now table rows are not affected by any
means, because the current row is only replaced temporarily for the
formatting purpose only and gets reverted as soon as the check is
finished.

Fixes #656.
2019-04-04 00:13:00 -07:00
Henry Qin 3c0ae2ff97 Revert "table alignment: break out of loop when separator found"
This reverts commit 23d273d547, which
fixes #655.

Description of fixed problem:
1. When looping through rows, if a separator was found, all subsequent
   rows would not get an assigned alignment.
2. This breaks `s:get_aligned_rows` because it calls `s:fmt_sep` and
   `s:fmt_row`, both of which expect `aligns` to have a value for every
   row number.
2019-04-03 11:44:36 -07:00
Rane Brown 4928132e5f Use shiftwidth to calculate diary index header indentation 2019-04-03 11:58:27 -06:00
Rane Brown 80a94cd8c7 Correctly indent diary section links when list_margin is 0 2019-04-03 10:48:23 -06:00
Rane Brown c21de17a34 Fix VimwikiShowVersion function. Closes #654.
Change a:xxx variable to l:xxx since argument variables are immutable as
of Vim patch 888. Convert the stable version number to a string prior to
printing.
2019-04-03 08:39:21 -06:00
Alexey Radkov e0fffb470a Separator line in a table requires special treatment (#651)
Fix #650 – horizontal table delimiter treated wrong
2019-04-01 23:13:24 +02:00
Henry Qin e91150478e Add back a newline in s:get_version()
Fixes #649
2019-04-01 11:02:27 -07:00
Monkin 308e2056f6 Update and format README.md 2019-04-01 11:02:27 -07:00
Rane Brown 4f5d4c9400 Change the tagfile name.
This changes the tags file used by vimwiki to '.vimwiki_tags' to prevent
conflicts with other tools that may generate a tags file using the same
name such as gutentags.
2019-04-01 09:46:41 -06:00
Rane Brown 41aa647aba Add option to set a character which replaces spaces when creating links.
The wikilocal option links_space_char will be used to replace any spaces
when creating a new wiki link and page. This only affects link creation
with a visual selection.
2019-03-31 21:19:50 -06:00
Rane Brown 3396e87dbe Fix problems with commands not taking a count and mapping behavior.
Commands such as :VimwikiIndex and :VimwikiDiaryIndex did not previously
take a count and the doucmentation was inconsistent/incorrect for the
behavior of these commands. Fixes #543.
2019-03-31 20:00:37 -07:00
Rane Brown 1ba99ae135
Merge pull request #636 to support file exclusion in link generation 2019-03-31 13:29:11 -06:00
Rane Brown c9229244a8 Don't change conceal behavior of wiki elements with max_urlsave option.
Closes #539
2019-03-30 21:52:56 -06:00
Steven Stallion 3b9aa6b162 Support file exclusion in link generation 2019-03-30 21:10:14 -05:00
Rane Brown 047947cbbe
Merge pull request #635 from sstallion/sstallion/autogenerate-tags
Support automatic generation of links and tags
2019-03-30 19:56:57 -06:00
Rane Brown 14c5302697
Merge pull request #644 from hq6/hq6_dev
Add gnt mapping to jump to the next unfinished task in a wiki page.
2019-03-30 19:41:57 -06:00
Steven Stallion 0e664a6230 Merge branch 'dev' of git://github.com/vimwiki/vimwiki into sstallion/autogenerate-tags 2019-03-30 20:34:57 -05:00
W d089a2c65a
Add info about bold&italic text to the doc 2019-03-30 20:22:12 +00:00
Henry Qin 3f7f85cfc6 Add command and map to jump to the next unfinished task.
Introduce the command `VimwikiNextTask` and the mapping `gnt` to jump to
the next unfinished task.
2019-03-30 12:45:19 -07:00
Michal Cizmazia b849a411e3
Add toc_link_format option
Add an option for setting the format of the links in the Table of Contents:
- Extended (the current and default)
- Brief (new format for the Vimwiki markup)
2019-03-29 21:28:11 +01:00
Steven Stallion fc158ba744 Support automatic generation of links and tags 2019-03-28 20:11:47 -05:00
Greg Anders e56c26c7ba Add an option to conceal preformatted text blocks
This merges PR #641.
2019-03-28 14:50:25 -07:00
Rane Brown f5cf991115
Merge pull request #634 from sstallion/sstallion/headers
Adjust generated header behavior for TOC, links, tags, and diary (oh my!)
2019-03-26 11:57:24 -06:00
Steven Stallion 6c2f9f999d Adjust generated header behavior for TOC, etc. 2019-03-26 12:03:09 -05:00
Rane Brown cdc9940887 Fix spelling per comment in #637 2019-03-25 08:44:59 -06:00
Rane Brown a013e8b1b5
Merge pull request #637 from tinmarino/dev
Add option : g:vimwiki_table_reduce_last_col to not expand the last column of a table.
2019-03-24 21:40:27 -06:00
Michael F. Schönitzer 6766c37ce0 Set release date for 2.4 2019-03-24 15:06:50 +01:00
tinmarino dfccfb1951 Add option : g:vimwiki_table_reduce_last_col. Used to not expand table last cells in order to avoid large, useless wraps 2019-03-23 11:23:58 -03:00
Rane Brown 32c7f289b7 Fix missing 'T' in syntax definition of VimwikiDelTextT
The missing 'T' character was causing strikethrough ~ characters to be
hidden within tables which is not the desired behavior. Closes #404.
2019-03-21 22:26:42 -06:00
Michael F. Schönitzer ae365a8b8f Merge branch 'master' into dev 2019-03-21 23:21:32 +01:00
Michael F. Schönitzer 5553cef249 Update version number 2019-03-21 23:09:36 +01:00
Michael F. Schönitzer 7fbeea2c1e Update the changelog 2019-03-21 23:06:01 +01:00
Michael F. Schönitzer 57385b29bb Update list of contributors 2019-03-21 21:52:59 +01:00
Michael F. Schönitzer d0e14dd11c Merge branch 'master' into rel-2.4-pre 2019-03-21 21:12:44 +01:00
Eric Langlois 8f5d38365b Added optional extra caption levels to diary index.
Added the option 'diary_caption_level', which controls the presence of
captions in the diary index linking to headers within the diary pages.

Possible values:
-1:  No headers are read from the diary page.
 0:  The first header from the diary page is used as the caption.
       There are no sub-captions.
 1:  Captions are created for headers of level 1 in the diary page.
 2:  Captions are created for headers up to level 2 in the diary page.
 etc.

When the value is >= 1, the primary caption of each diary page is set to
the first header read from that page if it is the unique lowest-level
header.
2019-03-20 14:09:57 -07:00
Rane Brown a5ef478750
Improverize issue template per #513 2019-03-20 06:24:16 -06:00
Rane Brown 7d82c7541d
Merge pull request #529 from sstallion/sstallion/markdown_link_ext
Add support for Markdown link extensions!!!
2019-03-19 21:54:32 -06:00
Samir Benmendil 9964026586 Don't override existing mappings 2019-03-19 22:03:50 +00:00
Steven Stallion eb00d30d9b Initial commit 2019-03-19 10:33:08 -05:00
Rane Brown c8d09d7c9e
Merge pull request #629 from gpanders/dev
Allow customization of header level of TOC
2019-03-18 17:20:30 -06:00
Лёха e0f4ab8c5e Revert implementation of function s:get_cell_aligns()
This commit reverses a change to s:get_cell_aligns introduced by
bdcfca1e5c.
2019-03-18 14:43:43 -07:00
Steven Stallion ad8e1d30bf Add g:vimwiki_create_link option to prevent link creation.
Adds a new global option named create_link, which allows the user to
control :VimwikiFollowLink behavior when attempting to follow a
non-existent link. The original behavior of creating a new link is
preserved. However, by setting this option to 0, new links will not be
created when pressing return over regular text. Closes #528.
2019-03-18 14:37:12 -07:00
Henry Qin c4b21b498e Convert DesignNotes to Markdown to fix display in GitHub. 2019-03-18 11:46:52 -07:00
Henry Qin bdcfca1e5c Merge branch 'lyokha-dev' into dev. Closes #47.
This PR optimizes large table reformatting to only look at a subset of
rows.
2019-03-18 11:33:11 -07:00
lyokha ad6a3bceb6 the cause of the linear slowing down was fixed 2019-03-18 17:49:13 +03:00
lyokha 1f4fb8ca58 notes on the newer table formatting algorithm 2019-03-18 16:02:52 +03:00
lyokha 0c82d9dcb8 Merge remote-tracking branch 'upstream/dev' into dev 2019-03-18 13:13:30 +03:00
Rane Brown 605604fc23
Create an issue template 2019-03-17 22:24:51 -06:00
Rane Brown 7f98bfbe4b
Create a pull request template. 2019-03-17 22:06:10 -06:00
Henry Qin efcc3f1fa5 Merge branch 'wiki-path' into 'dev'. Closes #573.
Introduce a `%wiki_path%` variable which can be used in HTML template
files to output the path of the wiki file being converted to HTML.
2019-03-17 18:19:49 -07:00
Henry Qin e6d6830db7 Merge branch 'colorcodes' into 'dev'. Closes PR #616.
This colors all CSS color codes found alone in inline code blocks to the
color they mention.
2019-03-17 18:09:06 -07:00
Hugo Hörnquist da52523710 Add documentation for colorcodes. 2019-03-17 22:50:56 +01:00
Hugo Hörnquist 2f87f92060 Better foreground for colorcodes. 2019-03-17 22:40:34 +01:00
Hugo Hörnquist 6f687aff52 Move location of %wiki_path% documentation. 2019-03-17 22:22:55 +01:00
Henry Qin 8941508e35 Allow AddHeaderLevel and RemoveHeaderLevel to take counts 2019-03-17 10:43:42 -07:00
Henry Qin b4c9a4f028 Add DesignNotes.wiki, a place for internal documentation 2019-03-17 10:43:12 -07:00
lyokha 88a6820e9e updated for the new aligns feature 2019-03-15 16:07:52 +03:00
Alexey Radkov fa6342c454
Merge branch 'dev' into dev 2019-03-15 15:38:22 +03:00
lyokha 5e4a89c898 faster table format on InsertLeave; faster s:get_rows() 2019-03-15 15:31:28 +03:00
Rane f40f054441 Merge branch 'md_bold_italics' into dev
This fixes Markdown syntax for bold, italic, and bold_italic. With these
changes **bold** and __bold__, *italic* and _italic_, and
***bold_italic*** and ___italic_bold___ are shown correctly.
This closes #23, closes #189, closes #318, and closes #576.
2019-03-15 06:25:01 -06:00
Rane 1f1966a4f6 Add description of markdown specific text decorators 2019-03-15 06:12:35 -06:00
Henry Qin abd12d4479 Merge PR #377 from https://github.com/schmeisers/vimwiki 2019-03-14 18:08:27 -07:00
Rane 6b29b6604c Fix bold_italic and italic_bold markdown syntax. 2019-03-14 15:21:04 -06:00
Rane e26d9fdb8e Fix bold and italic markdown syntax 2019-03-14 14:03:42 -06:00
Greg Anders bb40826def Allow customization of header level of TOC
Instead of forcing the TOC to always be at header level 1, allow the
user to specify via the option g:vimwiki_toc_header_level what level
they want.

This defaults to 1, so if the user does nothing then the old behavior
will remain the same.
2019-03-14 08:34:52 -06:00
lyokha 07ba7339f1 added docs about new commands gq1 and gw1 2019-03-14 14:44:08 +03:00
lyokha 30c0bdffaa synced README.md with the remote dev branch (3) 2019-03-14 14:25:35 +03:00
lyokha 7e176c659b synced README.md with the remote dev branch (2) 2019-03-14 14:24:13 +03:00
lyokha bfbfa2783e synced README.md with the remote dev branch 2019-03-14 14:21:28 +03:00
Alexey Radkov af8cdc4d62
Merge branch 'dev' into dev 2019-03-14 14:09:30 +03:00
lyokha a74e0821b0 resolved conflicts in tbl.vim 2019-03-14 13:36:51 +03:00
EinfachToll 54d1a997d9 Update Contributing.md 2019-03-11 21:24:19 +01:00
Michael F. Schönitzer 5ab8f8672e
Add call for help and note about Riot 2019-03-09 14:49:01 +01:00
Hugo Hörnquist 08ec02a755 Alternative where text color is inverse of background. 2019-02-19 21:04:57 +01:00
Hugo Hörnquist 21f5069e48 Code-blocks auto-color. 2019-02-19 20:45:10 +01:00
EinfachToll 1b2643ea19 Clarify the description of hl_cb_checked in the doc
Ref #605
2019-02-04 21:48:18 +01:00
EinfachToll e16dc41a50 The recommended branch to use is master, not dev 2019-02-01 17:51:41 +01:00
EinfachToll 19f1d36229 Revert "Initial commit"
This reverts commit 7699967a99.
Reason: It's wrong. In markdown, opposed to mediawiki, list items can be indented, e.g. when a
list contains a list.
2019-02-01 17:48:48 +01:00
Stefan Huber b8d0cf377d doc: Fix spelling for <Leader> 2019-02-01 17:43:05 +01:00
Nico a7160310c9 Patch for issue #585 - implement suggested improvements 2019-02-01 17:43:05 +01:00
Nicolas Brailovsky 0f38192b03 Patch for issue #585, fix anchor links for multiple extensions 2019-02-01 17:43:05 +01:00
CUI Hao (Lab) 41199e6e3b Update Chinese readme & add links to each readme 2019-02-01 17:43:05 +01:00
Fredrik Arnerup 69aa609941 Don't include trailing period in link 2019-02-01 17:43:05 +01:00
Daniel Quomsieh 72bbb1b740 fixed writing error 2019-02-01 17:43:05 +01:00
Steven Stallion 7699967a99 Initial commit 2019-02-01 17:43:05 +01:00
Michael F. Schönitzer 394efe4312 Add a command that shows the version or commit
Ref #512
2019-02-01 17:43:05 +01:00
EinfachToll ea13b0e848 Make master the recommended branch to use
Discussed in #505
2019-02-01 17:43:05 +01:00
EinfachToll daee3b4796 Fix a typo 2019-01-30 21:46:03 +01:00
Hugo Hörnquist bda3a59f91 Made headings link to themselves.
Made each heading link to itself, by placing an <a> tag inside each
<h[1-6]> tag.

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

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

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

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

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

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

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

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

* Avoid matching "TODO" on word boundaries

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

Similar to opening a tab,::

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

we can now open a split with::

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

and a vertical split with::

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

Similar to opening a tab,::

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

we can now open a split with::

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

and a vertical split with::

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

Similar to opening a tab,::

vimwiki#base#goto_index(1, 1)

we can now open a split with::

vimwiki#base#goto_index(1, 2)

and a vertical split with::

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

Similar to opening a tab,::

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

we can now open a split with::

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

and a vertical split with::

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

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

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

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

* Update documentation

* Add support for arbitrary size listsyms to vimwikihtml
2017-01-22 20:16:10 +01:00
EinfachToll 31760a7ef7 Fix a few regression bugs
Ref #256
2017-01-16 22:10:28 +01:00
EinfachToll fea76ace23 Use new access functions for buffer-local variables
Ref #256
2017-01-13 16:33:41 +01:00
EinfachToll ce5c822072 Start refactoring the rest -- part 6
Ref #256
2017-01-12 21:45:09 +01:00
EinfachToll b61ff8b5ee Start refactoring the rest -- part 6
Ref #256
2017-01-11 22:12:33 +01:00
EinfachToll 1806d3edfa Start refactoring the rest -- part 5
Ref #256
2017-01-07 21:51:15 +01:00
Michael Thessel 8507c95716 Added config option to allow for newlines in text when exporting to HTML 2017-01-05 22:17:37 -08:00
EinfachToll 4a96eb4d32 Remove two undocumented and probably buggy features 2017-01-04 22:10:10 +01:00
EinfachToll 203fb5b430 Start refactoring the rest -- part 4
Ref #256
2017-01-04 21:53:03 +01:00
EinfachToll b82245b09e Start refactoring the rest -- part 3
Ref #256
2016-12-31 20:47:19 +01:00
EinfachToll 7c98ce3934 Start refactoring the rest -- part 2
Ref #256
2016-12-28 22:17:08 +01:00
EinfachToll c9104fc2c1 Start refactoring the rest -- part 1
Ref #256
2016-12-25 21:35:56 +01:00
EinfachToll 250fd3c47b Use new access functions for wiki-local variables -- part 5
Ref #256
2016-12-23 20:05:53 +01:00
EinfachToll 2329d602a7 Use new access functions for wiki-local variables -- part 4
Ref #256
2016-12-22 21:00:19 +01:00
EinfachToll f497a4abc7 Use new access functions for wiki-local variables -- part 3
Ref #256
2016-12-22 19:55:20 +01:00
EinfachToll 61910cd93a Use new access functions for wiki-local variables -- part 2
Ref #256
2016-12-22 19:12:03 +01:00
EinfachToll 6221861957 Use new access functions for wiki-local variables -- part 1
Ref #256
2016-12-22 18:16:05 +01:00
EinfachToll 23ee20887a Use new access functions for global variables -- part 3
Ref #256
2016-12-21 22:11:44 +01:00
EinfachToll 49bdf7fa47 Use new access functions for global variables -- part 2
Ref #256
2016-12-21 21:28:48 +01:00
EinfachToll e6d997867a Use new access functions for global variables -- part 1
Ref #256
2016-12-21 19:43:34 +01:00
EinfachToll 6b34e954e8 Add new functions for variable access
Ref #256
2016-12-21 17:09:25 +01:00
EinfachToll 3a87437005 Merge pull request #276 from bcicen/add-vundle-install-steps
Add vundle install steps to readme
2016-12-18 21:43:33 +01:00
Bradley Cicenas 690936ec97 add vundle install steps to readme 2016-12-18 06:23:14 -06:00
Shafqat Bhuiyan febf716bf5 Fix example mapping for decreasing list item level 2016-12-13 10:30:51 +11:00
Alex Thorne 4c5b0fec6b
Fix typo in docs 2016-12-12 22:20:52 +00:00
EinfachToll bb75ec6deb Merge pull request #264 from christianrondeau/check-before-imap-cr
Prevent imap of `<CR>` if already mapped
2016-12-06 08:42:28 +01:00
Christian Rondeau 3b96f8ffeb Prevent imap of `<CR>` if already mapped 2016-12-05 18:17:38 -05:00
EinfachToll 0966031234 Highlight math not using TeX but TeX math
Fix #236
2016-11-24 16:46:56 +01:00
EinfachToll 2c9df65644 Merge pull request #251 from jconroy77/markdown_nested_syntax
Automatic detection of nested syntaxes in markdown
2016-11-23 21:49:37 +01:00
John Conroy 8534219694 Automatic detection of nested syntaxes in markdown 2016-10-31 15:35:57 -04:00
mMontu 777569f95f Workaround for slow folding methods (issue #225) 2016-07-12 11:41:44 -03:00
EinfachToll 3f66117894 When sorting tags, always match case because Vim expects it 2016-05-23 22:02:03 +02:00
EinfachToll 4831384ab9 Merge branch 'dev' 2016-05-18 22:07:49 +02:00
EinfachToll 3a5a5ef0ad Prefer the value of nested_syntaxes over detected syntax 2016-05-17 20:29:59 +02:00
EinfachToll f567009329 Merge pull request #201 from irfansharif/patch-1
fix a tag in the doc
2016-04-25 08:52:40 +02:00
irfan sharif 7e3234e0bf fix vimwiki.txt intro tag
previously redirected to `CONTENTS` page, changed to redirect to `Intro` page
2016-04-24 16:45:21 -04:00
EinfachToll 129c281810 Update changelog 2016-03-31 12:10:27 +02:00
EinfachToll 722d6e4b9a '+' on a raw url surrounds it with brackets
Fix #188
2016-03-21 09:02:22 +01:00
EinfachToll 0001b3cda9 Copy CSS file also with :Vimwiki2HTML 2016-03-19 22:01:25 +01:00
EinfachToll 68cdfe36df Unify all messages to the user 2016-03-19 21:29:42 +01:00
EinfachToll 4956976bb6 Some fixes in the doc 2016-03-19 19:55:08 +01:00
EinfachToll 4c2e13a284 Skip preformatted and math text while scanning for headers
Fix #191
2016-03-18 15:18:23 +01:00
EinfachToll 4bd0690a52 Simplify some regexes 2016-03-18 15:16:59 +01:00
EinfachToll 128581babc Merge remote-tracking branch 'optik-aper/master' into dev 2016-03-01 10:46:29 +01:00
Michael c2d1869227 Escape tilde (~) in path names otherwise regex comparison gets upset 2016-02-29 16:12:56 -05:00
EinfachToll 6f579711ab Merge pull request #186 from lotabout/master
fix #64: markdown style link support
2016-02-22 11:42:42 +01:00
zhang_ji 6d96516ab4 enhance #64: generate same link type for visual mode and normal mode 2016-02-22 16:00:37 +08:00
EinfachToll 0ea8d85b7f Sort links in the list generated by VimwikiGenerateTags
Fix #192
2016-02-19 11:32:58 +01:00
EinfachToll 5f9dbca89c Small cleanup of the merged PR
Ref #187
2016-01-28 10:52:40 +01:00
EinfachToll 2aeaea5f0d Merge pull request #187 from mMontu/nested
Dynamically detect nested syntaxes (fix #128)
2016-01-28 10:29:53 +01:00
mMontu a2888692fd Option for automatic detection of nested syntaxes 2016-01-27 13:30:30 -02:00
mMontu fc947523b0 Dynamically detect nested syntaxes (fix #128) 2016-01-27 10:14:49 -02:00
EinfachToll 91a004bc23 Remove superfluous debug message 2016-01-25 13:47:41 +01:00
EinfachToll 78cef05fa3 Fix HTML conversion of headers containing links
Fix #183
2016-01-22 13:32:01 +01:00
EinfachToll 1db5924271 Update the changelog 2016-01-21 13:27:43 +01:00
EinfachToll ff90e980de Locate the .tags file correctly on windows
Ref #184
2016-01-21 13:27:08 +01:00
EinfachToll bb3026dba8 Include subdir in wiki page name when rebuilding tags
Ref #184
2016-01-21 13:25:04 +01:00
zhang_ji b0cc6ff0de fix #64: markdown style link support 2016-01-18 16:51:08 +08:00
EinfachToll 949b29b694 Fix tags file path when 'path' contains spaces
Fix #176
2015-12-14 10:36:16 +01:00
EinfachToll f31550badb Merge pull request #165 from Tomsod/dev
Add command for opening yesterday's diary
2015-12-11 11:49:45 +01:00
EinfachToll 3bd3d9b860 Update changelog 2015-12-10 16:19:26 +01:00
EinfachToll e0d72759a6 Remember kids: always use :normal! with the bang in plugins
Fix #175
2015-12-10 16:07:36 +01:00
Ivan 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
EinfachToll 9be96884ba Remove g:VimwikiLog and the timing stuff
For profiling, there is Vim's :profile command
2015-12-07 12:29:25 +01:00
EinfachToll 2a70e1517e Remove g:vimwiki_debug, which probably nobody used 2015-12-07 12:27:32 +01:00
EinfachToll c565b38bb6 Remove some unreachable code 2015-12-07 12:25:17 +01:00
Ivan 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
Ivan Tishchenko 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
Ivan Tishchenko 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
EinfachToll 3eb20a6c98 Fix regression bug: Normalize paths if settings changed after startup
Fix #171
2015-11-30 13:33:22 +01:00
EinfachToll 7124a9be97 Add a note to the change log
Hopefully not too late.
Ref #173
2015-11-30 13:13:06 +01:00
Ivan Tishchenko 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
Ivan Tishchenko 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
Ivan Tishchenko 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
Ivan Tishchenko 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
EinfachToll 8231433bad Merge pull request #168 from hiberabyss/macurl
follow url silently in mac
2015-11-26 09:32:51 +01:00
Hongbo Liu 399e9a4512 follow url silently in mac 2015-11-26 11:54:32 +08:00
Tomsod M 64f71bc785
Add :VimwikiMakeYesterdayDiaryNote command
Opens diary for yesterday.
For when you stay up past midnight.
2015-10-29 01:00:00 +03:00
Alexey Radkov 920f41b318 fixed get_cells() FSM and gqq command
- get_cells() FSM correctly treats unclosed quotes now,
- fixed gqq command: now it aligns all the table
- proposed 'fast' variant of gqq: gq1 that aligns current + 2 above rows
2014-05-09 12:47:21 +04:00
Alexey Radkov 72ad6d1b16 minor stylistic change 2014-05-04 20:46:00 +04:00
Alexey Radkov 4d1bb91dbe small fix in s:get_aligned_rows() 2014-05-04 18:42:00 +04:00
Alexey Radkov cd25233cc8 fast <Tab> and <S-Tab> in Insert mode
this also fixes Tab navigation in a new added line
2014-05-04 17:09:42 +04:00
Alexey Radkov b79977d6b8 further large table optimizations
1. s:get_aligned_rows(): getting 2 last rows is enough for having been
   formatted tables
2. vimwiki#tbl#get_cells(): using faster strpart() instead concatenating
   every new character into variables cell and quote
3. checking by getline() whether the line was changed before setline()
   does matter on slower computers
2014-05-04 15:46:19 +04:00
Alexey Radkov 411d8da0a4 Merge remote-tracking branch 'upstream/dev' into dev 2014-05-04 15:25:38 +04:00
Alexey Radkov 0559bf8aed Merge remote-tracking branch 'upstream/master' into dev 2014-05-04 15:23:45 +04:00
68 changed files with 22454 additions and 4873 deletions

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

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

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

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

2
.gitignore vendored
View File

@ -2,6 +2,7 @@
# This section is devoted to this project
##############################
doc/tags
.tags
# Vim stuff
##############################
@ -20,3 +21,4 @@ Session.vim
.Trashes
ehthumbs.db
Thumbs.db
vimtest

27
.travis.yml Normal file
View File

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

72
CONTRIBUTING.md Normal file
View File

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

186
DesignNotes.md Normal file
View File

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

23
Dockerfile Normal file
View File

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

22
LICENSE.md Normal file
View File

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

View File

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

362
README.md
View File

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

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
#
# This script converts markdown into html, to be used with vimwiki's
# "customwiki2html" option. Experiment with the two proposed methods by
# "customwiki2html" option. Experiment with the two proposed methods by
# commenting / uncommenting the relevant lines below.
#
# NEW! An alternative converter was developed by Jason6Anderson, and can
@ -46,7 +46,7 @@ OUTPUT="$OUTPUTDIR"/$(basename "$INPUT" .$EXTENSION).html
# # Method 1:
# # markdown [-d] [-T] [-V] [-b url-base] [-C prefix] [-F bitmap] [-f flags] [-o file] [-s text] [-t text] [textfile]
#
#
# URLBASE=http://example.com
# $MARKDOWN -T -b $URLBASE -o $OUTPUT $INPUT

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,39 +1,41 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Desc: Path manipulation functions
" Description: Path manipulation functions
" Home: https://github.com/vimwiki/vimwiki/
function! vimwiki#path#chomp_slash(str) "{{{
function! vimwiki#path#chomp_slash(str) abort
return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}}
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)
function! vimwiki#path#is_equal(p1, p2) abort
return a:p1 ==? a:p2
endfunction
else
function! vimwiki#path#is_equal(p1, p2)
function! vimwiki#path#is_equal(p1, p2) abort
return a:p1 ==# a:p2
endfunction
endif "}}}
endif
" collapse sections like /a/b/../c to /a/c
function! vimwiki#path#normalize(path) "{{{
" collapse sections like /a/b/../c to /a/c and /a/b/./c to /a/b/c
function! vimwiki#path#normalize(path) abort
let path = a:path
while 1
let result = substitute(path, '/[^/]\+/\.\.', '', '')
let intermediateResult = substitute(path, '/[^/]\+/\.\.', '', '')
let result = substitute(intermediateResult, '/\./', '/', '')
if result ==# path
break
endif
let path = result
endwhile
return result
endfunction "}}}
endfunction
function! vimwiki#path#path_norm(path) "{{{
function! vimwiki#path#path_norm(path) abort
" /-slashes
if a:path !~# '^scp:'
let path = substitute(a:path, '\', '/', 'g')
@ -44,21 +46,24 @@ function! vimwiki#path#path_norm(path) "{{{
else
return a:path
endif
endfunction "}}}
endfunction
function! vimwiki#path#is_link_to_dir(link) "{{{
function! vimwiki#path#is_link_to_dir(link) abort
" Check if link is to a directory.
" It should be ended with \ or /.
return a:link =~# '\m[/\\]$'
endfunction "}}}
endfunction
function! vimwiki#path#abs_path_of_link(link) abort
return vimwiki#path#normalize(expand('%:p:h').'/'.a:link)
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) "{{{
function! vimwiki#path#path_common_pfx(path1, path2) abort
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
@ -72,28 +77,54 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
else
return join(p1[: idx-1], '/')
endif
endfunction "}}}
endfunction
function! vimwiki#path#wikify_path(path) "{{{
let result = resolve(expand(a:path, ':p'))
function! vimwiki#path#wikify_path(path) abort
let result = resolve(fnamemodify(a:path, ':p'))
if vimwiki#u#is_windows()
let result = substitute(result, '\\', '/', 'g')
endif
let result = vimwiki#path#chomp_slash(result)
return result
endfunction "}}}
endfunction
function! vimwiki#path#current_wiki_file() abort
return vimwiki#path#wikify_path(expand('%:p'))
endfunction
" Returns: the relative path from a:dir to a:file
function! vimwiki#path#relpath(dir, file) "{{{
function! vimwiki#path#relpath(dir, file) abort
" Check if dir here ('.') -> return file
if empty(a:dir) || a:dir =~# '^\.[/\\]\?$'
return a:file
endif
let result = []
let dir = split(a:dir, '/')
let file = split(a:file, '/')
if vimwiki#u#is_windows()
" TODO temporary fix see #478
" not sure why paths get converted back to using forward slash
" when passed to the function in the form C:\path\to\file
let dir = substitute(a:dir, '/', '\', 'g')
let file = substitute(a:file, '/', '\', 'g')
let dir = split(dir, '\')
let file = split(file, '\')
else
let dir = split(a:dir, '/')
let file = split(a:file, '/')
endif
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
call remove(dir, 0)
call remove(file, 0)
endwhile
if empty(dir) && empty(file)
return './'
if vimwiki#u#is_windows()
" TODO temporary fix see #478
return '.\'
else
return './'
endif
endif
for segment in dir
let result += ['..']
@ -101,17 +132,26 @@ function! vimwiki#path#relpath(dir, file) "{{{
for segment in file
let result += [segment]
endfor
let result_path = join(result, '/')
if a:file =~ '\m/$'
let result_path .= '/'
if vimwiki#u#is_windows()
" TODO temporary fix see #478
let result_path = join(result, '\')
if a:file =~? '\m\\$'
let result_path .= '\'
endif
else
let result_path = join(result, '/')
if a:file =~? '\m/$'
let result_path .= '/'
endif
endif
return result_path
endfunction "}}}
endfunction
" If the optional argument provided and nonzero,
" it will ask before creating a directory
" it will ask before creating a directory
" Returns: 1 iff directory exists or successfully created
function! vimwiki#path#mkdir(path, ...) "{{{
function! vimwiki#path#mkdir(path, ...) abort
let path = expand(a:path)
if path =~# '^scp:'
@ -122,29 +162,49 @@ function! vimwiki#path#mkdir(path, ...) "{{{
if isdirectory(path)
return 1
else
if !exists("*mkdir")
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)
if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc'))
let path = iconv(path, &encoding, vimwiki#vars#get_global('w32_dir_enc'))
endif
if a:0 && a:1 && input("Vimwiki: Make new directory: "
\ .path."\n [y]es/[N]o? ") !~? '^y'
if a:0 && a:1 && input('Vimwiki: Make new directory: '.path."\n [y]es/[N]o? ") !~? '^y'
return 0
endif
call mkdir(path, "p")
call mkdir(path, 'p')
return 1
endif
endfunction " }}}
endfunction
function! vimwiki#path#is_absolute(path) "{{{
function! vimwiki#path#is_absolute(path) abort
if vimwiki#u#is_windows()
return a:path =~? '\m^\a:'
else
return a:path =~# '\m^/\|\~/'
endif
endfunction "}}}
endfunction
" Combine a directory and a file into one path, doesn't generate duplicate
" path separator in case the directory is also having an ending / or \. This
" is because on windows ~\vimwiki//.tags is invalid but ~\vimwiki/.tags is a
" valid path.
if vimwiki#u#is_windows()
function! vimwiki#path#join_path(directory, file) abort
let directory = vimwiki#path#chomp_slash(a:directory)
let file = substitute(a:file, '\m^[\\/]\+', '', '')
return directory . '/' . file
endfunction
else
function! vimwiki#path#join_path(directory, file) abort
let directory = substitute(a:directory, '\m/\+$', '', '')
let file = substitute(a:file, '\m^/\+', '', '')
return directory . '/' . file
endfunction
endif

View File

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

View File

@ -1,8 +1,10 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
let s:TAGS_METADATA_FILE_NAME = '.tags'
let s:TAGS_METADATA_FILE_NAME = '.vimwiki_tags'
" Tags metadata in-memory format:
" metadata := { 'pagename': [entries, ...] }
@ -19,16 +21,17 @@ let s:TAGS_METADATA_FILE_NAME = '.tags'
" 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 != ''
function! vimwiki#tags#update_tags(full_rebuild, all_files) abort
let all_files = a:all_files !=? ''
if !a:full_rebuild
" Updating for one page (current)
let page_name = VimwikiGet('subdir') . expand('%:t:r')
let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r')
" Collect tags in current file
let tags = s:scan_tags(getline(1, '$'), page_name)
" Load metadata file
@ -40,13 +43,14 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
" Save
call s:write_tags_metadata(metadata)
else " full rebuild
let files = vimwiki#base#find_files(g:vimwiki_current_idx, 0)
let tags_file_last_modification =
\ getftime(vimwiki#tags#metadata_file_path())
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let tags_file_last_modification = getftime(vimwiki#tags#metadata_file_path())
let metadata = s:load_tags_metadata()
for file in files
if all_files || getftime(file) >= tags_file_last_modification
let page_name = fnamemodify(file, ':t:r')
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)
@ -54,20 +58,26 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
endfor
call s:write_tags_metadata(metadata)
endif
endfunction " }}}
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) "{{{
function! s:safesubstitute(text, search, replace, mode) abort
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
return substitute(a:text, a:search, escaped, a:mode)
endfunction
" Scans the list of text lines (argument) and produces tags metadata as a list of tag entries.
function! s:scan_tags(lines, page_name) abort
let entries = []
" Code wireframe to scan for headers -- borrowed from
" vimwiki#base#get_anchors(), with minor modifications.
let rxheader = g:vimwiki_{VimwikiGet('syntax')}_header_search
let rxtag = g:vimwiki_{VimwikiGet('syntax')}_tag_search
let rxheader = vimwiki#vars#get_syntaxlocal('header_search')
let rxtag = vimwiki#vars#get_syntaxlocal('tag_search')
let anchor_level = ['', '', '', '', '', '', '']
let current_complete_anchor = ''
@ -78,6 +88,11 @@ function! s:scan_tags(lines, page_name) "{{{
for line_nr in range(1, len(a:lines))
let line = a:lines[line_nr - 1]
" ignore verbatim blocks
if vimwiki#u#is_codeblock(line_nr)
continue
endif
" process headers
let h_match = matchlist(line, rxheader)
if !empty(h_match) " got a header
@ -93,7 +108,7 @@ function! s:scan_tags(lines, page_name) "{{{
else
let current_complete_anchor = ''
for l in range(level-1)
if anchor_level[l] != ''
if anchor_level[l] !=? ''
let current_complete_anchor .= anchor_level[l].'#'
endif
endfor
@ -102,13 +117,11 @@ function! s:scan_tags(lines, page_name) "{{{
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 == ''
if tag_group ==? ''
break
endif
let tagend = matchend(str, rxtag)
@ -134,28 +147,29 @@ function! s:scan_tags(lines, page_name) "{{{
endfor " loop over lines
return entries
endfunction " }}}
endfunction
" vimwiki#tags#metadata_file_path
" Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort "{{{
return fnamemodify(VimwikiGet('path') . '/' . s:TAGS_METADATA_FILE_NAME, ':p')
endfunction " }}}
function! vimwiki#tags#metadata_file_path() abort
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'),
\ s:TAGS_METADATA_FILE_NAME), ':p')
endfunction
" s:load_tags_metadata
" Loads tags metadata from file, returns a dictionary
function! s:load_tags_metadata() abort "{{{
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_'
if line =~# '^!_TAG_.*$'
continue
endif
let parts = matchlist(line, '^\(.\{-}\);"\(.*\)$')
if parts[0] == '' || parts[1] == '' || parts[2] == ''
if parts[0] ==? '' || parts[1] ==? '' || parts[2] ==? ''
throw 'VimwikiTags1: Metadata file corrupted'
endif
let std_fields = split(parts[1], '\t')
@ -163,11 +177,11 @@ function! s:load_tags_metadata() abort "{{{
throw 'VimwikiTags2: Metadata file corrupted'
endif
let vw_part = parts[2]
if vw_part[0] != "\t"
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:'
if len(vw_fields) != 1 || vw_fields[0] !~# '^vimwiki:'
throw 'VimwikiTags4: Metadata file corrupted'
endif
let vw_data = substitute(vw_fields[0], '^vimwiki:', '', '')
@ -191,31 +205,63 @@ function! s:load_tags_metadata() abort "{{{
endif
endfor
return metadata
endfunction " }}}
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) "{{{
function! s:remove_page_from_tags(metadata, page_name) abort
if has_key(a:metadata, a:page_name)
call remove(a:metadata, a:page_name)
return a:metadata
else
return a:metadata
endif
endfunction " }}}
endfunction
" s:merge_tags
" Merges metadata of one file into a:metadata
function! s:merge_tags(metadata, pagename, file_metadata) "{{{
function! s:merge_tags(metadata, pagename, file_metadata) abort
let metadata = a:metadata
let metadata[a:pagename] = a:file_metadata
return metadata
endfunction " }}}
endfunction
" Compares two actual lines from tags file. Return value is in strcmp style.
" See help on sort() -- that's what this function is going to be used for.
" See also s:write_tags_metadata below -- that's where we compose these tags
" file lines.
"
" This function is needed for tags sorting, since plain sort() compares line
" numbers as strings, not integers, and so, for example, tag at line 14
" preceeds the same tag on the same page at line 9. (Because string "14" is
" alphabetically 'less than' string "9".)
function! s:tags_entry_cmp(i1, i2) abort
let items = []
for orig_item in [a:i1, a:i2]
let fields = split(orig_item, "\t")
let item = {}
let item.text = fields[0]."\t".fields[1]
let item.lineno = 0 + matchstr(fields[2], '\m\d\+')
call add(items, item)
endfor
if items[0].text ># items[1].text
return 1
elseif items[0].text <# items[1].text
return -1
elseif items[0].lineno > items[1].lineno
return 1
elseif items[0].lineno < items[1].lineno
return -1
else
return 0
endif
endfunction
" s:write_tags_metadata
" Saves metadata object into a file. Throws exceptions in case of problems.
function! s:write_tags_metadata(metadata) "{{{
function! s:write_tags_metadata(metadata) abort
let metadata_path = vimwiki#tags#metadata_file_path()
let tags = []
for pagename in keys(a:metadata)
@ -227,21 +273,32 @@ function! s:write_tags_metadata(metadata) "{{{
let entry_data = substitute(entry_data, "\n", '\\n', 'g')
call add(tags,
\ entry.tagname . "\t"
\ . pagename . VimwikiGet('ext') . "\t"
\ . pagename . vimwiki#vars#get_wikilocal('ext') . "\t"
\ . entry.lineno
\ . ';"'
\ . "\t" . "vimwiki:" . entry_data
\ . "\t" . 'vimwiki:' . entry_data
\)
endfor
endfor
call sort(tags)
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
call sort(tags, 's:tags_entry_cmp')
let tag_comments = [
\ "!_TAG_PROGRAM_VERSION\t2.5",
\ "!_TAG_PROGRAM_URL\thttps://github.com/vimwiki/vimwiki",
\ "!_TAG_PROGRAM_NAME\tVimwiki Tags",
\ "!_TAG_PROGRAM_AUTHOR\tVimwiki",
\ "!_TAG_OUTPUT_MODE\tvimwiki-tags",
\ "!_TAG_FILE_SORTED\t1",
\ "!_TAG_FILE_FORMAT\t2",
\ ]
for c in tag_comments
call insert(tags, c)
endfor
call writefile(tags, metadata_path)
endfunction " }}}
endfunction
" vimwiki#tags#get_tags
" Returns list of unique tags found in the .tags file
function! vimwiki#tags#get_tags() "{{{
function! vimwiki#tags#get_tags() abort
let metadata = s:load_tags_metadata()
let tags = {}
for entries in values(metadata)
@ -250,59 +307,99 @@ function! vimwiki#tags#get_tags() "{{{
endfor
endfor
return keys(tags)
endfunction " }}}
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)
function! vimwiki#tags#generate_tags(create, ...) abort
let specific_tags = a:000
let header_level = vimwiki#vars#get_global('tags_header_level')
let metadata = s:load_tags_metadata()
" use a dictionary function for closure like capability
" copy all local variables into dict (add a: if arguments are needed)
let GeneratorTags = copy(l:)
function! GeneratorTags.f() abort
let need_all_tags = empty(self.specific_tags)
let metadata = s:load_tags_metadata()
" make a dictionary { tag_name: [tag_links, ...] }
let tags_entries = {}
for entries in values(metadata)
for entry in entries
if has_key(tags_entries, entry.tagname)
call add(tags_entries[entry.tagname], entry.link)
else
let tags_entries[entry.tagname] = [entry.link]
" make a dictionary { tag_name: [tag_links, ...] }
let tags_entries = {}
for entries in values(metadata)
for entry in entries
if has_key(tags_entries, entry.tagname)
call add(tags_entries[entry.tagname], entry.link)
else
let tags_entries[entry.tagname] = [entry.link]
endif
endfor
unlet entry " needed for older vims with sticky type checking since name is reused
endfor
let lines = []
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' '
for tagname in sort(keys(tags_entries))
if need_all_tags || index(self.specific_tags, tagname) != -1
if len(lines) > 0
call add(lines, '')
endif
let tag_tpl = printf('rxH%d_Template', self.header_level + 1)
call add(lines, s:safesubstitute(vimwiki#vars#get_syntaxlocal(tag_tpl), '__Header__', tagname, ''))
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
call add(lines, '')
endfor
endif
for taglink in sort(tags_entries[tagname])
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink3Template')
let link_infos = vimwiki#base#resolve_link(taglink)
if empty(link_infos.anchor)
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', taglink, '')
let entry = s:safesubstitute(entry, '__LinkDescription__', taglink, '')
else
let link_caption = split(link_infos.anchor, '#', 0)[-1]
let link_text = split(taglink, '#', 1)[0]
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', link_text, '')
let entry = s:safesubstitute(entry, '__LinkAnchor__', link_infos.anchor, '')
let entry = s:safesubstitute(entry, '__LinkDescription__', link_caption, '')
endif
call add(lines, bullet . entry)
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
call add(lines, bullet . substitute(link_tpl, '__LinkUrl__', taglink, ''))
endif
endfor
endif
endfor
endfor
let lines = []
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
\ vimwiki#lst#default_symbol().' '
for tagname in sort(keys(tags_entries))
if need_all_tags || index(specific_tags, tagname) != -1
call extend(lines, [
\ '',
\ substitute(g:vimwiki_rxH2_Template, '__Header__', tagname, ''),
\ '' ])
for taglink in tags_entries[tagname]
call add(lines, bullet .
\ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', taglink, ''))
endfor
endif
endfor
return lines
endfunction
let links_rx = '\m\%(^\s*$\)\|\%('.g:vimwiki_rxH2.'\)\|\%(^\s*'
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
\ .g:vimwiki_rxWikiLink.'$\)'
let tag_match = printf('rxH%d', header_level + 1)
let links_rx = '^\%('.vimwiki#vars#get_syntaxlocal(tag_match).'\)\|'.
\ '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx,
\ line('$')+1, 1)
endfunction " }}}
call vimwiki#base#update_listing_in_buffer(
\ GeneratorTags,
\ vimwiki#vars#get_global('tags_header'),
\ links_rx,
\ line('$')+1,
\ header_level,
\ a:create)
endfunction
" vimwiki#tags#complete_tags
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort " {{{
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 " }}}
endfunction

View File

@ -1,83 +1,91 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki autoload plugin file
" Desc: Tables
" Description: Tables
" | Easily | manageable | text | tables | ! |
" |--------|------------|-------|--------|---------|
" | Have | fun! | Drink | tea | Period. |
"
" Home: https://github.com/vimwiki/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_tbl_auto") || &cp
if exists('g:loaded_vimwiki_tbl_auto') || &compatible
finish
endif
let g:loaded_vimwiki_tbl_auto = 1
"}}}
let s:textwidth = &tw
" Misc functions {{{
function! s:rxSep() "{{{
return g:vimwiki_rxTableSep
endfunction "}}}
let s:textwidth = &textwidth
function! s:wide_len(str) "{{{
function! s:rxSep() abort
return vimwiki#vars#get_syntaxlocal('rxTableSep')
endfunction
function! s:wide_len(str) abort
" vim73 has new function that gives correct string width.
if exists("*strdisplaywidth")
if exists('*strdisplaywidth')
return strdisplaywidth(a:str)
endif
" get str display width in vim ver < 7.2
if !g:vimwiki_CJK_length
if !vimwiki#vars#get_global('CJK_length')
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
else
let savemodified = &modified
let save_cursor = getpos('.')
exe "norm! o\<esc>"
call setline(line("."), a:str)
let ret = virtcol("$") - 1
call setline(line('.'), a:str)
let ret = virtcol('$') - 1
d
call setpos('.', save_cursor)
let &modified = savemodified
endif
return ret
endfunction "}}}
endfunction
function! s:cell_splitter() "{{{
function! s:cell_splitter() abort
return '\s*'.s:rxSep().'\s*'
endfunction "}}}
endfunction
function! s:sep_splitter() "{{{
function! s:sep_splitter() abort
return '-'.s:rxSep().'-'
endfunction "}}}
endfunction
function! s:is_table(line) "{{{
return s:is_separator(a:line) || (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
endfunction "}}}
function! s:is_table(line) abort
return s:is_separator(a:line) ||
\ (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
endfunction
function! s:is_separator_tail(line) "{{{
function! s:is_separator(line) abort
return a:line =~# '^\s*'.s:rxSep().'\(:\=--\+:\='.s:rxSep().'\)\+\s*$'
endfunction
function! s:is_separator_tail(line) abort
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction "}}}
endfunction
function! s:is_last_column(lnum, cnum) "{{{
function! s:is_last_column(lnum, cnum) abort
let line = strpart(getline(a:lnum), a:cnum - 1)
"echomsg "DEBUG is_last_column> ".(line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$')
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
endfunction "}}}
endfunction
function! s:is_first_column(lnum, cnum) "{{{
function! s:is_first_column(lnum, cnum) abort
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
"echomsg "DEBUG is_first_column> ".(line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
return line =~# '^\s*$' || (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction "}}}
return line =~# '^\s*$' ||
\ (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction
function! s:count_separators_up(lnum) "{{{
function! s:count_separators_up(lnum) abort
let lnum = a:lnum - 1
while lnum > 1
if !s:is_separator(getline(lnum))
@ -87,9 +95,10 @@ function! s:count_separators_up(lnum) "{{{
endwhile
return (a:lnum-lnum)
endfunction "}}}
endfunction
function! s:count_separators_down(lnum) "{{{
function! s:count_separators_down(lnum) abort
let lnum = a:lnum + 1
while lnum < line('$')
if !s:is_separator(getline(lnum))
@ -99,88 +108,99 @@ function! s:count_separators_down(lnum) "{{{
endwhile
return (lnum-a:lnum)
endfunction "}}}
endfunction
function! s:create_empty_row(cols) "{{{
function! s:create_empty_row(cols) abort
let row = s:rxSep()
let cell = " ".s:rxSep()
let cell = ' '.s:rxSep()
for c in range(a:cols)
let row .= cell
endfor
return row
endfunction "}}}
endfunction
function! s:create_row_sep(cols) "{{{
function! s:create_row_sep(cols) abort
let row = s:rxSep()
let cell = "---".s:rxSep()
let cell = '---'.s:rxSep()
for c in range(a:cols)
let row .= cell
endfor
return row
endfunction "}}}
endfunction
function! vimwiki#tbl#get_cells(line) "{{{
function! vimwiki#tbl#get_cells(line, ...) abort
let result = []
let cell = ''
let quote = ''
let state = 'NONE'
let cell_start = 0
let quote_start = 0
let len = strlen(a:line) - 1
" 'Simple' FSM
for idx in range(strlen(a:line))
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state ==# 'NONE'
if ch == '|'
let state = 'CELL'
endif
elseif state ==# 'CELL'
if ch == '[' || ch == '{'
let state = 'BEFORE_QUOTE_START'
let quote = ch
elseif ch == '|'
call add(result, vimwiki#u#trim(cell))
let cell = ""
else
let cell .= ch
endif
elseif state ==# 'BEFORE_QUOTE_START'
if ch == '[' || ch == '{'
let state = 'QUOTE'
let quote .= ch
else
let state = 'CELL'
let cell .= quote.ch
let quote = ''
endif
elseif state ==# 'QUOTE'
if ch == ']' || ch == '}'
let state = 'BEFORE_QUOTE_END'
endif
let quote .= ch
elseif state ==# 'BEFORE_QUOTE_END'
if ch == ']' || ch == '}'
let state = 'CELL'
endif
let cell .= quote.ch
let quote = ''
while state !=# 'CELL'
if quote_start != 0 && state !=# 'CELL'
let state = 'CELL'
endif
endfor
for idx in range(quote_start, len)
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state ==# 'NONE'
if ch ==# '|'
let cell_start = idx + 1
let state = 'CELL'
endif
elseif state ==# 'CELL'
if ch ==# '[' || ch ==# '{'
let state = 'BEFORE_QUOTE_START'
let quote_start = idx
elseif ch ==# '|'
let cell = strpart(a:line, cell_start, idx - cell_start)
if a:0 && a:1
let cell = substitute(cell, '^ \(.*\) $', '\1', '')
else
let cell = vimwiki#u#trim(cell)
endif
call add(result, cell)
let cell_start = idx + 1
endif
elseif state ==# 'BEFORE_QUOTE_START'
if ch ==# '[' || ch ==# '{'
let state = 'QUOTE'
let quote_start = idx
else
let state = 'CELL'
endif
elseif state ==# 'QUOTE'
if ch ==# ']' || ch ==# '}'
let state = 'BEFORE_QUOTE_END'
endif
elseif state ==# 'BEFORE_QUOTE_END'
if ch ==# ']' || ch ==# '}'
let state = 'CELL'
endif
endif
endfor
if state ==# 'NONE'
break
endif
endwhile
if cell.quote != ''
call add(result, vimwiki#u#trim(cell.quote, '|'))
endif
return result
endfunction "}}}
endfunction
function! s:col_count(lnum) "{{{
function! s:col_count(lnum) abort
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
endfunction "}}}
endfunction
function! s:get_indent(lnum) "{{{
function! s:get_indent(lnum, depth) abort
if !s:is_table(getline(a:lnum))
return
endif
@ -195,48 +215,123 @@ function! s:get_indent(lnum) "{{{
break
endif
let lnum -= 1
if a:depth > 0 && lnum < a:lnum - a:depth
break
endif
endwhile
return indent
endfunction " }}}
endfunction
function! s:get_rows(lnum) "{{{
function! s:get_rows(lnum, ...) abort
if !s:is_table(getline(a:lnum))
return
endif
let upper_rows = []
let lower_rows = []
let rows = []
let lnum = a:lnum - 1
while lnum >= 1
let depth = a:0 > 0 ? a:1 : 0
let ldepth = 0
while lnum >= 1 && (depth == 0 || ldepth < depth)
let line = getline(lnum)
if s:is_table(line)
call add(upper_rows, [lnum, line])
call insert(rows, [lnum, line])
else
break
endif
let lnum -= 1
let ldepth += 1
endwhile
call reverse(upper_rows)
let lnum = a:lnum
while lnum <= line('$')
let line = getline(lnum)
if s:is_table(line)
call add(lower_rows, [lnum, line])
call add(rows, [lnum, line])
else
break
endif
if depth > 0
break
endif
let lnum += 1
endwhile
return upper_rows + lower_rows
endfunction "}}}
return rows
endfunction
function! s:get_cell_max_lens(lnum, ...) "{{{
function! s:get_cell_aligns(lnum, ...) abort
let aligns = {}
let depth = a:0 > 0 ? a:1 : 0
for [lnum, row] in s:get_rows(a:lnum, depth)
if s:is_separator(row)
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let cell = cells[idx]
if cell =~# '^--\+:'
let aligns[idx] = 'right'
elseif cell =~# '^:--\+:'
let aligns[idx] = 'center'
else
let aligns[idx] = 'left'
endif
endfor
else
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
if !has_key(aligns, idx)
let aligns[idx] = 'left'
endif
endfor
endif
endfor
return aligns
endfunction
function! s:get_cell_aligns_fast(rows) abort
let aligns = {}
let clen = 0
for [lnum, row] in a:rows
if s:is_separator(row)
return s:get_cell_aligns(lnum, 1)
endif
let cells = vimwiki#tbl#get_cells(row, 1)
let clen = len(cells)
for idx in range(clen)
let cell = cells[idx]
if !has_key(aligns, idx)
let cs = matchlist(cell, '^\(\s*\)[^[:space:]].\{-}\(\s*\)$')
if !empty(cs)
let lstart = len(cs[1])
let lend = len(cs[2])
if lstart > 0 && lend > 0
let aligns[idx] = 'center'
elseif lend > 0
let aligns[idx] = 'left'
elseif lstart > 0
let aligns[idx] = 'right'
endif
endif
endif
endfor
endfor
for idx in range(clen)
if !has_key(aligns, idx)
return {}
endif
endfor
return aligns
endfunction
function! s:get_cell_max_lens(lnum, ...) abort
let max_lens = {}
for [lnum, row] in s:get_rows(a:lnum)
let rows = a:0 > 2 ? a:3 : s:get_rows(a:lnum)
for [lnum, row] in rows
if s:is_separator(row)
continue
endif
@ -251,30 +346,79 @@ function! s:get_cell_max_lens(lnum, ...) "{{{
endfor
endfor
return max_lens
endfunction "}}}
endfunction
function! s:get_aligned_rows(lnum, col1, col2) "{{{
let rows = s:get_rows(a:lnum)
let startlnum = rows[0][0]
function! s:get_aligned_rows(lnum, col1, col2, depth) abort
let rows = []
let aligns = {}
let startlnum = 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 max_lens = {}
let check_all = 1
if a:depth > 0
let rows = s:get_rows(a:lnum, a:depth)
let startlnum = rows[0][0]
let lrows = len(rows)
if lrows == a:depth + 1
let line = rows[-1][1]
if !s:is_separator(line)
let lcells = vimwiki#tbl#get_cells(line)
let lclen = len(lcells)
let lmax_lens = repeat([0], lclen)
let laligns = repeat(['left'], lclen)
let rows[-1][1] = s:fmt_row(lcells, lmax_lens, laligns, 0, 0)
endif
let i = 1
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, i != lrows - 1))
let i += 1
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
" user option not to expand last call
if vimwiki#vars#get_global('table_reduce_last_col')
let last_index = keys(max_lens)[-1]
let max_lens[last_index] = 1
endif
let fst_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows[0:0])
let check_all = max_lens != fst_lens
let aligns = s:get_cell_aligns_fast(rows[0:-2])
let rows[-1][1] = line
endif
endif
if check_all
" all the table must be re-formatted
let rows = s:get_rows(a:lnum)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row))
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
" user option not to expand last call
if vimwiki#vars#get_global('table_reduce_last_col')
let last_index = keys(max_lens)[-1]
let max_lens[last_index] = 1
endif
endif
if empty(aligns)
let aligns = s:get_cell_aligns(a:lnum)
endif
let result = []
for [lnum, row] in rows
if s:is_separator(row)
let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
let new_row = s:fmt_sep(max_lens, aligns, a:col1, a:col2)
else
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, a:col1, a:col2)
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, aligns, a:col1, a:col2)
endif
call add(result, [lnum, new_row])
endfor
return result
endfunction "}}}
endfunction
" Number of the current column. Starts from 0.
function! s:cur_column() "{{{
function! s:cur_column() abort
let line = getline('.')
if !s:is_table(line)
return -1
@ -291,24 +435,28 @@ function! s:cur_column() "{{{
endif
endwhile
return col
endfunction "}}}
endfunction
" }}}
" Format functions {{{
function! s:fmt_cell(cell, max_len) "{{{
function! s:fmt_cell(cell, max_len, align) abort
let cell = ' '.a:cell.' '
let diff = a:max_len - s:wide_len(a:cell)
if diff == 0 && empty(a:cell)
let diff = 1
endif
let cell .= repeat(' ', diff)
if a:align ==# 'left'
let cell .= repeat(' ', diff)
elseif a:align ==# 'right'
let cell = repeat(' ',diff).cell
else
let cell = repeat(' ',diff/2).cell.repeat(' ',diff-diff/2)
endif
return cell
endfunction "}}}
endfunction
function! s:fmt_row(cells, max_lens, col1, col2) "{{{
function! s:fmt_row(cells, max_lens, aligns, col1, col2) abort
let new_line = s:rxSep()
for idx in range(len(a:cells))
if idx == a:col1
@ -317,26 +465,36 @@ function! s:fmt_row(cells, max_lens, col1, col2) "{{{
let idx = a:col1
endif
let value = a:cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep()
let new_line .= s:fmt_cell(value, a:max_lens[idx], a:aligns[idx]).s:rxSep()
endfor
let idx = len(a:cells)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep()
let new_line .= s:fmt_cell('', a:max_lens[idx], a:aligns[idx]).s:rxSep()
let idx += 1
endwhile
return new_line
endfunction "}}}
endfunction
function! s:fmt_cell_sep(max_len) "{{{
function! s:fmt_cell_sep(max_len, align) abort
let cell = ''
if a:max_len == 0
return repeat('-', 3)
let cell .= '-'
else
return repeat('-', a:max_len+2)
let cell .= repeat('-', a:max_len)
endif
endfunction "}}}
if a:align ==# 'right'
return cell.'-:'
elseif a:align ==# 'left'
return cell.'--'
else
return ':'.cell.':'
endif
endfunction
function! s:fmt_sep(max_lens, col1, col2) "{{{
function! s:fmt_sep(max_lens, aligns, col1, col2) abort
let new_line = s:rxSep()
for idx in range(len(a:max_lens))
if idx == a:col1
@ -344,50 +502,59 @@ function! s:fmt_sep(max_lens, col1, col2) "{{{
elseif idx == a:col2
let idx = a:col1
endif
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
let new_line .= s:fmt_cell_sep(a:max_lens[idx], a:aligns[idx]).s:rxSep()
endfor
return new_line
endfunction "}}}
"}}}
endfunction
" Keyboard functions "{{{
function! s:kbd_create_new_row(cols, goto_first) "{{{
function! s:kbd_create_new_row(cols, goto_first) abort
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'), 2)\<CR>"
let cmd .= "\<ESC>0"
if a:goto_first
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>"
else
let cmd .= (col('.')-1)."l"
let cmd .= (col('.')-1).'l'
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
endif
let cmd .= "a"
let cmd .= 'a'
return cmd
endfunction "}}}
endfunction
function! s:kbd_goto_next_row() "{{{
function! s:kbd_goto_next_row() abort
let cmd = "\<ESC>j"
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
let cmd .= 'a'
return cmd
endfunction "}}}
endfunction
function! s:kbd_goto_prev_row() "{{{
function! s:kbd_goto_prev_row() abort
let cmd = "\<ESC>k"
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
let cmd .= 'a'
return cmd
endfunction "}}}
endfunction
" Used in s:kbd_goto_next_col
function! vimwiki#tbl#goto_next_col() "{{{
function! vimwiki#tbl#goto_next_col() abort
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
let depth = 2
let newcol = s:get_indent(lnum, depth)
let rows = s:get_rows(lnum, depth)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, 1))
endfor
let max_lens = s:get_cell_max_lens(lnum, cells, startlnum, rows)
for cell_len in values(max_lens)
if newcol >= curcol-1
break
@ -396,26 +563,34 @@ function! vimwiki#tbl#goto_next_col() "{{{
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
endfunction
function! s:kbd_goto_next_col(jumpdown) "{{{
function! s:kbd_goto_next_col(jumpdown) abort
let cmd = "\<ESC>"
if a:jumpdown
let seps = s:count_separators_down(line('.'))
let cmd .= seps."j0"
let cmd .= seps.'j0'
endif
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
return cmd
endfunction "}}}
endfunction
" Used in s:kbd_goto_prev_col
function! vimwiki#tbl#goto_prev_col() "{{{
function! vimwiki#tbl#goto_prev_col() abort
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
let depth = 2
let newcol = s:get_indent(lnum, depth)
let rows = s:get_rows(lnum, depth)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, 1))
endfor
let max_lens = s:get_cell_max_lens(lnum, cells, startlnum, rows)
let prev_cell_len = 0
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
@ -429,29 +604,28 @@ function! vimwiki#tbl#goto_prev_col() "{{{
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
endfunction
function! s:kbd_goto_prev_col(jumpup) "{{{
function! s:kbd_goto_prev_col(jumpup) abort
let cmd = "\<ESC>"
if a:jumpup
let seps = s:count_separators_up(line('.'))
let cmd .= seps."k"
let cmd .= "$"
let cmd .= seps.'k'
let cmd .= '$'
endif
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd
endfunction "}}}
endfunction
"}}}
" Global functions {{{
function! vimwiki#tbl#kbd_cr() "{{{
function! vimwiki#tbl#kbd_cr() abort
let lnum = line('.')
if !s:is_table(getline(lnum))
return ""
return ''
endif
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
@ -460,9 +634,10 @@ function! vimwiki#tbl#kbd_cr() "{{{
else
return s:kbd_goto_next_row()
endif
endfunction "}}}
endfunction
function! vimwiki#tbl#kbd_tab() "{{{
function! vimwiki#tbl#kbd_tab() abort
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<Tab>"
@ -476,9 +651,10 @@ function! vimwiki#tbl#kbd_tab() "{{{
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(is_sep || last)
endfunction "}}}
endfunction
function! vimwiki#tbl#kbd_shift_tab() "{{{
function! vimwiki#tbl#kbd_shift_tab() abort
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<S-Tab>"
@ -488,13 +664,14 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> ".first
if (is_sep || first) && !s:is_table(getline(lnum-1))
return ""
return ''
endif
return s:kbd_goto_prev_col(is_sep || first)
endfunction "}}}
endfunction
function! vimwiki#tbl#format(lnum, ...) "{{{
if !(&filetype ==? 'vimwiki')
function! vimwiki#tbl#format(lnum, ...) abort
if !vimwiki#u#ft_is_vw()
return
endif
let line = getline(a:lnum)
@ -502,6 +679,8 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
return
endif
let depth = a:0 == 1 ? a:1 : 0
if a:0 == 2
let col1 = a:1
let col2 = a:2
@ -510,22 +689,26 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
let col2 = 0
endif
let indent = s:get_indent(a:lnum)
let indent = s:get_indent(a:lnum, depth)
if &expandtab
let indentstring = repeat(' ', indent)
else
let indentstring = repeat(' ', indent / &tabstop) . repeat(' ', indent % &tabstop)
execute "let indentstring = repeat('\<TAB>', indent / &tabstop) . repeat(' ', indent % &tabstop)"
endif
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
" getting N = depth last rows is enough for having been formatted tables
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2, depth)
let row = indentstring.row
call setline(lnum, row)
if getline(lnum) != row
call setline(lnum, row)
endif
endfor
let &tw = s:textwidth
endfunction "}}}
function! vimwiki#tbl#create(...) "{{{
let &textwidth = s:textwidth
endfunction
function! vimwiki#tbl#create(...) abort
if a:0 > 1
let cols = a:1
let rows = a:2
@ -556,34 +739,36 @@ function! vimwiki#tbl#create(...) "{{{
for r in range(rows - 1)
call add(lines, row)
endfor
call append(line('.'), lines)
endfunction "}}}
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
call append(line('.'), lines)
endfunction
function! vimwiki#tbl#align_or_cmd(cmd, ...) abort
if s:is_table(getline('.'))
call vimwiki#tbl#format(line('.'))
call call('vimwiki#tbl#format', [line('.')] + a:000)
else
exe 'normal! '.a:cmd
endif
endfunction "}}}
endfunction
function! vimwiki#tbl#reset_tw(lnum) "{{{
if !(&filetype ==? 'vimwiki')
function! vimwiki#tbl#reset_tw(lnum) abort
if !vimwiki#u#ft_is_vw()
return
endif
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let s:textwidth = &tw
let &tw = 0
endfunction "}}}
" TODO: move_column_left and move_column_right are good candidates to be
" refactored.
function! vimwiki#tbl#move_column_left() "{{{
let s:textwidth = &textwidth
let &textwidth = 0
endfunction
" TODO: move_column_left and move_column_right are good candidates to be refactored.
function! vimwiki#tbl#move_column_left() abort
"echomsg "DEBUG move_column_left: "
@ -599,7 +784,7 @@ function! vimwiki#tbl#move_column_left() "{{{
endif
if cur_col > 0
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep().'\).\zs'
@ -609,16 +794,16 @@ function! vimwiki#tbl#move_column_left() "{{{
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
else
break
endif
endwhile
endif
endfunction
endfunction "}}}
function! vimwiki#tbl#move_column_right() "{{{
function! vimwiki#tbl#move_column_right() abort
let line = getline('.')
@ -632,7 +817,7 @@ function! vimwiki#tbl#move_column_right() "{{{
endif
if cur_col < s:col_count(line('.'))-1
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep().'\).\zs'
@ -642,33 +827,35 @@ function! vimwiki#tbl#move_column_right() "{{{
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
else
break
endif
endwhile
endif
endfunction
endfunction "}}}
function! vimwiki#tbl#get_rows(lnum) "{{{
function! vimwiki#tbl#get_rows(lnum) abort
return s:get_rows(a:lnum)
endfunction "}}}
endfunction
function! vimwiki#tbl#is_table(line) "{{{
function! vimwiki#tbl#is_table(line) abort
return s:is_table(a:line)
endfunction "}}}
endfunction
function! vimwiki#tbl#is_separator(line) "{{{
function! vimwiki#tbl#is_separator(line) abort
return s:is_separator(a:line)
endfunction "}}}
endfunction
function! vimwiki#tbl#cell_splitter() "{{{
function! vimwiki#tbl#cell_splitter() abort
return s:cell_splitter()
endfunction "}}}
endfunction
function! vimwiki#tbl#sep_splitter() "{{{
function! vimwiki#tbl#sep_splitter() abort
return s:sep_splitter()
endfunction "}}}
endfunction
"}}}

View File

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

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

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

BIN
doc/entries.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

BIN
doc/lists.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

10
doc/logo.svg Normal file
View File

@ -0,0 +1,10 @@
<svg width="200" height="43" viewBox="0 0 372 80" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M45.592 20.804C48.4347 22.4987 49.856 24.3027 49.856 26.216C49.856 27.3093 49.3093 28.8127 48.216 30.726L31.242 59.836C30.6953 60.7653 29.8207 61.6127 28.618 62.378C27.4153 63.0887 26.2127 63.444 25.01 63.444C23.862 63.444 22.7413 63.1707 21.648 62.624C20.6093 62.0227 19.8713 61.4213 19.434 60.82L18.696 59.918L1.64 30.726C0.546667 28.922 0 27.446 0 26.298C0 24.33 1.42133 22.4987 4.264 20.804C6.34133 19.6013 7.98133 19 9.184 19C10.3867 19 11.316 19.3827 11.972 20.148C12.6827 20.8587 13.4207 21.952 14.186 23.428L24.928 44.092L35.67 23.428C36.2713 22.3893 36.7087 21.6513 36.982 21.214C37.31 20.722 37.802 20.2573 38.458 19.82C39.114 19.328 39.9887 19.082 41.082 19.082C42.1753 19.082 43.6787 19.656 45.592 20.804Z" fill="black"/>
<path d="M54.341 27.036C54.341 25.7787 54.3683 24.8493 54.423 24.248C54.5323 23.592 54.7783 22.854 55.161 22.034C55.9263 20.6127 58.0583 19.902 61.557 19.902C64.181 19.902 66.0397 20.3667 67.133 21.296C68.0623 22.0613 68.5544 23.2367 68.609 24.822C68.6637 25.3687 68.691 26.1613 68.691 27.2V55.9C68.691 57.1573 68.6363 58.114 68.527 58.77C68.4724 59.3713 68.2263 60.082 67.789 60.902C67.0784 62.3233 64.9737 63.034 61.475 63.034C58.031 63.034 55.9263 62.296 55.161 60.82C54.7783 60 54.5323 59.2893 54.423 58.688C54.3683 58.0867 54.341 57.13 54.341 55.818V27.036Z" fill="black"/>
<path d="M89.3454 25.56C91.9147 21.6787 95.0034 19.738 98.6114 19.738C104.187 19.738 108.342 22.116 111.075 26.872C111.677 26.052 112.387 25.2047 113.207 24.33C114.082 23.4007 115.449 22.4167 117.307 21.378C119.166 20.2847 121.079 19.738 123.047 19.738C127.421 19.738 131.083 21.4327 134.035 24.822C136.987 28.1567 138.463 33.7053 138.463 41.468V55.818C138.463 57.0753 138.409 58.032 138.299 58.688C138.245 59.2893 137.999 60 137.561 60.82C136.851 62.296 134.746 63.034 131.247 63.034C127.803 63.034 125.699 62.2687 124.933 60.738C124.551 59.918 124.305 59.2073 124.195 58.606C124.141 57.95 124.113 56.9933 124.113 55.736V41.386C124.113 36.63 122.419 34.252 119.029 34.252C117.116 34.252 115.804 34.8807 115.093 36.138C114.437 37.3953 114.109 39.172 114.109 41.468V55.818C114.109 57.13 114.055 58.0867 113.945 58.688C113.891 59.2893 113.645 60 113.207 60.82C112.442 62.296 110.31 63.034 106.811 63.034C103.367 63.034 101.263 62.2687 100.497 60.738C100.115 59.918 99.8687 59.2073 99.7594 58.606C99.7047 57.95 99.6774 56.9933 99.6774 55.736V41.386C99.6774 36.63 97.9827 34.252 94.5934 34.252C91.3134 34.252 89.6734 36.63 89.6734 41.386V55.9C89.6734 57.1573 89.6187 58.114 89.5094 58.77C89.4547 59.3713 89.2087 60.082 88.7714 60.902C87.9514 62.3233 85.8194 63.034 82.3754 63.034C78.9314 63.034 76.8267 62.296 76.0614 60.82C75.6787 60 75.4327 59.2893 75.3234 58.688C75.2687 58.0867 75.2414 57.13 75.2414 55.818V26.954C75.2414 25.6967 75.2687 24.7673 75.3234 24.166C75.4327 23.51 75.7061 22.7993 76.1434 22.034C76.9634 20.558 78.9041 19.82 81.9654 19.82C85.0267 19.82 87.0221 20.312 87.9514 21.296C88.8807 22.28 89.3454 23.7013 89.3454 25.56Z" fill="black"/>
<path d="M219.3 71.3359C216.999 70.2839 215.158 68.7386 213.777 66.7002C212.462 64.6618 211.147 62.3932 209.832 59.8945C209.634 59.5 209.437 59.1055 209.24 58.7109C209.042 58.3164 208.845 57.9548 208.648 57.626L207.267 55.0615L206.478 53.4834L205.294 54.5684L203.519 56.1465L202.533 57.1328C200.823 58.7109 199.081 60.2891 197.305 61.8672C195.596 63.3796 193.754 64.7604 191.782 66.0098C189.875 67.1934 187.836 68.1797 185.667 68.9688C183.562 69.6921 181.261 70.0866 178.762 70.1523L176.592 69.0674C175.343 68.4098 174.291 67.818 173.436 67.292C172.581 66.7659 171.595 65.944 170.477 64.8262C170.148 64.2344 169.852 63.6755 169.589 63.1494C169.392 62.6234 169.162 62.0973 168.899 61.5713C168.176 60.2562 167.584 59.0726 167.124 58.0205C166.663 56.9684 166.203 55.7848 165.743 54.4697C165.94 53.5492 166.236 52.0039 166.63 49.834C167.025 47.5983 167.485 45.1654 168.011 42.5352C168.603 39.9049 169.195 37.2747 169.787 34.6445C170.444 31.9486 171.102 29.6143 171.759 27.6416C172.351 25.932 173.009 24.1237 173.732 22.2168C174.521 20.3099 175.343 18.5674 176.198 16.9893C177.118 15.3454 178.105 13.9645 179.157 12.8467C180.209 11.6631 181.327 10.9727 182.51 10.7754C182.839 11.2357 183.201 11.5645 183.595 11.7617C183.99 11.959 184.351 12.1234 184.68 12.2549C185.601 13.57 186.488 14.6878 187.343 15.6084C188.264 16.529 189.316 17.4495 190.5 18.3701C190.171 20.014 189.678 21.8551 189.02 23.8936C188.428 25.8662 187.771 27.8717 187.047 29.9102C186.39 31.8828 185.732 33.8226 185.075 35.7295C184.417 37.6364 183.891 39.2803 183.497 40.6611C183.102 41.779 182.773 43.0283 182.51 44.4092C181.918 46.8421 181.36 50.1628 180.833 54.3711C181.623 54.1738 182.477 53.7464 183.398 53.0889C184.319 52.4313 185.206 51.7409 186.061 51.0176C187.047 50.2285 188.034 49.3408 189.02 48.3545C190.269 47.1051 191.321 45.9544 192.176 44.9023C193.031 43.8503 193.82 42.7653 194.543 41.6475C195.333 40.5296 196.122 39.3132 196.911 37.998C197.7 36.6172 198.653 35.0062 199.771 33.165C200.757 31.5869 201.777 29.9102 202.829 28.1348C203.946 26.2936 205.031 24.5511 206.083 22.9072C207.201 21.1976 208.286 19.6523 209.338 18.2715C210.39 16.8906 211.344 15.8057 212.199 15.0166C212.725 15.6742 213.382 16.2988 214.171 16.8906C215.026 17.4824 215.914 17.9427 216.834 18.2715C217.229 18.8633 217.591 19.4222 217.919 19.9482C218.314 20.4085 218.676 20.8359 219.004 21.2305C219.399 21.8223 219.761 22.3812 220.089 22.9072C220.484 23.4333 220.846 23.9593 221.174 24.4854C221.109 24.9456 221.01 25.5374 220.878 26.2607C220.747 26.984 220.583 27.7731 220.385 28.6279C220.254 29.4827 220.089 30.3704 219.892 31.291C219.695 32.1458 219.498 32.9678 219.3 33.7568C218.774 36.2555 218.38 38.1296 218.117 39.3789C217.854 40.6283 217.656 41.6146 217.525 42.3379C217.459 43.0612 217.393 43.6859 217.328 44.2119C217.328 44.6722 217.328 45.3298 217.328 46.1846C217.262 46.8421 217.295 47.4997 217.426 48.1572C217.492 48.749 217.624 49.3737 217.821 50.0312C218.018 50.6888 218.281 51.2806 218.61 51.8066L222.555 48.749C223.673 47.8942 224.725 46.7435 225.711 45.2969C226.764 43.7845 227.75 42.0749 228.67 40.168C229.657 38.1953 230.61 36.0583 231.531 33.7568C232.451 31.4554 233.372 29.1211 234.292 26.7539C235.673 23.2689 237.054 19.8825 238.435 16.5947C239.882 13.307 241.263 10.7754 242.578 9C244.024 9.92057 245.274 10.874 246.326 11.8604C247.444 12.7809 248.397 13.8001 249.186 14.918C249.975 16.0358 250.6 17.318 251.06 18.7646C251.586 20.2113 251.948 21.9209 252.145 23.8936C250.961 26.195 249.811 28.5622 248.693 30.9951C247.641 33.4281 246.622 35.861 245.635 38.2939C244.32 41.4502 242.939 44.6064 241.493 47.7627C240.112 50.9189 238.567 53.9437 236.857 56.8369C235.147 59.6644 233.24 62.2946 231.136 64.7275C229.032 67.0947 226.599 69.1003 223.837 70.7441C223.114 70.5469 222.489 70.4482 221.963 70.4482C220.911 70.4482 220.024 70.7441 219.3 71.3359Z" fill="#E5E5E5"/>
<path d="M268.025 63.1494C268.354 65.1221 268.222 66.6673 267.63 67.7852C267.104 68.903 266.315 69.7249 265.263 70.251C264.277 70.8428 263.126 71.1716 261.811 71.2373C260.496 71.3031 259.247 71.2373 258.063 71.04C257.405 70.1195 256.814 68.9688 256.288 67.5879C255.762 66.207 255.268 64.7933 254.808 63.3467C254.348 61.8343 253.92 60.3548 253.526 58.9082C253.197 57.4616 252.901 56.1794 252.638 55.0615C252.967 54.2725 253.164 53.3848 253.23 52.3984C253.361 51.3464 253.427 50.2943 253.427 49.2422C253.493 48.1901 253.526 47.138 253.526 46.0859C253.592 44.9681 253.69 43.916 253.822 42.9297C254.282 40.168 254.94 37.5378 255.794 35.0391C256.715 32.5404 257.438 29.943 257.964 27.2471C258.096 26.6553 258.03 26.0964 257.767 25.5703C257.57 25.0443 257.537 24.5511 257.668 24.0908C257.734 23.8278 257.931 23.6634 258.26 23.5977C258.589 23.4661 258.786 23.236 258.852 22.9072C259.049 22.1839 259.082 21.5921 258.951 21.1318C258.885 20.6715 259.016 20.1126 259.345 19.4551C259.674 18.929 260.069 18.1729 260.529 17.1865C261.055 16.1344 261.252 15.0495 261.121 13.9316C261.712 13.5371 262.271 13.0768 262.797 12.5508C263.323 12.0247 263.849 11.5645 264.375 11.1699C264.967 10.7096 265.592 10.3151 266.25 9.98633C266.973 9.65755 267.828 9.49316 268.814 9.49316C269.34 10.1507 269.669 10.874 269.8 11.6631C269.998 12.4521 270.162 13.2412 270.293 14.0303C270.491 14.8193 270.754 15.5755 271.083 16.2988C271.411 16.9564 271.97 17.4824 272.759 17.877C272.759 18.403 272.759 19.0605 272.759 19.8496C272.759 20.6387 272.792 21.4277 272.858 22.2168C272.924 22.9401 273.055 23.6305 273.252 24.2881C273.515 24.8799 273.91 25.2744 274.436 25.4717C273.252 28.6279 272.135 31.7513 271.083 34.8418C270.096 37.9323 269.274 41.0557 268.617 44.2119C267.959 47.3024 267.532 50.4258 267.334 53.582C267.203 56.7383 267.433 59.9274 268.025 63.1494Z" fill="#E5E5E5"/>
<path d="M338.942 66.5029C335.786 66.6344 332.991 66.5687 330.558 66.3057C328.191 66.0426 325.857 65.418 323.555 64.4316C323.424 64.3659 323.292 64.2015 323.161 63.9385C323.029 63.6755 322.898 63.4782 322.766 63.3467C322.372 63.1494 321.878 63.0837 321.287 63.1494C320.761 63.1494 320.3 63.0837 319.906 62.9521C319.38 62.6891 318.558 62.196 317.44 61.4727C316.322 60.6836 315.303 59.9603 314.382 59.3027C313.199 58.3822 312.081 57.4616 311.029 56.541C309.977 55.6204 309.056 54.6341 308.267 53.582C308.07 53.319 307.807 53.1875 307.478 53.1875C307.149 53.1217 306.853 53.0231 306.59 52.8916C304.683 54.0752 303.072 55.5547 301.757 57.3301C300.442 59.1055 299.193 60.9137 298.009 62.7549C296.826 64.596 295.576 66.3385 294.261 67.9824C292.946 69.6263 291.269 70.8757 289.231 71.7305C288.639 71.7305 288.113 71.6318 287.653 71.4346C287.193 71.2373 286.765 70.9743 286.371 70.6455C285.976 70.3825 285.582 70.1195 285.187 69.8564C284.792 69.5934 284.365 69.3962 283.905 69.2646C283.905 68.4756 283.74 67.7523 283.412 67.0947C283.149 66.4372 282.853 65.8125 282.524 65.2207C282.261 64.6289 282.064 64.07 281.932 63.5439C281.801 62.9521 281.932 62.3932 282.327 61.8672C281.932 61.4727 281.34 61.0452 280.551 60.585C280.946 60.1904 281.11 59.8288 281.044 59.5C281.044 59.1712 280.979 58.8424 280.847 58.5137C280.716 58.1849 280.584 57.8232 280.453 57.4287C280.387 57.0342 280.486 56.6396 280.749 56.2451C281.077 56.2451 281.472 56.1794 281.932 56.0479C281.538 55.5218 281.34 55.2259 281.34 55.1602C281.406 55.0286 281.34 54.8643 281.143 54.667C281.012 54.2725 281.077 54.0423 281.34 53.9766C281.603 53.8451 281.866 53.7135 282.129 53.582C282.392 50.36 282.951 47.3682 283.806 44.6064C284.661 41.8447 285.614 39.1816 286.667 36.6172C287.719 34.0527 288.738 31.4554 289.724 28.8252C290.776 26.195 291.631 23.3675 292.289 20.3428C293.012 19.6195 293.571 18.7646 293.965 17.7783C294.426 16.792 294.886 15.8057 295.346 14.8193C295.872 13.833 296.431 12.8796 297.023 11.959C297.68 10.9727 298.568 10.1836 299.686 9.5918C300.607 9.65755 301.429 9.92057 302.152 10.3809C302.875 10.7754 303.763 10.9398 304.815 10.874C305.012 11.2028 305.177 11.5316 305.308 11.8604C305.505 12.1891 305.736 12.5179 305.999 12.8467L307.478 12.5508C308.201 13.1426 308.826 13.8988 309.352 14.8193C309.944 15.6742 310.338 16.5947 310.536 17.5811C310.733 18.5674 310.7 19.5208 310.437 20.4414C310.174 21.2962 309.549 21.9867 308.563 22.5127C308.629 22.8415 308.629 23.1045 308.563 23.3018C308.563 23.4333 308.53 23.5648 308.464 23.6963C308.399 23.8278 308.366 23.9593 308.366 24.0908C308.366 24.2223 308.464 24.4196 308.662 24.6826C307.347 25.6689 306.36 27.0498 305.703 28.8252C305.045 30.6006 304.683 32.1787 304.618 33.5596C305.407 32.7705 306.262 32.0143 307.182 31.291C308.168 30.502 309.155 29.7458 310.141 29.0225C311.193 28.2992 312.18 27.6087 313.1 26.9512C314.086 26.2936 314.974 25.6361 315.763 24.9785C317.933 23.0059 320.004 21.4277 321.977 20.2441C324.015 18.9948 326.153 17.6139 328.388 16.1016C328.914 15.9701 329.309 15.9701 329.572 16.1016C329.901 16.1673 330.229 16.266 330.558 16.3975C330.558 16.0029 330.427 15.7728 330.164 15.707C329.966 15.6413 329.901 15.3783 329.966 14.918C330.953 14.6549 331.807 14.359 332.531 14.0303C333.254 13.6357 334.043 13.2741 334.898 12.9453C335.49 13.5371 336.049 14.1618 336.575 14.8193C337.101 15.4111 337.824 15.7728 338.745 15.9043C339.073 16.6276 339.468 17.1865 339.928 17.5811C340.389 17.9098 340.849 18.2386 341.309 18.5674C341.769 18.8962 342.164 19.2907 342.493 19.751C342.887 20.2113 343.117 20.9346 343.183 21.9209C342.92 22.3812 342.624 22.8743 342.295 23.4004C342.032 23.9264 341.769 24.5511 341.506 25.2744C340.191 26.458 338.843 27.5101 337.462 28.4307C336.147 29.3512 334.799 30.2389 333.418 31.0938C332.038 31.9486 330.624 32.8034 329.177 33.6582C327.731 34.513 326.251 35.5322 324.739 36.7158C324.41 37.1761 323.983 37.6035 323.457 37.998C322.996 38.3268 322.503 38.6885 321.977 39.083C321.451 39.4118 320.958 39.7734 320.498 40.168C320.037 40.5625 319.676 41.0228 319.413 41.5488C319.215 41.6146 319.018 41.6475 318.821 41.6475C318.624 41.6475 318.426 41.6803 318.229 41.7461C318.032 42.2064 317.703 42.568 317.243 42.8311C316.848 43.0941 316.585 43.4557 316.454 43.916C317.44 46.0202 318.722 47.6312 320.3 48.749C321.878 49.8669 323.654 50.6888 325.626 51.2148C327.599 51.6751 329.736 51.9382 332.038 52.0039C334.339 52.0039 336.739 52.0039 339.238 52.0039C339.501 51.9382 339.599 51.8066 339.534 51.6094C339.534 51.3464 339.698 51.2477 340.027 51.3135C341.605 51.8395 342.821 52.5957 343.676 53.582C344.531 54.5026 345.55 55.4232 346.734 56.3438C346.602 58.8424 345.846 60.9137 344.465 62.5576C343.084 64.2015 341.243 65.5166 338.942 66.5029Z" fill="#E5E5E5"/>
<path d="M365.573 63.1494C365.902 65.1221 365.77 66.6673 365.178 67.7852C364.652 68.903 363.863 69.7249 362.811 70.251C361.825 70.8428 360.674 71.1716 359.359 71.2373C358.044 71.3031 356.794 71.2373 355.611 71.04C354.953 70.1195 354.361 68.9688 353.835 67.5879C353.309 66.207 352.816 64.7933 352.356 63.3467C351.896 61.8343 351.468 60.3548 351.074 58.9082C350.745 57.4616 350.449 56.1794 350.186 55.0615C350.515 54.2725 350.712 53.3848 350.778 52.3984C350.909 51.3464 350.975 50.2943 350.975 49.2422C351.041 48.1901 351.074 47.138 351.074 46.0859C351.139 44.9681 351.238 43.916 351.37 42.9297C351.83 40.168 352.487 37.5378 353.342 35.0391C354.263 32.5404 354.986 29.943 355.512 27.2471C355.644 26.6553 355.578 26.0964 355.315 25.5703C355.118 25.0443 355.085 24.5511 355.216 24.0908C355.282 23.8278 355.479 23.6634 355.808 23.5977C356.137 23.4661 356.334 23.236 356.4 22.9072C356.597 22.1839 356.63 21.5921 356.499 21.1318C356.433 20.6715 356.564 20.1126 356.893 19.4551C357.222 18.929 357.616 18.1729 358.077 17.1865C358.603 16.1344 358.8 15.0495 358.668 13.9316C359.26 13.5371 359.819 13.0768 360.345 12.5508C360.871 12.0247 361.397 11.5645 361.923 11.1699C362.515 10.7096 363.14 10.3151 363.797 9.98633C364.521 9.65755 365.375 9.49316 366.362 9.49316C366.888 10.1507 367.217 10.874 367.348 11.6631C367.545 12.4521 367.71 13.2412 367.841 14.0303C368.039 14.8193 368.302 15.5755 368.63 16.2988C368.959 16.9564 369.518 17.4824 370.307 17.877C370.307 18.403 370.307 19.0605 370.307 19.8496C370.307 20.6387 370.34 21.4277 370.406 22.2168C370.472 22.9401 370.603 23.6305 370.8 24.2881C371.063 24.8799 371.458 25.2744 371.984 25.4717C370.8 28.6279 369.682 31.7513 368.63 34.8418C367.644 37.9323 366.822 41.0557 366.165 44.2119C365.507 47.3024 365.08 50.4258 364.882 53.582C364.751 56.7383 364.981 59.9274 365.573 63.1494Z" fill="#E5E5E5"/>
<rect x="144.77" width="15" height="80" rx="4" fill="#00FFA3"/>
</svg>

After

Width:  |  Height:  |  Size: 15 KiB

BIN
doc/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
doc/todos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

File diff suppressed because it is too large Load Diff

BIN
doc/wiki.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,610 +1,469 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki plugin file
" Home: https://github.com/vimwiki/vimwiki/
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
if exists("g:loaded_vimwiki") || &cp
if exists('g:loaded_vimwiki') || &compatible
finish
endif
let g:loaded_vimwiki = 1
let s:old_cpo = &cpo
set cpo&vim
" Set to version number for release, otherwise -1 for dev-branch
let s:plugin_vers = 2.5
" 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 "}}}
"}}}
" Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h')
" HELPER functions {{{
function! s:default(varname, value) "{{{
if !exists('g:vimwiki_'.a:varname)
let g:vimwiki_{a:varname} = a:value
endif
endfunction "}}}
let s:old_cpo = &cpoptions
set cpoptions&vim
function! s:path_html(idx) "{{{
let path_html = VimwikiGet('path_html', a:idx)
if !empty(path_html)
return path_html
else
let g:VimwikiLog.path_html += 1 "XXX
let path = VimwikiGet('path', a:idx)
return substitute(path, '[/\\]\+$', '', '').'_html/'
endif
endfunction "}}}
function! s:normalize_path(path) "{{{
let g:VimwikiLog.normalize_path += 1 "XXX
" resolve doesn't work quite right with symlinks ended with / or \
let path = substitute(a:path, '[/\\]\+$', '', '')
if path !~# '^scp:'
return resolve(expand(path)).'/'
else
return path.'/'
endif
endfunction "}}}
if exists('g:vimwiki_autowriteall')
let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall
else
let s:vimwiki_autowriteall_saved = 1
endif
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')
return b:vimwiki_idx
else
return -1
endif
endfunction " }}}
function! s:setup_buffer_leave() "{{{
if g:vimwiki_debug == 3
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if &filetype ==? 'vimwiki'
" cache global vars of current state XXX: SLOW!?
call vimwiki#base#cache_buffer_state()
endif
if g:vimwiki_debug == 3
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let &autowriteall = s:vimwiki_autowriteall
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
endif
endfunction "}}}
function! s:setup_filetype() "{{{
if g:vimwiki_debug == 3
echom "Setup_filetype g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let time0 = reltime() " start the clock "XXX
" Find what wiki current buffer belongs to.
let path = expand('%:p:h')
let idx = vimwiki#base#find_wiki(path)
if g:vimwiki_debug == 3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
endif
if idx == -1 && g:vimwiki_global_ext == 0
" this is called when the cursor leaves the buffer
function! s:setup_buffer_leave() abort
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
"XXX when idx = -1? (an orphan page has been detected)
"TODO: refactor (same code in setup_buffer_enter)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
let &autowriteall = s:vimwiki_autowriteall_saved
if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
" create a new temporary wiki for the current buffer
function! s:create_temporary_wiki() abort
let path = expand('%:p:h')
let ext = '.'.expand('%:e')
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
if has_key(syntax_mapping, ext)
let syntax = syntax_mapping[ext]
else
let syntax = vimwiki#vars#get_wikilocal_default('syntax')
endif
let new_temp_wiki_settings = {'path': path,
\ 'ext': ext,
\ 'syntax': syntax,
\ }
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
" Update the wiki number of the current buffer, because it may have changed when adding this
" temporary wiki.
call vimwiki#vars#set_bufferlocal('wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
endfunction
" This function is called when Vim opens a new buffer with a known wiki
" extension. Both when the buffer has never been opened in this session and
" when it has.
function! s:setup_new_wiki_buffer() abort
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
if wiki_nr == -1 " it's not in a known wiki directory
if vimwiki#vars#get_global('global_ext')
call s:create_temporary_wiki()
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
call Validate_wiki_options(idx)
endif
" 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')
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
" the user does not want a temporary wiki, so do nothing
return
endif
"TODO: refactor (same code in setup_filetype)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
call Validate_wiki_options(idx)
endif
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
endif
" If you have
" au GUIEnter * VimwikiIndex
" Then change it to
" au GUIEnter * nested VimwikiIndex
if &filetype == ''
set filetype=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
elseif &syntax ==? 'vimwiki'
" to force a rescan of the filesystem which may have changed
" and update VimwikiLinks syntax group that depends on it;
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
if exists("b:vimwiki_fs_rescan") && VimwikiGet('maxhi')
set syntax=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set syntax=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
endif
let b:vimwiki_fs_rescan = 1
endif
let time1 = vimwiki#u#time(time0) "XXX
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
" new tab with the same buffer folding is reset to vim defaults. So we
" insist vimwiki folding here.
if g:vimwiki_folding ==? 'expr'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif g:vimwiki_folding ==? 'syntax'
setlocal fdm=syntax
setlocal foldtext=VimwikiFoldText()
else
setlocal fdm=manual
exe "normal zE"
if vimwiki#vars#get_wikilocal('maxhi')
call vimwiki#vars#set_bufferlocal('existing_wikifiles', vimwiki#base#get_wikilinks(wiki_nr, 1, ''))
call vimwiki#vars#set_bufferlocal('existing_wikidirs',
\ vimwiki#base#get_wiki_directories(wiki_nr))
endif
" And conceal level too.
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
" sourced
call vimwiki#u#ft_set()
endfunction
" this is called when the cursor enters the buffer
function! s:setup_buffer_enter() abort
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
" Set up menu
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 "}}}
call s:set_global_options()
endfunction
function! s:setup_buffer_reenter() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if !vimwiki#base#recall_buffer_state()
" Do not repeat work of s:setup_buffer_enter() and s:setup_filetype()
" Once should be enough ...
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if !exists("s:vimwiki_autowriteall")
let s:vimwiki_autowriteall = &autowriteall
endif
let &autowriteall = g:vimwiki_autowriteall
endfunction "}}}
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
" this is called when the buffer enters a window or when running a diff
function! s:setup_buffer_win_enter() abort
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
" a registered wiki and not a temporary wiki)
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
return
endif
if !vimwiki#u#ft_is_vw()
call vimwiki#u#ft_set()
endif
call s:set_windowlocal_options()
endfunction
function! s:setup_cleared_syntax() abort
" highlight groups that get cleared
" on colorscheme change because they are not linked to Vim-predefined groups
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def VimwikiUnderline gui=underline
if g:vimwiki_hl_headers == 1
if vimwiki#vars#get_global('hl_headers') == 1
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='
\ . vimwiki#vars#get_global('hcolor_guifg_'.&background)[i-1]
\ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&background)[i-1]
\ .' term=bold cterm=bold'
endfor
endif
endfunction "}}}
endfunction
" OPTION get/set functions {{{
" return complete list of options
function! VimwikiGetOptionNames() "{{{
return keys(s:vimwiki_defaults)
endfunction "}}}
function! VimwikiGetOptions(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
let option_dict = {}
for kk in keys(s:vimwiki_defaults)
let option_dict[kk] = VimwikiGet(kk, idx)
endfor
return option_dict
endfunction "}}}
" Return value of option for current wiki or if second parameter exists for
" wiki with a given index.
" If the option is not found, it is assumed to have been previously cached in a
" buffer local dictionary, that acts as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiGet(option, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(g:vimwiki_list[idx], a:option)
let val = g:vimwiki_list[idx][a:option]
elseif has_key(s:vimwiki_defaults, a:option)
let val = s:vimwiki_defaults[a:option]
let g:vimwiki_list[idx][a:option] = val
else
let val = b:vimwiki_list[a:option]
endif
" XXX no call to vimwiki#base here or else the whole autoload/base gets loaded!
return val
endfunction "}}}
" Set option for current wiki or if third parameter exists for
" wiki with a given index.
" If the option is not found or recognized (i.e. does not exist in
" s:vimwiki_defaults), it is saved in a buffer local dictionary, that acts
" as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiSet(option, value, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(s:vimwiki_defaults, a:option) ||
\ has_key(g:vimwiki_list[idx], a:option)
let g:vimwiki_list[idx][a:option] = a:value
elseif exists('b:vimwiki_list')
let b:vimwiki_list[a:option] = a:value
else
let b:vimwiki_list = {}
let b:vimwiki_list[a:option] = a:value
endif
endfunction "}}}
" 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.
function! VimwikiClear(option, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if exists('b:vimwiki_list') && has_key(b:vimwiki_list, a:option)
call remove(b:vimwiki_list, a:option)
endif
endfunction "}}}
" }}}
function! s:vimwiki_get_known_extensions() " {{{
function! s:vimwiki_get_known_extensions() abort
" 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
for idx in range(vimwiki#vars#number_of_wikis())
let ext = vimwiki#vars#get_wikilocal('ext', idx)
let extensions[ext] = 1
endfor
" append map g:vimwiki_ext2syntax
for ext in keys(g:vimwiki_ext2syntax)
" append extensions from g:vimwiki_ext2syntax
for ext in keys(vimwiki#vars#get_global('ext2syntax'))
let extensions[ext] = 1
endfor
return keys(extensions)
endfunction " }}}
endfunction
" }}}
" CALLBACK functions "{{{
" User can redefine it.
if !exists("*VimwikiLinkHandler") "{{{
" Set settings which are global for Vim, but should only be executed for
" Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer
" and reset when the cursor leaves the buffer.
function! s:set_global_options() abort
let s:vimwiki_autowriteall_saved = &autowriteall
let &autowriteall = vimwiki#vars#get_global('autowriteall')
if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
" Set settings which are local to a window. In a new tab they would be reset to
" Vim defaults. So we enforce our settings here when the cursor enters a
" Vimwiki buffer.
function! s:set_windowlocal_options() abort
if !&diff " if Vim is currently in diff mode, don't interfere with its folding
let foldmethod = vimwiki#vars#get_global('folding')
if foldmethod =~? '^expr.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^syntax.*'
setlocal foldmethod=syntax
setlocal foldtext=VimwikiFoldText()
elseif foldmethod =~? '^custom.*'
" do nothing
else
setlocal foldmethod=manual
normal! zE
endif
endif
if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel')
let &conceallevel = vimwiki#vars#get_global('conceallevel')
endif
if vimwiki#vars#get_global('auto_chdir')
exe 'lcd' vimwiki#vars#get_wikilocal('path')
endif
endfunction
function! s:get_version() abort
if s:plugin_vers != -1
echo 'Stable version: ' . string(s:plugin_vers)
else
let l:plugin_rev = system('git --git-dir ' . s:plugin_dir . '/.git rev-parse --short HEAD')
let l:plugin_branch = system('git --git-dir ' . s:plugin_dir . '/.git rev-parse --abbrev-ref HEAD')
let l:plugin_date = system('git --git-dir ' . s:plugin_dir . '/.git show -s --format=%ci')
if v:shell_error == 0
echo 'Os: ' . vimwiki#u#os_name()
echo 'Vim: ' . v:version
echo 'Branch: ' . l:plugin_branch
echo 'Revision: ' . l:plugin_rev
echo 'Date: ' . l:plugin_date
else
echo 'Unknown version'
endif
endif
endfunction
" Initialization of Vimwiki starts here. Make sure everything below does not
" cause autoload/vimwiki/base.vim to be loaded
call vimwiki#vars#init()
" Define callback functions which the user can redefine
if !exists('*VimwikiLinkHandler')
function VimwikiLinkHandler(url)
return 0
endfunction
endif "}}}
endif
if !exists("*VimwikiLinkConverter") "{{{
if !exists('*VimwikiLinkConverter')
function VimwikiLinkConverter(url, source, target)
" Return the empty string when unable to process link
return ''
endfunction
endif "}}}
endif
if !exists("*VimwikiWikiIncludeHandler") "{{{
function! VimwikiWikiIncludeHandler(value) "{{{
if !exists('*VimwikiWikiIncludeHandler')
function! VimwikiWikiIncludeHandler(value)
return ''
endfunction "}}}
endif "}}}
" CALLBACK }}}
endfunction
endif
" DEFAULT wiki {{{
let s:vimwiki_defaults = {}
let s:vimwiki_defaults.path = '~/vimwiki/'
let s:vimwiki_defaults.path_html = '' " '' is replaced by derived path.'_html/'
let s:vimwiki_defaults.css_name = 'style.css'
let s:vimwiki_defaults.index = 'index'
let s:vimwiki_defaults.ext = '.wiki'
let s:vimwiki_defaults.maxhi = 0
let s:vimwiki_defaults.syntax = 'default'
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
let s:vimwiki_defaults.template_default = 'default'
let s:vimwiki_defaults.template_ext = '.tpl'
" write a level 1 header to new wiki files
" a:fname should be an absolute filepath
function! s:create_h1(fname) abort
if vimwiki#vars#get_global('auto_header')
let idx = vimwiki#vars#get_bufferlocal('wiki_nr')
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
let s:vimwiki_defaults.auto_toc = 0
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
" file.
let s:vimwiki_defaults.temp = 0
" don't do anything for unregistered wikis
if idx == -1
return
endif
" diary
let s:vimwiki_defaults.diary_rel_path = 'diary/'
let s:vimwiki_defaults.diary_index = 'diary'
let s:vimwiki_defaults.diary_header = 'Diary'
let s:vimwiki_defaults.diary_sort = 'desc'
" don't create header for the diary index page
if vimwiki#path#is_equal(a:fname,
\ vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx).
\ vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx))
return
endif
" Do not change this! Will wait till vim become more datetime awareable.
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
" get tail of filename without extension
let title = expand('%:t:r')
" NEW! in v2.0
" custom_wiki2html
let s:vimwiki_defaults.custom_wiki2html = ''
"
let s:vimwiki_defaults.list_margin = -1
" don't insert header for index page
if title ==# vimwiki#vars#get_wikilocal('index', idx)
return
endif
let s:vimwiki_defaults.auto_tags = 0
"}}}
" don't substitute space char for diary pages
if title !~# '^\d\{4}-\d\d-\d\d'
" NOTE: it is possible this could remove desired characters if the 'links_space_char'
" character matches characters that are intentionally used in the title.
let title = substitute(title, vimwiki#vars#get_wikilocal('links_space_char'), ' ', 'g')
endif
" DEFAULT options {{{
call s:default('list', [s:vimwiki_defaults])
call s:default('use_mouse', 0)
call s:default('folding', '')
call s:default('menu', 'Vimwiki')
call s:default('global_ext', 1)
call s:default('ext2syntax', {}) " syntax map keyed on extension
call s:default('hl_headers', 0)
call s:default('hl_cb_checked', 0)
call s:default('list_ignore_newline', 1)
call s:default('listsyms', ' .oOX')
call s:default('use_calendar', 1)
call s:default('table_mappings', 1)
call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('CJK_length', 0)
call s:default('dir_link', '')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
call s:default('user_htmls', '')
call s:default('autowriteall', 1)
call s:default('toc_header', 'Contents')
" insert the header
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
keepjumps call append(0, '# ' . title)
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
keepjumps call append(1, '')
endfor
else
keepjumps call append(0, '= ' . title . ' =')
endif
endif
endfunction
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)
" Define autocommands for all known wiki extensions
call s:default('diary_months',
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ })
let s:known_extensions = s:vimwiki_get_known_extensions()
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
" Scheme regexes {{{
call s:default('schemes', 'wiki\d\+,diary,local')
call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'.
\ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp')
call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel')
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', 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 {{{
augroup filetypedetect
" clear FlexWiki's stuff
au! * *.wiki
augroup end
if index(s:known_extensions, '.wiki') > -1
augroup filetypedetect
" clear FlexWiki's stuff
au! * *.wiki
augroup end
endif
augroup vimwiki
autocmd!
for 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 *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
endfor
autocmd ColorScheme * call s:setup_cleared_syntax()
" ['.md', '.mdown'] => *.md,*.mdown
let pat = join(map(s:known_extensions, '"*" . v:val'), ',')
exe 'autocmd BufNewFile,BufRead '.pat.' call s:setup_new_wiki_buffer()'
exe 'autocmd BufEnter '.pat.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave '.pat.' call s:setup_buffer_leave()'
exe 'autocmd BufWinEnter '.pat.' call s:setup_buffer_win_enter()'
if exists('##DiffUpdated')
exe 'autocmd DiffUpdated '.pat.' call s:setup_buffer_win_enter()'
endif
" automatically generate a level 1 header for new files
exe 'autocmd BufNewFile '.pat.' call s:create_h1(expand("%:p"))'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
if vimwiki#vars#get_global('table_auto_fmt')
exe 'autocmd InsertLeave '.pat.' call vimwiki#tbl#format(line("."), 2)'
exe 'autocmd InsertEnter '.pat.' call vimwiki#tbl#reset_tw(line("."))'
endif
if vimwiki#vars#get_global('folding') =~? ':quick$'
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
" Don't screw up folds when inserting text that might affect them, until
" leaving insert mode. Foldmethod is local to the window. Protect against
" screwing up folding when switching between windows.
exe 'autocmd InsertEnter '.pat.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'.
\ ' | setlocal foldmethod=manual | endif'
exe 'autocmd InsertLeave,WinLeave '.pat.' if exists("w:last_fdm") |'.
\ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
endif
augroup END
"}}}
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#base#ui_select()
" XXX: why not using <count> instead of v:count1?
" See Issue 324.
command! -count=1 VimwikiIndex
\ call vimwiki#base#goto_index(v:count1)
command! -count=1 VimwikiTabIndex
\ call vimwiki#base#goto_index(v:count1, 1)
command! -count=1 VimwikiDiaryIndex
\ call vimwiki#diary#goto_diary_index(v:count1)
command! -count=1 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1)
command! -count=1 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1, 1)
" these commands take a count e.g. :VimwikiIndex 2
" the default behavior is to open the index, diary etc.
" for the CURRENT wiki if no count is given
command! -count=0 VimwikiIndex
\ call vimwiki#base#goto_index(<count>)
command! -count=0 VimwikiTabIndex
\ call vimwiki#base#goto_index(<count>, 1)
command! -count=0 VimwikiDiaryIndex
\ call vimwiki#diary#goto_diary_index(<count>)
command! -count=0 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(<count>)
command! -count=0 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(<count>, 1)
command! -count=0 VimwikiMakeYesterdayDiaryNote
\ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
command! -count=0 VimwikiMakeTomorrowDiaryNote
\ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
"}}}
" MAPPINGS {{{
if !hasmapto('<Plug>VimwikiIndex')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'w <Plug>VimwikiIndex'
command! VimwikiShowVersion call s:get_version()
" <Plug> global definitions
nnoremap <silent><script> <Plug>VimwikiIndex
\ :<C-U>call vimwiki#base#goto_index(v:count)<CR>
nnoremap <silent><script> <Plug>VimwikiTabIndex
\ :<C-U>call vimwiki#base#goto_index(v:count, 1)<CR>
nnoremap <silent><script> <Plug>VimwikiUISelect
\ :VimwikiUISelect<CR>
nnoremap <silent><script> <Plug>VimwikiDiaryIndex
\ :<C-U>call vimwiki#diary#goto_diary_index(v:count)<CR>
nnoremap <silent><script> <Plug>VimwikiDiaryGenerateLinks
\ :VimwikiDiaryGenerateLinks<CR>
nnoremap <silent><script> <Plug>VimwikiMakeDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count)<CR>
nnoremap <silent><script> <Plug>VimwikiTabMakeDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 1)<CR>
nnoremap <silent><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))<CR>
nnoremap <silent><script> <Plug>VimwikiMakeTomorrowDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))<CR>
" get the user defined prefix (default <leader>w)
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
" default global key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').global)
call vimwiki#u#map_key('n', s:map_prefix . 'w', '<Plug>VimwikiIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . 't', '<Plug>VimwikiTabIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . 's', '<Plug>VimwikiUISelect', 2)
call vimwiki#u#map_key('n', s:map_prefix . 'i', '<Plug>VimwikiDiaryIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>i', '<Plug>VimwikiDiaryGenerateLinks', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>w', '<Plug>VimwikiMakeDiaryNote', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>t', '<Plug>VimwikiTabMakeDiaryNote', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>y', '<Plug>VimwikiMakeYesterdayDiaryNote', 2)
call vimwiki#u#map_key('n', s:map_prefix . '<Leader>m', '<Plug>VimwikiMakeTomorrowDiaryNote', 2)
endif
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<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')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'s <Plug>VimwikiUISelect'
endif
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
function! s:build_menu(topmenu) abort
let wnamelist = []
for idx in range(vimwiki#vars#number_of_wikis())
let wname = vimwiki#vars#get_wikilocal('name', idx)
if wname ==? ''
" fall back to the path if wiki isn't named
let wname = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
endif
if !hasmapto('<Plug>VimwikiDiaryIndex')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'i <Plug>VimwikiDiaryIndex'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if index(wnamelist, wname) != -1
" append wiki index number to duplicate entries
let wname = wname . ' ' . string(idx + 1)
endif
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
" add entry to the list of names for duplicate checks
call add(wnamelist, wname)
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
" escape spaces and periods
let wname = escape(wname, '\ \.')
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
"}}}
" MENU {{{
function! s:build_menu(topmenu)
let idx = 0
while idx < len(g:vimwiki_list)
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ \.')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#base#goto_index('.(idx + 1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
let idx += 1
endwhile
" build the menu
execute 'menu '.a:topmenu.'.Open\ index.'.wname.
\ ' :call vimwiki#base#goto_index('.(idx+1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.wname.
\ ' :call vimwiki#diary#make_note('.(idx+1).')<CR>'
endfor
endfunction
function! s:build_table_menu(topmenu)
function! s:build_table_menu(topmenu) abort
exe 'menu '.a:topmenu.'.-Sep- :'
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
exe 'nmenu '.a:topmenu.
\ '.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
exe 'nmenu disable '.a:topmenu.'.Table'
endfunction
"XXX make sure anything below does not cause autoload/base to be loaded
if !empty(g:vimwiki_menu)
call s:build_menu(g:vimwiki_menu)
call s:build_table_menu(g:vimwiki_menu)
endif
" }}}
" CALENDAR Hook "{{{
if g:vimwiki_use_calendar
if !empty(vimwiki#vars#get_global('menu'))
call s:build_menu(vimwiki#vars#get_global('menu'))
call s:build_table_menu(vimwiki#vars#get_global('menu'))
endif
" Hook for calendar.vim
if vimwiki#vars#get_global('use_calendar')
let g:calendar_action = 'vimwiki#diary#calendar_action'
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
endif
"}}}
let &cpo = s:old_cpo
let &cpoptions = s:old_cpo

View File

@ -1,35 +0,0 @@
" 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,414 +1,243 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Home: https://github.com/vimwiki/vimwiki/
" Quit if syntax file is already loaded
if version < 600
if v:version < 600
syntax clear
elseif exists("b:current_syntax")
elseif exists('b:current_syntax')
finish
endif
"TODO do nothing if ...? (?)
let g:starttime = reltime() " start the clock
if VimwikiGet('maxhi')
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 s:timescans = vimwiki#u#time(g:starttime) "XXX
"let b:xxx = 1
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
"if VimwikiGet('maxhi')
" ...
"endif
" LINKS: assume this is common to all syntaxes "{{{
" LINKS: WebLinks {{{
" match URL for common protocols;
" see http://en.wikipedia.org/wiki/URI_scheme http://tools.ietf.org/html/rfc3986
let g:vimwiki_rxWebProtocols = ''.
\ '\%('.
\ '\%('.
\ '\%('.join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\):'.
\ '\%(//\)'.
\ '\)'.
\ '\|'.
\ '\%('.join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').'\):'.
\ '\)'
"
let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
\ '\S\{-1,}'. '\%(([^ \t()]*)\)\='
" }}}
" }}}
call vimwiki#u#reload_regexes()
let s:time0 = vimwiki#u#time(g:starttime) "XXX
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
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 = s:wikilink_prefix . '__LinkUrl__'.
\ s:wikilink_suffix
" [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = s:wikilink_prefix . '__LinkUrl__'.
\ s:wikilink_separator . '__LinkDescription__' . s:wikilink_suffix
" 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 s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
" [[URL]], or [[URL|DESCRIPTION]]
" a) match [[URL|DESCRIPTION]]
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 = 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 = s:rx_wikilink_prefix.
\ g:vimwiki_rxWikiLinkUrl.s:rx_wikilink_separator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. s:rx_wikilink_suffix
" }}}
" LINKS: Syntax helper {{{
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
" }}}
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
" LINKS: setup of wikiincl regexps {{{
let g:vimwiki_rxWikiInclPrefix = '{{'
let g:vimwiki_rxWikiInclSuffix = '}}'
let g:vimwiki_rxWikiInclSeparator = '|'
"
" '{{__LinkUrl__}}'
let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}'
let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ '__LinkDescription__'.
\ g:vimwiki_rxWikiInclSuffix
let 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. '\)'.'\{-}'
"
"
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]}
let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]}
let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix.
\ '\zs'. g:vimwiki_rxWikiInclUrl. '\ze'.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiInclPrefix1 = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.g:vimwiki_rxWikiInclSeparator
let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
\ g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Setup weblink regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
" Maxim:
" Simplify free-standing links: URL starts with non(letter|digit)scheme till
" the whitespace.
" Stuart, could you check it with markdown templated links? [](http://...), as
" the last bracket is the part of URL now?
let g:vimwiki_rxWeblink = '\<'. g:vimwiki_rxWeblinkUrl . '\S*'
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr = ''
" }}}
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
" LINKS: highlighting is complicated due to "nonexistent" links feature
function! s:add_target_syntax_ON(target, type) abort
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
endfunction
function! s:add_target_syntax_OFF(target) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
function! s:add_target_syntax_OFF(target) abort
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
endfunction
function! s:highlight_existing_links() "{{{
function! s:highlight_existing_links() abort
" Wikilink
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
\ '\%(#[^|]*\)\?\|#[^|]*\)'
let safe_links = '\%('.vimwiki#base#file_pattern(
\ vimwiki#vars#get_bufferlocal('existing_wikifiles')) . '\%(#[^|]*\)\?\|#[^|]*\)'
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
" match [[URL]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction "}}}
endfunction
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
if vimwiki#vars#get_wikilocal('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink)
call s:add_target_syntax_OFF(vimwiki#vars#get_syntaxlocal('rxWikiLink'))
" WikiIncl
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
call s:add_target_syntax_OFF(vimwiki#vars#get_global('rxWikiIncl'))
" Subsequently, links verified on vimwiki's path are highlighted as existing
let s:time01 = vimwiki#u#time(g:starttime) "XXX
call s:highlight_existing_links()
let s:time02 = vimwiki#u#time(g:starttime) "XXX
else
let s:time01 = vimwiki#u#time(g:starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink'), 'VimwikiLink')
" WikiIncl
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
let s:time02 = vimwiki#u#time(g:starttime) "XXX
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiIncl'), 'VimwikiLink')
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiLink')
" WikiLink
" All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" }}}
" generic headers "{{{
if g:vimwiki_symH
"" symmetric
for 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 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 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'
execute 'syntax match VimwikiHeader'.s:i
\ . ' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
\ 'VimwikiLink,@Spell'
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).'/ end=/'.
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).
\ '/me=s-1 transparent fold'
endfor
" }}}
" possibly concealed chars " {{{
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
" 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: '.s:rx_wikilink_prefix
echom 'WikiLink Suffix: '.s:rx_wikilink_suffix
echom 'WikiLink Prefix1: '.s:rx_wikilink_prefix1
echom 'WikiLink Suffix1: '.s:rx_wikilink_suffix1
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
if vimwiki#vars#get_global('conceal_onechar_markers')
execute 'syn match VimwikiEqInChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_eqin').'/'.s:conceal
execute 'syn match VimwikiBoldChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_bold').'/'.s:conceal
execute 'syn match VimwikiItalicChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_italic').'/'.s:conceal
execute 'syn match VimwikiBoldItalicChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'.s:conceal
execute 'syn match VimwikiItalicBoldChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_italicbold').'/'.s:conceal
execute 'syn match VimwikiCodeChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_code').'/'.s:conceal
execute 'syn match VimwikiDelTextChar contained /'.
\ vimwiki#vars#get_syntaxlocal('char_deltext').'/'.s:conceal
execute 'syn match VimwikiSuperScript contained /'.
\ vimwiki#vars#get_syntaxlocal('char_superscript').'/'.s:conceal
execute 'syn match VimwikiSubScript contained /'.
\ vimwiki#vars#get_syntaxlocal('char_subscript').'/'.s:conceal
endif
" 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 s:options = ' contained transparent contains=NONE'
"
if exists('+conceallevel')
let s:options .= s:conceal
endif
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
" VimwikiLinkRest group is left undefined if link shortening is not desired
if exists("+conceallevel") && g:vimwiki_url_maxsave > 0
let s:options .= s:conceal
if exists('+conceallevel') && vimwiki#vars#get_global('url_maxsave') > 0
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.s:options
\.'\%([/#?]\w\|\S\{'.vimwiki#vars#get_global('url_maxsave').'}\)`'.' cchar=~'.s:options
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.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
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix1').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix1').'/'.s:options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.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
" }}}
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix1').'/'.s:options
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1').'/'.s:options
" non concealed chars " {{{
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.g:vimwiki_rxH.'\+\)\|\%('.g:vimwiki_rxH.'\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldCharT contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeCharT contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
" Emoticons
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
" non concealed chars
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.
\ vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH').
\ '\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_eqin').'/'
execute 'syn match VimwikiBoldCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_bold').'/'
execute 'syn match VimwikiItalicCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_italic').'/'
execute 'syn match VimwikiBoldItalicCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'
execute 'syn match VimwikiItalicBoldCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_italicbold').'/'
execute 'syn match VimwikiCodeCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_code').'/'
execute 'syn match VimwikiDelTextCharT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_deltext').'/'
execute 'syn match VimwikiSuperScriptT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_superscript').'/'
execute 'syn match VimwikiSubScriptT contained /'
\ .vimwiki#vars#get_syntaxlocal('char_subscript').'/'
execute 'syntax match VimwikiTodo /'. vimwiki#vars#get_global('rxTodo') .'/'
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
@ -420,105 +249,130 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
syntax match VimwikiCellSeparator
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" Lists
execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
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'
" Lists
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
if vimwiki#vars#get_global('hl_cb_checked') == 1
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
\ . '\s*\[['.vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ']\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
execute 'syntax match VimwikiCheckBoxDone /'
\ . vimwiki#vars#get_syntaxlocal('rxListItemAndChildren')
\ .'/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endif
execute 'syntax match VimwikiEqIn /'.g:vimwiki_rxEqIn.'/ contains=VimwikiEqInChar'
execute 'syntax match VimwikiEqInT /'.g:vimwiki_rxEqIn.'/ contained contains=VimwikiEqInCharT'
execute 'syntax match VimwikiEqIn /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
\ '/ contains=VimwikiEqInChar,@NoSpell'
execute 'syntax match VimwikiEqInT /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
\ '/ contained contains=VimwikiEqInCharT,@NoSpell'
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
execute 'syntax match VimwikiBold /'.vimwiki#vars#get_syntaxlocal('rxBold').
\ '/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.vimwiki#vars#get_syntaxlocal('rxBold').
\ '/ contained contains=VimwikiBoldCharT,@Spell'
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT,@Spell'
execute 'syntax match VimwikiItalic /'.vimwiki#vars#get_syntaxlocal('rxItalic').
\ '/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /'.vimwiki#vars#get_syntaxlocal('rxItalic').
\ '/ contained contains=VimwikiItalicCharT,@Spell'
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiBoldItalic /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
\ '/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiItalicBold /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
\ '/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contained contains=VimwikiDelTextCharT,@Spell'
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT,@Spell'
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contained contains=VimwikiSuperScriptCharT,@Spell'
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT,@Spell'
execute 'syntax match VimwikiSubScript /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
\ '/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
\ '/ contained contains=VimwikiSubScriptCharT,@Spell'
execute 'syntax match VimwikiCode /'.vimwiki#vars#get_syntaxlocal('rxCode').
\ '/ contains=VimwikiCodeChar,@NoSpell'
execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').
\ '/ contained contains=VimwikiCodeCharT'
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : ''
execute 'syntax region VimwikiPre matchgroup=VimwikiPreDelim start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@NoSpell'.concealpre
execute 'syntax region VimwikiMath start=/^\s*'.g:vimwiki_rxMathStart.
\ '/ end=/^\s*'.g:vimwiki_rxMathEnd.'\s*$/ contains=@Spell'
execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@NoSpell'
" placeholders
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholderParam /\s.*/ contained
syntax match VimwikiPlaceholder
\ /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder
\ /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholder
\ /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
syntax match VimwikiPlaceholderParam /.*/ contained
" html tags
if g:vimwiki_valid_html_tags != ''
let s:html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
if vimwiki#vars#get_global('valid_html_tags') !=? ''
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').
\ '/ contains=@Spell,VimwikiTodo'
endif
" tags
execute 'syntax match VimwikiTag /'.g:vimwiki_rxTags.'/'
execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
" }}}
" header groups highlighting "{{{
if g:vimwiki_hl_headers == 0
" header groups highlighting
if vimwiki#vars#get_global('hl_headers') == 0
" Strangely in default colorscheme Title group is not set to bold for cterm...
if !exists("g:colors_name")
if !exists('g:colors_name')
hi Title cterm=bold
endif
for s:i in range(1,6)
execute 'hi def link VimwikiHeader'.s:i.' Title'
endfor
else
" default colors when headers of different levels are highlighted differently
" not making it yet another option; needed by ColorScheme autocommand
let g:vimwiki_hcolor_guifg_light = ['#aa5858','#507030','#1030a0','#103040','#505050','#636363']
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black']
let g:vimwiki_hcolor_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
for 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'
execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='
\ .vimwiki#vars#get_global('hcolor_guifg_'.&background)[s:i-1].' gui=bold ctermfg='
\ .vimwiki#vars#get_global('hcolor_ctermfg_'.&background)[s:i-1].' term=bold cterm=bold'
endfor
endif
"}}}
" syntax group highlighting "{{{
hi def link VimwikiMarkers Normal
@ -531,7 +385,7 @@ hi def link VimwikiBoldT VimwikiBold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def link VimwikiItalicT VimwikiItalic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def VimwikiBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic
hi def link VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic
@ -543,6 +397,7 @@ hi def link VimwikiCodeT VimwikiCode
hi def link VimwikiPre PreProc
hi def link VimwikiPreT VimwikiPre
hi def link VimwikiPreDelim VimwikiPre
hi def link VimwikiMath Number
hi def link VimwikiMathT VimwikiMath
@ -556,7 +411,6 @@ hi def link VimwikiLinkT VimwikiLink
hi def link VimwikiList Identifier
hi def link VimwikiListTodo VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiEmoticons Character
hi def link VimwikiHR Identifier
hi def link VimwikiTag Keyword
@ -600,33 +454,37 @@ hi def link VimwikiCodeCharT VimwikiMarkers
hi def link VimwikiHeaderCharT VimwikiMarkers
hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
"}}}
" Load syntax-specific functionality
call vimwiki#u#reload_regexes_custom()
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
let b:current_syntax="vimwiki"
" EMBEDDED syntax setup "{{{
let s:nested = VimwikiGet('nested_syntaxes')
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
let b:current_syntax='vimwiki'
" EMBEDDED syntax setup
let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes')
if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes')
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), 'keep')
endif
if !empty(s:nested)
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
call vimwiki#base#nested_syntax(s:vim_syntax,
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ vimwiki#vars#get_syntaxlocal('rxPreStart').'\%(.*[[:blank:][:punct:]]\)\?'.
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
\ vimwiki#vars#get_syntaxlocal('rxPreEnd'), 'VimwikiPre')
endfor
endif
" LaTeX
call vimwiki#base#nested_syntax('tex',
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
call vimwiki#base#nested_syntax('tex',
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
\ '\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
"}}}
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
syntax spell toplevel
let s:timeend = vimwiki#u#time(g:starttime) "XXX
call VimwikiLog_extend('timing',['syntax:scans',s:timescans],['syntax:regexloaded',s:time0],['syntax:beforeHLexisting',s:time01],['syntax:afterHLexisting',s:time02],['syntax:end',s:timeend])

View File

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

View File

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

View File

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

View File

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

75
test/README.md Normal file
View File

@ -0,0 +1,75 @@
# Vimwiki Tests
This directory contains a test framework used to automatically test/verify
Vimwiki functionality. It is based on the following tools:
- [vim-testbed GitHub](https://github.com/tweekmonster/vim-testbed) or on [testbed/vim dockerhub](https://hub.docker.com/r/testbed/vim)
- [Vader](https://github.com/junegunn/vader.vim)
- [Vint](https://github.com/Kuniwak/vint)
## Resources
- [Vim patches](http://ftp.vim.org/pub/vim/patches/)
- Example test cases:
- [vim-easy-align](https://github.com/junegunn/vim-easy-align/tree/master/test)
- [vim-plug](https://github.com/junegunn/vim-plug/tree/master/test)
- [ale](https://github.com/w0rp/ale/tree/master/test)
- [Other projects](https://github.com/junegunn/vader.vim/wiki/Projects-using-Vader)
## Building Docker Image
To build the Docker image run `docker build -t vimwiki .` from the Vimwiki
repository root (same location as the Dockerfile).
## Running Tests
### Manual Steps
Starting in the test directory run this command:
```sh
docker run -it --rm -v $PWD/../:/testplugin -v $PWD/../test:/home vimwiki vim_7.4.1099 -u test/vimrc -i NONE
```
This will open a vim instance in the docker container and then all tests
can be run with `:Vader test/*` or individual tests can be run.
**Note:** Substitute `vim_7.4.1099` for any of the vim versions in the Dockerfile.
### Automated Tests
The script in the `test/` directory named `run_test.sh` can be used to
automatically run all tests for all installed vim versions. The vim/nvim
versions are parsed from the Dockerfile. This script will also run `Vint` for all
plugin source files. For more information run `./run_tests.sh -h`.
## Inside the container
- `$USER` -> `vimtest` : unprivileged => very hard to mess up things
- `$HOME` -> `/home/vimtest` : but it is readonly !
- `$PWD` -> `/testplugin` : mapped to vimwiki plugin root directory
For more information, read the [base docker image](https://github.com/tweekmonster/vim-testbed)
## Known Issues
1. neovim v0.2.x does not work correctly with Vader output from the docker
container. No test results are printed and an error message saying
`Vim: Error reading input, exiting...`
- Probably need to look into this more and determine if the issue is Vader,
Neovim, or Docker.
2. Vader does not play nice with the location list. Tests that use the location
list should be placed in `independent_runs/`.
- [Vader Issue #199](https://github.com/junegunn/vader.vim/issues/199)
## Notable Vim patches
- `v7.3.831` `getbufvar` added a default value
- `v7.4.236` add ability to check patch with has("patch-7.4.123")
- `v7.4.279` added the option to for `globpath()` to return a list
- `v7.4.1546` sticky type checking removed (allow a variables type to change)
- `v7.4.1989` `filter()` accepts a Funcref
- `v7.4.2044` lambda support added - see `:h expr-lambda`
- `v7.4.2120` Added function "closure" argument
- `v7.4.2137` add `funcref()`
- `v8.0` async jobs and timers

View File

@ -0,0 +1,103 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
# 1 VimwikiGenerateLinks
##########################
Given (Void):
Execute (Goto markdown resource wiki):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
Execute (Edit Test file / VimwikiGenerateLinks):
edit $HOME/testmarkdown/Test.md
AssertEqual $HOME . '/testmarkdown/Test.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
VimwikiGenerateLinks
Expect (The links with a header):
# Generated Links
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
Do (Save Test.md && Re-GenerateLinks):
:edit $HOME/testmarkdown/Test.md\<CR>
:set bt=\<CR>
:write %\<CR>
:VimwikiGenerateLinks\<CR>
Expect (The links with a header with file Test):
# Generated Links
- [Generated Links](Test)
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
# 2 VimwikiDiaryGenerateLinks
#############################
Execute (New Command):
Log "2. Testing VimwikiDiaryGenerateLinks TODO"
set sw=4
AssertEqual 4, &sw
Do (Edit diary/2019-12-10):
:edit $HOME/testmarkdown/diary/2019-12-10.md\<CR>
iinformative content\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2019-07-13):
:edit $HOME/testmarkdown/diary/2019-07-13.md\<CR>
i# informative title\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2018-03-01):
:edit $HOME/testmarkdown/diary/2019-03-01.md\<CR>
:call WriteMe()\<CR>
Do (Edit diary.md && GenerateDiaryLinks):
:edit $HOME/testmarkdown/diary/diary.md\<CR>
:VimwikiDiaryGenerateLinks\<CR>
Expect (diary index generated):
# Diary
## 2019
### December
- [2019-12-10](2019-12-10)
### July
- [informative title](2019-07-13)
### March
- [2019-03-01](2019-03-01)
Execute (Clean):
Log "End: Clean"
call system("rm $HOME/testmarkdown/diary/2019-12-10.md")
call system("rm $HOME/testmarkdown/diary/2019-07-13.md")
call system("rm $HOME/testmarkdown/diary/2019-03-01.md")
call system("rm $HOME/testmarkdown/diary/diary.md")
Include: vader_includes/vader_teardown.vader
" vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View File

@ -0,0 +1,96 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (Setup):
set sw=4
AssertEqual 4, &sw
Execute (Edit Test-Tag.md):
edit $HOME/testmarkdown/Test-Tag.md
AssertEqual $HOME . '/testmarkdown/Test-Tag.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Create File Content):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
I
:top-tag:\<CR>
\<CR>
# A header\<CR>
\<CR>
:test-tag:\<CR>
\<CR>
# Another header\<CR>
\<CR>
Words here.\<CR>
If tag isn't within 2 lines of header then it has a direct link instead of\<CR>
a link to the header.\<CR>
\<CR>
:second-tag:
\<Esc>
:write\<CR>
:VimwikiRebuildTags\<CR>
Execute (Edit tags file):
edit $HOME/testmarkdown/.vimwiki_tags
AssertEqual $HOME . '/testmarkdown/.vimwiki_tags', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
# Note: tags file uses tabs
Expect (Correctly formatted tags file):
!_TAG_FILE_FORMAT 2
!_TAG_FILE_SORTED 1
!_TAG_OUTPUT_MODE vimwiki-tags
!_TAG_PROGRAM_AUTHOR Vimwiki
!_TAG_PROGRAM_NAME Vimwiki Tags
!_TAG_PROGRAM_URL https://github.com/vimwiki/vimwiki
!_TAG_PROGRAM_VERSION 2.5
second-tag Test-Tag.md 13;" vimwiki:Test-Tag\tTest-Tag#second-tag
test-tag Test-Tag.md 5;" vimwiki:Test-Tag\tTest-Tag#A header
top-tag Test-Tag.md 1;" vimwiki:Test-Tag\tTest-Tag
Execute (Generate tags):
edit $HOME/testmarkdown/Test-Tag.md
VimwikiGenerateTagLinks
Expect (Correctly generated tags section):
:top-tag:
# A header
:test-tag:
# Another header
Words here.
If tag isn't within 2 lines of header then it has a direct link instead of
a link to the header.
:second-tag:
# Generated Tags
## second-tag
- [second-tag](Test-Tag#second-tag)
## test-tag
- [A header](Test-Tag#A header)
## top-tag
- [Test-Tag](Test-Tag)
Execute (Clean Test-Tag and .vimwiki_tags):
Log "End: Clean"
call system("rm $HOME/testmarkdown/Test.md")
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag.md")
call DeleteHiddenBuffers()
Include: vader_includes/vader_teardown.vader

64
test/command_goto.vader Normal file
View File

@ -0,0 +1,64 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (VimwikiGoto buzz_bozz && Assert):
VimwikiIndex 2
VimwikiGoto buzz_bozz
AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')
Do (VimwikiGoto <CR> buzz_bozz && Assert):
:VimwikiIndex 2\<CR>
:VimwikiGoto\<CR>
buzz_bozz\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Execute (:VimwikiGoto + Completion):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
let s_complete=string(vimwiki#base#get_globlinks_escaped())
Assert -1 != stridx(s_complete, 'buzz_bozz')
Execute (Create dir1/dir2/test_goto_file.md):
call system("mkdir $HOME/testmarkdown/dir1")
call system("mkdir $HOME/testmarkdown/dir1/dir2")
edit $HOME/testmarkdown/dir1/dir2/test_goto_file.md
call WriteMe()
Execute (:VimwikiGoto + Completion in directory):
" Return to base
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
" Complete without argment
let s_complete1=string(vimwiki#base#get_globlinks_escaped())
Assert -1 != stridx(s_complete1, 'test_goto_file')
" Complete with file argument
let s_complete2=string(vimwiki#base#get_globlinks_escaped('test_goto_file'))
Assert -1 != stridx(s_complete2, 'test_goto_file')
" Complete with start of file argument
let s_complete3=string(vimwiki#base#get_globlinks_escaped('test_got'))
Assert -1 != stridx(s_complete3, 'test_goto_file')
" Complete with (nested) dir2 argument
let s_complete4=string(vimwiki#base#get_globlinks_escaped('dir2'))
Assert -1 != stridx(s_complete4, 'test_goto_file')
" Complete with bad argument
let l_complete5=vimwiki#base#get_globlinks_escaped('this_string_is_nowhere')
let s_complete5=string(l_complete5)
Assert -1 == stridx(s_complete5, 'test_goto_file')
AssertEqual 0, len(l_complete5)
Execute (Clean):
Log "End: Clean"
call system("rm $HOME/testmarkdown/dir1")
Include: vader_includes/vader_teardown.vader
# vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View File

@ -0,0 +1,189 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (Mkdir dir1 dir2 dir11 dir12):
call system("mkdir $HOME/testmarkdown/dir1")
call system("mkdir $HOME/testmarkdown/dir1/dir11")
call system("mkdir $HOME/testmarkdown/dir1/dir12")
call system("mkdir $HOME/testmarkdown/dir2")
Given vimwiki (Void):
Execute (Create Test-Rename -> dir1/dir11/in_dir11.md and dir1/dir12/in_dir12.md and dir2/in_dir2.md):
edit $HOME/testmarkdown/Test-Rename.md
AssertEqual $HOME . '/testmarkdown/Test-Rename.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
call append(0, ['# Test Rename', 'in_root.md', 'dir1/dir11/in_dir11.md', 'dir1/dir12/in_dir12.md', 'dir2/in_dir2.md'])
call WriteMe()
Do (Create in_root):
:Log 'Open Test-Rename.md'\<CR>
:edit $HOME/testmarkdown/Test-Rename.md\<CR>
:AssertEqual $HOME . '/testmarkdown/Test-Rename.md', expand('%')\<CR>\<Esc>
:Log 'Delete last line (easyer latter checks without trailing spaces)'\<CR>
Gdd
:Log 'Open in_root.md'\<CR>
gg
j\<CR>
j\<CR>
j\<CR>
j\<CR>
ggj0y$
:AssertEqual '[in_root](in_root.md)', @"\<CR>
0\<CR>
:AssertEqual $HOME . '/testmarkdown/in_root.md', expand('%')\<CR>
:Log 'Add link in_root.md -> dir1/dir11/in_dir11'\<CR>
ggi# Title in root\<CR>\<Esc>
idir1/dir11/in_dir11\<Esc>
:call WriteMe()\<CR>
:AssertEqual $HOME . '/testmarkdown/in_root.md', expand('%')\<CR>
:Log 'Open in_dir11.md: creating dirs'\<CR>
ggj"ay$
:AssertEqual 'reg dir1/dir11/in_dir11', 'reg ' . @a\<CR>
0\<CR>\<CR>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
:Log 'One backspace for fun'\<CR>
\<BS>
:AssertEqual 'file ' . $HOME . '/testmarkdown/in_root.md', 'file ' . expand('%')\<CR>
Do (Create dir_11 -> dir_11):
:edit $HOME/testmarkdown/dir1/dir11/in_dir11_fix.md\<CR>
:Log 'Add link in_dir11_fix.md -> in_dir11'\<CR>
ggi# Title in dir11 fix\<CR>\<Esc>
iin_dir11\<Esc>
:call WriteMe()\<CR>
:Log 'Open in_dir11.md: creating dirs'\<CR>
ggj"ay$
:AssertEqual 'reg in_dir11', 'reg ' . @a\<CR>
0\<CR>\<CR>
y\<CR>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
:Log 'One backspace for fun'\<CR>
\<BS>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11_fix.md', 'file ' . expand('%')\<CR>
Execute (Fill in_dir11 content):
edit $HOME/testmarkdown/dir1/dir11/in_dir11.md
call append(0, ['# Title in_dir11', '[dir2 link](../../dir2/in_dir2.md)'])
call WriteMe()
Do (RenameLink in_dir11 -> new_dir11):
:edit $HOME/testmarkdown/dir1/dir11/in_dir11.md\<CR>
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<CR>
:Log 'Rename'\<CR>
:call WriteMe()\<CR>
:VimwikiRenameFile\<CR>
y\<CR>
in_dir11_new\<CR>
:call WriteMe()\<Cr>
:Log 'Append filename'\<CR>
:call append('$', [expand('%')])\<CR>
Expect(With new filename at the end):
# Title in_dir11
[dir2 link](../../dir2/in_dir2.md)
/home/vimtest/testmarkdown/dir1/dir11/in_dir11_new.md
Execute (edit in_dir11_fix):
edit $HOME/testmarkdown/dir1/dir11/in_dir11_fix.md
Expect(Link to in_dir11_new):
# Title in dir11 fix
[in_dir11](in_dir11_new)
Execute (edit Test-Rename.md):
edit $HOME/testmarkdown/Test-Rename.md
Expect (Link to in_dir11_new):
# Test Rename
[in_root](in_root.md)
[dir1 dir11 in_dir11](dir1/dir11/in_dir11_new.md)
[dir1 dir12 in_dir12](dir1/dir12/in_dir12.md)
[dir2 in_dir2](dir2/in_dir2.md)
Do (in_dir2 -> in_dir2_new):
:edit $HOME/testmarkdown/dir2/in_dir2.md\<CR>
:Log 'Append filename'\<CR>
:call append('$', [expand('%')])\<CR>
:Log 'Rename'\<CR>
:call WriteMe()\<CR>
:VimwikiRenameFile\<CR>
y\<CR>
in_dir2_new\<CR>
:call WriteMe()\<Cr>
:Log 'Append filename'\<CR>
:call append('$', [expand('%')])\<CR>
Expect (old and new filenames):
/home/vimtest/testmarkdown/dir2/in_dir2.md
/home/vimtest/testmarkdown/dir2/in_dir2_new.md
Execute (edit Test-Rename.md):
edit $HOME/testmarkdown/Test-Rename.md
Expect (Link to in_dir11_new):
# Test Rename
[in_root](in_root.md)
[dir1 dir11 in_dir11](dir1/dir11/in_dir11_new.md)
[dir1 dir12 in_dir12](dir1/dir12/in_dir12.md)
[dir2 in_dir2](dir2/in_dir2_new.md)
Execute (edit in_dir11.md):
edit $HOME/testmarkdown/dir1/dir11/in_dir11_new.md
Expect (Link to in_dir2_new):
# Title in_dir11
[dir2 link](../../dir2/in_dir2_new.md)
/home/vimtest/testmarkdown/dir1/dir11/in_dir11_new.md
Execute (Clean dir1 and dir2):
Log "End: Clean"
call DeleteHiddenBuffers()
call system('rm $HOME/testmarkdown/Test-Rename.md')
call system('rm $HOME/testmarkdown/in_root.md')
call system('rm -r $HOME/testmarkdown/dir1')
call system('rm -r $HOME/testmarkdown/dir2')
Include: vader_includes/vader_teardown.vader
# vim: sw=2 foldmethod=indent foldlevel=30 foldignore=#

149
test/command_toc.vader Normal file
View File

@ -0,0 +1,149 @@
Include: vader_includes/vader_setup.vader
Execute (Reset TOC header to default):
let g:vimwiki_global_vars['toc_header'] = "Contents"
Given vimwiki (Headings):
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
Execute (VimwikiTOC):
VimwikiTOC
Expect (With a TOC sw=8):
# Contents
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Set sw=4 && VimwikiTOC):
set sw=4
VimwikiTOC
Expect (With a TOC sw=4):
# Contents
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Do (Destroy some stuff):
jj
dd
jj
dd
Execute (VimwikiTOC):
VimwikiTOC
Expect (Brand new TOC):
# Contents
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Let toc_header = Sommaire && VimwikiTOC):
let g:vimwiki_global_vars['toc_header'] = "Sommaire"
VimwikiTOC
Expect (Append a Sommaire && Leave Contents alone):
# Sommaire
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Do (Destroy some stuff):
jj
dd
jj
dd
Execute (VimwikiTOC):
VimwikiTOC
Expect (Brand new TOC with sommaire):
# Sommaire
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Include: vader_includes/vader_teardown.vader
" vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View File

@ -0,0 +1,59 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Given (Void):
Execute (Edit TestHtml Wiki):
edit $HOME/testwiki/TestHtml.wiki
AssertEqual $HOME . '/testwiki/TestHtml.wiki', expand('%')
AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 0, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Markdwon with %plainhtml):
:edit $HOME/testwiki/TestHtml.wiki\<CR>
i%plainhtml<div id="test">\<CR>
my paragraph\<CR>
%plainhtml</div>\<CR>\<Esc>
:set bt=\<CR>
:write\<CR>
Execute (Save and Convert to html):
edit $HOME/testwiki/TestHtml.wiki
Vimwiki2HTML
Given (Void):
Do (Get Html body):
:read $HOME/html/default/TestHtml.html\<CR>
# Goto body
gg/<body>\<CR>
# Copy in b
"bdat
# Delete All
ggdG
# Paste body
"bP
# Remove last line
Gdd
# Save (Not necessary)
:write
Expect (Plain Html):
# the whole default html file should be here as a base + the modifications
# from "Given"
<body>
<div id="test">
<p>
my paragraph
</p>
</div>
</body>
Include: vader_includes/vader_teardown.vader

View File

@ -0,0 +1,461 @@
Include: vader_setup
# 0 Configure {{{1
##################
Execute (Configure: Set vimwiki list to markdown resource):
Log "Let mapleader = ,"
let mapleader = ','
Log "Declare function DestroyVar"
function! DestroyVar(var)
if ! exists(a:var) | return | endif
execute "unlet " . a:var
endfunction
Log "Declare function AssertTab"
function! AssertTab(nr)
" Vader is creating 2 tabs
AssertEqual a:nr + 2, tabpagenr()
endfunction
Log "Destroy vimrc or previous run heritage"
call DestroyVar('g:vimwiki_list')
call DestroyVar('g:vimwiki_global_vars')
call DestroyVar('g:vimwiki_wikilocal_vars')
Log "Destroy vimrc variable, works better that way"
call DestroyVar('g:vimwiki_default')
call DestroyVar('g:vimwiki_markdown')
call DestroyVar('g:vimwiki_mediawiki')
Log "Declare my vimwiki_list"
let g:vimwiki_list = [{
\ 'path': 'test/resources/testmarkdown',
\ 'syntax': 'markdown',
\ 'ext': '.md'
\ }]
Log "Declare my extension for temporary wiki"
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
Log "Reload vimwiki <- vader_setup.vader"
call ReloadVimwiki()
Execute (Assert: 2 wiki in Index):
AssertEqual 2, len(vimwiki_wikilocal_vars)
Execute (VimwikiIndex):
VimwikiIndex 1
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
AssertEqual 'vimwiki', &filetype
AssertEqual 'test/resources/testmarkdown/', vimwiki_wikilocal_vars[0]['path']
AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
Execute (Open buzz bozz):
edit test/resources/testmarkdown/buzz_bozz.md
AssertEqual 'test/resources/testmarkdown/buzz_bozz.md', expand('%')
# 1 Global {{{1
###############
Execute (===========================================================):
Log "Checking global map"
Do (,ww -> open index [Assert]):
,ww
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wt -> open index in tab [Assert]):
,wt
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,w,w -> open diary [Assert]):
,w,w
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,t -> open diary in tab [Assert]):
,w,t
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,ws -> list and select wiki [Assert]):
,ws
1
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wi -> open diary index [Assert]):
,wi
:AssertEqual 'test/resources/testmarkdown/diary/diary.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,y -> open yesterday [Assert]):
,w,y
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() - 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,m -> open tomorrow [Assert]):
,wm
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() + 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
# 2 Local {{{1
##############
Execute (===========================================================):
Log "Checking local map"
# 2.1 Heading {{{2
##############
Do (,wn -> Create new wiki [Assert]):
,wn
new_file1
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file1.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wd -> Delete wiki yes [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 2
\<Esc>
,wd
yes
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
Do (,wd -> Delete wiki no [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 1
\<Esc>
,wd
no
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file2.md', expand('%')
\<CR>
Do (,wn -> Rename wiki [Assert]):
,wn
new_file1
\<CR>
ithis is content 1
\<Esc>
,wn
new_file2
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file2.md', expand('%')
\<CR>
Given (Some headings):
# Head 1
## Head 1.1
content 1
# Head2
content 2
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
Do (= -> add header level):
=
Expect (Inc header level):
## Head 1
## Head 1.1
content 1
# Head2
content 2
Do (- -> Dec header level):
j
-
Expect (Dec header level):
# Head 1
# Head 1.1
content 1
# Head2
content 2
# TODO fix for vim_7.3.429
# Do ([[ -> Go to the previous header):
# G
# k
# [[
# A placeholder
#
# Expect (placeholder):
# # Head 1
# ## Head 1.1 placeholder
# content 1
#
# # Head2
# content 2
#
# Do (]] -> Go to the next header):
# ]]
# A placeholder
#
# Expect (placeholder):
# # Head 1
# ## Head 1.1 placeholder
# content 1
#
# # Head2
# content 2
#
# Do ([= -> Go to the previous header which has the same level):
# G
# k
# [=
# A placeholder
#
# Expect (placeholder):
# # Head 1 placeholder
# ## Head 1.1
# content 1
#
# # Head2
# content 2
#
# Do (]= -> Go to the next header which has the same level):
# ]=
# A placeholder
#
# Expect (placeholder):
# # Head 1
# ## Head 1.1
# content 1
#
# # Head2 placeholder
# content 2
#
# Do (]u Go one level up):
# j
# ]u
# A placeholder
#
# Expect (placeholder):
# # Head 1 placeholder
# ## Head 1.1
# content 1
#
# # Head2
# content 2
#
# Do ([u Go one level up):
# j
# [u
# A placeholder
#
# Expect (placeholder):
# # Head 1 placeholder
# ## Head 1.1
# content 1
#
# # Head2
# content 2
# 2.2 List {{{2
##############
Given (Number list):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
set sw=2
Do (gll):
gll
Expect (Increase):
1. I
2. Relly
1. Love
1. Very
1. Much
2. You
Do (gLl):
gLl
Expect (Increase self + child):
1. I
1. Relly
1. Love
1. Very
1. Much
2. You
Do (glh):
jjj
glh
Expect (Decrease):
1. I
1. Relly
2. Love
3. Very
1. Much
4. You
Do (gLh):
jjj
gLh
Expect (Decrease self + child):
1. I
1. Relly
2. Love
3. Very
1. Much
4. You
Do (glr):
\<C-A>\<C-A>
glr
Expect (Renumber):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
Do (gl*):
gl*
Expect (item -> *):
* I
1. Relly
1. Love
1. Very
1. Much
2. You
Do (gL*):
gL*
Expect (list -> *):
* I
1. Relly
* Love
1. Very
1. Much
* You
# 3 Text Object {{{1
####################
Execute (===========================================================):
Log "Checking text object"
# 3.1 HEading Object {{{2
####################
Given (Some headings):
# Head 1
## Head 1.1
content 1
# Head2
content 2
Do (ah):
j
dah
Expect (Change A header including its content up to the next header):
# Head 1
# Head2
content 2
Do (ih):
j
dih
Expect (The content under a header):
# Head 1
## Head 1.1
# Head2
content 2
Do (aH):
daH
Expect (A header including all of its subheaders):
# Head2
content 2
Do (iH):
diH
Expect (Like 'aH', but excluding the header itself):
# Head 1
# Head2
content 2
Include: vader_teardown
# vim: foldmethod=marker foldlevel=30 sw=2

View File

@ -0,0 +1,66 @@
Include: vader_setup
Execute (Setup search testing wrapper):
function! TestSearch(search_command, test_name)
" Note: after each search, the location list of the current window (0)
" will contain the search results. A non-empty list indicates success.
" Search for a single word (a pattern with no spaces)
redir => output
silent execute a:search_command
redir END
Assert !empty(getloclist(0)), a:test_name.": no location list result"
Assert match(output, '\d of \d') > -1, a:test_name.": no result message"
" Tests that VimwikiSearch is quoting the pattern correctly.
" If not, Vim will see anything after the first space in the pattern
" as a file name and attempt to open it.
Assert match(output, 'Cannot open file') == -1, "'open file': unquoted pattern?"
return output
endfunction
Execute (Search test wiki):
" Open test wiki
edit test/resources/testwiki/index.wiki
" Make sure we opened the test wiki successfully by checking the
" title (first line) and filetype.
AssertEqual "= Test Wiki =", getline(1)
AssertEqual "vimwiki", &filetype
call TestSearch('VimwikiSearch foo', 'pattern with no spaces')
call TestSearch('VimwikiSearch foo bar', 'pattern with spaces')
call TestSearch('VimwikiSearch foo\bar', 'pattern with ''\''')
call TestSearch('VimwikiSearch baz{13}', 'pattern with literal {}')
call TestSearch('VimwikiSearch /\vbuz{5}/', 'proper regex')
call TestSearch('VWS foo bar', 'use VWS abbreviation')
Execute (Search space path wiki):
" Open wiki with spaces in path to test fname escaping
edit test/resources/testwiki\ space/index.wiki
" Make sure we opened the space path wiki successfully
AssertEqual "= Space Path Wiki =", getline(1)
call TestSearch('VimwikiSearch foo', 'simple search in space path wiki')
Execute (Search failure message):
" Important note: No search tests will succeed after this.
" The failed search will cause a Vim error to be thrown and
" any search with lvimgrep within Vader will result in an
" empty location list and empty messages queue. It is
" difficult to tell if the search itself is failing or if it
" is just an inability to view the results.
" Open test wiki again
edit test/resources/testwiki/index.wiki
" Now test a negative search and make sure we are returning
" the expected VimWiki error.
redir => output
silent VimwikiSearch not_exist
redir END
Assert match(output, 'VimwikiSearch: No match found.') > -1, "expected custom error"
Include: vader_teardown

View File

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

View File

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

125
test/link_creation.vader Normal file
View File

@ -0,0 +1,125 @@
Include: vader_includes/vader_setup.vader
Given vimwiki (Text that is not a wikilink):
test
www.google.com
https://www.google.com
multiple words
let's
let's
file.wiki
file.md
file.mw
Execute (Set syntax to default):
call SetSyntax('default')
Do (Create links default syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Vimwiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
[[let's]]
[[let]]'s
[[file.wiki]]
[[file.md]]
[[file.mw]]
Execute (Set syntax to markdown):
call SetSyntax('markdown')
Do (Create links markdown syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Markdown links):
[test](test)
[www.google.com](www.google.com)
[https://www.google.com](https://www.google.com)
[multiple words](multiple words)
[let's](let's)
[let](let)'s
[file wiki](file.wiki)
[file](file.md)
[file mw](file.mw)
Execute (Set syntax to mediawiki):
call SetSyntax('media')
Do (Create links mediawiki syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Mediawiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
[[let's]]
[[let]]'s
[[file.wiki]]
[[file.md]]
[[file.mw]]
Include: vader_includes/vader_teardown.vader

View File

@ -0,0 +1,225 @@
Include: vader_includes/vader_setup.vader
Given vimwiki (Internal links + one link to filenew):
# Contents
- [Test1](#Test1)
- [Test2](#Test2)
# Test1
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
# Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
Execute (Set filename wiki_test.md):
file wiki_test.md
call SetSyntax('markdown')
Do (Navigate with <Tab>):
A more Contents\<Esc>
\<Tab>
\<Enter>
A more Test1\<Esc>
\<Tab>
\<Tab>
\<Enter>
A more Test2\<Esc>
Expect (Content added to titles):
# Contents more Contents
- [Test1](#Test1)
- [Test2](#Test2)
# Test1 more Test1
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
# Test2 more Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew)
Do (Navigate with <Tab> and <Enter> and come back with <Bs>):
\<Tab>
\<Enter>
# Cursor at Test1
\<Tab>
\<Tab>
\<Enter>
# Cursor at Test2
\<Tab>
\<Tab>
\<Tab>
# Cursor at Test2/filenew
A not yet\<Esc>
\<Bs>
# Cursor at Test1/test2
A near Test1/test2
\<Esc>
\<Bs>
# Cursor at Contents/test1
A near Contents/test1
\<Esc>
Expect (Vimwiki links):
# Contents
- [Test1](#Test1) near Contents/test1
- [Test2](#Test2)
# Test1
- [Test1](#Test1)
- [Test2](#Test2) near Test1/test2
- [filenew](filenew)
# Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew) not yet
Do (Navigate with <Tab> comeback with <Bs> from filenew):
\<Tab>
A first shot\<Esc>
0\<Tab>
# Cursor at Contents/test1
\<Enter>
\<Tab>
\<Tab>
A first shot\<Esc>
0\<Tab>
# Cursor at Test1/test2
\<Enter>
G
# Cursor at Test2/filenew
A first shot\<Esc>
0\<Tab>
# Cursor at Test2/filenew
\<Enter>
# Cursor in filenew (a new file)
A anything in filenew: empirically it does not count\<Esc>
\<Bs>
# Cursor at Test2/filenew
\<Bs>
# Cursor at Test1/test2
\<Bs>
# Cursor at Contents/test1
A second shot
Expect (Just Contents/test1 got the second shot):
# Contents
- [Test1](#Test1) first shot second shot
- [Test2](#Test2)
# Test1
- [Test1](#Test1)
- [Test2](#Test2) first shot
- [filenew](filenew)
# Test2
- [Test1](#Test1)
- [Test2](#Test2)
- [filenew](filenew) first shot
Execute (Delete filenew buffer):
bd! /testplugin/filenew.md
Do (Navigate with <Tab> comeback with <Bs> too far):
\<Tab>
# Cursor at Contents/test1
\<Enter>
\<Tab>
\<Tab>
# Cursor at Test1/test2
\<Enter>
\<Tab>
# Cursor at Test2/test1
\<Enter>
\<Tab>
\<Tab>
# Cursor at Test1/test2
\<Enter>
A first test2\<Esc>
\<Tab>
# Cursor at Test2/test1
\<Enter>
A first test1\<Esc>
# Back
\<Bs>
# Cursor at Test2/test1
A second test2/test1\<Esc>
\<Bs>
# Cursor at Test1/test2
A second test1/test2\<Esc>
\<Bs>
# Cursor at Test2/test1
\<Bs>
# Cursor at Test1/test2
\<Bs>
# Cursor at Contents/test1
# Finished
\<Bs>
\<Bs>
\<Bs>
\<Bs>
A 1\<Esc>
\<Bs>
A 2\<Esc>
\<Bs>
A 3\<Esc>
\<Bs>
A 4\<Esc>
Expect (After too many <Bs>, cursor stays at the first <Enter> spot in first file: Contents/test1):
# Contents
- [Test1](#Test1) 1 2 3 4
- [Test2](#Test2)
# Test1 first test1
- [Test1](#Test1)
- [Test2](#Test2) second test1/test2
- [filenew](filenew)
# Test2 first test2
- [Test1](#Test1) second test2/test1
- [Test2](#Test2)
- [filenew](filenew)
Given vimwiki (link to self):
- [Bad link](Very bad.html)
- [My own file](wiki_test)
- [Test1](#Test1)
- [Test2](#Test2)
Do (Follow link to self and append chars):
\<Tab>
\<Tab>
\<Enter>
a this_is_18_chars \<Esc>
Expect (Some chars appended at self link):
- [Bad link](Very bad.html)
- [ this_is_18_chars My own file](wiki_test)
- [Test1](#Test1)
- [Test2](#Test2)
Include: vader_includes/vader_teardown.vader

View File

@ -0,0 +1,282 @@
# Testting <CR> keypress in insert mode on list item
#
# Note: some trailing spaces are necessary at the end of list items like `1.`
# better read this file with `set list`
Include: vader_includes/vader_setup.vader
Given vimwiki (List with hard wraps):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
- Item 5
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 3 5<CR>
Execute (Set syntax markdown):
call SetSyntax('markdown')
Do (Extend list):
4j
A\<CR>Another item\<Esc>
5j
A\<CR>New sub item\<Esc>
Expect (Extended list):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Another item
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
- New sub item
- Item 5
Given vimwiki (List with code block):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
```
int x = 2 + 2;
return 0;
```
- Item 5
```c
int x = 2 + 2;
return 0;
```
- Item 6 that is split
Across multiple lines.
Done.
Do (CR and CR in code block):
4j
A\<CR>Another item\<Esc>
6j
A\<CR>int y = 1;\<Esc>
1j
A\<CR>x = x + y;\<Esc>
4j
A\<CR>int y = 2;\<Esc>
3j
A\<CR>A new bullet doesn't get added here, oh well.\<Esc>
3j
A\<CR>Done and Done\<Esc>
Expect (No list continuation in code block):
- Item 1
- Item 2
- Item 3 that is split across multiple lines
This is the second line.
This is the third line.
- Another item
- Item 4
- Sub item 1
- Sub item split across multiple lines
This is the second line.
This is the third line.
```
int y = 1;
int x = 2 + 2;
x = x + y;
return 0;
```
- Item 5
```c
int y = 2;
int x = 2 + 2;
return 0;
```
A new bullet doesn't get added here, oh well.
- Item 6 that is split
Across multiple lines.
Done.
- Done and Done
Given vimwiki (List from help file):
1. item
---
1. item
continue
---
1.
---
1.
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 1<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
# Note: trailing space <- autoindent
Expect (List per VimwikiReturn 1 1):
1. item
2.
---
1. item
continue
---
1.
2.
---
1.
2.
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 2 2<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
# Note: some trailing space added
Expect (List per VimwikiReturn 2 2):
1. item
---
1. item
continue
2.
---
1.
---
1.
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 3 3<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
Expect (List per VimwikiReturn 3 3):
1. item
2.
---
1. item
continue
2.
---
---
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 4 4<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
Expect (List per VimwikiReturn 4 4):
1. item
---
1. item
continue
---
---
---
Execute (Map CR):
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 3 5<CR>
Do (List ops):
A\<CR>\<Esc>
4j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
3j
A\<CR>\<Esc>
Expect (List per VimwikiReturn 3 5):
1. item
2.
---
1. item
continue
2.
---
---
1.
---
Include: vader_includes/vader_teardown.vader

108
test/list_margin.vader Normal file
View File

@ -0,0 +1,108 @@
Include: vader_includes/vader_setup.vader
Execute (Create temp directory):
silent execute '!mkdir -p $HOME/list_margin/'
cd $HOME/list_margin
Execute (Create wiki files):
write page1.wiki
write page2.wiki
write page3.wiki
write page1.mw
write page2.mw
write page3.mw
write page1.md
write page2.md
write page3.md
Given vimwiki (Scratch file):
Execute (Set syntax default):
set shiftwidth=8
AssertEqual 8, &shiftwidth
call SetSyntax('default')
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Execute (Generate Links):
VimwikiGenerateLinks
Expect (Links with default margin):
= Generated Links =
- [[page1]]
- [[page2]]
- [[page3]]
Execute (Set list margin == 2):
call vimwiki#vars#set_wikilocal('list_margin', 2, vimwiki#vars#get_bufferlocal('wiki_nr'))
VimwikiGenerateLinks
Expect (Links with margin == 2):
= Generated Links =
- [[page1]]
- [[page2]]
- [[page3]]
Execute (Set syntax media):
call SetSyntax('media')
call vimwiki#vars#set_wikilocal('list_margin', -1, vimwiki#vars#get_bufferlocal('wiki_nr'))
Execute (Generate Links):
VimwikiGenerateLinks
Expect (Links with default margin):
= Generated Links =
* [[page1]]
* [[page2]]
* [[page3]]
Execute (Set list margin == 1):
call vimwiki#vars#set_wikilocal('list_margin', 1, vimwiki#vars#get_bufferlocal('wiki_nr'))
VimwikiGenerateLinks
Expect (Links with margin == 1):
= Generated Links =
* [[page1]]
* [[page2]]
* [[page3]]
Execute (Set syntax markdown):
call SetSyntax('markdown')
" list margin should default to 0 for markdown
Execute (Generate Links):
VimwikiGenerateLinks
Expect (Links with default margin):
# Generated Links
- [page1](page1)
- [page2](page2)
- [page3](page3)
Execute (Set list margin == 5):
call vimwiki#vars#set_wikilocal('list_margin', 5, vimwiki#vars#get_bufferlocal('wiki_nr'))
VimwikiGenerateLinks
Expect (Links with margin == 5):
# Generated Links
- [page1](page1)
- [page2](page2)
- [page3](page3)
Execute (Return to default location & cleanup):
cd /testplugin
Include: vader_includes/vader_teardown.vader

191
test/list_update.vader Normal file
View File

@ -0,0 +1,191 @@
Include: vader_includes/vader_setup.vader
Given vimwiki (Sample nested list, vimwiki syntax):
* [ ] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Execute (Set syntax to default):
call SetSyntax('default')
Do (Toggle top-level):
\<C-Space>
Expect (All tree toggled):
* [X] Top Level
* [X] Child 1
* [X] Child 2
* [X] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [X] Post code
* [X] Sub-child
* [X] Sub-sub-child
Do (Toggle child):
j
\<C-Space>
Expect (Child toggled, top updated):
* [.] Top Level
* [X] Child 1
* [ ] Child 2
* [ ] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Do (Toggle sub-child):
G
\<C-Space>
Expect (Sub-child toggled, parents updated):
* [.] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
{{{code
* [ ] print "hello, world"
}}}
{{{morecode
print "hello again"
}}}
* [o] Post code
* [ ] Sub-child
* [X] Sub-sub-child
Given markdown (Sample nested list, markdown syntax):
* [ ] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Execute (Set syntax to markdown):
call SetSyntax('markdown')
Do (Toggle top-level):
\<C-Space>
Expect (All tree toggled):
* [X] Top Level
* [X] Child 1
* [X] Child 2
* [X] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [X] Post code
* [X] Sub-child
* [X] Sub-sub-child
Do (Toggle child):
j
\<C-Space>
Expect (Child toggled, top updated):
* [.] Top Level
* [X] Child 1
* [ ] Child 2
* [ ] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [ ] Post code
* [ ] Sub-child
* [ ] Sub-sub-child
Do (Toggle sub-child):
G
\<C-Space>
Expect (Sub-child toggled, parents updated):
* [.] Top Level
* [ ] Child 1
* [ ] Child 2
* [ ] Post space
```code
* [ ] print "hello, world"
```
```morecode
print "hello again"
```
* [o] Post code
* [ ] Sub-child
* [X] Sub-sub-child
Include: vader_includes/vader_teardown.vader

10923
test/resources/delay.wiki Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
# Buzz Bozz
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@ -0,0 +1,59 @@
# Test Wiki
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar
foo bar
biz baz
foo\bar
baz{13} <--- this is for testing a literal "baz{13}"
buzzzzz <--- this is for testing regex /buz{5}/
# Links
1. [[buzz_bozz|l_Buzz Bozz]]
2. [l_Buzz_Bozz](buzz_bozz)
3. [l_Flashy](#Typefaces#Flashy)
4. [l_Test Wiki](#Test Wiki)
# Typefaces
## Generic
~~strikeout text~~
`code (no syntax) text`
super^script^
sub,,script,,
## Markdown
**bold text** or __bold text__
*italic text* or _italic text_
***bold_italic text*** or ___italic_bold text___
## Flashy
TODO, DONE, STARTED, FIXME, FIXED, XXX.
# More
## Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
# Etiam dapibus iaculis
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
### Morbi id sodales sem
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
## Praesent tempor turpis est
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

View File

@ -0,0 +1,3 @@
= Buzz Bozz =
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@ -0,0 +1,30 @@
= Space Path Wiki =
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar foo bar biz baz.
[[buzz_bozz|Buzz Bozz]]
== Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
== Etiam dapibus iaculis ==
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
=== Morbi id sodales sem ===
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
== Praesent tempor turpis est ==
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

View File

@ -0,0 +1,3 @@
= Buzz Bozz =
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@ -0,0 +1,35 @@
= Test Wiki =
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar
foo bar
biz baz
foo\bar
baz{13} <--- this is for testing a literal "baz{13}"
buzzzzz <--- this is for testing regex /buz{5}/
[[buzz_bozz|Buzz Bozz]]
== Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
== Etiam dapibus iaculis ==
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
=== Morbi id sodales sem ===
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
== Praesent tempor turpis est ==
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

248
test/run_tests.sh Executable file
View File

@ -0,0 +1,248 @@
#!/usr/bin/env bash
# credit to https://github.com/w0rp/ale for script ideas and the color vader
# output function.
printHelp() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Runs Vimwiki Vader tests or Vint in a Docker container"
echo ""
echo "-h Print help message"
echo ""
echo "-n Specify vim/nvim version to run tests for."
echo " Multiple versions can be specified by quoting the value and"
echo " separating versions with a space. E.g. -v \"vim1 vim2\"."
echo " Default is all available versions."
echo ""
echo "-l List available versions that can be used with the '-v' option"
echo ""
echo "-t Select test type: 'vader', 'vint', or 'all'"
echo ""
echo "-o Comma seperated list of tests to run."
echo " E.g. -o \"list_margin,command_toc\""
echo ""
echo "-v Turn on verbose output."
exit 0
}
printVersions() {
# print the names of all vim/nvim versions
getVers
}
runVader() {
echo "Starting Docker container and Vader tests."
if [[ -z $only ]]; then
ind="test/independent_runs/*.vader"
res="test/*"
else
IFS=',' read -ra TEST <<< "$only"
for i in "${TEST[@]}"; do
if [[ -f "$i" ]]; then
res="$res test/${i}"
elif [[ -f "${i}.vader" ]]; then
res="$res test/${i}.vader"
elif [[ -f "independent_runs/${i}" ]]; then
ind="$ind test/independent_runs/${i}"
elif [[ -f "independent_runs/${i}.vader" ]]; then
ind="$ind test/independent_runs/${i}.vader"
else
printf "WARNING: Test \"%s\" not found.\n", "$i"
fi
done
fi
# run tests for each specified version
for v in $vers; do
echo ""
echo "Running version: $v"
vim="/vim-build/bin/$v -u test/vimrc -i NONE"
test_cmd="for VF in ${ind}; do $vim \"+Vader! \$VF\"; done"
set -o pipefail
# tests that must be run in individual vim instances
# see README.md for more information
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
/bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color
# remaining tests
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
"$v" -u test/vimrc -i NONE "+Vader! ${res}" 2>&1 | vader_filter | vader_color
set +o pipefail
done
}
runVint() {
echo "Starting Docker container and running Vint."
docker run -a stdout "${flags[@]}" vint -s .
}
getVers() {
sed -n 's/.* -name \([^ ]*\) .*/\1/p' ../Dockerfile
}
vader_filter() {
local err=0
while read -r; do
if [[ "$verbose" == 0 ]]; then
# only print possible error cases
if [[ "$REPLY" = *'docker:'* ]] || \
[[ "$REPLY" = *'Starting Vader:'* ]] || \
[[ "$REPLY" = *'Vader error:'* ]] || \
[[ "$REPLY" = *'Vim: Error '* ]]; then
echo "$REPLY"
elif [[ "$REPLY" = *'[EXECUTE] (X)'* ]] || \
[[ "$REPLY" = *'[ EXPECT] (X)'* ]]; then
echo "$REPLY"
err=1
elif [[ "$REPLY" = *'Success/Total:'* ]]; then
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
if [ "$success" -lt "$total" ]; then
err=1
fi
echo "$REPLY"
fi
else
# just print everything
echo "$REPLY"
fi
done
if [[ "$err" == 1 ]]; then
echo ""
echo "!---------Failed tests detected---------!"
echo "Run with the '-v' flag for verbose output"
echo ""
fi
}
# Say Hi
echo -en "Starting $(basename $0) for VimWiki\n"
red='\033[0;31m'
green='\033[0;32m'
nc='\033[0m'
vader_color() {
while read -r; do
if [[ "$REPLY" = *'[EXECUTE] (X)'* ]] || \
[[ "$REPLY" = *'[ EXPECT] (X)'* ]] || \
[[ "$REPLY" = *'Vim: Error '* ]] || \
[[ "$REPLY" = *'Vader error:'* ]]; then
echo -en "$red"
elif [[ "$REPLY" = *'[EXECUTE]'* ]] || [[ "$REPLY" = *'[ GIVEN]'* ]]; then
echo -en "$nc"
fi
if [[ "$REPLY" = *'Success/Total'* ]]; then
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
if [ "$success" -lt "$total" ]; then
echo -en "$red"
else
echo -en "$green"
fi
echo "$REPLY"
echo -en "$nc"
else
echo "$REPLY"
fi
done
echo -en "$nc"
}
# list of vim/nvim versions
vers="$(getVers)"
# type of tests to run - vader/vint/all
type="all"
# verbose output flag
verbose=0
# only run these tests
only=""
# docker flags
flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki)
while getopts ":hvn:lt:o:" opt; do
case ${opt} in
h )
printHelp
;;
n )
vers="$OPTARG"
;;
v )
verbose=1
;;
l )
printVersions
;;
t )
type="$OPTARG"
;;
o )
only="$OPTARG"
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
exit 1
;;
esac
done
# shift out processed parameters
shift $((OPTIND -1))
# error handling for non-option arguments
if [[ $# -ne 0 ]]; then
echo "Error: Got $# non-option arguments." 1>&2
exit 1
fi
# stop tests on ctrl-c or ctrl-z
trap exit 1 SIGINT SIGTERM
# select which tests should run
o_error=0
case $type in
"vader" )
runVader
echo "Vader: returned $?"
o_error=$(( $? | $o_error ))
;;
"vint" )
runVint
echo "Vint: returned $?"
o_error=$(( $? | $o_error ))
;;
"all" )
runVint
echo "Vint: returned $?"
o_error=$(( $? | $o_error ))
runVader
echo "Vader: returned $?"
o_error=$(( $? | $o_error ))
;;
* )
echo "Error: invalid type - '$type'" 1>&2
exit 1
esac
echo "Script $(basename $0) exiting: $o_error"
exit $o_error

318
test/syntax.vader Normal file
View File

@ -0,0 +1,318 @@
Include: vader_includes/vader_setup.vader
# 1 Typeface {{{1
#################
Given vimwiki (TODO, XXX):
TODO
DONE
STARTED
FIXME
FIXED
XXX
Execute (Assert Syntax VimwikiTodo):
AssertEqual SyntaxAt(1, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(2, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(3, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(4, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(5, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(6, 1), 'VimwikiTodo'
Given vimwiki (Typeface for markdown like italic):
**bold text 1**
__bold text 2__
*italic text 1*
_italic text 2_
***bold italic text 1***
___bold italic text 2___
~~strikeout text~~
`code (no syntax) text`
sp^script^
sb,,script,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface):
AssertEqual SyntaxAt(1, 4), 'VimwikiBold'
AssertEqual SyntaxAt(2, 4), 'VimwikiBold'
AssertEqual SyntaxAt(3, 4), 'VimwikiItalic'
AssertEqual SyntaxAt(4, 4), 'VimwikiItalic'
AssertEqual SyntaxAt(5, 4), 'VimwikiBoldItalic'
AssertEqual SyntaxAt(6, 4), 'VimwikiItalicBold'
AssertEqual SyntaxAt(7, 4), 'VimwikiDelText'
AssertEqual SyntaxAt(8, 4), 'VimwikiCode'
AssertEqual SyntaxAt(9, 4), 'VimwikiSuperScript'
AssertEqual SyntaxAt(10, 4), 'VimwikiSubScript'
# 2 Links {{{1
#################
Given vimwiki (Wiki Links):
Plain link: >
[[This is a link]]
With description: >
[[This is a link source|Description of the link]]
Interwiki1: >
[[wiki1:This is a link]]
Interwiki2: >
[[wn.My Name:This is a link]]
Interwiki3: >
[[wn.MyWiki:This is a link source|Description of the link]]
Diary: >
[[diary:2012-03-05]]
Anchor1: >
[[Todo List#Tomorrow|Tasks for tomorrow]]
Anchor2: >
[[#Tomorrow]]
Raw1: >
https://github.com/vimwiki/vimwiki.git
Raw2: >
mailto:habamax@gmail.com
Raw3: >
ftp://vim.org
File1: >
[[file:/home/somebody/a/b/c/music.mp3]]
File2: >
[[file:C:/Users/somebody/d/e/f/music.mp3]]
File3: >
[[file:~/a/b/c/music.mp3]]
File4: >
[[file:../assets/data.csv|Important Data]]
File5: >
[[local:C:/Users/somebody/d/e/f/music.mp3]]
File6: >
[[file:/home/user/documents/|Link to a directory]]
Thumbnail links: >
[[http://someaddr.com/bigpicture.jpg|{{http://someaddr.com/thumbnail.jpg}}]]
Execute (Assert Syntax link):
AssertEqual SyntaxAt(2, 6), 'VimwikiLink'
AssertEqual SyntaxAt(4, 6), 'VimwikiLink'
AssertEqual SyntaxAt(6, 6), 'VimwikiLink'
AssertEqual SyntaxAt(8, 6), 'VimwikiLink'
AssertEqual SyntaxAt(10, 6), 'VimwikiLink'
AssertEqual SyntaxAt(12, 6), 'VimwikiLink'
AssertEqual SyntaxAt(14, 6), 'VimwikiLink'
AssertEqual SyntaxAt(16, 6), 'VimwikiLink'
AssertEqual SyntaxAt(18, 6), 'VimwikiLink'
AssertEqual SyntaxAt(20, 6), 'VimwikiLink'
AssertEqual SyntaxAt(22, 6), 'VimwikiLink'
AssertEqual SyntaxAt(24, 6), 'VimwikiLink'
AssertEqual SyntaxAt(26, 6), 'VimwikiLink'
AssertEqual SyntaxAt(28, 6), 'VimwikiLink'
AssertEqual SyntaxAt(30, 6), 'VimwikiLink'
AssertEqual SyntaxAt(32, 6), 'VimwikiLink'
AssertEqual SyntaxAt(34, 6), 'VimwikiLink'
AssertEqual SyntaxAt(36, 6), 'VimwikiLink'
Given vimwiki (Markdown Links):
Inline link: >
[Looks like this](URL)
Image link: >
![Looks like this](URL)
Reference-style links: >
a) [Link Name][Id]
b) [Id][], using the "implicit link name" shortcut
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax link):
AssertEqual SyntaxAt(2, 8), 'VimwikiWeblink1'
AssertEqual SyntaxAt(5, 8), 'VimwikiImage'
AssertEqual SyntaxAt(8, 8), 'VimwikiWikiLink1'
AssertEqual SyntaxAt(9, 8), 'VimwikiWikiLink1'
# 3 Header {{{1
###############
Given vimwiki (Wiki Headers):
= Header level 1 =
== Header level 2 ==
=== Header level 3 ===
==== Header level 4 ====
===== Header level 5 =====
====== Header level 6 ======
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax Header):
AssertEqual SyntaxAt(1, 10), 'VimwikiHeader1'
AssertEqual SyntaxAt(2, 10), 'VimwikiHeader2'
AssertEqual SyntaxAt(3, 10), 'VimwikiHeader3'
AssertEqual SyntaxAt(4, 10), 'VimwikiHeader4'
AssertEqual SyntaxAt(5, 10), 'VimwikiHeader5'
AssertEqual SyntaxAt(6, 10), 'VimwikiHeader6'
Given vimwiki (Markdown Headers):
# Header level 1
## Header level 2
### Header level 3
#### Header level 4
##### Header level 5
###### Header level 6
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax Header):
AssertEqual SyntaxAt(1, 10), 'VimwikiHeader1'
AssertEqual SyntaxAt(2, 10), 'VimwikiHeader2'
AssertEqual SyntaxAt(3, 10), 'VimwikiHeader3'
AssertEqual SyntaxAt(4, 10), 'VimwikiHeader4'
AssertEqual SyntaxAt(5, 10), 'VimwikiHeader5'
AssertEqual SyntaxAt(6, 10), 'VimwikiHeader6'
# 10 Code {{{1
# 10.1 Code Indent (4 spaces) {{{2
#################################
Given vimwiki (Code indent):
this is markdown
this is code
Execute (Assert Syntax normal (i.e. no hi)):
AssertEqual SyntaxAt(1, 5), ''
AssertEqual SyntaxAt(2, 5), ''
# 10.2 Code Inline (1 backtick) {{{2
###################################
Given vimwiki (Code inline):
Well use the `man`
Execute (Assert Syntax Code):
AssertEqual SyntaxAt(1, 16), 'VimwikiCode'
# 10.3 Code Block (3 backtiks) {{{2
##################################
Given vimwiki (Markdown, Text and Vim):
this is markdown
this is TODO
```
this is text
```
```vim
" this is vim
set hlsearch
```
`````vim
" this is vim
set hlsearch
`````
~~~vim
" this is vim
set hlsearch
~~~
~~~~~vim
" this is vim
set hlsearch
~~~~~~~~~~~
Execute (Set syntax markdown):
let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
call SetSyntax('markdown')
Execute (Assert ft, normal syntax and VimwikiTodo):
AssertEqual &ft, 'vimwiki'
AssertEqual SyntaxAt(1, 1), ''
AssertEqual SyntaxAt(2, 9), 'VimwikiTodo'
Execute (Assert Code syntax):
AssertEqual SyntaxAt(4, 1), 'VimwikiPreDelim'
AssertEqual SyntaxAt(5, 1), 'VimwikiPre'
AssertEqual SyntaxAt(9, 1), 'vimLineComment'
AssertEqual SyntaxAt(10, 1), 'vimCommand'
AssertEqual SyntaxAt(13, 1), 'VimwikiPre'
AssertEqual SyntaxAt(14, 1), 'vimLineComment'
AssertEqual SyntaxAt(15, 1), 'vimCommand'
AssertEqual SyntaxAt(16, 1), 'VimwikiPre'
AssertEqual SyntaxAt(18, 1), 'VimwikiPre'
AssertEqual SyntaxAt(19, 1), 'vimLineComment'
AssertEqual SyntaxAt(20, 1), 'vimCommand'
AssertEqual SyntaxAt(21, 1), 'VimwikiPre'
AssertEqual SyntaxAt(23, 1), 'VimwikiPre'
AssertEqual SyntaxAt(24, 1), 'vimLineComment'
AssertEqual SyntaxAt(25, 1), 'vimCommand'
AssertEqual SyntaxAt(26, 1), 'VimwikiPre'
# 11 Math {{{1
# 11.1 Math Markdown {{{2
#######################
Given vimwiki (Math markdown):
math inline: $ \sum_i a_i^2 = 1 $
math block:
$$
\sum_i a_i^2
=
1
$$
math block env:
$$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
$$
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert math syntax):
AssertEqual SyntaxAt(1, 18), 'VimwikiEqIn'
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
# 11.2 Math Wiki {{{2
##############################
Given vimwiki (Math wiki):
math inline: $ \sum_i a_i^2 = 1 $
math block:
{{$
\sum_i a_i^2
=
1
}}$
math block env:
{{$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
}}$
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert math syntax):
AssertEqual SyntaxAt(1, 18), 'VimwikiEqIn'
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
Include: vader_includes/vader_teardown.vader
# vim: foldmethod=marker foldlevel=30 sw=2

157
test/table_autoformat.vader Normal file
View File

@ -0,0 +1,157 @@
Include: vader_includes/vader_setup.vader
# Autoformat {{{1
#################
Given vimwiki (Unaligned table):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
Do (A to trigger insertLeave):
A
Expect (Table autoformat):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Do (gqq to reformats table after making changes.):
gqq
Expect (Table autoformat):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_reduce_last_col = 1):
let g:vimwiki_global_vars['table_reduce_last_col'] = 1
Do (A to trigger insertLeave):
A
Expect (Last column not expanded):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_reduce_last_col = 0 [restore]):
let g:vimwiki_global_vars['table_reduce_last_col'] = 0
Execute (Option table_auto_fmt = 0):
let g:vimwiki_global_vars['table_auto_fmt'] = 0
Expect (Same as input):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_auto_fmt = 1 [restore]):
let g:vimwiki_global_vars['table_auto_fmt'] = 1
# Move and edit cells {{{1
##########################
Do (Use <Tab> in insert mode):
GI
\<Tab>
this_is_16_chars
\<Tab>
this_is_16_chars
\<Esc>
Expect (Table autoformated with more content):
| title1 | title2 |
| - | - |
| a1 | b1 |
| this_is_16_charsa2 | this_is_16_chars |
Do (VimwikiTableMoveColumnRight):
gg:VimwikiTableMoveColumnRight\<CR>
Expect (Column inverted):
| title2 | title1 |
| - | - |
| b1 | a1 |
| | a2 |
Do (CR must insert new row):
GI\<Cr>a3
Expect (Table with new row starting by a3):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
| a3 | |
# VimwikiTable Command {{{1
###########################
Given (Nothing):
Execute (VimwikiTable):
VimwikiTable
Expect (Table 5 x 2):
| | | | | |
|---|---|---|---|---|
| | | | | |
Execute (VimwikiTable 8 3):
VimwikiTable 8 3
Expect (Table 8 x 3):
| | | | | | | | |
|---|---|---|---|---|---|---|---|
| | | | | | | | |
| | | | | | | | |
# Justify Cell Content {{{1
###########################
Given vimwiki (To be justified from help file [Coffe price]):
| Date | Item | Price |
|------------|:------:|--------:|
| yest |Coffee |$15.00 |
| 2017-02-13 |Tea |$2.10 |
| 2017-03-14 |Cake |$143.12 |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
Do (A to trigger insertLeave):
A
Expect (Text justified):
| Date | Item | Price |
|------------|:------:|--------:|
| yest | Coffee | $15.00 |
| 2017-02-13 | Tea | $2.10 |
| 2017-03-14 | Cake | $143.12 |
Include: vader_includes/vader_teardown.vader
# vim: foldmethod=marker foldlevel=30

32
test/tabnext_delay.vader Normal file
View File

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

View File

@ -0,0 +1,89 @@
Before (Define functions):
" change the syntax using a temporary wiki
function! SetSyntax(vw_syn)
if a:vw_syn ==# 'default'
let ext = 'wiki'
elseif a:vw_syn ==# 'markdown'
let ext = 'md'
elseif a:vw_syn ==# 'media'
let ext = 'mw'
else
Log 'ERROR: Invalid syntax "' . a:vw_syn . '" in SetSyntax()'
Log 'NOTE: function only accepts "media" for setting mediawiki syntax'
return
endif
let path = expand('%:p:h')
let new_temp_wiki_settings = {'path': path,
\ 'ext': ext,
\ 'syntax': a:vw_syn,
\ }
" Remove any temporary wikis each time this function is called.
" This is necessary to ensure syntax is properly set when running multiple tests
" NOTE: this assumes there are 3 defined wikis in the vimrc. The last wiki
" contains default settings for temporary wikis (so there are always
" num wikis in vimrc + 1)
let num_wikis = len(g:vimwiki_wikilocal_vars)
while num_wikis > 4
call remove(g:vimwiki_wikilocal_vars, num_wikis - 1)
let num_wikis = num_wikis - 1
endwhile
" add the new wiki
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
call vimwiki#vars#set_bufferlocal('wiki_nr', 3)
" verify syntax was set correctly
Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn, 'ERROR: Vimwiki syntax not set correctly.'
endfunction
" reload plugin to change settings
function! ReloadVimwiki()
" clear mappings so plugin can be reloaded
" this is needed if running manually multiple times
nmapclear
unlet g:loaded_vimwiki
source plugin/vimwiki.vim
endfunction
" Copy wiki test resources so that vimtest user can write them
function! CopyResources()
call system('cp -r /testplugin/test/resources/* $HOME/')
" Make diary directory
call system('mkdir $HOME/testwiki/diary')
call system('mkdir $HOME/testmarkdown/diary')
endfunction
" Delete Hidden buffer, usefull to clean
" Stole from: https://stackoverflow.com/a/8459043/2544873
function! DeleteHiddenBuffers()
let tpbl=[]
call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))')
for buf in filter(range(1, bufnr('$')), 'bufexists(v:val) && index(tpbl, v:val)==-1')
if bufname(buf) =~ 'Vader'
continue
endif
silent execute 'bwipeout!' buf
endfor
endfunction
" Write current file: helper to hide `set bt=`
function! WriteMe()
set buftype=
write %
endfunction
" print a command output to the buffer
function! PrintCommand(cmd)
redir => message
silent execute a:cmd
redir END
if empty(message)
Log 'no output'
else
silent put=message
endif
endfunction
# vim: ft=vim

View File

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

67
test/vimrc Normal file
View File

@ -0,0 +1,67 @@
source /rtp.vim
set runtimepath+=/vader
" vint: -ProhibitSetNoCompatible
set nocompatible
filetype plugin indent on
syntax enable
" Wiki's resources to be used after:
" :!cp -r /testplugin/test/resources/* $HOME/
" or from a test.vader file Execute block:
" call CopyResources()
" This complication aims for these copies to be writable
" default syntax
let vimwiki_default = {}
let vimwiki_default.path = $HOME . '/testwiki'
let vimwiki_default.path_html = $HOME . '/html/default'
let vimwiki_default.syntax = 'default'
let vimwiki_default.ext = '.wiki'
let vimwiki_default.name = 'DefaultSyntax'
" markdown syntax - https://github.github.com/gfm/
let vimwiki_markdown = {}
let vimwiki_markdown.path = $HOME . '/testmarkdown'
let vimwiki_markdown.path_html = $HOME . '/html/markdown'
let vimwiki_markdown.syntax = 'markdown'
let vimwiki_markdown.ext = '.md'
let vimwiki_markdown.name = 'MarkdownSyntax'
" mediawiki syntax - https://www.mediawiki.org/wiki/Help:Formatting
let vimwiki_mediawiki = {}
let vimwiki_mediawiki.path = $HOME . '/testmediawiki'
let vimwiki_mediawiki.path_html = $HOME . '/html/mediawiki'
let vimwiki_mediawiki.syntax = 'media'
let vimwiki_mediawiki.ext = '.mw'
let vimwiki_mediawiki.name = 'MediaWikiSyntax'
" register the 3 wikis
let g:vimwiki_list = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki]
" basic settings
set backspace=indent,eol,start
set wildmode=longest:full,full
set wildmenu
set wildignorecase
set splitbelow
set splitright
set timeoutlen=600
set ignorecase
set smartcase
set hidden
set laststatus=2
set hlsearch
" use ctrl-p/n for history completion instead of up/down arrows
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
" jj to go back to command mode
inoremap jj <esc>
" Use <C-L> to clear the highlighting of :set hlsearch and also preserve the
" default behavior of redrawing the screen
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif