122 Commits

Author SHA1 Message Date
Rane Brown 99dc186df0 Possible fix for #642.
When using a custom Wiki2HTML on Windows the normalized paths caused the
closing quote to be escaped and not pass the correct arguments to the
system call. This fix removes the trailing slash for Windows while
leaving the default behavior the same.
2019-03-28 22:56:01 -06: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
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
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 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
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
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
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
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
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
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 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
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
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
17 changed files with 1565 additions and 492 deletions
+55
View File
@@ -0,0 +1,55 @@
# Filing a bug
Before filing a bug or starting to write a patch, check the latest development version from
https://github.com/vimwiki/vimwiki/tree/dev to see if your problem is already fixed.
Issues can be filed at https://github.com/vimwiki/vimwiki/issues/ .
# Creating a pull request
If you want to provide a pull request on GitHub, please start from the `dev` branch, not from the
`master` branch. (Caution, GitHub shows `master` as the default branch from which to start a PR.)
# More info and advice for (aspiring) core developers
- Before implementing a non-trivial feature, think twice what it means for the user. We should
always try to keep backward compatiblility. If you are not sure, discuss it on GitHub.
- Also, when thinking about adding a new feature, it should be something which fits into the
overall design of Vimwiki and which a significant portion of the users may like. Keep in mind
that everybody has their own way to use Vimwiki.
- Keep the coding style consistent.
- Test your changes. Keep in mind that Vim has a ton of options and the users tons of different
setups. Take a little time to think about under which circumstances your changes could break.
## Git branching model
- there are two branches with eternal lifetime:
- `dev`: This is where the main development happens. Tasks which are done in one or only a few
commits go here directly. Always try to keep this branch in a working state, that is, if the
task you work on requires multiple commits, make sure intermediate commits don't make Vimwiki
unusable (or at least push these commits at one go).
- `master`: This branch is for released states only. Whenever a reasonable set of changes has
piled up in the `dev` branch, a [release is done](#Preparing a release). After a release,
`dev` has been merged into `master` and `master` got exactly one additional commit in which
the version number in `plugin/vimwiki.vim` is updated. Apart from these commits and the merge
commit from `dev`, nothing happens on `master`. Never should `master` merge into `dev`. When
the users ask, we should recommend this branch for them to use.
- Larger changes which require multiple commits are done in feature branches. They are based on
`dev` and merge into `dev` when the work is done.
## Preparing a release
1. `git checkout dev`
2. Update the changelog in the doc, nicely grouped, with a new version number and release date.
3. Update the list of contributors.
4. Update the version number at the top of the doc file.
5. If necessary, update the Readme and the home page.
6. `git checkout master && git merge dev`
7. Update the version number at the top of plugin/vimwiki.vim.
8. Set a tag with the version number in Git: `git tag vX.Y`
9. `git push --tags`
10. In GitHub, go to _Releases_ -> _Draft a new release_ -> choose the tag, convert the changelog from the
doc to markdown and post it there. Make plans to build an automatic converter and immediately
forget this plan.
11. Tell the world.
%% vim:tw=99
+186
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.
+1 -1
View File
@@ -135,7 +135,7 @@ normal 模式:
`vimrc` 中加入以下插件设置: `vimrc` 中加入以下插件设置:
Plug 'vimwiki/vimwiki', { 'branch': 'dev' } Plug 'vimwiki/vimwiki'
然后运行 `:PlugInstall` 然后运行 `:PlugInstall`
+13
View File
@@ -107,6 +107,19 @@ Commands
* `:Vimwiki2HTML` -- Convert current wiki link to HTML * `:Vimwiki2HTML` -- Convert current wiki link to HTML
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML * `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
* `:help vimwiki-commands` -- list all commands * `:help vimwiki-commands` -- list all commands
* `:help vimwiki` -- General vimwiki help docs
Changing Wiki Syntax
------------------------------------------------------------------------------
Vimwiki currently ships with 3 syntaxes: Vimwiki (default), Markdown (markdown), and MediaWiki (media)
If you would prefer to use either Markdown or MediaWiki syntaxes, set the following option in your .vimrc:
```
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
Installation Installation
+213 -96
View File
@@ -9,6 +9,9 @@ endif
let g:loaded_vimwiki_auto = 1 let g:loaded_vimwiki_auto = 1
let g:vimwiki_max_scan_for_caption = 5
function! s:safesubstitute(text, search, replace, mode) function! s:safesubstitute(text, search, replace, mode)
" Substitute regexp but do not interpret replace " Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&') let escaped = escape(a:replace, '\&')
@@ -180,6 +183,7 @@ function! vimwiki#base#resolve_link(link_text, ...)
if link_infos.scheme =~# '\mwiki\d\+' if link_infos.scheme =~# '\mwiki\d\+'
let link_infos.index = eval(matchstr(link_infos.scheme, '\D\+\zs\d\+\ze')) let link_infos.index = eval(matchstr(link_infos.scheme, '\D\+\zs\d\+\ze'))
if link_infos.index < 0 || link_infos.index >= vimwiki#vars#number_of_wikis() if link_infos.index < 0 || link_infos.index >= vimwiki#vars#number_of_wikis()
let link_infos.index = -1
let link_infos.filename = '' let link_infos.filename = ''
return link_infos return link_infos
endif endif
@@ -196,7 +200,10 @@ function! vimwiki#base#resolve_link(link_text, ...)
\ vimwiki#vars#get_wikilocal('ext', link_infos.index) \ vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif endif
else else
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index) let ext = fnamemodify(link_text, ':e')
if ext == '' " append ext iff one not already present
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif
endif endif
elseif link_infos.scheme ==# 'diary' elseif link_infos.scheme ==# 'diary'
@@ -225,22 +232,32 @@ endfunction
function! vimwiki#base#system_open_link(url) function! vimwiki#base#system_open_link(url)
" handlers " handlers
function! s:win32_handler(url) function! s:win32_handler(url)
"http://vim.wikia.com/wiki/Opening_current_Vim_file_in_your_Windows_browser "Disable shellslash for cmd and command.com, but enable for all other shells
"disable 'shellslash', otherwise the url will be enclosed in single quotes, "See Issue #560
"which is problematic if (&shell =~? "cmd") || (&shell =~? "command.com")
"see https://github.com/vimwiki/vimwiki/issues/54#issuecomment-48011289
if exists('+shellslash') if exists('+shellslash')
let old_ssl = &shellslash let old_ssl = &shellslash
set noshellslash set noshellslash
let url = shellescape(a:url, 1) let url = shellescape(a:url, 1)
let &shellslash = old_ssl let &shellslash = old_ssl
else
let url = shellescape(a:url, 1)
endif
execute 'silent ! start "Title" /B ' . url
else else
let url = shellescape(a:url, 1)
endif if exists('+shellslash')
if &l:shell ==? "powershell" let old_ssl = &shellslash
execute 'silent ! start ' . a:url set shellslash
else let url = shellescape(a:url, 1)
execute 'silent ! start "Title" /B ' . a:url let &shellslash = old_ssl
else
let url = shellescape(a:url, 1)
endif
execute 'silent ! start ' . url
endif endif
endfunction endfunction
function! s:macunix_handler(url) function! s:macunix_handler(url)
@@ -274,7 +291,11 @@ function! vimwiki#base#open_link(cmd, link, ...)
endif endif
if link_infos.filename == '' if link_infos.filename == ''
echomsg 'Vimwiki Error: Unable to resolve link!' if link_infos.index == -1
echomsg 'Vimwiki Error: No registered wiki ''' . link_infos.scheme . '''.'
else
echomsg 'Vimwiki Error: Unable to resolve link!'
endif
return return
endif endif
@@ -333,17 +354,34 @@ function! vimwiki#base#generate_links()
let bullet = repeat(' ', vimwiki#lst#get_list_margin()) . vimwiki#lst#default_symbol().' ' let bullet = repeat(' ', vimwiki#lst#get_list_margin()) . vimwiki#lst#default_symbol().' '
for link in links for link in links
let abs_filepath = vimwiki#path#abs_path_of_link(link) let link_infos = vimwiki#base#resolve_link(link)
if !s:is_diary_file(abs_filepath) if !s:is_diary_file(link_infos.filename)
call add(lines, bullet. if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
\ s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate1'), let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
\ '__LinkUrl__', link, '')) else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
endif
let link_caption = vimwiki#base#read_caption(link_infos.filename)
if link_caption == '' " default to link if caption not found
let link_caption = link
endif
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', link, '')
let entry = s:safesubstitute(entry, '__LinkDescription__', link_caption, '')
call add(lines, bullet. entry)
endif endif
endfor endfor
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' ' let links_rx = '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Links', links_rx, line('$')+1, 1) call vimwiki#base#update_listing_in_buffer(
\ lines,
\ vimwiki#vars#get_global('links_header'),
\ links_rx,
\ line('$')+1,
\ vimwiki#vars#get_global('links_header_level'),
\ 1)
endfunction endfunction
@@ -583,7 +621,12 @@ function! s:get_links(wikifile, idx)
endif endif
let syntax = vimwiki#vars#get_wikilocal('syntax', a:idx) let syntax = vimwiki#vars#get_wikilocal('syntax', a:idx)
let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax) if syntax == 'markdown'
let rx_link = vimwiki#vars#get_syntaxlocal('rxWeblink1MatchUrl', syntax)
else
let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax)
endif
let links = [] let links = []
let lnum = 0 let lnum = 0
@@ -726,19 +769,22 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...)
" This hack is necessary because apparently Vim messes up the result of " This hack is necessary because apparently Vim messes up the result of
" getpos() directly after this command. Strange. " getpos() directly after this command. Strange.
if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p'))) if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p')))
try if &autowriteall && !&hidden " in this case, the file is saved before switching to the
if &autowriteall && !&hidden " in this case, the file is saved before switching to the " new buffer. This causes Vim to show two messages in the command line which triggers
" new buffer. This causes Vim to show two messages in the command line which triggers " the annoying hit-enter prompt. Solution: show no messages at all.
" the annoying hit-enter prompt. Solution: show no messages at all. silent execute a:command fname
silent execute a:command fname else
else try
execute a:command fname execute a:command fname
endif catch /E37:/
catch /E37:/ echomsg 'Vimwiki: Can''t leave the current buffer, because it is modified. Hint: Take a look at'
echomsg 'Vimwiki: The current file is modified. Hint: Take a look at' \ ''':h g:vimwiki_autowriteall'' to see how to save automatically.'
\ ''':h g:vimwiki_autowriteall'' to see how to save automatically.' return
return catch /E325:/
endtry echom 'Vimwiki: Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.'
return
endtry
endif
" If the opened file was not already loaded by Vim, an autocommand is " If the opened file was not already loaded by Vim, an autocommand is
" triggered at this point " triggered at this point
@@ -855,16 +901,17 @@ function! s:update_wiki_link(fname, old, new)
endfunction endfunction
function! s:update_wiki_links_dir(dir, old_fname, new_fname) function! s:update_wiki_links_dir(wiki_nr, dir, old_fname, new_fname)
let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g') let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
let new_fname = a:new_fname let new_fname = a:new_fname
let old_fname_r = vimwiki#base#apply_template( let old_fname_r = vimwiki#base#apply_template(
\ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate'), old_fname, '', '') \ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate',
\ vimwiki#vars#get_wikilocal('syntax', a:wiki_nr)), old_fname, '', '')
let files = split(glob(vimwiki#vars#get_wikilocal('path').a:dir.'*'. let files = split(glob(vimwiki#vars#get_wikilocal('path', a:wiki_nr).a:dir.'*'.
\ vimwiki#vars#get_wikilocal('ext')), '\n') \ vimwiki#vars#get_wikilocal('ext', a:wiki_nr)), '\n')
for fname in files for fname in l:files
call s:update_wiki_link(fname, old_fname_r, new_fname) call s:update_wiki_link(fname, old_fname_r, new_fname)
endfor endfor
endfunction endfunction
@@ -878,11 +925,11 @@ function! s:tail_name(fname)
endfunction endfunction
function! s:update_wiki_links(old_fname, new_fname) function! s:update_wiki_links(wiki_nr, old_fname, new_fname,old_fname_relpath)
let old_fname = a:old_fname let old_fname = a:old_fname
let new_fname = a:new_fname let new_fname = a:new_fname
let subdirs = split(a:old_fname, '[/\\]')[: -2] let subdirs = split(a:old_fname_relpath, '[/\\]')[: -2]
" TODO: Use Dictionary here... " TODO: Use Dictionary here...
let dirs_keys = [''] let dirs_keys = ['']
@@ -904,7 +951,7 @@ function! s:update_wiki_links(old_fname, new_fname)
while idx < len(dirs_keys) while idx < len(dirs_keys)
let dir = dirs_keys[idx] let dir = dirs_keys[idx]
let new_dir = dirs_vals[idx] let new_dir = dirs_vals[idx]
call s:update_wiki_links_dir(dir, new_dir.old_fname, new_dir.new_fname) call s:update_wiki_links_dir(a:wiki_nr, dir, new_dir.old_fname, new_dir.new_fname)
let idx = idx + 1 let idx = idx + 1
endwhile endwhile
endfunction endfunction
@@ -975,10 +1022,11 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort
let group='texMathZoneGroup' let group='texMathZoneGroup'
endif endif
let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : ''
execute 'syntax region textSnip'.ft. execute 'syntax region textSnip'.ft.
\ ' matchgroup='.a:textSnipHl. \ ' matchgroup='.a:textSnipHl.
\ ' start="'.a:start.'" end="'.a:end.'"'. \ ' start="'.a:start.'" end="'.a:end.'"'.
\ ' contains=@'.group.' keepend' \ ' contains=@'.group.' keepend'.concealpre
" A workaround to Issue 115: Nested Perl syntax highlighting differs from " A workaround to Issue 115: Nested Perl syntax highlighting differs from
" regular one. " regular one.
@@ -996,15 +1044,15 @@ endfunction
" creates or updates auto-generated listings in a wiki file, like TOC, diary " creates or updates auto-generated listings in a wiki file, like TOC, diary
" links, tags list etc. " links, tags list etc.
" - the listing consists of a level 1 header and a list of strings as content " - the listing consists of a header and a list of strings as content
" - a:content_regex is used to determine how long a potentially existing list is " - a:content_regex is used to determine how long a potentially existing list is
" - a:default_lnum is the line number where the new listing should be placed if " - a:default_lnum is the line number where the new listing should be placed if
" it's not already present " it's not already present
" - if a:create is true, it will be created if it doesn't exist, otherwise it " - if a:create is true, it will be created if it doesn't exist, otherwise it
" will only be updated if it already exists " will only be updated if it already exists
function! vimwiki#base#update_listing_in_buffer(strings, start_header, function! vimwiki#base#update_listing_in_buffer(strings, start_header,
\ content_regex, default_lnum, create) \ content_regex, default_lnum, header_level, create)
" apparently, Vim behaves strange when files change while in diff mode " Vim behaves strangely when files change while in diff mode
if &diff || &readonly if &diff || &readonly
return return
endif endif
@@ -1012,7 +1060,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
" check if the listing is already there " check if the listing is already there
let already_there = 0 let already_there = 0
let header_rx = '\m^\s*'.substitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'), let header_level = 'rxH' . a:header_level . '_Template'
let header_rx = '\m^\s*'.substitute(vimwiki#vars#get_syntaxlocal(header_level),
\ '__Header__', a:start_header, '') .'\s*$' \ '__Header__', a:start_header, '') .'\s*$'
let start_lnum = 1 let start_lnum = 1
@@ -1050,32 +1099,48 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
" fold gets deleted. So we temporarily disable folds, and then reenable " fold gets deleted. So we temporarily disable folds, and then reenable
" them right back. " them right back.
let foldenable_save = &l:foldenable let foldenable_save = &l:foldenable
setlo nofoldenable setlocal nofoldenable
silent exe start_lnum.','.string(end_lnum - 1).'delete _' silent exe 'keepjumps ' . start_lnum.','.string(end_lnum - 1).'delete _'
let &l:foldenable = foldenable_save let &l:foldenable = foldenable_save
let lines_diff = 0 - (end_lnum - start_lnum) let lines_diff = 0 - (end_lnum - start_lnum)
else else
let start_lnum = a:default_lnum let start_lnum = a:default_lnum
let is_cursor_after_listing = ( cursor_line > a:default_lnum ) let is_cursor_after_listing = ( cursor_line > a:default_lnum )
let whitespaces_in_first_line = '' let whitespaces_in_first_line = ''
" append newline if not replacing first line
if start_lnum > 1
keepjumps call append(start_lnum -1, '')
let start_lnum += 1
endif
endif endif
let start_of_listing = start_lnum let start_of_listing = start_lnum
" write new listing " write new listing
let new_header = whitespaces_in_first_line let new_header = whitespaces_in_first_line
\ . s:safesubstitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'), \ . s:safesubstitute(vimwiki#vars#get_syntaxlocal(header_level),
\ '__Header__', a:start_header, '') \ '__Header__', a:start_header, '')
call append(start_lnum - 1, new_header) keepjumps call append(start_lnum - 1, new_header)
let start_lnum += 1 let start_lnum += 1
let lines_diff += 1 + len(a:strings) let lines_diff += 1
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
keepjumps call append(start_lnum - 1, '')
let start_lnum += 1
let lines_diff += 1
endfor
endif
for string in a:strings for string in a:strings
call append(start_lnum - 1, string) keepjumps call append(start_lnum - 1, string)
let start_lnum += 1 let start_lnum += 1
let lines_diff += 1
endfor endfor
" append an empty line if there is not one
if start_lnum <= line('$') && getline(start_lnum) !~# '\m^\s*$' " remove empty line if end of file, otherwise append if needed
call append(start_lnum - 1, '') if start_lnum == line('$')
silent exe 'keepjumps ' . start_lnum.'delete _'
elseif start_lnum < line('$') && getline(start_lnum) !~# '\m^\s*$'
keepjumps call append(start_lnum - 1, '')
let lines_diff += 1 let lines_diff += 1
endif endif
@@ -1107,8 +1172,10 @@ function! vimwiki#base#find_prev_link()
endfunction endfunction
" This is an API function, that is, remappable by the user. Don't change the signature. function! vimwiki#base#follow_link(split, ...)
function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) let reuse_other_split_window = a:0 >= 1 ? a:1 : 0
let move_cursor_to_new_window = a:0 >= 2 ? a:2 : 1
" Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the " Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
" default open_link handler " default open_link handler
@@ -1144,7 +1211,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
" if we want to and can reuse a split window, jump to that window and open " if we want to and can reuse a split window, jump to that window and open
" the new file there " the new file there
if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && a:reuse if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && reuse_other_split_window
let previous_window_nr = winnr('#') let previous_window_nr = winnr('#')
if previous_window_nr > 0 && previous_window_nr != winnr() if previous_window_nr > 0 && previous_window_nr != winnr()
execute previous_window_nr . 'wincmd w' execute previous_window_nr . 'wincmd w'
@@ -1168,7 +1235,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
call vimwiki#base#open_link(cmd, lnk) call vimwiki#base#open_link(cmd, lnk)
if !a:move_cursor if !move_cursor_to_new_window
if (a:split ==# 'hsplit' || a:split ==# 'vsplit') if (a:split ==# 'hsplit' || a:split ==# 'vsplit')
execute 'wincmd p' execute 'wincmd p'
elseif a:split ==# 'tab' elseif a:split ==# 'tab'
@@ -1177,9 +1244,9 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
endif endif
else else
if a:0 > 0 if a:0 >= 3
execute "normal! ".a:1 execute "normal! ".a:3
else elseif vimwiki#vars#get_global('create_link')
call vimwiki#base#normalize_link(0) call vimwiki#base#normalize_link(0)
endif endif
endif endif
@@ -1277,12 +1344,10 @@ function! vimwiki#base#rename_link()
let new_link = input('Enter new name: ') let new_link = input('Enter new name: ')
if new_link =~# '[/\\]' if new_link =~# '[/\\]'
" It is actually doable but I do not have free time to do it.
echomsg 'Vimwiki Error: Cannot rename to a filename with path!' echomsg 'Vimwiki Error: Cannot rename to a filename with path!'
return return
endif endif
" check new_fname - it should be 'good', not empty
if substitute(new_link, '\s', '', 'g') == '' if substitute(new_link, '\s', '', 'g') == ''
echomsg 'Vimwiki Error: Cannot rename to an empty filename!' echomsg 'Vimwiki Error: Cannot rename to an empty filename!'
return return
@@ -1294,6 +1359,7 @@ function! vimwiki#base#rename_link()
endif endif
let new_link = subdir.new_link let new_link = subdir.new_link
let wiki_nr = vimwiki#vars#get_bufferlocal("wiki_nr")
let new_fname = vimwiki#vars#get_wikilocal('path') . new_link . vimwiki#vars#get_wikilocal('ext') let new_fname = vimwiki#vars#get_wikilocal('path') . new_link . vimwiki#vars#get_wikilocal('ext')
" do not rename if file with such name exists " do not rename if file with such name exists
@@ -1337,7 +1403,7 @@ function! vimwiki#base#rename_link()
setlocal nomore setlocal nomore
" update links " update links
call s:update_wiki_links(s:tail_name(old_fname), new_link) call s:update_wiki_links(wiki_nr, s:tail_name(old_fname), s:tail_name(new_link),old_fname)
" restore wiki buffers " restore wiki buffers
for bitem in blist for bitem in blist
@@ -1598,7 +1664,10 @@ function! vimwiki#base#TO_table_col(inner, visual)
endfunction endfunction
function! vimwiki#base#AddHeaderLevel() function! vimwiki#base#AddHeaderLevel(...)
if a:1 > 1
call vimwiki#base#AddHeaderLevel(a:1 - 1)
endif
let lnum = line('.') let lnum = line('.')
let line = getline(lnum) let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH') let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
@@ -1626,7 +1695,10 @@ function! vimwiki#base#AddHeaderLevel()
endfunction endfunction
function! vimwiki#base#RemoveHeaderLevel() function! vimwiki#base#RemoveHeaderLevel(...)
if a:1 > 1
call vimwiki#base#RemoveHeaderLevel(a:1 - 1)
endif
let lnum = line('.') let lnum = line('.')
let line = getline(lnum) let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH') let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
@@ -1790,13 +1862,31 @@ endfunction
" a:create == 0: update if TOC exists " a:create == 0: update if TOC exists
function! vimwiki#base#table_of_contents(create) function! vimwiki#base#table_of_contents(create)
let headers = s:collect_headers() let headers = s:collect_headers()
let toc_header_text = vimwiki#vars#get_global('toc_header')
if !a:create
" Do nothing if there is no TOC to update. (This is a small performance optimization -- if
" auto_toc == 1, but the current buffer has no TOC but is long, saving the buffer could
" otherwise take a few seconds for nothing.)
let toc_already_present = 0
for entry in headers
if entry[2] ==# toc_header_text
let toc_already_present = 1
break
endif
endfor
if !toc_already_present
return
endif
endif
let numbering = vimwiki#vars#get_global('html_header_numbering') let numbering = vimwiki#vars#get_global('html_header_numbering')
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]] let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
let complete_header_infos = [] let complete_header_infos = []
for header in headers for header in headers
let h_text = header[2] let h_text = header[2]
let h_level = header[1] let h_level = header[1]
if h_text ==# vimwiki#vars#get_global('toc_header') " don't include the TOC's header itself if h_text ==# toc_header_text " don't include the TOC's header itself
continue continue
endif endif
let headers_levels[h_level-1] = [h_text, headers_levels[h_level-1][1]+1] let headers_levels[h_level-1] = [h_text, headers_levels[h_level-1][1]+1]
@@ -1824,22 +1914,26 @@ function! vimwiki#base#table_of_contents(create)
let indentstring = repeat(' ', vimwiki#u#sw()) let indentstring = repeat(' ', vimwiki#u#sw())
let bullet = vimwiki#lst#default_symbol().' ' let bullet = vimwiki#lst#default_symbol().' '
for [lvl, link, desc] in complete_header_infos for [lvl, link, desc] in complete_header_infos
let esc_link = substitute(link, "'", "''", 'g')
let esc_desc = substitute(desc, "'", "''", 'g')
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
if vimwiki#vars#get_wikilocal('syntax') == 'markdown' if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template') let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink2Template')
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
endif endif
let link = s:safesubstitute(link_tpl, '__LinkUrl__', let link = s:safesubstitute(link_tpl, '__LinkUrl__',
\ '#'.esc_link, '') \ '#'.link, '')
let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '') let link = s:safesubstitute(link, '__LinkDescription__', desc, '')
call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link) call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
endfor endfor
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' ' let links_rx = '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
call vimwiki#base#update_listing_in_buffer(lines, call vimwiki#base#update_listing_in_buffer(
\ vimwiki#vars#get_global('toc_header'), links_rx, 1, a:create) \ lines,
\ toc_header_text,
\ links_rx,
\ 1,
\ vimwiki#vars#get_global('toc_header_level'),
\ a:create)
endfunction endfunction
@@ -1864,17 +1958,21 @@ endfunction
function! s:clean_url(url) function! s:clean_url(url)
let url = split(a:url, '/\|=\|-\|&\|?\|\.') " remove protocol and tld
let url = substitute(a:url, '^\a\+\d*:', '', '')
let url = substitute(url, '^//', '', '')
let url = substitute(url, '^\([^/]\+\)\.\a\{2,4}/', '\1/', '')
let url = split(url, '/\|=\|-\|&\|?\|\.')
let url = filter(url, 'v:val !=# ""') let url = filter(url, 'v:val !=# ""')
let url = filter(url, 'v:val !=# "www"') if url[0] == "www"
let url = filter(url, 'v:val !=# "com"') let url = url[1:]
let url = filter(url, 'v:val !=# "org"') endif
let url = filter(url, 'v:val !=# "net"') if url[-1] =~ '^\(htm\|html\|php\)$'
let url = filter(url, 'v:val !=# "edu"') let url = url[0:-2]
let url = filter(url, 'v:val !=# "http\:"') endif
let url = filter(url, 'v:val !=# "https\:"') " remove words consisting of only hexadecimal digits or non-word characters
let url = filter(url, 'v:val !=# "file\:"') let url = filter(url, 'v:val !~ "^\\A\\{4,}$"')
let url = filter(url, 'v:val !=# "xml\:"') let url = filter(url, 'v:val !~ "^\\x\\{4,}$" || v:val !~ "\\d"')
return join(url, " ") return join(url, " ")
endfunction endfunction
@@ -1916,17 +2014,22 @@ function! s:normalize_link_in_diary(lnk)
let link_exists_in_wiki = filereadable(link_wiki) let link_exists_in_wiki = filereadable(link_wiki)
let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d' let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d'
if ! link_exists_in_wiki || link_exists_in_diary || link_is_date if link_exists_in_diary || link_is_date
let str = a:lnk let str = a:lnk
let rxUrl = vimwiki#vars#get_global('rxWord') let rxUrl = vimwiki#vars#get_global('rxWord')
let rxDesc = '' let rxDesc = ''
let template = vimwiki#vars#get_global('WikiLinkTemplate1') let template = vimwiki#vars#get_global('WikiLinkTemplate1')
else elseif link_exists_in_wiki
let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/')) let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/'))
let str = repeat('../', depth) . a:lnk . '|' . a:lnk let str = repeat('../', depth) . a:lnk . '|' . a:lnk
let rxUrl = '^.*\ze|' let rxUrl = '^.*\ze|'
let rxDesc = '|\zs.*$' let rxDesc = '|\zs.*$'
let template = vimwiki#vars#get_global('WikiLinkTemplate2') let template = vimwiki#vars#get_global('WikiLinkTemplate2')
else
let str = a:lnk
let rxUrl = '.*'
let rxDesc = ''
let template = vimwiki#vars#get_global('WikiLinkTemplate1')
endif endif
return vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) return vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
@@ -1970,9 +2073,8 @@ function! s:normalize_link_syntax_n()
if s:is_diary_file(expand("%:p")) if s:is_diary_file(expand("%:p"))
let sub = s:normalize_link_in_diary(lnk) let sub = s:normalize_link_in_diary(lnk)
else else
let sub = vimwiki#base#normalize_link_helper(lnk, let sub = s:safesubstitute(
\ vimwiki#vars#get_global('rxWord'), '', \ vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', lnk, '')
\ vimwiki#vars#get_global('WikiLinkTemplate1'))
endif endif
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub) call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
return return
@@ -2043,6 +2145,21 @@ function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort
endfunction endfunction
function! vimwiki#base#read_caption(file)
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
if filereadable(a:file)
for line in readfile(a:file, '', g:vimwiki_max_scan_for_caption)
if line =~# rx_header
return vimwiki#u#trim(matchstr(line, rx_header))
endif
endfor
endif
return ''
endfunction
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------
" Load syntax-specific Wiki functionality " Load syntax-specific Wiki functionality
for s:syn in s:vimwiki_get_known_syntaxes() for s:syn in s:vimwiki_get_known_syntaxes()
+126 -27
View File
@@ -10,9 +10,6 @@ endif
let g:loaded_vimwiki_diary_auto = 1 let g:loaded_vimwiki_diary_auto = 1
let s:vimwiki_max_scan_for_caption = 5
function! s:prefix_zero(num) function! s:prefix_zero(num)
if a:num < 10 if a:num < 10
return '0'.a:num return '0'.a:num
@@ -63,26 +60,98 @@ function! s:get_month_name(month)
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)] return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
endfunction endfunction
function! s:get_first_header(fl)
" Get the first header in the file within the first s:vimwiki_max_scan_for_caption lines.
let header_rx = vimwiki#vars#get_syntaxlocal('rxHeader')
for line in readfile(a:fl, '', g:vimwiki_max_scan_for_caption)
if line =~# header_rx
return vimwiki#u#trim(matchstr(line, header_rx))
endif
endfor
return ''
endfunction
function! s:get_all_headers(fl, maxlevel)
" Get a list of all headers in a file up to a given level.
" Returns a list whose elements are pairs [level, title]
let headers_rx = {}
for i in range(1, a:maxlevel)
let headers_rx[i] = vimwiki#vars#get_syntaxlocal('rxH'.i.'_Text')
endfor
let headers = []
for line in readfile(a:fl, '')
for [i, header_rx] in items(headers_rx)
if line =~# header_rx
call add(headers, [i, vimwiki#u#trim(matchstr(line, header_rx))])
break
endif
endfor
endfor
return headers
endfunction
function! s:count_headers_level_less_equal(headers, maxlevel)
" Count headers with level <= maxlevel in a list of [level, title] pairs.
let l:count = 0
for [header_level, _] in a:headers
if header_level <= a:maxlevel
let l:count += 1
endif
endfor
return l:count
endfunction
function! s:get_min_header_level(headers)
" The minimum level of any header in a list of [level, title] pairs.
if len(a:headers) == 0
return 0
endif
let minlevel = a:headers[0][0]
for [level, _] in a:headers
let minlevel = min([minlevel, level])
endfor
return minlevel
endfunction
function! s:read_captions(files) function! s:read_captions(files)
let result = {} let result = {}
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader') let caption_level = vimwiki#vars#get_wikilocal('diary_caption_level')
for fl in a:files for fl in a:files
" remove paths and extensions " remove paths and extensions
let fl_key = substitute(fnamemodify(fl, ':t'), vimwiki#vars#get_wikilocal('ext').'$', '', '') let fl_captions = {}
if filereadable(fl) " Default; no captions from the file.
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption) let fl_captions['top'] = ''
if line =~# rx_header && !has_key(result, fl_key) let fl_captions['rest'] = []
let result[fl_key] = vimwiki#u#trim(matchstr(line, rx_header))
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 endif
endfor endif
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 endfor
return result return result
endfunction endfunction
@@ -138,9 +207,13 @@ function! s:format_diary()
let links_with_captions = s:read_captions(s:get_diary_files()) let links_with_captions = s:read_captions(s:get_diary_files())
let g_files = s:group_links(links_with_captions) let g_files = s:group_links(links_with_captions)
let g_keys = s:sort(keys(g_files))
for year in g_keys
if len(result) > 0
call add(result, '')
endif
for year in s:sort(keys(g_files))
call add(result, '')
call add(result, call add(result,
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , '')) \ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , ''))
@@ -149,22 +222,43 @@ function! s:format_diary()
call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'), call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'),
\ '__Header__', s:get_month_name(month), '')) \ '__Header__', s:get_month_name(month), ''))
for [fl, cap] in s:sort(items(g_files[year][month])) if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
call add(result, '')
endfor
endif
for [fl, captions] in s:sort(items(g_files[year][month]))
let topcap = captions['top']
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2') let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
if vimwiki#vars#get_wikilocal('syntax') == 'markdown' if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template') let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
if empty(cap) " When using markdown syntax, we should ensure we always have a link description. if empty(topcap) " When using markdown syntax, we should ensure we always have a link description.
let cap = fl let topcap = fl
endif endif
elseif empty(cap)
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
endif endif
let entry = substitute(link_tpl, '__LinkUrl__', fl, '') if empty(topcap)
let entry = substitute(entry, '__LinkDescription__', cap, '') let top_link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) else
let top_link_tpl = link_tpl
endif
let bullet = vimwiki#lst#default_symbol().' '
let entry = substitute(top_link_tpl, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', topcap, '')
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).bullet.entry)
for [depth, subcap] in captions['rest']
if empty(subcap)
continue
endif
let entry = substitute(link_tpl, '__LinkUrl__', fl.'#'.subcap, '')
let entry = substitute(entry, '__LinkDescription__', subcap, '')
call add(result, repeat(' ', vimwiki#lst#get_list_margin() * (2 + depth)).'- '.entry)
endfor
endfor endfor
endfor endfor
@@ -231,6 +325,11 @@ function! vimwiki#diary#goto_diary_index(wnum)
endif endif
call vimwiki#base#edit_file('e', s:diary_index(idx), '') call vimwiki#base#edit_file('e', s:diary_index(idx), '')
if vimwiki#vars#get_wikilocal('auto_diary_index')
call vimwiki#diary#generate_diary_section()
write! " save changes
endif
endfunction endfunction
@@ -280,9 +379,10 @@ function! vimwiki#diary#generate_diary_section()
let current_file = vimwiki#path#path_norm(expand("%:p")) let current_file = vimwiki#path#path_norm(expand("%:p"))
let diary_file = vimwiki#path#path_norm(s:diary_index()) let diary_file = vimwiki#path#path_norm(s:diary_index())
if vimwiki#path#is_equal(current_file, diary_file) if vimwiki#path#is_equal(current_file, diary_file)
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)' let content_rx = '^\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)\|'.
\ '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
call vimwiki#base#update_listing_in_buffer(s:format_diary(), call vimwiki#base#update_listing_in_buffer(s:format_diary(),
\ vimwiki#vars#get_wikilocal('diary_header'), content_rx, line('$')+1, 1) \ vimwiki#vars#get_wikilocal('diary_header'), content_rx, 1, 1, 1)
else else
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!' echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
endif endif
@@ -319,4 +419,3 @@ function vimwiki#diary#calendar_sign(day, month, year)
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext') \ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile)) return filereadable(expand(sfile))
endfunction endfunction
+56 -22
View File
@@ -204,13 +204,6 @@ function! s:subst_func(line, regexp, func, ...)
endfunction endfunction
function! s:save_vimwiki_buffer()
if &filetype ==? 'vimwiki' && filewritable(expand('%'))
silent update
endif
endfunction
function! s:process_date(placeholders, default_date) function! s:process_date(placeholders, default_date)
if !empty(a:placeholders) if !empty(a:placeholders)
for [placeholder, row, idx] in a:placeholders for [placeholder, row, idx] in a:placeholders
@@ -351,7 +344,27 @@ endfunction
function! s:tag_code(value) function! s:tag_code(value)
return '<code>'.s:safe_html_preformatted(s:mid(a:value, 1)).'</code>' let l:retstr = '<code'
let l:str = s:mid(a:value, 1)
let l:match = match(l:str, '^#[a-fA-F0-9]\{6\}$')
if l:match != -1
let l:r = eval("0x".l:str[1:2])
let l:g = eval("0x".l:str[3:4])
let l:b = eval("0x".l:str[5:6])
let l:fg_color =
\ (((0.299 * r + 0.587 * g + 0.114 * b) / 0xFF) > 0.5)
\ ? "black" : "white"
let l:retstr .=
\ " style='background-color:" . l:str .
\ ";color:" . l:fg_color . ";'"
endif
let l:retstr .= '>'.s:safe_html_preformatted(l:str).'</code>'
return l:retstr
endfunction endfunction
@@ -373,7 +386,7 @@ endfunction
function! s:linkify_link(src, descr) function! s:linkify_link(src, descr)
let src_str = ' href="'.s:escape_html_attribute(a:src).'"' let src_str = ' href="'.s:escape_html_attribute(a:src).'"'
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','') let descr = vimwiki#u#trim(a:descr)
let descr = (descr == "" ? a:src : descr) let descr = (descr == "" ? a:src : descr)
let descr_str = (descr =~# vimwiki#vars#get_global('rxWikiIncl') let descr_str = (descr =~# vimwiki#vars#get_global('rxWikiIncl')
\ ? s:tag_wikiincl(descr) \ ? s:tag_wikiincl(descr)
@@ -445,7 +458,8 @@ function! s:tag_wikilink(value)
let str = a:value let str = a:value
let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl')) let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
let descr = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr')) let descr = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'))
let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url) let descr = vimwiki#u#trim(descr)
let descr = (descr != '' ? descr : url)
let line = VimwikiLinkConverter(url, s:current_wiki_file, s:current_html_file) let line = VimwikiLinkConverter(url, s:current_wiki_file, s:current_html_file)
if line == '' if line == ''
@@ -843,7 +857,7 @@ function! s:process_tag_math(line, math)
" environment properly " environment properly
let s:current_math_env = matchstr(class, '^%\zs\S\+\ze%') let s:current_math_env = matchstr(class, '^%\zs\S\+\ze%')
if s:current_math_env != "" if s:current_math_env != ""
call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', '')) call add(lines, substitute(class, '^%\(\S\+\)%', '\\begin{\1}', ''))
elseif class != "" elseif class != ""
call add(lines, "\\\[".class) call add(lines, "\\\[".class)
else else
@@ -1078,11 +1092,13 @@ function! s:process_tag_h(line, id)
let h_text = num.' '.h_text let h_text = num.' '.h_text
endif endif
let h_complete_id = s:escape_html_attribute(h_complete_id) let h_complete_id = s:escape_html_attribute(h_complete_id)
let h_part = '<div id="'.h_complete_id.'"><h'.h_level.' id="'.h_id.'"' let h_part = '<div id="'.h_complete_id.'">'
let h_part .= '<h'.h_level.' id="'.h_id.'" class="header">'
let h_part .= '<a href="#'.h_complete_id.'"'
else else
let h_part = '<div id="'.h_id.'" class="toc"><h1 id="'.h_id.'"' let h_part = '<div id="'.h_id.'" class="toc"><h'.h_level.' id="'.h_id.'"'
endif endif
@@ -1094,7 +1110,7 @@ function! s:process_tag_h(line, id)
let h_text = s:process_inline_tags(h_text, a:id) let h_text = s:process_inline_tags(h_text, a:id)
let line = h_part.h_text.'</h'.h_level.'></div>' let line = h_part.h_text.'</a></h'.h_level.'></div>'
let processed = 1 let processed = 1
endif endif
@@ -1402,24 +1418,38 @@ function! s:use_custom_wiki2html()
\ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html)) \ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html))
endfunction endfunction
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) function! vimwiki#html#CustomWiki2HTML(path, wikifile, force)
call vimwiki#path#mkdir(a:path) call vimwiki#path#mkdir(a:path)
" fix for trailing / causing " to be escaped on windows, see #642
if has('win16') || has('win95') || has('win32') || has('win64')
let l:path = substitute(a:path, '\\$', '', '')
let l:css = substitute(shellescape(s:default_CSS_full_name(a:path)), '\\$', '', '')
" template path ends in / even on windows hence the different substitute
let l:tmpl = shellescape(expand(substitute(vimwiki#vars#get_wikilocal('template_path'), '/$', '', '')))
let l:rpath = substitute(shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))), '\\$', '', '')
else
let l:path = a:path
let l:css = shellescape(s:default_CSS_full_name(a:path))
let l:tmpl = shellescape(expand(vimwiki#vars#get_wikilocal('template_path')))
let l:rpath = shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir')))
endif
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '. echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '.
\ a:force. ' '. \ a:force. ' '.
\ vimwiki#vars#get_wikilocal('syntax'). ' '. \ vimwiki#vars#get_wikilocal('syntax'). ' '.
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '. \ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '.
\ shellescape(a:path). ' '. \ shellescape(l:path). ' '.
\ shellescape(a:wikifile). ' '. \ shellescape(a:wikifile). ' '.
\ shellescape(s:default_CSS_full_name(a:path)). ' '. \ l:css . ' '.
\ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ? \ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ?
\ shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '. \ l:tmpl : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ? \ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_default') : '-'). ' '. \ vimwiki#vars#get_wikilocal('template_default') : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ? \ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '. \ vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '.
\ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ? \ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ?
\ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '. \ l:rpath : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ? \ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ?
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-')) \ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-'))
endfunction endfunction
@@ -1533,6 +1563,7 @@ function! s:convert_file(path_html, wikifile)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let date = s:process_date(placeholders, strftime('%Y-%m-%d')) let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
let wiki_path = strpart(s:current_wiki_file, strlen(vimwiki#vars#get_wikilocal('path')))
let html_lines = s:get_html_template(template_name) let html_lines = s:get_html_template(template_name)
@@ -1541,6 +1572,7 @@ function! s:convert_file(path_html, wikifile)
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")') call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'. call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")') \ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
call map(html_lines, 'substitute(v:val, "%wiki_path%", "'. wiki_path .'", "g")')
let css_name = expand(vimwiki#vars#get_wikilocal('css_name')) let css_name = expand(vimwiki#vars#get_wikilocal('css_name'))
let css_name = substitute(css_name, '\', '/', 'g') let css_name = substitute(css_name, '\', '/', 'g')
@@ -1586,9 +1618,11 @@ function! vimwiki#html#WikiAll2HTML(path_html)
echomsg 'Vimwiki: Saving Vimwiki files ...' echomsg 'Vimwiki: Saving Vimwiki files ...'
let save_eventignore = &eventignore let save_eventignore = &eventignore
let &eventignore = "all" let &eventignore = "all"
let cur_buf = bufname('%') try
bufdo call s:save_vimwiki_buffer() wall
exe 'buffer '.cur_buf catch
" just ignore errors
endtry
let &eventignore = save_eventignore let &eventignore = save_eventignore
let path_html = expand(a:path_html) let path_html = expand(a:path_html)
+72 -52
View File
@@ -299,6 +299,13 @@ function! s:regexp_of_marker(item)
endfunction endfunction
" Returns: Whether or not the checkbox of a list item is [X] or [-]
function! s:is_closed(item)
let state = a:item.cb
return state ==# vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
\ || state ==# vimwiki#vars#get_global('listsym_rejected')
endfunction
" --------------------------------------------------------- " ---------------------------------------------------------
" functions for navigating between items " functions for navigating between items
" --------------------------------------------------------- " ---------------------------------------------------------
@@ -756,10 +763,47 @@ function! s:set_state(item, new_rate)
endfunction endfunction
"Set state of the list item to [ ] or [o] or whatever " Sets the state of the list item to [ ] or [o] or whatever. Updates the states of its child items.
"Updates the states of its child items " If the new state should be [X] or [-], the state of the current list item is changed to this
function! s:set_state_plus_children(item, new_rate) " state, but if a child item already has [X] or [-] it is left alone.
call s:set_state(a:item, a:new_rate) function! s:set_state_plus_children(item, new_rate, ...)
let retain_state_if_closed = a:0 > 0 && a:1 > 0
if !(retain_state_if_closed && (a:new_rate == 100 || a:new_rate == -1) && s:is_closed(a:item))
call s:set_state(a:item, a:new_rate)
endif
let all_children_are_done = 1
let all_children_are_rejected = 1
let child_item = s:get_first_child(a:item)
while 1
if child_item.type == 0
break
endif
if child_item.cb != vimwiki#vars#get_global('listsym_rejected')
let all_children_are_rejected = 0
endif
if child_item.cb != vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
let all_children_are_done = 0
endif
if !all_children_are_done && !all_children_are_rejected
break
endif
let child_item = s:get_next_child_item(a:item, child_item)
endwhile
if (a:new_rate == 100 && all_children_are_done) ||
\ (a:new_rate == -1) && all_children_are_rejected
return
endif
if (a:new_rate == -1 && all_children_are_done) ||
\ (a:new_rate == 100 && all_children_are_rejected)
let retain_closed_children = 0
else
let retain_closed_children = 1
endif
let child_item = s:get_first_child(a:item) let child_item = s:get_first_child(a:item)
while 1 while 1
@@ -767,7 +811,7 @@ function! s:set_state_plus_children(item, new_rate)
break break
endif endif
if child_item.cb != '' if child_item.cb != ''
call s:set_state_plus_children(child_item, a:new_rate) call s:set_state_plus_children(child_item, a:new_rate, retain_closed_children)
endif endif
let child_item = s:get_next_child_item(a:item, child_item) let child_item = s:get_next_child_item(a:item, child_item)
endwhile endwhile
@@ -802,6 +846,7 @@ function! s:update_state(item)
let sum_children_rate = 0 let sum_children_rate = 0
let count_children_with_cb = 0 let count_children_with_cb = 0
let count_rejected_children = 0
let child_item = s:get_first_child(a:item) let child_item = s:get_first_child(a:item)
@@ -811,16 +856,24 @@ function! s:update_state(item)
endif endif
if child_item.cb != '' if child_item.cb != ''
let rate = s:get_rate(child_item) let rate = s:get_rate(child_item)
if rate != -1 if rate == -1
let count_children_with_cb += 1 " for calculating the parent rate, a [-] item counts as much as a [X] item ...
let sum_children_rate += rate let rate = 100
" ... with the exception that a parent with *only* [-] items will be [-] too
let count_rejected_children += 1
endif endif
let count_children_with_cb += 1
let sum_children_rate += rate
endif endif
let child_item = s:get_next_child_item(a:item, child_item) let child_item = s:get_next_child_item(a:item, child_item)
endwhile endwhile
if count_children_with_cb > 0 if count_children_with_cb > 0
let new_rate = sum_children_rate / count_children_with_cb if count_rejected_children == count_children_with_cb
let new_rate = -1
else
let new_rate = sum_children_rate / count_children_with_cb
endif
call s:set_state_recursively(a:item, new_rate) call s:set_state_recursively(a:item, new_rate)
else else
let rate = s:get_rate(a:item) let rate = s:get_rate(a:item)
@@ -841,13 +894,13 @@ endfunction
"Creates checkbox in a list item. "Creates checkbox in a list item.
"Returns: 1 if successful "Returns: 1 if successful
function! s:create_cb(item) function! s:create_cb(item, start_rate)
if a:item.type == 0 || a:item.cb != '' if a:item.type == 0 || a:item.cb != ''
return 0 return 0
endif endif
let new_item = a:item let new_item = a:item
let new_item.cb = vimwiki#vars#get_syntaxlocal('listsyms_list')[0] let new_item.cb = s:rate_to_state(a:start_rate)
call s:substitute_rx_in_line(new_item.lnum, call s:substitute_rx_in_line(new_item.lnum,
\ vimwiki#u#escape(new_item.mrkr) . '\zs\ze', ' [' . new_item.cb . ']') \ vimwiki#u#escape(new_item.mrkr) . '\zs\ze', ' [' . new_item.cb . ']')
@@ -866,8 +919,7 @@ function! s:remove_cb(item)
endfunction endfunction
"Change state of checkbox " Change state of the checkboxes in the lines of the given range
"in the lines of the given range
function! s:change_cb(from_line, to_line, new_rate) function! s:change_cb(from_line, to_line, new_rate)
let from_item = s:get_corresponding_item(a:from_line) let from_item = s:get_corresponding_item(a:from_line)
if from_item.type == 0 if from_item.type == 0
@@ -894,9 +946,9 @@ function! s:change_cb(from_line, to_line, new_rate)
endfunction endfunction
"Toggles checkbox between two states in the lines of the given range, " Toggles checkbox between two states in the lines of the given range, creates checkboxes (with
"creates chceckboxes if there aren't any. " a:start_rate as state) if there aren't any.
function! s:toggle_create_cb(from_line, to_line, state1, state2) function! s:toggle_create_cb(from_line, to_line, state1, state2, start_rate)
let from_item = s:get_corresponding_item(a:from_line) let from_item = s:get_corresponding_item(a:from_line)
if from_item.type == 0 if from_item.type == 0
return return
@@ -908,7 +960,7 @@ function! s:toggle_create_cb(from_line, to_line, state1, state2)
let parent_items_of_lines = [] let parent_items_of_lines = []
for cur_ln in range(from_item.lnum, a:to_line) for cur_ln in range(from_item.lnum, a:to_line)
let cur_item = s:get_item(cur_ln) let cur_item = s:get_item(cur_ln)
let success = s:create_cb(cur_item) let success = s:create_cb(cur_item, a:start_rate)
if success if success
let cur_parent_item = s:get_parent(cur_item) let cur_parent_item = s:get_parent(cur_item)
@@ -974,46 +1026,14 @@ endfunction
"Toggles checkbox between [ ] and [X] or creates one "Toggles checkbox between [ ] and [X] or creates one
"in the lines of the given range "in the lines of the given range
function! vimwiki#lst#toggle_cb(from_line, to_line) function! vimwiki#lst#toggle_cb(from_line, to_line)
return s:toggle_create_cb(a:from_line, a:to_line, 100, 0) return s:toggle_create_cb(a:from_line, a:to_line, 100, 0, 0)
endfunction endfunction
"Toggles checkbox between [ ] and [-] or creates one "Toggles checkbox between [ ] and [-] or creates one
"in the lines of the given range "in the lines of the given range
function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) function! vimwiki#lst#toggle_rejected_cb(from_line, to_line)
return s:toggle_create_cb(a:from_line, a:to_line, -1, 0) return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1)
endfunction
"Increment checkbox between [ ] and [X]
"in the lines of the given range
function! vimwiki#lst#increment_cb(from_line, to_line)
let from_item = s:get_corresponding_item(a:from_line)
if from_item.type == 0
return
endif
"if from_line has CB, increment it and set all siblings to the same new state
let rate_first_line = s:get_rate(from_item)
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let new_rate = min([rate_first_line + 100/(n-1)+1, 100])
call s:change_cb(a:from_line, a:to_line, new_rate)
endfunction
"Toggles checkbox between [ ] and [X] or creates one
"in the lines of the given range
function! vimwiki#lst#toggle_cb(from_line, to_line)
return s:toggle_create_cb(a:from_line, a:to_line, 100, 0)
endfunction
"Toggles checkbox between [ ] and [-] or creates one
"in the lines of the given range
function! vimwiki#lst#toggle_rejected_cb(from_line, to_line)
return s:toggle_create_cb(a:from_line, a:to_line, -1, 0)
endfunction endfunction
@@ -1395,7 +1415,7 @@ function! s:clone_marker_from_to(from, to)
let new_indent = ( vimwiki#vars#get_syntaxlocal('recurring_bullets') ? 0 : indent(a:from) ) let new_indent = ( vimwiki#vars#get_syntaxlocal('recurring_bullets') ? 0 : indent(a:from) )
call s:set_indent(a:to, new_indent) call s:set_indent(a:to, new_indent)
if item_from.cb != '' if item_from.cb != ''
call s:create_cb(s:get_item(a:to)) call s:create_cb(s:get_item(a:to), 0)
call s:update_state(s:get_parent(s:get_item(a:to))) call s:update_state(s:get_parent(s:get_item(a:to)))
endif endif
if item_from.type == 2 if item_from.type == 2
+1
View File
@@ -25,6 +25,7 @@ del {text-decoration: line-through; color: #777777;}
.justcenter {text-align: center;} .justcenter {text-align: center;}
.center {margin-left: auto; margin-right: auto;} .center {margin-left: auto; margin-right: auto;}
.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;} .tag {background-color: #eeeeee; font-family: monospace; padding: 2px;}
.header a {text-decoration: none; color: inherit;}
/* classes for items of todo lists */ /* classes for items of todo lists */
.rejected { .rejected {
+40 -10
View File
@@ -296,6 +296,7 @@ function! vimwiki#tags#generate_tags(...) abort
let need_all_tags = (a:0 == 0) let need_all_tags = (a:0 == 0)
let specific_tags = a:000 let specific_tags = a:000
let header_level = vimwiki#vars#get_global('tags_header_level')
let metadata = s:load_tags_metadata() let metadata = s:load_tags_metadata()
" make a dictionary { tag_name: [tag_links, ...] } " make a dictionary { tag_name: [tag_links, ...] }
@@ -310,26 +311,55 @@ function! vimwiki#tags#generate_tags(...) abort
endfor endfor
endfor endfor
let tag_match = printf('rxH%d', header_level + 1)
let tag_tpl = printf('rxH%d_Template', header_level + 1)
let lines = [] let lines = []
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' ' let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' '
for tagname in sort(keys(tags_entries)) for tagname in sort(keys(tags_entries))
if need_all_tags || index(specific_tags, tagname) != -1 if need_all_tags || index(specific_tags, tagname) != -1
call extend(lines, [ if len(lines) > 0
\ '', call add(lines, '')
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''), endif
\ '' ])
call add(lines,
\ substitute(vimwiki#vars#get_syntaxlocal(tag_tpl), '__Header__', tagname, ''))
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
call add(lines, '')
endfor
endif
for taglink in sort(tags_entries[tagname]) for taglink in sort(tags_entries[tagname])
call add(lines, bullet . substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
\ '__LinkUrl__', taglink, '')) let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink3Template')
let link_infos = vimwiki#base#resolve_link(taglink)
let link_caption = vimwiki#base#read_caption(link_infos.filename)
let link_text = split(taglink, '#', 1)[0]
let entry = substitute(link_tpl, '__LinkUrl__', link_text, '')
let entry = substitute(entry, '__LinkAnchor__', link_infos.anchor, '')
let entry = substitute(entry, '__LinkDescription__', link_caption, '')
call add(lines, bullet.entry)
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
call add(lines, bullet . substitute(link_tpl, '__LinkUrl__', taglink, ''))
endif
endfor endfor
endif endif
endfor endfor
let links_rx = '\m\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH2').'\)\|\%(^\s*' let links_rx = '^\%('.vimwiki#vars#get_syntaxlocal(tag_match).'\)\|'.
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' ' \ '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
\ .vimwiki#vars#get_syntaxlocal('rxWikiLink').'$\)'
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx, line('$')+1, 1) call vimwiki#base#update_listing_in_buffer(
\ lines,
\ vimwiki#vars#get_global('tags_header'),
\ links_rx,
\ line('$')+1,
\ header_level,
\ 1)
endfunction endfunction
+206 -85
View File
@@ -63,7 +63,7 @@ endfunction
function! s:is_separator(line) function! s:is_separator(line)
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$' return a:line =~# '^\s*'.s:rxSep().'\(:\=--\+:\='.s:rxSep().'\)\+\s*$'
endfunction endfunction
@@ -72,6 +72,11 @@ function! s:is_separator_tail(line)
endfunction endfunction
function! s:is_last_column(lnum, cnum)
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction
function! s:is_last_column(lnum, cnum) function! s:is_last_column(lnum, cnum)
let line = strpart(getline(a:lnum), a:cnum - 1) let line = strpart(getline(a:lnum), a:cnum - 1)
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$' return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
@@ -135,56 +140,62 @@ function! s:create_row_sep(cols)
endfunction endfunction
function! vimwiki#tbl#get_cells(line) function! vimwiki#tbl#get_cells(line, ...)
let result = [] let result = []
let cell = ''
let quote = ''
let state = 'NONE' let state = 'NONE'
let cell_start = 0
let quote_start = 0
let len = strlen(a:line) - 1
" 'Simple' FSM " 'Simple' FSM
for idx in range(strlen(a:line)) while state != 'CELL'
" The only way I know Vim can do Unicode... if quote_start != 0 && state != 'CELL'
let ch = a:line[idx] let state = 'CELL'
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 = ''
endif 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 return result
endfunction endfunction
@@ -194,7 +205,7 @@ function! s:col_count(lnum)
endfunction endfunction
function! s:get_indent(lnum) function! s:get_indent(lnum, depth)
if !s:is_table(getline(a:lnum)) if !s:is_table(getline(a:lnum))
return return
endif endif
@@ -209,50 +220,94 @@ function! s:get_indent(lnum)
break break
endif endif
let lnum -= 1 let lnum -= 1
if a:depth > 0 && lnum < a:lnum - a:depth
break
endif
endwhile endwhile
return indent return indent
endfunction endfunction
function! s:get_rows(lnum) function! s:get_rows(lnum, ...)
if !s:is_table(getline(a:lnum)) if !s:is_table(getline(a:lnum))
return return
endif endif
let upper_rows = [] let rows = []
let lower_rows = []
let lnum = a:lnum - 1 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) let line = getline(lnum)
if s:is_table(line) if s:is_table(line)
call add(upper_rows, [lnum, line]) call insert(rows, [lnum, line])
else else
break break
endif endif
let lnum -= 1 let lnum -= 1
let ldepth += 1
endwhile endwhile
call reverse(upper_rows)
let lnum = a:lnum let lnum = a:lnum
while lnum <= line('$') while lnum <= line('$')
let line = getline(lnum) let line = getline(lnum)
if s:is_table(line) if s:is_table(line)
call add(lower_rows, [lnum, line]) if lnum == a:lnum
let cells = vimwiki#tbl#get_cells(line)
let clen = len(cells)
let max_lens = repeat([0], clen)
let aligns = repeat(['left'], clen)
let line = s:fmt_row(cells, max_lens, aligns, 0, 0)
endif
call add(rows, [lnum, line])
else else
break break
endif endif
if depth > 0
break
endif
let lnum += 1 let lnum += 1
endwhile endwhile
return upper_rows + lower_rows return rows
endfunction
function! s:get_cell_aligns(lnum)
let aligns = {}
for [lnum, row] in s:get_rows(a:lnum)
let found_separator = s:is_separator(row)
if found_separator
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let cell = cells[idx]
if cell =~# '^--\+:'
let aligns[idx] = 'right'
elseif cell =~# '^:--\+:'
let aligns[idx] = 'center'
else
let aligns[idx] = 'left'
endif
endfor
return aligns
endif
endfor
if !found_separator
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let aligns[idx] = 'left'
endfor
endif
return aligns
endfunction endfunction
function! s:get_cell_max_lens(lnum, ...) function! s:get_cell_max_lens(lnum, ...)
let max_lens = {} 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) if s:is_separator(row)
continue continue
endif endif
@@ -270,20 +325,54 @@ function! s:get_cell_max_lens(lnum, ...)
endfunction endfunction
function! s:get_aligned_rows(lnum, col1, col2) function! s:get_aligned_rows(lnum, col1, col2, depth)
let rows = s:get_rows(a:lnum) let rows = []
let startlnum = rows[0][0] let startlnum = 0
let cells = [] let cells = []
for [lnum, row] in rows let max_lens = {}
call add(cells, vimwiki#tbl#get_cells(row)) let check_all = 1
endfor if a:depth > 0
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum) let rows = s:get_rows(a:lnum, a:depth)
let startlnum = rows[0][0]
let lrows = len(rows)
if lrows == a:depth + 1
let i = 1
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, i != lrows - 1))
let i += 1
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
" user option not to expand last call
if vimwiki#vars#get_global('table_reduce_last_col')
let last_index = keys(max_lens)[-1]
let max_lens[last_index] = 1
endif
let fst_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows[0:0])
let check_all = max_lens != fst_lens
endif
endif
if check_all
" all the table must be re-formatted
let rows = s:get_rows(a:lnum)
let startlnum = rows[0][0]
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row))
endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
" user option not to expand last call
if vimwiki#vars#get_global('table_reduce_last_col')
let last_index = keys(max_lens)[-1]
let max_lens[last_index] = 1
endif
endif
let aligns = s:get_cell_aligns(a:lnum)
let result = [] let result = []
for [lnum, row] in rows for [lnum, row] in rows
if s:is_separator(row) 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 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 endif
call add(result, [lnum, new_row]) call add(result, [lnum, new_row])
endfor endfor
@@ -312,20 +401,25 @@ function! s:cur_column()
endfunction endfunction
function! s:fmt_cell(cell, max_len) function! s:fmt_cell(cell, max_len, align)
let cell = ' '.a:cell.' ' let cell = ' '.a:cell.' '
let diff = a:max_len - s:wide_len(a:cell) let diff = a:max_len - s:wide_len(a:cell)
if diff == 0 && empty(a:cell) if diff == 0 && empty(a:cell)
let diff = 1 let diff = 1
endif endif
if a:align == 'left'
let cell .= repeat(' ', diff) 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 return cell
endfunction endfunction
function! s:fmt_row(cells, max_lens, col1, col2) function! s:fmt_row(cells, max_lens, aligns, col1, col2)
let new_line = s:rxSep() let new_line = s:rxSep()
for idx in range(len(a:cells)) for idx in range(len(a:cells))
if idx == a:col1 if idx == a:col1
@@ -334,28 +428,36 @@ function! s:fmt_row(cells, max_lens, col1, col2)
let idx = a:col1 let idx = a:col1
endif endif
let value = a:cells[idx] 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 endfor
let idx = len(a:cells) let idx = len(a:cells)
while idx < len(a:max_lens) 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 let idx += 1
endwhile endwhile
return new_line return new_line
endfunction endfunction
function! s:fmt_cell_sep(max_len) function! s:fmt_cell_sep(max_len, align)
let cell = ''
if a:max_len == 0 if a:max_len == 0
return repeat('-', 3) let cell .= '-'
else else
return repeat('-', a:max_len+2) let cell .= repeat('-', a:max_len)
endif
if a:align == 'right'
return cell.'-:'
elseif a:align == 'left'
return cell.'--'
else
return ':'.cell.':'
endif endif
endfunction endfunction
function! s:fmt_sep(max_lens, col1, col2) function! s:fmt_sep(max_lens, aligns, col1, col2)
let new_line = s:rxSep() let new_line = s:rxSep()
for idx in range(len(a:max_lens)) for idx in range(len(a:max_lens))
if idx == a:col1 if idx == a:col1
@@ -363,7 +465,7 @@ function! s:fmt_sep(max_lens, col1, col2)
elseif idx == a:col2 elseif idx == a:col2
let idx = a:col1 let idx = a:col1
endif 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 endfor
return new_line return new_line
endfunction endfunction
@@ -371,7 +473,7 @@ endfunction
function! s:kbd_create_new_row(cols, goto_first) function! s:kbd_create_new_row(cols, goto_first)
let cmd = "\<ESC>o".s:create_empty_row(a:cols) let cmd = "\<ESC>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" let cmd .= "\<ESC>0"
if a:goto_first if a:goto_first
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>"
@@ -407,8 +509,15 @@ endfunction
function! vimwiki#tbl#goto_next_col() function! vimwiki#tbl#goto_next_col()
let curcol = virtcol('.') let curcol = virtcol('.')
let lnum = line('.') let lnum = line('.')
let newcol = s:get_indent(lnum) let depth = 2
let max_lens = s:get_cell_max_lens(lnum) 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) for cell_len in values(max_lens)
if newcol >= curcol-1 if newcol >= curcol-1
break break
@@ -435,8 +544,15 @@ endfunction
function! vimwiki#tbl#goto_prev_col() function! vimwiki#tbl#goto_prev_col()
let curcol = virtcol('.') let curcol = virtcol('.')
let lnum = line('.') let lnum = line('.')
let newcol = s:get_indent(lnum) let depth = 2
let max_lens = s:get_cell_max_lens(lnum) 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 let prev_cell_len = 0
for cell_len in values(max_lens) for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space> let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
@@ -526,6 +642,8 @@ function! vimwiki#tbl#format(lnum, ...)
return return
endif endif
let depth = a:0 == 1 ? a:1 : 0
if a:0 == 2 if a:0 == 2
let col1 = a:1 let col1 = a:1
let col2 = a:2 let col2 = a:2
@@ -534,16 +652,19 @@ function! vimwiki#tbl#format(lnum, ...)
let col2 = 0 let col2 = 0
endif endif
let indent = s:get_indent(a:lnum) let indent = s:get_indent(a:lnum, depth)
if &expandtab if &expandtab
let indentstring = repeat(' ', indent) let indentstring = repeat(' ', indent)
else else
let indentstring = repeat(' ', indent / &tabstop) . repeat(' ', indent % &tabstop) let indentstring = repeat(' ', indent / &tabstop) . repeat(' ', indent % &tabstop)
endif 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 let row = indentstring.row
call setline(lnum, row) if getline(lnum) != row
call setline(lnum, row)
endif
endfor endfor
let &tw = s:textwidth let &tw = s:textwidth
@@ -586,9 +707,9 @@ function! vimwiki#tbl#create(...)
endfunction endfunction
function! vimwiki#tbl#align_or_cmd(cmd) function! vimwiki#tbl#align_or_cmd(cmd, ...)
if s:is_table(getline('.')) if s:is_table(getline('.'))
call vimwiki#tbl#format(line('.')) call call('vimwiki#tbl#format', [line('.')] + a:000)
else else
exe 'normal! '.a:cmd exe 'normal! '.a:cmd
endif endif
+245 -80
View File
@@ -13,7 +13,7 @@
" global user variables and syntax stuff which is the same for every syntax. " 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 " - wiki-local variables. They are stored in g:vimwiki_wikilocal_vars which is a list of
" dictionaries. One dict for every registered wiki. The last dictionary contains default values " dictionaries, one dict for every registered wiki. The last dictionary contains default values
" (used for temporary wikis). " (used for temporary wikis).
" "
" - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and " - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and
@@ -28,50 +28,10 @@
function! s:populate_global_variables() function! s:populate_global_variables()
let g:vimwiki_global_vars = { let g:vimwiki_global_vars = {}
\ 'CJK_length': 0,
\ 'auto_chdir': 0,
\ 'autowriteall': 1,
\ 'conceallevel': 2,
\ 'diary_months':
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ },
\ 'dir_link': '',
\ 'ext2syntax': {},
\ 'folding': '',
\ 'global_ext': 1,
\ 'hl_cb_checked': 0,
\ 'hl_headers': 0,
\ 'html_header_numbering': 0,
\ 'html_header_numbering_sym': '',
\ 'list_ignore_newline': 1,
\ 'text_ignore_newline': 1,
\ 'listsyms': ' .oOX',
\ 'listsym_rejected': '-',
\ 'map_prefix': '<Leader>w',
\ 'menu': 'Vimwiki',
\ 'table_auto_fmt': 1,
\ 'table_mappings': 1,
\ 'toc_header': 'Contents',
\ 'url_maxsave': 15,
\ 'use_calendar': 1,
\ 'use_mouse': 0,
\ 'user_htmls': '',
\ 'valid_html_tags': 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em',
\ 'w32_dir_enc': '',
\ }
" copy the user's settings from variables of the form g:vimwiki_<option> into the dict call s:read_global_settings_from_user()
" g:vimwiki_global_vars (or set a default value) call s:normalize_global_settings()
for key in keys(g:vimwiki_global_vars)
if exists('g:vimwiki_'.key)
let g:vimwiki_global_vars[key] = g:vimwiki_{key}
endif
endfor
" non-configurable global variables: " non-configurable global variables:
@@ -179,30 +139,142 @@ function! s:populate_global_variables()
endfunction endfunction
function! s:read_global_settings_from_user()
let global_settings = {
\ 'CJK_length': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_chdir': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'autowriteall': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'conceallevel': {'type': type(0), 'default': 2, 'min': 0, 'max': 3},
\ 'conceal_pre': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'create_link': {'type': type(0), 'default': 1, 'min':0, 'max': 1},
\ 'diary_months': {'type': type({}), 'default':
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ }},
\ 'dir_link': {'type': type(''), 'default': ''},
\ 'ext2syntax': {'type': type({}), 'default': {}},
\ 'folding': {'type': type(''), 'default': '', 'possible_values': ['', 'expr', 'syntax',
\ 'list', 'custom', ':quick', 'expr:quick', 'syntax:quick', 'list:quick',
\ 'custom:quick']},
\ 'global_ext': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'hl_cb_checked': {'type': type(0), 'default': 0, 'min': 0, 'max': 2},
\ 'hl_headers': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'html_header_numbering': {'type': type(0), 'default': 0, 'min': 0, 'max': 6},
\ 'html_header_numbering_sym': {'type': type(''), 'default': ''},
\ 'list_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'text_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'links_header': {'type': type(''), 'default': 'Generated Links', 'min_length': 1},
\ 'links_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 6},
\ 'listsyms': {'type': type(''), 'default': ' .oOX', 'min_length': 2},
\ 'listsym_rejected': {'type': type(''), 'default': '-', 'length': 1},
\ 'map_prefix': {'type': type(''), 'default': '<Leader>w'},
\ 'markdown_header_style': {'type': type(0), 'default': 1, 'min':0, 'max': 2},
\ 'markdown_link_ext': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'menu': {'type': type(''), 'default': 'Vimwiki'},
\ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'table_reduce_last_col': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'table_mappings': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'tags_header': {'type': type(''), 'default': 'Generated Tags', 'min_length': 1},
\ 'tags_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 5},
\ 'toc_header': {'type': type(''), 'default': 'Contents', 'min_length': 1},
\ 'toc_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 6},
\ 'url_maxsave': {'type': type(0), 'default': 15, 'min': 0},
\ 'use_calendar': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'use_mouse': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'user_htmls': {'type': type(''), 'default': ''},
\ 'valid_html_tags': {'type': type(''), 'default':
\ 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em'},
\ 'w32_dir_enc': {'type': type(''), 'default': ''},
\ }
" copy the user's settings from variables of the form g:vimwiki_<option> into the dict
" g:vimwiki_global_vars (or set a default value)
for key in keys(global_settings)
if exists('g:vimwiki_'.key)
let users_value = g:vimwiki_{key}
let value_infos = global_settings[key]
call s:check_users_value(key, users_value, value_infos, 1)
let g:vimwiki_global_vars[key] = users_value
else
let g:vimwiki_global_vars[key] = global_settings[key].default
endif
endfor
" validate some settings individually
let key = 'diary_months'
let users_value = g:vimwiki_global_vars[key]
for month in range(1, 12)
if !has_key(users_value, month) || type(users_value[month]) != type('') ||
\ empty(users_value[month])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
let key = 'ext2syntax'
let users_value = g:vimwiki_global_vars[key]
for ext in keys(users_value)
if empty(ext) || index(['markdown', 'media', 'mediawiki', 'default'], users_value[ext]) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
endfunction
function! s:normalize_global_settings()
let keys = keys(g:vimwiki_global_vars.ext2syntax)
for ext in keys
" ensure the file extensions in ext2syntax start with a dot
if ext[0] != '.'
let new_ext = '.' . ext
let g:vimwiki_global_vars.ext2syntax[new_ext] = g:vimwiki_global_vars.ext2syntax[ext]
call remove(g:vimwiki_global_vars.ext2syntax, ext)
endif
" for convenience, we also allow the term 'mediawiki'
if g:vimwiki_global_vars.ext2syntax[ext] ==# 'mediawiki'
let g:vimwiki_global_vars.ext2syntax[ext] = 'media'
endif
endfor
endfunction
function! s:populate_wikilocal_options() function! s:populate_wikilocal_options()
let default_values = { let default_values = {
\ 'auto_export': 0, \ 'auto_diary_index': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_tags': 0, \ 'auto_export': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_toc': 0, \ 'auto_tags': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'automatic_nested_syntaxes': 1, \ 'auto_toc': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'css_name': 'style.css', \ 'automatic_nested_syntaxes': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'custom_wiki2html': '', \ 'css_name': {'type': type(''), 'default': 'style.css', 'min_length': 1},
\ 'custom_wiki2html_args': '', \ 'custom_wiki2html': {'type': type(''), 'default': ''},
\ 'diary_header': 'Diary', \ 'custom_wiki2html_args': {'type': type(''), 'default': ''},
\ 'diary_index': 'diary', \ 'diary_header': {'type': type(''), 'default': 'Diary', 'min_length': 1},
\ 'diary_rel_path': 'diary/', \ 'diary_index': {'type': type(''), 'default': 'diary', 'min_length': 1},
\ 'diary_sort': 'desc', \ 'diary_rel_path': {'type': type(''), 'default': 'diary/', 'min_length': 1},
\ 'ext': '.wiki', \ 'diary_caption_level': {'type': type(0), 'default': 0, 'min': -1, 'max': 6},
\ 'index': 'index', \ 'diary_sort': {'type': type(''), 'default': 'desc', 'possible_values': ['asc', 'desc']},
\ 'list_margin': -1, \ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1},
\ 'maxhi': 0, \ 'index': {'type': type(''), 'default': 'index', 'min_length': 1},
\ 'nested_syntaxes': {}, \ 'list_margin': {'type': type(0), 'default': -1, 'min': -1},
\ 'path': '~/vimwiki/', \ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'path_html': '', \ 'nested_syntaxes': {'type': type({}), 'default': {}},
\ 'syntax': 'default', \ 'path': {'type': type(''), 'default': $HOME . '/vimwiki/', 'min_length': 1},
\ 'template_default': 'default', \ 'path_html': {'type': type(''), 'default': ''},
\ 'template_ext': '.tpl', \ 'syntax': {'type': type(''), 'default': 'default',
\ 'template_path': '~/vimwiki/templates/', \ 'possible_values': ['default', 'markdown', 'media', 'mediawiki']},
\ 'template_default': {'type': type(''), 'default': 'default', 'min_length': 1},
\ 'template_ext': {'type': type(''), 'default': '.tpl'},
\ 'template_path': {'type': type(''), 'default': $HOME . '/vimwiki/templates/'},
\ } \ }
let g:vimwiki_wikilocal_vars = [] let g:vimwiki_wikilocal_vars = []
@@ -210,9 +282,10 @@ function! s:populate_wikilocal_options()
let default_wiki_settings = {} let default_wiki_settings = {}
for key in keys(default_values) for key in keys(default_values)
if exists('g:vimwiki_'.key) 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} let default_wiki_settings[key] = g:vimwiki_{key}
else else
let default_wiki_settings[key] = default_values[key] let default_wiki_settings[key] = default_values[key].default
endif endif
endfor endfor
@@ -222,11 +295,10 @@ function! s:populate_wikilocal_options()
let new_wiki_settings = {} let new_wiki_settings = {}
for key in keys(default_values) for key in keys(default_values)
if has_key(users_wiki_settings, key) if has_key(users_wiki_settings, key)
call s:check_users_value(key, users_wiki_settings[key], default_values[key], 0)
let new_wiki_settings[key] = users_wiki_settings[key] let new_wiki_settings[key] = users_wiki_settings[key]
elseif exists('g:vimwiki_'.key)
let new_wiki_settings[key] = g:vimwiki_{key}
else else
let new_wiki_settings[key] = default_values[key] let new_wiki_settings[key] = default_wiki_settings[key]
endif endif
endfor endfor
@@ -246,11 +318,79 @@ function! s:populate_wikilocal_options()
let temporary_wiki_settings.is_temporary_wiki = 1 let temporary_wiki_settings.is_temporary_wiki = 1
call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings) call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings)
call s:validate_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 endfunction
function! s:validate_settings() function! s:check_users_value(key, users_value, value_infos, comes_from_global_variable)
let type_code_to_name = {
\ type(0): 'number',
\ type(''): 'string',
\ type([]): 'list',
\ type({}): 'dictionary'}
let setting_origin = a:comes_from_global_variable ?
\ printf('''g:vimwiki_%s''', a:key) :
\ printf('''%s'' in g:vimwiki_list', a:key)
if has_key(a:value_infos, 'type') && type(a:users_value) != a:value_infos.type
echom printf('Vimwiki Error: The provided value of the option %s is a %s, ' .
\ 'but expected is a %s. See '':h g:vimwiki_%s''.', setting_origin,
\ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key)
endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'min') &&
\ a:users_value < a:value_infos.min
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
\ . ' too small. The minimum value is %i. See '':h g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.min, a:key)
endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'max') &&
\ a:users_value > a:value_infos.max
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
\ . ' too large. The maximum value is %i. See '':h g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.max, a:key)
endif
if has_key(a:value_infos, 'possible_values') &&
\ index(a:value_infos.possible_values, a:users_value) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s is'
\ . ' invalid. Allowed values are %s. See ''g:vimwiki_%s''.', a:users_value,
\ setting_origin, string(a:value_infos.possible_values), a:key)
endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'length') &&
\ strwidth(a:users_value) != a:value_infos.length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
\ . ' contain exactly %i character(s) but has %i. See '':h g:vimwiki_%s''.',
\ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key)
endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'min_length') &&
\ strwidth(a:users_value) < a:value_infos.min_length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
\ . ' have at least %d character(s) but has %d. See '':h g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key)
endif
endfunction
function! s:normalize_wikilocal_settings()
for wiki_settings in g:vimwiki_wikilocal_vars for wiki_settings in g:vimwiki_wikilocal_vars
let wiki_settings['path'] = s:normalize_path(wiki_settings['path']) let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
@@ -262,8 +402,18 @@ function! s:validate_settings()
\ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/') \ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/')
endif endif
let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path']) 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 wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path'])
let ext = wiki_settings['ext']
if !empty(ext) && ext[0] != '.'
let wiki_settings['ext'] = '.' . ext
endif
" for convenience, we also allow the term 'mediawiki'
if wiki_settings.syntax ==# 'mediawiki'
let wiki_settings.syntax = 'media'
endif
endfor endfor
endfunction endfunction
@@ -302,6 +452,9 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] = let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']' \ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
\ .header_symbol.'\{'.i.'}\s*$' \ .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'] = let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']' \ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
\ .header_symbol.'\{'.i.'}\s*$' \ .header_symbol.'\{'.i.'}\s*$'
@@ -318,6 +471,8 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
\ repeat(header_symbol, i).' __Header__' \ repeat(header_symbol, i).' __Header__'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] = let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$' \ '^\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'] = let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$' \ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] = let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
@@ -358,7 +513,7 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
"create regexp for bulleted list items "create regexp for bulleted list items
if !empty(g:vimwiki_syntax_variables[a:syntax].bullet_types) if !empty(g:vimwiki_syntax_variables[a:syntax].bullet_types)
let g:vimwiki_syntax_variables[a:syntax].rxListBullet = let g:vimwiki_syntax_variables[a:syntax].rxListBullet =
\ join( map(g:vimwiki_syntax_variables[a:syntax].bullet_types, \ join( map(copy(g:vimwiki_syntax_variables[a:syntax].bullet_types),
\'vimwiki#u#escape(v:val).' \'vimwiki#u#escape(v:val).'
\ .'repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)' \ .'repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)'
\ ) , '\|') \ ) , '\|')
@@ -548,10 +703,21 @@ function! s:populate_extra_markdown_vars()
let mkd_syntax.rxWeblink1Prefix = '[' let mkd_syntax.rxWeblink1Prefix = '['
let mkd_syntax.rxWeblink1Suffix = ')' let mkd_syntax.rxWeblink1Suffix = ')'
let mkd_syntax.rxWeblink1Separator = '](' 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) " [DESCRIPTION](URL)
let mkd_syntax.Weblink1Template = mkd_syntax.rxWeblink1Prefix . '__LinkDescription__'. let mkd_syntax.Weblink1Template = mkd_syntax.rxWeblink1Prefix . '__LinkDescription__'.
\ mkd_syntax.rxWeblink1Separator. '__LinkUrl__'. \ mkd_syntax.rxWeblink1Separator. '__LinkUrl__'. mkd_syntax.rxWeblink1Ext.
\ mkd_syntax.rxWeblink1Suffix \ 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 = '[^\\]' let valid_chars = '[^\\]'
@@ -564,8 +730,8 @@ function! s:populate_extra_markdown_vars()
" 1. [DESCRIPTION](URL) " 1. [DESCRIPTION](URL)
" 1a) match [DESCRIPTION](URL) " 1a) match [DESCRIPTION](URL)
let mkd_syntax.rxWeblink1 = mkd_syntax.rxWeblink1Prefix. let mkd_syntax.rxWeblink1 = mkd_syntax.rxWeblink1Prefix.
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1Separator. \ mkd_syntax.rxWeblink1Descr . mkd_syntax.rxWeblink1Separator.
\ mkd_syntax.rxWeblink1Descr . mkd_syntax.rxWeblink1Suffix \ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1Suffix
" 1b) match URL within [DESCRIPTION](URL) " 1b) match URL within [DESCRIPTION](URL)
let mkd_syntax.rxWeblink1MatchUrl = mkd_syntax.rxWeblink1Prefix. let mkd_syntax.rxWeblink1MatchUrl = mkd_syntax.rxWeblink1Prefix.
\ mkd_syntax.rxWeblink1Descr. mkd_syntax.rxWeblink1Separator. \ mkd_syntax.rxWeblink1Descr. mkd_syntax.rxWeblink1Separator.
@@ -700,7 +866,7 @@ function! vimwiki#vars#add_temporary_wiki(settings)
let new_temp_wiki_settings[key] = value let new_temp_wiki_settings[key] = value
endfor endfor
call insert(g:vimwiki_wikilocal_vars, new_temp_wiki_settings, -1) call insert(g:vimwiki_wikilocal_vars, new_temp_wiki_settings, -1)
call s:validate_settings() call s:normalize_wikilocal_settings()
endfunction endfunction
@@ -708,4 +874,3 @@ endfunction
function! vimwiki#vars#number_of_wikis() function! vimwiki#vars#number_of_wikis()
return len(g:vimwiki_wikilocal_vars) - 1 return len(g:vimwiki_wikilocal_vars) - 1
endfunction endfunction
+283 -56
View File
@@ -9,7 +9,7 @@
|___| |___| |_| |_||__| |__||___| |___| |_||___| ~ |___| |___| |_| |_||__| |__||___| |___| |_||___| ~
Version: 2.3 Version: 2.4
============================================================================== ==============================================================================
CONTENTS *vimwiki* CONTENTS *vimwiki*
@@ -513,6 +513,12 @@ gqq Format table. If you made some changes to a table
or without swapping insert/normal modes this command or without swapping insert/normal modes this command
gww will reformat it. gww will reformat it.
*vimwiki_gq1* *vimwiki_gw1*
gq1 Fast format table. The same as the previous, except
or that only a few lines above the current line are
gw1 tested. If the alignment of the current line differs,
then the whole table gets reformatted.
*vimwiki_<A-Left>* *vimwiki_<A-Left>*
<A-Left> Move current table column to the left. <A-Left> Move current table column to the left.
See |:VimwikiTableMoveColumnLeft| See |:VimwikiTableMoveColumnLeft|
@@ -677,12 +683,24 @@ Vimwiki file.
*:VimwikiGoBackLink* *:VimwikiGoBackLink*
Go back to the wiki page you came from. Go back to the wiki page you came from.
*:VimwikiSplitLink* *:VimwikiSplitLink* [reuse] [move_cursor]
Split and follow wiki link (create target wiki page if needed). Split and follow wiki link (create target wiki page if needed).
*:VimwikiVSplitLink* If the argument 'reuse' is given and nonzero, the link is opened in a
possibly existing split window instead of making a new split.
If 'move_cursor' is given and nonzero, the cursor moves to the window with
the opened link, otherwise, it stays in the window with the link.
*:VimwikiVSplitLink* [reuse] [move_cursor]
Vertical split and follow wiki link (create target wiki page if needed). Vertical split and follow wiki link (create target wiki page if needed).
If the argument 'reuse' is given and nonzero, the link is opened in a
possibly existing split window instead of making a new split.
If 'move_cursor' is given and nonzero, the cursor moves to the window with
the opened link, otherwise, it stays in the window with the link.
*:VimwikiTabnewLink* *:VimwikiTabnewLink*
Follow wiki link in a new tab (create target wiki page if needed). Follow wiki link in a new tab (create target wiki page if needed).
@@ -829,35 +847,6 @@ Vimwiki file.
are specified, outputs all tags. To make this command work properly, make are specified, outputs all tags. To make this command work properly, make
sure the tags have been built (see |vimwiki-build-tags|). sure the tags have been built (see |vimwiki-build-tags|).
------------------------------------------------------------------------------
4.3. Functions *vimwiki-functions*
Functions to interact with Vimwiki. (It's intended that most commands will be
replaced with corresponding function calls in the future.)
Warning: this is currently unstable and likely to change.
To map them to a key, use >
nnoremap <C-K> :call vimwiki#base#function_name(arg1, arg2)<CR>
<
*vimwiki-follow_link*
vimwiki#base#follow_link({split}, {reuse}, {move_cursor})
Open the link under the cursor. {split} can have the following values:
'nosplit' open the link in the current window
'vsplit' open in a vertically split window
'hsplit' open in a horizontally split window
'tab' open in a new tab
If {reuse} is 1 and {split} one of 'vsplit' or 'hsplit', open the link in
a possibly existing split window instead of making a new split.
If {move_cursor} is 1 the cursor moves to the window or tab with the
opened link, otherwise, it stays in the window or tab with the link.
For example, <CR> is per default mapped to
vimwiki#base#follow_link('nosplit', 0, 1)
============================================================================== ==============================================================================
5. Wiki syntax *vimwiki-syntax* 5. Wiki syntax *vimwiki-syntax*
@@ -894,6 +883,20 @@ is decorated: >
super^script^ super^script^
sub,,script,, sub,,script,,
For Markdown syntax these variations are used: >
**bold text** or __bold text__
*italic text* or _italic text_
***bold_italic text*** or ___italic_bold text___
Furthermore, there are a number of words which are highlighted extra flashy:
TODO, DONE, STARTED, FIXME, FIXED, XXX.
When rendered as HTML, code blocks containing only a hash prefixed 6 digit hex
number will be colored as themselves. For example >
`#ffe119`
Becomes >
<code style='background-color:#ffe119;color:black;'>#ffe119</code>
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
5.2. Links *vimwiki-syntax-links* 5.2. Links *vimwiki-syntax-links*
@@ -1683,7 +1686,7 @@ checkbox without a childitem.
It is possible to toggle several list items using visual mode. But note that It is possible to toggle several list items using visual mode. But note that
instead of toggling every item individually, all items get checked if the instead of toggling every item individually, all items get checked if the
first item is unchecked and all items get unchecked if the first item is first item was unchecked and all items get unchecked if the first item was
checked. checked.
Use gl<Space> (see |vimwiki_gl<Space>|) to remove a single checkbox and Use gl<Space> (see |vimwiki_gl<Space>|) to remove a single checkbox and
@@ -1730,6 +1733,15 @@ values: >
To indent table indent the first row. Then format it with 'gqq'. To indent table indent the first row. Then format it with 'gqq'.
You can specify the type of horizontal alignment for columns in the separator
using the ':' character. The default is left-align. >
| Date | Item | Price |
|------------|:------:|--------:|
| yest | Coffee | $15.00 |
| 2017-02-13 | Tea | $2.10 |
| 2017-03-14 | Cake | $143.12 |
<
============================================================================== ==============================================================================
10. Diary *vimwiki-diary* 10. Diary *vimwiki-diary*
@@ -1769,7 +1781,7 @@ See |g:vimwiki_use_calendar| option to turn it off/on.
============================================================================== ==============================================================================
12. Anchors *vimwiki-anchors* 11. Anchors *vimwiki-anchors*
Every header, tag, and bold text can be used as an anchor. To jump to it, use Every header, tag, and bold text can be used as an anchor. To jump to it, use
a wikilink of the form > a wikilink of the form >
@@ -1856,6 +1868,12 @@ as described in |vimwiki-register-wiki|, or may be registered on the fly as
described in |vimwiki-temporary-wiki|. For a list of per-wiki options, see described in |vimwiki-temporary-wiki|. For a list of per-wiki options, see
|vimwiki-local-options|. |vimwiki-local-options|.
A note for Vim power users:
If you have an elaborated Vim setup, where you e.g. load plugins
conditionally, make sure the settings are set before Vimwiki loads (that is,
before plugin/vimwiki.vim is sourced). If this is not possible, try this
command after the Vimwiki settings are (re-) set: >
:call vimwiki#vars#init()
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
12.1 Registered Wiki *g:vimwiki_list* *vimwiki-register-wiki* 12.1 Registered Wiki *g:vimwiki_list* *vimwiki-register-wiki*
@@ -2052,13 +2070,17 @@ Each template could look like: >
</html> </html>
where where
%title% is replaced by a wiki page name or by a |vimwiki-title| `%title%` is replaced by a wiki page name or by a |vimwiki-title|
%date% is replaced with the current date or by |vimwiki-date| `%date%` is replaced with the current date or by |vimwiki-date|
%root_path% is replaced by a count of ../ for pages buried in subdirs: `%root_path%` is replaced by a count of ../ for pages buried in subdirs:
if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
%root_path% is replaced by '../../../'. `%root_path%` is replaced by '../../../'.
`%wiki_path%` Path to current wiki-file.` The file path to the current wiki
file. For example, if you are on page a/b.wiki %wiki-path% contains
"a/b.wiki". Mostly useful if you want to link the to raw wiki page from
the rendered version.
%content% is replaced by a wiki file content. `%content%` is replaced by a wiki file content.
The default template will be applied to all wiki pages unless a page specifies The default template will be applied to all wiki pages unless a page specifies
@@ -2222,6 +2244,26 @@ Description~
Sort links in a diary index page. Sort links in a diary index page.
*vimwiki-option-diary_caption_level*
------------------------------------------------------------------------------
Key Default value~
diary_caption_level 0
Description~
Controls the presence of captions in the diary index linking to headers within
the diary pages.
Possible values:
-1: No headers are read from the diary page.
0: The first header from the diary page is used as the caption.
There are no sub-captions.
1: Captions are created for headers of level 1 in the diary page.
2: Captions are created for headers up to level 2 in the diary page.
etc.
When the value is >= 1, the primary caption of each diary page is set to the
first header read from that page if it is the unique lowest-level header.
*vimwiki-option-custom_wiki2html* *vimwiki-option-custom_wiki2html*
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Key Default value~ Key Default value~
@@ -2264,15 +2306,15 @@ be located at https://github.com/vimwiki-backup/vimwiki/issues/384
To use the internal wiki2html converter, use an empty string (the default). To use the internal wiki2html converter, use an empty string (the default).
vimwiki-option-custom_wiki2html_args *vimwiki-option-custom_wiki2html_args*
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Key Default value~ Key Default value~
custom_wiki2html_args '' custom_wiki2html_args ''
Description Description~
If a custom script is called with |vimwiki-option-custom_wiki2html|, additional If a custom script is called with |vimwiki-option-custom_wiki2html|, additional
parameters can be passed by setting them using 'custom_wiki2html_args' in parameters can be passed using this option: >
|g:vimwiki_list|. let g:vimwiki_list = [{'path': '~/path/', 'custom_wiki2html_args': 'stuff'}]
*vimwiki-option-list_margin* *vimwiki-option-list_margin*
@@ -2304,6 +2346,17 @@ current wiki page is saved: >
let g:vimwiki_list = [{'path': '~/my_site/', 'auto_tags': 1}] let g:vimwiki_list = [{'path': '~/my_site/', 'auto_tags': 1}]
*vimwiki-option-auto_diary_index*
------------------------------------------------------------------------------
Key Default value Values~
auto_diary_index 0 0, 1
Description~
Set this option to 1 to automatically update the diary index when opened.
See |:VimwikiDiaryGenerateLinks|: >
let g:vimwiki_list = [{'path': '~/my_site/', 'auto_diary_index': 1}]
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
12.4 Global Options *vimwiki-global-options* 12.4 Global Options *vimwiki-global-options*
@@ -2319,7 +2372,7 @@ Global options are configured using the following pattern: >
Highlight headers with =Reddish=, ==Greenish==, ===Blueish=== colors. Highlight headers with =Reddish=, ==Greenish==, ===Blueish=== colors.
Value Description~ Value Description~
1 Use VimwikiHeader1-VimwikiHeader6 group colors to highlight 1 Use VimwikiHeader1 - VimwikiHeader6 group colors to highlight
different header levels. different header levels.
0 Use |hl-Title| color for headers. 0 Use |hl-Title| color for headers.
Default: 0 Default: 0
@@ -2336,11 +2389,13 @@ Highlight checked list items with a special color:
Value Description~ Value Description~
0 Don't highlight anything. 0 Don't highlight anything.
1 Highlight checked [X] list item with |group-name| "Comment". 1 Highlight only the first line of a checked [X] list item.
2 Highlight checked [X] list item and all its child items. 2 Highlight a complete checked list item and all its child items.
Default: 0 Default: 0
The |group-name| "Comment" is used for highlighting.
Note: Option 2 does not work perfectly. Specifically, it might break if the Note: Option 2 does not work perfectly. Specifically, it might break if the
list item contains preformatted text or if you mix tabs and spaces for list item contains preformatted text or if you mix tabs and spaces for
indenting. Also, indented headers can be highlighted erroneously. indenting. Also, indented headers can be highlighted erroneously.
@@ -2506,6 +2561,31 @@ Value Description~
Default: 1 Default: 1
------------------------------------------------------------------------------
*g:vimwiki_create_link*
Create target wiki page if it does not exist. See |:VimwikiFollowLink|.
Value Description~
0 Do not create target wiki page.
1 Create target wiki page.
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_markdown_link_ext*
Append wiki file extension to links in Markdown. This is needed for
compatibility with other Markdown tools.
Value Description~
0 Do not append wiki file extension.
1 Append wiki file extension.
Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*VimwikiLinkHandler* *VimwikiLinkHandler*
@@ -2639,6 +2719,21 @@ Value Description~
Default: 1 Default: 1
------------------------------------------------------------------------------
*g:vimwiki_table_reduce_last_col*
If set, the last column separator will not be expanded to fill the cell. When
`:set wrap` this option improves how a table is displayed, particularly on
small screens. If |g:vimwiki_table_auto_fmt| is set to 0, this option has no
effect.
Value Description~
0 Enable table auto formating for all columns.
1 Disable table auto formating for the last column.
Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_w32_dir_enc* *g:vimwiki_w32_dir_enc*
@@ -2792,6 +2887,26 @@ URLs and hides markers and URL for links that have a description.
Default: 2 Default: 2
------------------------------------------------------------------------------
*g:vimwiki_conceal_pre*
Conceal preformatted text markers. For example,
>
{{{python
def say_hello():
print("Hello, world!")
}}}
>
would appear as simply
>
def say_hello():
print("Hello, world!")
>
in your wiki file.
Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_autowriteall* *g:vimwiki_autowriteall*
@@ -2868,6 +2983,15 @@ appropriate word in your mother tongue like this: >
The default is 'Contents'. The default is 'Contents'.
------------------------------------------------------------------------------
*g:vimwiki_toc_header_level*
The header level of the Table of Contents (see |vimwiki-toc|). Valid values
are from 1 to 6.
The default is 1.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_map_prefix* *g:vimwiki_map_prefix*
@@ -2892,6 +3016,54 @@ Value Description~
Default: 0 Default: 0
------------------------------------------------------------------------------
*g:vimwiki_links_header*
A string with the magic header that tells Vimwiki where the generated links
are located in a file. You can change it to the appropriate word in your
mother tongue like this: >
let g:vimwiki_links_header = 'Generierte Links'
The default is 'Generated Links'.
------------------------------------------------------------------------------
*g:vimwiki_links_header_level*
The header level of generated links. Valid values are from 1 to 6.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_tags_header*
A string with the magic header that tells Vimwiki where the generated tags
are located in a file. You can change it to the appropriate word in your
mother tongue like this: >
let g:vimwiki_tags_header = 'Generierte Stichworte'
The default is 'Generated Tags'.
------------------------------------------------------------------------------
*g:vimwiki_tags_header_level*
The header level of generated tags. Valid values are from 1 to 5.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_markdown_header_style*
The number of newlines to be inserted after a header is generated. Valid
values are from 0 to 2.
The default is 1.
============================================================================== ==============================================================================
13. Getting help *vimwiki-help* 13. Getting help *vimwiki-help*
@@ -2908,14 +3080,7 @@ Your help in making Vimwiki better is really appreciated!
Any help, whether it is a spelling correction or a code snippet to patch -- Any help, whether it is a spelling correction or a code snippet to patch --
everything is welcomed. everything is welcomed.
Before filing a bug or starting to write a patch, check the latest development See CONTRIBUTING.md for info about how to file bugs etc.
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/.
If you want to provide a pull request on GitHub, please start from the dev
branch, not from the master branch.
============================================================================== ==============================================================================
15. Development *vimwiki-development* 15. Development *vimwiki-development*
@@ -2962,6 +3127,21 @@ Contributors and their Github usernames in roughly chronological order:
- Daniel Trnka (@trnila) - Daniel Trnka (@trnila)
- Yuchen Pei (@ycpei) - Yuchen Pei (@ycpei)
- @maqiv - @maqiv
- @dpc
- Drew Hays (@Dru89)
- Daniel Etrata (@danetrata)
- Keith Haber (@kjhaber)
- @beuerle
- Silvio Ricardo Cordeiro (@silvioricardoc)
- @blyoa
- Jonathan McElroy (@jonathanmcelroy)
- @PetrusZ
- Brian Gianforcaro (@bgianfo)
- Ben Burrill (@benburrill)
- Zhuang Ma (@mzlogin)
- Huy Le (@huynle)
- Nick Borden (@hcwndbyw)
- Steven Stallion (@sstallion)
============================================================================== ==============================================================================
@@ -2974,14 +3154,61 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from
https://github.com/vimwiki-backup/vimwiki/issues. https://github.com/vimwiki-backup/vimwiki/issues.
2.4 (not yet released)~
New:~
* Add the option |g:vimwiki_text_ignore_newline|.
* |g:vimwiki_listsyms| can have fewer or more than 5 symbols.
* glx on a list item marks a checkbox as won't do, see |vimwiki_glx|.
* Add the option |g:vimwiki_listsym_rejected| to set the character used
for won't-do list items.
* gln and glp change the "done" status of a checkbox, see |vimwiki_gln|.
* |:VimwikiSplitLink| and |:VimwikiVSplitLink| can now reuse an existing
split window and not move the cursor.
* Add 'aH' and 'iH' text objects, see |vimwiki-text-objects|.
* Add the keys |vimwiki_[[|, |vimwiki_]]|, |vimwiki_[=|, |vimwiki_]=| and
|vimwiki_]u| for navigating between headers.
* Add the command |:VimwikiMakeTomorrowDiaryNote|.
* |g:vimwiki_folding| has a new option 'custom'.
* Add the ':quick' option for faster folding, see |g:vimwiki_folding|.
* Add the %date placeholder, see |vimwiki-date|.
* Add the option |vimwiki-option-custom_wiki2html_args|.
* Add support for HTML-style comments when using markdown syntax.
Removed:~
* Remove the undocumented and buggy command :VimwikiReadLocalOptions
which allowed to store Vimwiki related settings in a local file.
* Remove the undocumented command :VimwikiPrintWikiState.
* For complicated reasons, Vimwiki doesn't clean up its settings anymore
if you change the filetype of a wiki buffer.
Fixed:~
* Make |vimwiki-option-automatic_nested_syntaxes| work also for markdown.
* Issue #236: Highlight math blocks as TeX math, not TeX.
* Issue #264: Don't overwrite mappings to i_<CR> from other plugins.
* Fix an error where <BS> sometimes didn't work under Windows.
* Issue #302: |:VimwikiDiaryGenerateLinks| had issues with markdown.
* Issue #445: Better handling of |'autowriteall'| and |'hidden'|.
* Improve 'ah' and 'ih' text objects, see |vimwiki-text-objects|.
* Allow opening of links using Powershell.
* Allow any visual mode to be used with |vimwiki_+|.
* Markdown syntax for |vimwiki-toc| is used, when appropriate.
* Wikis can now be in subfolders of other wikis.
* Issue #482: |:VimwikiMakeDiaryNote| now uses the diary of the current wiki.
* Opening the diary and wikis from the menu works correctly now.
* Issue #497: Make |:VimwikiMakeDiaryNote| work outside a wiki buffer.
* Use markdown syntax in the diary when appropriate.
* Various other minor fixes.
2.3 (2016-03-31)~ 2.3 (2016-03-31)~
New: New:~
* Add |:VimwikiMakeYesterdayDiaryNote| command * Add |:VimwikiMakeYesterdayDiaryNote| command
* Issue #128: add option |vimwiki-option-automatic_nested_syntaxes| * Issue #128: add option |vimwiki-option-automatic_nested_syntaxes|
* Issue #192: Sort links in the list generated by |:VimwikiGenerateTags| * Issue #192: Sort links in the list generated by |:VimwikiGenerateTags|
Fixed: Fixed:~
* Issue #176: Fix issue when the wiki path contains spaces * Issue #176: Fix issue when the wiki path contains spaces
* Also look for tags in wiki files in subdirectories * Also look for tags in wiki files in subdirectories
* Locate the .tags file correctly on Windows * Locate the .tags file correctly on Windows
+13 -10
View File
@@ -63,13 +63,13 @@ function! Complete_wikifiles(findstart, base)
elseif a:base !~# '#' elseif a:base !~# '#'
" we look for wiki files " we look for wiki files
if a:base =~# '^wiki\d:' if a:base =~# '\m^wiki\d\+:'
let wikinumber = eval(matchstr(a:base, '^wiki\zs\d')) let wikinumber = eval(matchstr(a:base, '\m^wiki\zs\d\+'))
if wikinumber >= vimwiki#vars#number_of_wikis() if wikinumber >= vimwiki#vars#number_of_wikis()
return [] return []
endif endif
let prefix = matchstr(a:base, '^wiki\d:\zs.*') let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*')
let scheme = matchstr(a:base, '^wiki\d:\ze') let scheme = matchstr(a:base, '\m^wiki\d\+:\ze')
elseif a:base =~# '^diary:' elseif a:base =~# '^diary:'
let wikinumber = -1 let wikinumber = -1
let prefix = matchstr(a:base, '^diary:\zs.*') let prefix = matchstr(a:base, '^diary:\zs.*')
@@ -259,8 +259,8 @@ command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
command! -buffer VimwikiRenameLink call vimwiki#base#rename_link() command! -buffer VimwikiRenameLink call vimwiki#base#rename_link()
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1) command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1)
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link() command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('hsplit', 0, 1) command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', <f-args>)
command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', 0, 1) command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', <f-args>)
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>) command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
@@ -305,8 +305,8 @@ command! -buffer VimwikiListToggle call vimwiki#lst#toggle_list_item()
" table commands " table commands
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>) command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
command! -buffer VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq') command! -buffer -nargs=? VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq', <f-args>)
command! -buffer VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww') command! -buffer -nargs=? VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww', <f-args>)
command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left() command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left()
command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right() command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right()
@@ -584,6 +584,8 @@ endif
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR> nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
nnoremap <buffer> gww :VimwikiTableAlignW<CR> nnoremap <buffer> gww :VimwikiTableAlignW<CR>
nnoremap <buffer> gq1 :VimwikiTableAlignQ 2<CR>
nnoremap <buffer> gw1 :VimwikiTableAlignW 2<CR>
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft') if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
endif endif
@@ -633,13 +635,14 @@ vnoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel') if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif endif
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :<C-U>call vimwiki#base#AddHeaderLevel()<CR> nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
\<C-U>call vimwiki#base#AddHeaderLevel(v:count)<CR>
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel') if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
endif endif
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel : nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
\<C-U>call vimwiki#base#RemoveHeaderLevel()<CR> \<C-U>call vimwiki#base#RemoveHeaderLevel(v:count)<CR>
if !hasmapto('<Plug>VimwikiGoToParentHeader') if !hasmapto('<Plug>VimwikiGoToParentHeader')
nmap <silent><buffer> ]u <Plug>VimwikiGoToParentHeader nmap <silent><buffer> ]u <Plug>VimwikiGoToParentHeader
+31 -29
View File
@@ -36,7 +36,7 @@ function! s:setup_buffer_leave()
let &autowriteall = s:vimwiki_autowriteall_saved let &autowriteall = s:vimwiki_autowriteall_saved
if vimwiki#vars#get_global('menu') != "" if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table' exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif endif
endfunction endfunction
@@ -152,7 +152,7 @@ function! s:set_global_options()
let s:vimwiki_autowriteall_saved = &autowriteall let s:vimwiki_autowriteall_saved = &autowriteall
let &autowriteall = vimwiki#vars#get_global('autowriteall') let &autowriteall = vimwiki#vars#get_global('autowriteall')
if vimwiki#vars#get_global('menu') !=# '' if !empty(vimwiki#vars#get_global('menu'))
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table' exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif endif
endfunction endfunction
@@ -162,23 +162,25 @@ endfunction
" Vim defaults. So we enforce our settings here when the cursor enters a " Vim defaults. So we enforce our settings here when the cursor enters a
" Vimwiki buffer. " Vimwiki buffer.
function! s:set_windowlocal_options() function! s:set_windowlocal_options()
let foldmethod = vimwiki#vars#get_global('folding') if !&diff " if Vim is currently in diff mode, don't interfere with its folding
if foldmethod =~? '^expr.*' let foldmethod = vimwiki#vars#get_global('folding')
setlocal foldmethod=expr if foldmethod =~? '^expr.*'
setlocal foldexpr=VimwikiFoldLevel(v:lnum) setlocal foldmethod=expr
setlocal foldtext=VimwikiFoldText() setlocal foldexpr=VimwikiFoldLevel(v:lnum)
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*' setlocal foldtext=VimwikiFoldText()
setlocal foldmethod=expr elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
setlocal foldexpr=VimwikiFoldListLevel(v:lnum) setlocal foldmethod=expr
setlocal foldtext=VimwikiFoldText() setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
elseif foldmethod =~? '^syntax.*' setlocal foldtext=VimwikiFoldText()
setlocal foldmethod=syntax elseif foldmethod =~? '^syntax.*'
setlocal foldtext=VimwikiFoldText() setlocal foldmethod=syntax
elseif foldmethod =~? '^custom.*' setlocal foldtext=VimwikiFoldText()
" do nothing elseif foldmethod =~? '^custom.*'
else " do nothing
setlocal foldmethod=manual else
normal! zE setlocal foldmethod=manual
normal! zE
endif
endif endif
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel") if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
@@ -251,15 +253,15 @@ endif
augroup vimwiki augroup vimwiki
autocmd! autocmd!
autocmd ColorScheme * call s:setup_cleared_syntax()
for s:ext in s:known_extensions for s:ext in s:known_extensions
exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()' exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()'
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()' exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()' exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()'
exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()'
" Format tables when exit from insert mode. Do not use textwidth to " Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables. " autowrap tables.
if vimwiki#vars#get_global('table_auto_fmt') if vimwiki#vars#get_global('table_auto_fmt')
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))' exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."), 2)'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))' exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif endif
if vimwiki#vars#get_global('folding') =~? ':quick$' if vimwiki#vars#get_global('folding') =~? ':quick$'
@@ -307,43 +309,43 @@ command! VimwikiShowVersion call s:get_version()
let s:map_prefix = vimwiki#vars#get_global('map_prefix') let s:map_prefix = vimwiki#vars#get_global('map_prefix')
if !hasmapto('<Plug>VimwikiIndex') if !hasmapto('<Plug>VimwikiIndex') && maparg(s:map_prefix.'w', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'w <Plug>VimwikiIndex' exe 'nmap <silent><unique> '.s:map_prefix.'w <Plug>VimwikiIndex'
endif endif
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR> nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabIndex') if !hasmapto('<Plug>VimwikiTabIndex') && maparg(s:map_prefix.'t', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'t <Plug>VimwikiTabIndex' exe 'nmap <silent><unique> '.s:map_prefix.'t <Plug>VimwikiTabIndex'
endif endif
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR> nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect') if !hasmapto('<Plug>VimwikiUISelect') && maparg(s:map_prefix.'s', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'s <Plug>VimwikiUISelect' exe 'nmap <silent><unique> '.s:map_prefix.'s <Plug>VimwikiUISelect'
endif endif
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR> nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
if !hasmapto('<Plug>VimwikiDiaryIndex') if !hasmapto('<Plug>VimwikiDiaryIndex') && maparg(s:map_prefix.'i', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'i <Plug>VimwikiDiaryIndex' exe 'nmap <silent><unique> '.s:map_prefix.'i <Plug>VimwikiDiaryIndex'
endif endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR> nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks') if !hasmapto('<Plug>VimwikiDiaryGenerateLinks') && maparg(s:map_prefix.'<Leader>i', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks' exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
endif endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR> nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote') if !hasmapto('<Plug>VimwikiMakeDiaryNote') && maparg(s:map_prefix.'<Leader>w', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote' exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
endif endif
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR> nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote') if !hasmapto('<Plug>VimwikiTabMakeDiaryNote') && maparg(s:map_prefix.'<Leader>t', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote' exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
endif endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR> \ :VimwikiTabMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote') if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote') && maparg(s:map_prefix.'<Leader>y', 'n') == ""
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote' exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
endif endif
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
+6 -4
View File
@@ -297,7 +297,7 @@ execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItal
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText'). execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contains=VimwikiDelTextChar,@Spell' \ '/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText'). execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contained contains=VimwikiDelTextChar,@Spell' \ '/ contained contains=VimwikiDelTextCharT,@Spell'
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript'). execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contains=VimwikiSuperScriptChar,@Spell' \ '/ contains=VimwikiSuperScriptChar,@Spell'
@@ -318,8 +318,9 @@ execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').
" <hr> horizontal rule " <hr> horizontal rule
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/' execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
execute 'syntax region VimwikiPre start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart'). let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : ''
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell' execute 'syntax region VimwikiPre matchgroup=VimwikiPreDelim start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell'.concealpre
execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart'). execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart').
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@Spell' \ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@Spell'
@@ -383,7 +384,7 @@ hi def link VimwikiBoldT VimwikiBold
hi def VimwikiItalic term=italic cterm=italic gui=italic hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def link VimwikiItalicT VimwikiItalic 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 VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic hi def link VimwikiItalicBoldT VimwikiBoldItalic
@@ -395,6 +396,7 @@ hi def link VimwikiCodeT VimwikiCode
hi def link VimwikiPre PreProc hi def link VimwikiPre PreProc
hi def link VimwikiPreT VimwikiPre hi def link VimwikiPreT VimwikiPre
hi def link VimwikiPreDelim VimwikiPre
hi def link VimwikiMath Number hi def link VimwikiMath Number
hi def link VimwikiMathT VimwikiMath hi def link VimwikiMathT VimwikiMath
+18 -20
View File
@@ -13,38 +13,36 @@ let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$' let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$'
let s:markdown_syntax.char_eqin = '\$' let s:markdown_syntax.char_eqin = '\$'
" text: *strong* " text: **strong** or __strong__
" let s:markdown_syntax.rxBold = '\*[^*]\+\*'
let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'. \'\(\*\|_\)\{2\}'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'. \'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*'. \'\1\{2\}'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bold = '*' let s:markdown_syntax.char_bold = '\*\*\|__'
" text: _emphasis_ " text: _emphasis_ or *emphasis*
" let s:markdown_syntax.rxItalic = '_[^_]\+_'
let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'. \'\(\*\|_\)'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'. \'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_'. \'\1'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italic = '_' let s:markdown_syntax.char_italic = '\*\|_'
" text: *_bold italic_* or _*italic bold*_ " text: *_bold italic_* or _*italic bold*_
let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'. \'\(\*\)\{3\}'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'. \'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'_\*'. \'\1\{3\}'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bolditalic = '\*_' let s:markdown_syntax.char_bolditalic = '\*\*\*'
let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'. \'\(_\)\{3\}'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'. \'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'\*_'. \'\1\{3\}'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italicbold = '_\*' let s:markdown_syntax.char_italicbold = '___'
" text: `code` " text: `code`
let s:markdown_syntax.rxCode = '`[^`]\+`' let s:markdown_syntax.rxCode = '`[^`]\+`'