forked from lervag/wiki.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiki.txt
1333 lines (1027 loc) · 48.9 KB
/
wiki.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*wiki.txt* A simple wiki plugin for Vim
*wiki.vim*
Author: Karl Yngve Lervåg <[email protected]>
License: MIT license {{{
Copyright (c) 2021 Karl Yngve Lervåg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
}}}
==============================================================================
CONTENTS *wiki-contents*
Introduction |wiki-intro|
Requirements |wiki-intro-requirements|
Features |wiki-intro-features|
Configuration |wiki-config|
Options |wiki-config-options|
Events |wiki-config-events|
Mappings |wiki-mappings|
Text objects |wiki-mappings-text-obj|
Journal mappings |wiki-mappings-default|
Commands |wiki-commands|
Links |wiki-link|
Link URLs |wiki-link-url|
Wiki links |wiki-link-wiki|
Markdown links |wiki-link-markdown|
Markdown image links |wiki-link-image|
Reference links |wiki-link-reference|
Zotero shortlinks |wiki-link-zotero|
AsciiDoc cross references |wiki-link-adoc-xref|
AsciiDoc link macro |wiki-link-adoc-link|
Completion |wiki-completion|
Autocomplete |wiki-completion-auto|
Tags |wiki-tags|
Templates |wiki-templates|
Template function context |wiki-templates-context|
Template file format |wiki-templates-format|
Journal summaries |wiki-templates-journal-summaries|
==============================================================================
INTRODUCTION *wiki-intro*
This is a Vim plugin for writing and maintaining a personal wiki. The plugin
was initially based on vimwiki (https://github.com/vimwiki/vimwiki), but it is
written mostly from scratch and is based on a more "do one thing and do it
well" philosophy.
The plugin will activate by default for any `.wiki` files, but this may be
customized with |g:wiki_filetypes| and |g:wiki_global_load|. One may also
explicitly activate with |WikiEnable|. The wiki root is automatically detected
as long as there is a top-level `index.wiki` file available. If no such file
is found, it sets the root to the same directory as the current file. In
addition, one may specify a main wiki with the |g:wiki_root| option. This
allows convenient mappings and commands for opening the main wiki from
anywhere.
Note: |wiki.vim| is `not` a filetype plugin. It is designed so that it may be used
along with filetype plugins, e.g. for dedicated Markdown plugins. One
may also use `wiki-ft.vim` (https://github.com/lervag/wiki-ft.vim) for
simple syntax highlighting and folding of `.wiki` files, if desired.
------------------------------------------------------------------------------
REQUIREMENTS *wiki-intro-requirements*
This plugin is mainly developed on and for Linux. Some or most of the features
should still work on Windows and OSX, but currently there are no guaranties.
On Windows, it is assumed that users enable 'shellslash' to avoid issues with
backslashes versus forward slashes.
The following is a list of external tools that are used for some of the
features:
| Program | Feature |
| ---------------------------- + ------------------------------ |
| `date` | for journal related stuff |
| `xdg-open` | for opening `pdf` files on Linux |
| `pandoc` (https://pandoc.org/) | for |WikiExport| |
------------------------------------------------------------------------------
FEATURES *wiki-intro-features*
- Wiki functionality
- Global mappings for accessing a specified wiki
- Local mappings for
- Navigation (follow links, go back, etc)
- Renaming pages (will also update links in other pages)
- Creating a table of contents
- Toggling links
- Viewing wiki link graphs
- Completion of wiki links and link anchors
- Text objects
- `iu au` Link URL
- `it at` Link text
- New page templates
- Support for journal entries
- Navigating the journal back and forth with `<Plug>(wiki-journal-next)`
and `<Plug>(wiki-journal-prev)`.
- Support for parsing journal entries in order to make weekly and monthly
summaries. The parsed result needs manual editing for good results.
- Utility functionality
- |WikiExport| command for exporting to e.g. `pdf` with `pandoc`
- Third-party support
- |CtrlP|: |CtrlPWiki| command (https://github.com/ctrlpvim/ctrlp.vim)
- |fzf|: |WikiFzfPages|, |WikiFzfToc|, and |WikiFzfTags| commands
(https://github.com/junegunn/fzf.vim)
- |unite| source (https://github.com/Shougo/unite.vim)
- |denite| source (https://github.com/Shougo/denite.nvim)
------------------------------------------------------------------------------
USAGE *wiki-intro-usage*
This outlines the basic steps to get started:
1. Create a wiki directory where the wiki files should be stored, for instance
`~/wiki`.
2. Add the following to your `vimrc` file: >
let g:wiki_root = '~/wiki'
3. Now you can open the index file (by default `index.wiki`) with `<leader>ww`
and start to add your notes as desired.
==============================================================================
CONFIGURATION *wiki-config*
The following subsections presents a list of available options and events that
can be used to customize the behaviour of wiki.vim.
------------------------------------------------------------------------------
OPTIONS *wiki-config-options*
*g:wiki_cache_root*
Specify the cache directory for |wiki.vim|.
Default value: OS dependent
`Linux and MacOS`: '~/.cache/wiki.vim/'
`Windows`: Standard temporary folder (based on |tempname()|)
*g:wiki_cache_persistent*
Specify whether to use persistent caching.
Default value: 1
*g:wiki_date_exe*
Specify the executable for `date`, which is used "behind the scenes" to
manipulate and calculate dates for the journal features.
On MacOS/OSX, one can install `coreutils` from Homebrew and then use the
`gdate` program with: >
let g:wiki_date_exe = 'gdate'
<
Default: 'date'
*g:wiki_export*
A dictionary that specifies the default configuration for |WikiExport|
options. See the specifications for the options for more information.
Default: >
let g:wiki_export = {
\ 'args' : '',
\ 'from_format' : 'markdown',
\ 'ext' : 'pdf',
\ 'link_ext_replace': v:false,
\ 'view' : v:false,
\ 'output': fnamemodify(tempname(), ':h'),
\}
*g:wiki_filetypes*
List of filetypes for which |wiki.vim| should be enabled.
Default: ['wiki']
*g:wiki_file_handler*
Name of a function or a |FuncRef| for a function that should be used to
handle local files (see also |wiki-link-url|). The function should give
a non-zero return value if it properly handled the URL. If not, the plugin
falls back to opening the URL with Vim. An example: >
let g:wiki_file_handler = 'WikiFileHandler'
function! WikiFileHandler(...) abort dict
if self.path =~# 'pdf$'
silent execute '!zathura' fnameescape(self.path) '&'
return 1
endif
return 0
endfunction
*g:wiki_fzf_pages_force_create_key*
Key combination that, when pressed while searching with |WikiFzfPages|, will
create a new page with the name of the query. The value must be a string
recognized by fzf's `--expect` argument; see fzf's manual page for a list of
available keys.
Default: `'alt-enter'`
*g:wiki_fzf_pages_opts*
A string with additional user options for |WikiFzfPages|. This can be used
e.g. to add a previewer. Users should be aware that the page candidates are
"prettified" with the `--with-nth=1` and `-d` options for fzf, so to obtain
the page path in a previewer option one must use the field index expression 1.
E.g.: >
let g:wiki_fzf_pages_opts = '--preview "cat {1}"'
<
Default: `''`
*g:wiki_global_load*
|wiki.vim| is inherently agnostic in that it assumes any recognized filetype
specifies a wiki. However, some people might want to load |wiki.vim| for
ONLY files within a globally specified directory |g:wiki_root|. To allow
this behaviour, one can set this option to 0.
Default: 1
*g:wiki_journal*
A dictionary for configuring the journal/diary feature. Available options
are:
name~
Name of journal (used to set journal path).
frequency~
One of 'daily', 'weekly', or 'monthly'.
date_format~
Dictionary of filename formats for the 'daily', 'weekly', and 'monthly'
frequencies. The formats may contain the following keys:
%y year (two digits)
%Y year (four digits)
%m month (01..12)
%d day of month (01..31)
%V ISO week number with Monday as first day of week
%U week number with Sunday as first day of week
Default: >
let g:wiki_journal = {
\ 'name': 'journal',
\ 'frequency': 'daily',
\ 'date_format': {
\ 'daily' : '%Y-%m-%d',
\ 'weekly' : '%Y_w%V',
\ 'monthly' : '%Y_m%m',
\ },
\}
*g:wiki_link_extension*
Specify the extension that should be applied to wiki links. This should be
in the format `.ext`, e.g. `.md` or `.wiki`.
Default: ''
*g:wiki_link_toggle_on_follow*
This option allows to disable the toggle behaviour in |WikiLinkFollow| where
"normal" text under the cursor is transformed into links. The behaviour is
enabled by default. If disabled, one may still use |WikiLinkToggle| to
transform text into links.
Default: 1
*g:wiki_link_target_type*
This option may be used to pick the default style of link that will be used.
Available styles for the default target type are:
`md` (|wiki-link-markdown|)
Markdown style links.
`wiki` (|wiki-link-wiki|)
Wiki style links.
`adoc_xref_bracket` (|wiki-link-adoc-xref|)
`adoc_xref_inline`
AsciiDoc cross-reference style links (angled brackets style or inline
`xref:...` style).
Toggling between link types can still be achieved using |WikiLinkToggle|.
Default: 'wiki'
*g:wiki_link_toggles*
This option specifies the template for toggling a specific type of link with
|WikiLingToggle| or |<plug>(wiki-link-toggle)|.
This allows to customize how links are changed when they are toggled. For
instance, to add/remove extensions for wiki and markdown style links, one
could use: >
function WikiToggleWiki(url, text) abort dict
return wiki#link#md#template(a:url . '.wiki',
\ empty(a:text) ? a:url : a:text)
endfunction
function WikiToggleMd(url, text) abort dict
let l:url = substitute(a:url, '\.wiki$', '', '')
return wiki#link#wiki#template(l:url, a:text)
endfunction
let g:wiki_link_toggles = {
\ 'md': 'WikiToggleMd',
\ 'wiki': 'WikiToggleWiki',
\}
<
Default: >
let g:wiki_link_toggles = {
\ 'md': 'wiki#link#wiki#template',
\ 'wiki': 'wiki#link#md#template',
\ 'date': 'wiki#link#wiki#template',
\ 'shortcite': 'wiki#link#md#template',
\ 'url': 'wiki#link#md#template',
\}
*g:wiki_map_create_page*
This option may be used to specify a map or transformation for page names
provided to |WikiOpen|. For example: >
let g:wiki_map_create_page = 'MyFunction'
function MyFunction(name) abort
let l:name = wiki#get_root() . '/' . a:name
" If the file is new, then append the current date
return filereadable(l:name)
\ ? a:name
\ : a:name . '_' . strftime('%Y%m%d')
endfunction
<
With the above setting, if one enters a page name "foo" for |WikiOpen| on
the date 2020-04-11, the page "foo_20200411" will be created.
Default: ''
*g:wiki_map_link_create*
This option may be used to transform text before creating a new link. An
example: >
let g:wiki_map_link_create = 'MyFunction'
function MyFunction(text) abort
return substitute(tolower(a:text), '\s\+', '-', 'g')
endfunction
<
With the above setting, links created with |WikiLinkFollow| or
|WikiLinkToggle| (or related mappings) will be transformed by `MyFunction`.
As an example, if one creates a link from the text "Some text", the link
becomes "[[some-text|Some text]]".
Default: ''
*g:wiki_mappings_use_defaults*
Whether or not to use default mappings (see |wiki-mappings-default|). The
allowed values are:
'all' use all default mappings
'local' use only buffer-local default mappings
'global' use only global default mappings
'none' do not use any of the default mappings
Default: 'all'
*g:wiki_mappings_global*
*g:wiki_mappings_local*
These options allow one to customize global and buffer local mappings
through dictionaries where the keys are the right-hand sides and the values
are the desired mappings, e.g.: >
let g:wiki_mappings_global = {
\ '<plug>(wiki-reload)' : ',wx',
\}
<
This example maps `,wx` to |<plug>(wiki-reload)|. The other maps are kept at
their default (unless |g:wiki_mappings_use_default| specifies otherwise).
Some mappings are defined in other mod s than normal mode. In this
case, one can use the following syntax: >
let g:wiki_mappings_local = {
\ '<plug>(wiki-export)' : '<c-p>',
\ 'x_<plug>(wiki-export)' : '<c-p>',
\}
<
Here `<c-p>` is mapped to |<plug>(wiki-export)| in normal mode and
visual mode, respectively. The available `<plug>` mappings are listed in
|wiki-mappings|.
Default: Undefined
*g:wiki_month_names*
A list of the names for each month. Used for interpolating month names in
the month template, |g:wiki_template_title_month|.
Default: `['January', 'February', ..., 'December']`
*g:wiki_resolver*
The name of the function to resolve wiki-schemed links, i.e., the standard
link scheme. The default should work well for most people, but this option
allows to adjust the resolver to ones own liking.
The function takes two arguments:
fname~
The unresolved filename. This may be empty, which is typically the case
for inter-page links (e.g. `[[#SomeSection]]`).
origin~
The path of the origin file, i.e. the file from which the link was
activated. This may be empty if a link is followed programmatically from
an empty buffer.
The function must return an absolute path to the destination file.
Note: The function `wiki#get_root()` can be useful to get the path to the
wiki root.
Default: `'wiki#url#wiki#resolver'`
*g:wiki_root*
Option to specify the wiki root path, i.e. the wiki that is opened with the
`<leader>ww` mapping. The option value must be a string that is either
i) a specific path, or
ii) the name of a function that returns a path.
The latter method allows more flexible determination of the root path, e.g.
project specific root paths. An example: >
function! WikiRoot()
let l:local = finddir('wiki', ';./')
return !empty(l:local) ? l:local : '~/wiki'
endfunction
let g:wiki_root = 'WikiRoot'
<
This setting would first search for a `wiki` directory in the current
relative directory, and fallback to a global `wiki` if the local wiki is not
found.
Note: The (returned) path must be either a relative or absolute path to an
existing directory.
Default: ''
*g:wiki_toc_title*
The title of TOC listings.
Default: `'Contents'`
*g:wiki_tags*
A dictionary that specifies the default configuration for |WikiTagSearch|
options. See the specifications for the options for more information.
Default: >
let g:wiki_tags = {
\ 'output' : 'loclist',
}
*g:wiki_tags_format_pattern*
A regular expression describing the search pattern for a single tag. See
also |wiki-tags| for more info on the tags feature.
The default expression recognizes tags confined inside `:`s, e.g. `:mytag:`.
To change the format to recognize hashed tags like `#tag1` and `#my-other-tag`,
one can use something like this: >
let g:wiki_tags_format_pattern = '\v%(^|\s)#\zs[^# ]+'
<
Default: >
let g:wiki_tags_format_pattern = '\v%(^|\s):\zs[^: ]+\ze:'
*g:wiki_tags_scan_num_lines*
A number of lines to read from the top of a page when scanning tags. To scan
lines from the bottom, use a negative number, e.g. >
let g:wiki_tags_scan_num_lines = -10
<
To scan the entire files, use: >
let g:wiki_tags_scan_num_lines = 'all'
<
Default: >
let g:wiki_tags_scan_num_lines = 15
*g:wiki_templates*
A list of templates for prefilling new pages. Each template should be
specified as a dictionary with a matcher and a source. Matching may be done
with regular expressions or with user functions. Similarly, sources can be
specified as a file source as specified in |wiki-templates-format|, or as
a user function with a single argument `context` as specified in
|wiki-templates-context|.
The possible dictionary keys of a template are:
match_re~
|String|
A regular expression that will be matched against the new page name.
Note: The name is not the same as the path and it does not include the
file name extension. For more advanced matching, you need a custom
matcher function, i.e. the next key.
match_func~
|Funcref|
A function that should return |v:true| if the template should be applied
or |v:false| if it should not apply.
source_filename~
|String|
The path to a template file. If this is a relative path, then it will be
relative to whichever path Vim or neovim is currently at when the
template is executed. If the template file is not found, then the
template will not be applied and the next template in the list will be
tried.
source_func~
|Funcref|
A user function that can use e.g. |append()| to add lines to the file.
For example: >
function! TemplateFallback(context)
call append(0, '# ' . a:context.name)
call append(1, '')
call append(2, 'Foobar')
endfunction
let g:wiki_templates = [
\ { 'match_re': 'index',
\ 'source_filename': '/home/user/templates/index.md'},
\ { 'match_re': 'foo',
\ 'source_filename': '.footemplate.md'},
\ { 'match_func': {x -> v:true},
\ 'source_func': function('TemplateFallback')},
\]
<
Notice that in the second template, the `;` is appended to the source
filename. This means the template file is first searched for in the current
directory of the new page, then in the parent directory, and so on. If the
template file is not found, then the next template will be tried.
Default: `[]`
*g:wiki_template_title_month*
A string that specifies the title of the month template. The following keys
are interpolated:
`%(month)` Month number
`%(month-name)` Name of month (see |g:wiki_month_names|)
`%(year)` Year (4 digits)
See |wiki-templates-journal-summaries| for more info.
Default: `'# Summary, %(year) %(month-name)'`
*g:wiki_template_title_week*
A string that specifies the title of the week template. The following keys
are interpolated:
`%(week)` Week number
`%(year)` Year (4 digits)
See |wiki-templates-journal-summaries| for more info.
Default: `'# Summary, %(year) week %(week)'`
*g:wiki_viewer*
A dictionary that specifies which viewer to use for a given filetype. The
entry `_` specifies the fallback or generic viewer. This option thus allows
one to setup different viewers for different file types that are used by the
generic link scheme handler (|wiki-link-url|) and by |WikiExport|.
Default: >
let g:wiki_viewer = {
\ '_' : OS Dependent: 'xdg-open' (Linux) | 'open' (OSX),
\}
*g:wiki_write_on_nav*
Option to specify whether or not to save the current file automatically
before navigating (forward or backward) between wiki links.
Default: 0
*g:wiki_zotero_root*
A string that specifies the Zotero root folder used for the zotero URL
scheme, see |wiki-link-url|.
Default: `'~/.local/zotero'`
------------------------------------------------------------------------------
EVENTS *wiki-config-events*
The following |User| events are available. The following shows an example for
how to use this: >
augroup MyWikiAutocmds
autocmd!
autocmd User WikiLinkFollowed normal! zz
autocmd User WikiBufferInitialized
\ nmap <buffer> gf <plug>(wiki-link-follow)
augroup END
*WikiBufferInitialized*
Event is triggered after the buffer features are initialized. This event
allows one to apply custom mappings and similar.
*WikiLinkFollowed*
Event is triggered after a link has been followed.
*WikiReloadPost*
Event is triggered after wiki.vim has been reloaded with |WikiReload|.
==============================================================================
COMMANDS *wiki-commands*
The following is a list of commands that are available in the wiki. Most of
the commands are also available as mappings of the form `<plug>(wiki-[name])`.
*WikiEnable*
Load |wiki.vim| for the current file. If the current file type is not in
|g:wiki_filetypes|, then it will be added, so that interwiki links will be
possible.
*<plug>(wiki-index)*
*WikiIndex*
Go to wiki index. When not inside a wiki page, the index is specified by the
option |g:wiki_root|.
*<plug>(wiki-open)*
*WikiOpen*
Open (or create) a page. Asks for user input to specify the page name. When
not already inside a wiki, the wiki root is given by |g:wiki_root|. If
|g:wiki_map_create_page| is specified, it will be used to transform the
input name before opening/creating the page.
*<plug>(wiki-journal)*
*WikiJournal*
Go to todays journal entry.
*<plug>(wiki-reload)*
*WikiReload*
Reload the wiki plugin. Mostly useful for plugin development.
*<plug>(wiki-graph-find-backlinks)*
*WikiGraphFindBacklinks*
Find backlinks to current page.
*<plug>(wiki-graph-check-links)*
*WikiGraphCheckLinks*
Check the wiki for broken links. If any broken links are found, they are
added to the location list (|location-list|) and the location list is
opened. The process of checking for broken links can take a while if you
have a large wiki.
*<plug>(wiki-graph-in)*
*<plug>(wiki-graph-out)*
*WikiGraphIn*
*WikiGraphOut*
Show link graph in to or out of the current page. A count may be given to
limit the depth of the graph.
*<plug>(wiki-link-next)*
*WikiLinkNext*
Go to next link.
*<plug>(wiki-link-prev)*
*WikiLinkPrev*
Go to previous link.
*<plug>(wiki-link-follow)*
*WikiLinkFollow*
Follow link. Will create a new link if the text under the cursor is not
already a link. If |g:wiki_map_link_create| is specified, it will be used to
transform the link when creating it.
*#User#WikiLinkFollowed*
The user autocommand `WikiLinkFollowed` is triggered after a wiki link has
been followed. This allows the user to add custom functionality after
following wiki links. For example, to center the cursor inside the window
after following a link: >
augroup MyWikiAutocmds
autocmd!
autocmd User WikiLinkFollowed normal! zz
augroup END
*<plug>(wiki-link-follow-split)*
*WikiLinkFollowSplit*
Similar to |WikiLinkfollow|, except wiki links are followed in a |vsplit|.
*<plug>(wiki-link-return)*
*WikiLinkReturn*
Go back to previous page, i.e. undo the last follow operation.
*<plug>(wiki-link-toggle)*
*<plug>(wiki-link-toggle-visual)* |xmap|
*<plug>(wiki-link-toggle-operator)* |map-operator|
*WikiLinkToggle*
Toggle wiki link. If |g:wiki_map_link_create| is specified, it will be used
to transform the link when creating it.
*<plug>(wiki-link-show)*
*WikiLinkShow*
Show some info on link under cursor.
*<plug>(wiki-link-extract-header)*
*WikiLinkExtractHeader*
Set link title from the first header of the target file.
*<plug>(wiki-page-delete)*
*WikiPageDelete*
Delete wiki page.
*<plug>(wiki-page-rename)*
*WikiPageRename*
Rename wiki page (will update all links to the page).
*<plug>(wiki-page-toc)*
*WikiPageToc*
Create/Update table of contents.
*<plug>(wiki-page-toc-local)*
*WikiPageTocLocal*
Create/Update table of contents (section local variant).
*<plug>(wiki-journal-index)*
*WikiJournalIndex*
Insert a sorted list of links to all journal pages below the cursor. It uses
the link style specified by |g:wiki_link_target_type|.
*<plug>(wiki-journal-next)*
*WikiJournalNext*
Go to next day/week/month.
*<plug>(wiki-journal-prev)*
*WikiJournalPrev*
Go to previous day/week/month.
*<plug>(wiki-journal-copy-tonext)*
*WikiJournalCopyToNext*
Copy current entry to next work day (unless the entry for next workday
already exists).
*<plug>(wiki-journal-toweek)*
*WikiJournalToWeek*
Go to week summary. If not existing, then parse the day entries to make
a first draft. The title is given by |g:wiki_template_title_week|. For more
info, see |wiki-templates-journal-summaries|.
*<plug>(wiki-journal-tomonth)*
*WikiJournalToMonth*
Go to month summary. If not existing, then parse the day entries and
relevant week summaries to make a first draft. The title is given by
|g:wiki_template_title_month|. See also |wiki-templates-journal-summaries|.
*<plug>(wiki-export)*
[range]*WikiExport* [options] [fname]
Export the current wiki file with `pandoc`. The main argument `fname`
specifies the target filename and format (implied by the file extension),
e.g. `test.pdf` or `test.html`. If `fname` is not specified, then the
`-path` option is used to determine the output location. In this case, the
`-view` option is activated regardless of the basic configuration.
Available options are given below. The default values are specified in the
dictionary |g:wiki_export|.
-args~
Specify extra arguments for `pandoc`.
-from-format FRMT | -f FRMT~
Specify format of the wiki page.
-ext EXT~
Specify extension to use if `fname` is not provided.
-link_ext_replace~
Set to true to replace in-wiki link extensions with html. This enables
in-browser wiki navigation. Requires `ext` be set to `html` and for
|g:wiki_link_extension| to be non-empty to have any meaningful effect.
-output~
Set output directory where the exported file is stored. Relative paths are
relative to the wiki root.
-view~
Set to true to open documents with specified `viewer` by default.
-viewer PATH~
Specify viewer to use to open the exported file. This implies `-view` and
overrides the |g:wiki_viewer| option.
Note: This feature requires `pandoc` (https://pandoc.org/) to build the
output files.
*<plug>(wiki-tag-list)*
*WikiTagList*
Show list of detected tags.
*<plug>(wiki-tag-reload)*
*WikiTagReload*
Source wiki files and reload tags.
*<plug>(wiki-tag-search)*
*WikiTagSearch* [options] [tag]
List wiki pages that contain the desired `tag`. If the argument `tag` is not
supplied, the command asks for input. See also |wiki-tags| for more
information of the tags feature and |WikiFzfTags| for an alternative search
mechanism.
Available options are (use |g:wiki_tags| to set default values):
-output TRG~
Where to put the search result. `TRG` may be one of:
* `loclist` Use |location-list|
* `echo` Display results on screen
* `scratch` Add results to a scratch buffer
* `cursor` Insert result below cursor
*CtrlPWiki*
Open |CtrlP| in find file mode for wiki files in current wiki or in the main
wiki defined by |g:wiki_root|.
*<plug>(wiki-fzf-pages)*
*WikiFzfPages*
Open |fzf| in find file mode for wiki files in current wiki or in the main
wiki defined by |g:wiki_root|.
One may pass additional options to fzf with the |g:wiki_fzf_pages_opts|
option. This allows more fine grained control of fzf, e.g. to add
a previewer.
This can also be used to create a new page. If a query is typed and the key
specified by |g:wiki_fzf_pages_force_create_key| is pressed (alt-enter, by
default), a page whose name is equal to the query will be created if it
doesn't already exist. If the page does already exist, it will be opened.
If |g:wiki_map_create_page| is defined, the new page name is determined by
first applying that function to the query.
For example, suppose you search for "foo", and there is one result: an
already-existing page named "foobar". If the enter key is pressed, the
existing "foobar" will be opened, as usual. However, if
|g:wiki_fzf_pages_force_create_key| is pressed instead, a new page titled
"foo" will be created and opened.
For convenience, if the input query does not have any results, simply
pressing enter will also create a page. E.g., if you searched for "My Fzf
Page", and this term does not exist, then it will instead open a new page
"My Fzf Page.wiki" (or similar, depending on the value of other options).
*<plug>(wiki-fzf-tags)*
*WikiFzfTags*
Open |fzf| and search for tags.
*<plug>(wiki-fzf-toc)*
*WikiFzfToc*
Open |fzf| and list table of contents entries for the current wiki page.
==============================================================================
MAPPINGS *wiki-mappings*
Here we describe the mappings provided by the wiki plugin, as well as the
default maps. Note that most of the mappings are also available as commands.
These mappings are described in |wiki-commands|.
------------------------------------------------------------------------------
TEXT OBJECTS *wiki-mappings-text-obj*
The following mappings are available as visual mode and operator mode
mappings, i.e. |xmap| and |omap|.
*<plug>(wiki-au)*
*<plug>(wiki-iu)*
Text object for link URLs.
*<plug>(wiki-at)*
*<plug>(wiki-it)*
Text object for link texts.
------------------------------------------------------------------------------
DEFAULT MAPPINGS *wiki-mappings-default*
This is a list of default mappings. For a more detailed description of each
mapping, read the documentation of the `<plug>(wiki-[name])` form of the
mapping. The mode specifier is a single letter which indicates which mode the
mapping is valid in. See e.g. |nmap|, |imap|, |omap| or |xmap| for more
information about the different modes.
---------------------------------------------------------------------~
MODE LHS RHS~
---------------------------------------------------------------------~
`n` <leader>ww |<plug>(wiki-index)| [GLOBAL]
`n` <leader>wn |<plug>(wiki-open)| [GLOBAL]
`n` <leader>w<leader>w |<plug>(wiki-journal)| [GLOBAL]
`n` <leader>wx |<plug>(wiki-reload)| [GLOBAL]
`n` <leader>wb |<plug>(wiki-graph-find-backlinks)|
`n` <leader>wlc |<plug>(wiki-graph-check-links)|
`n` <leader>wg |<plug>(wiki-graph-in)|
`n` <leader>wG |<plug>(wiki-graph-out)|
`n` <leader>wf |<plug>(wiki-link-toggle)|
`n` <leader>wd |<plug>(wiki-page-delete)|
`n` <leader>wr |<plug>(wiki-page-rename)|
`n` <leader>wt |<plug>(wiki-page-toc)|
`n` <leader>wT |<plug>(wiki-page-toc-local)|
`n` <leader>wp |<plug>(wiki-export)|
`x` <leader>wp |<plug>(wiki-export)|
`n` <leader>wll |<plug>(wiki-link-show)|
`n` <leader>wlh |<plug>(wiki-link-extract-header)|
`n` <leader>wsl |<plug>(wiki-tag-list)|
`n` <leader>wsr |<plug>(wiki-tag-reload)|
`n` <leader>wss |<plug>(wiki-tag-search)|
`n` <tab> |<plug>(wiki-link-next)|
`n` <cr> |<plug>(wiki-link-follow)|
`n` <c-w><cr> |<plug>(wiki-link-follow-split)|
`n` <s-tab> |<plug>(wiki-link-prev)|
`n` <bs> |<plug>(wiki-link-return)|
`n` gl |<plug>(wiki-link-toggle-operator)|
`x` <cr> |<plug>(wiki-link-toggle-visual)|
`ox` au |<plug>(wiki-au)|
`ox` iu |<plug>(wiki-iu)|
`ox` at |<plug>(wiki-at)|
`ox` it |<plug>(wiki-it)|
---------------------------------------------------------------------~
==============================================================================
LINKS *wiki-link*
Links are one of the most essential features of a wiki, and as such, requires
particular attention. A link is a structure that consists of an URL (see
|wiki-link-url|) and a possibly empty description. It may be followed with
the mappings `<cr>` or `<c-cr>`, where the latter will open the link in a split
(if it is an internal link). One may use `<bs>` to navigate back after
following a link.
These are the link formats that are currently supported with some examples:
- Link URLs |wiki-link-url|
`http://www.example.com`
`wiki:index`
`journal:2013-04-05`
`doi:10.1002%2Fandp.19053220607`
- Wiki links |wiki-link-wiki|
`[[URL]]`
`[[URL|Description]]`
- Markdown links |wiki-link-markdown|
`[Description](URL)`
- Markdown image links |wiki-link-image|
`![Caption text](URL)`
- Reference links |wiki-link-reference|
`[Target]`
`[Description][Target]`
- Zotero shortlink |wiki-link-zotero|
`@citekey`
- AsciiDoc cross-reference links |wiki-link-adoc-xref|
`<<URL#,Description>>`
`xref:URL[Description]`
- AsciiDoc link macro |wiki-link-adoc-link|
`link:URL[Description]`
------------------------------------------------------------------------------
LINK URLS *wiki-link-url*
An URL, which is short for Uniform Resource Locator, has the general format
`[scheme:]address`
The `scheme` specifies which kind of link it is. When the URL is typed
directly and with a proper scheme, it will typically be possible to follow the
link directly without putting it inside a fuller link type.
When the scheme is not specified for URLs inside one of the other link types,
then the `wiki` scheme is generally assumed (unless otherwise stated).
The following schemes are supported:
wiki~
journal~