diff --git a/autoload/wiki/complete.vim b/autoload/wiki/complete.vim index 031a7deb..4ea27395 100644 --- a/autoload/wiki/complete.vim +++ b/autoload/wiki/complete.vim @@ -144,6 +144,27 @@ function! s:completer_mdlink.findstart(line) dict abort " {{{2 return l:cnum + strlen(self.base) endfunction +" }}}1 +" {{{1 AdocLink + +let s:completer_adoclink = deepcopy(s:completer_wikilink) + +function! s:completer_adoclink.findstart(line) dict abort " {{{2 + let l:cnum = match(a:line, '<<\zs[^,]\{-}') + if l:cnum < 0 | return -1 | endif + + let l:base = a:line[l:cnum:] + + let self.rooted = l:base[0] ==# '/' + + " completing of anchors is disabled because they won't be found for asciidoc + " anyway: wiki#rx#header_items regex is uded for search of anchors and it + " requires Markdown-style headers. This could be resolved by passing a + " specific regular expression to wiki#page#get_anchors() + let self.is_anchor = 0 + return l:cnum +endfunction + " }}}1 " {{{1 Zotero diff --git a/autoload/wiki/link.vim b/autoload/wiki/link.vim index e2ad86ea..a5dfdb45 100644 --- a/autoload/wiki/link.vim +++ b/autoload/wiki/link.vim @@ -7,6 +7,7 @@ function! wiki#link#get() abort " {{{1 for l:matcher in [ \ wiki#link#wiki#matcher(), + \ wiki#link#adoc#matcher(), \ wiki#link#md_fig#matcher(), \ wiki#link#md#matcher(), \ wiki#link#ref_target#matcher(), @@ -33,6 +34,7 @@ function! wiki#link#get_all(...) abort "{{{1 let l:matchers = [ \ wiki#link#wiki#matcher(), + \ wiki#link#adoc#matcher(), \ wiki#link#md_fig#matcher(), \ wiki#link#md#matcher(), \ wiki#link#ref_target#matcher(), diff --git a/autoload/wiki/link/adoc.vim b/autoload/wiki/link/adoc.vim new file mode 100644 index 00000000..4d900c3a --- /dev/null +++ b/autoload/wiki/link/adoc.vim @@ -0,0 +1,21 @@ +" A simple wiki plugin for Vim +" +" Maintainer: Karl Yngve LervÄg +" Email: karl.yngve@gmail.com +" + +function! wiki#link#adoc#matcher() abort " {{{1 + return { + \ 'type' : 'adoc', + \ 'rx' : g:wiki#rx#link_adoc, + \ 'rx_url' : '<<\zs[^#]\{-}\ze.adoc#,[^>]\{-}>>', + \ 'rx_text' : '<<[^#]\{-}#,\zs[^>]\{-}\ze>>', + \} +endfunction + +" }}}1 +function! wiki#link#adoc#template(url, text) abort " {{{1 + return printf('<<%s.adoc#,%s>>', a:url, empty(a:text) ? a:url : a:text) +endfunction + +" }}}1 diff --git a/autoload/wiki/rx.vim b/autoload/wiki/rx.vim index d690b28e..bd88cd90 100644 --- a/autoload/wiki/rx.vim +++ b/autoload/wiki/rx.vim @@ -36,6 +36,7 @@ let wiki#rx#url = '\<\l\+:\%(\/\/\)\?[^ \t()\[\]|]\+' let wiki#rx#reftext = '[^\\\[\]]\{-}' let wiki#rx#reftarget = '\%(\d\+\|\a[-_. [:alnum:]]\+\)' let wiki#rx#link_md = '\[[^\\\[\]]\{-}\]([^\\]\{-})' +let wiki#rx#link_adoc = '<<[^#]\{-}#,[^>]\{-}>>' let wiki#rx#link_md_fig = '!' . wiki#rx#link_md let wiki#rx#link_ref_single = '[\]\[]\@' let wiki#rx#link_wiki = '\[\[\/\?[^\\\]]\{-}\%(|[^\\\]]\{-}\)\?\]\]' let wiki#rx#link = join([ \ wiki#rx#link_wiki, + \ wiki#rx#link_adoc, \ '!\?' . wiki#rx#link_md, \ wiki#rx#link_ref_target, \ wiki#rx#link_ref_single, diff --git a/doc/wiki.txt b/doc/wiki.txt index 29305389..2c35656f 100644 --- a/doc/wiki.txt +++ b/doc/wiki.txt @@ -228,9 +228,10 @@ OPTIONS *wiki-config-options* *g:wiki_link_target_type* This option may be used to pick the default style of link that will be used. - Setting this to `md` will cause Markdown style links to be added by default, - rather than `wiki` style links. Toggling between link types can still be - achieved using |WikiLinkToggle|. + Available styles are `md` which will cause Markdown style links to be added + by default, `adoc` - Asciidoc inter-page cross reference style links and + `wiki` style links. Toggling between link types can still be achieved using + |WikiLinkToggle|. Default: 'wiki' @@ -830,6 +831,8 @@ These are the link formats that are currently supported: `[Description][Target]` - Zotero shortlink |wiki-link-zotero| `@citekey` +- Asciidoc links |wiki-link-adoc| + `<>` ------------------------------------------------------------------------------ LINK URLS *wiki-link-url* @@ -960,6 +963,14 @@ As a minor convenience link type, Zotero URLs may be written in short as `@citekey` instead of `zot:citekey`. See also |wiki-link-url| for more info on the Zotero URL scheme and handler. +------------------------------------------------------------------------------ +ASCIIDOC LINKS *wiki-link-adoc* + +Asciidoc links use Asciidoctor's Inter-document Cross References syntax and +look like this: > + + <> + ============================================================================== LISTS *wiki-lists* diff --git a/plugin/wiki.vim b/plugin/wiki.vim index 1520f3f3..2245a9f1 100644 --- a/plugin/wiki.vim +++ b/plugin/wiki.vim @@ -52,8 +52,9 @@ call wiki#init#option('wiki_zotero_root', '~/.local/zotero') call wiki#init#option('wiki_mappings_use_defaults', 'all') call wiki#init#option('wiki_write_on_nav', 0) call wiki#init#option('wiki_link_toggles', { - \ 'md': 'wiki#link#wiki#template', \ 'wiki': 'wiki#link#md#template', + \ 'md': 'wiki#link#adoc#template', + \ 'adoc': 'wiki#link#wiki#template', \ 'date': 'wiki#link#wiki#template', \ 'shortcite': 'wiki#link#md#template', \ 'url': 'wiki#link#md#template',