Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions autoload/wiki/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions autoload/wiki/link.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
21 changes: 21 additions & 0 deletions autoload/wiki/link/adoc.vim
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions autoload/wiki/rx.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[\]\[]\@<!\[' . wiki#rx#reftarget . '\][\]\[]\@!'
let wiki#rx#link_ref_double =
Expand All @@ -49,6 +50,7 @@ let wiki#rx#link_shortcite = '\%(\s\|^\|\[\)\zs@[-_a-zA-Z0-9]\+\>'
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,
Expand Down
17 changes: 14 additions & 3 deletions doc/wiki.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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|
`<<URL#,Description>>`

------------------------------------------------------------------------------
LINK URLS *wiki-link-url*
Expand Down Expand Up @@ -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: >

<<URL#,Description>>

==============================================================================
LISTS *wiki-lists*

Expand Down
3 changes: 2 additions & 1 deletion plugin/wiki.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down