2018-04-20 07:03:53 +02:00
|
|
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
2010-01-20 01:00:00 +01:00
|
|
|
" Vimwiki filetype plugin file
|
2015-02-23 12:10:42 +01:00
|
|
|
" Home: https://github.com/vimwiki/vimwiki/
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
|
|
|
|
" Cause: load only onces per buffer
|
2019-12-21 04:41:03 +01:00
|
|
|
if exists('b:did_ftplugin')
|
2010-01-20 01:00:00 +01:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
|
2013-07-18 07:55:24 +02:00
|
|
|
|
2019-12-21 04:41:03 +01:00
|
|
|
if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel')
|
2016-12-21 19:43:34 +01:00
|
|
|
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
|
2010-08-24 02:00:00 +02:00
|
|
|
endif
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
" This is for GOTO FILE: gf
|
2016-12-22 21:00:19 +01:00
|
|
|
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
|
2010-01-20 01:00:00 +01:00
|
|
|
setlocal isfname-=[,]
|
|
|
|
|
2019-12-21 04:41:03 +01:00
|
|
|
exe 'setlocal tags+=' . escape(vimwiki#tags#metadata_file_path(), ' \|"')
|
2015-01-09 23:44:25 +01:00
|
|
|
|
2014-02-13 12:42:24 +01:00
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Help for omnicompletion
|
2019-12-21 04:41:03 +01:00
|
|
|
function! Complete_wikifiles(findstart, base) abort
|
2020-08-08 10:02:15 +02:00
|
|
|
" s:line_context = link | tag | ''
|
2014-02-13 12:42:24 +01:00
|
|
|
if a:findstart == 1
|
2020-08-08 10:02:15 +02:00
|
|
|
" Find line context
|
|
|
|
" Called: first time
|
2015-02-09 21:56:28 +01:00
|
|
|
let column = col('.')-2
|
2014-02-13 12:42:24 +01:00
|
|
|
let line = getline('.')[:column]
|
2020-08-08 10:02:15 +02:00
|
|
|
|
|
|
|
" Check Link:
|
|
|
|
" -- WikiLink
|
2015-02-09 21:56:28 +01:00
|
|
|
let startoflink = match(line, '\[\[\zs[^\\[\]]*$')
|
2014-02-13 12:42:24 +01:00
|
|
|
if startoflink != -1
|
2020-08-08 10:02:15 +02:00
|
|
|
let s:line_context = 'link'
|
2014-02-13 12:42:24 +01:00
|
|
|
return startoflink
|
|
|
|
endif
|
2020-08-08 10:02:15 +02:00
|
|
|
" -- WebLink
|
2016-12-23 20:05:53 +01:00
|
|
|
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
|
2015-02-09 21:56:28 +01:00
|
|
|
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
|
2014-02-13 12:42:24 +01:00
|
|
|
if startofinlinelink != -1
|
2020-08-08 10:02:15 +02:00
|
|
|
let s:line_context = 'link'
|
2014-02-13 12:42:24 +01:00
|
|
|
return startofinlinelink
|
|
|
|
endif
|
|
|
|
endif
|
2020-08-08 10:02:15 +02:00
|
|
|
|
|
|
|
" Check Tag:
|
|
|
|
let tf = vimwiki#vars#get_syntaxlocal('tag_format')
|
|
|
|
let startoftag = match(line, tf.pre_mark . '\zs' . tf.in . '*$')
|
2015-01-04 23:29:42 +01:00
|
|
|
if startoftag != -1
|
2020-08-08 10:02:15 +02:00
|
|
|
let s:line_context = 'tag'
|
2015-01-04 23:29:42 +01:00
|
|
|
return startoftag
|
|
|
|
endif
|
2020-08-08 10:02:15 +02:00
|
|
|
|
|
|
|
" Nothing can do ...
|
2015-02-09 21:40:17 +01:00
|
|
|
let s:line_context = ''
|
2014-02-13 12:42:24 +01:00
|
|
|
return -1
|
|
|
|
else
|
2015-02-09 21:40:17 +01:00
|
|
|
" Completion works for wikilinks/anchors, and for tags. s:line_content
|
2018-04-17 07:13:37 +02:00
|
|
|
" tells us which string came before a:base. There seems to be no easier
|
2015-02-09 21:40:17 +01:00
|
|
|
" solution, because calling col('.') here returns garbage.
|
2019-12-21 04:41:03 +01:00
|
|
|
if s:line_context ==? ''
|
2015-02-09 21:40:17 +01:00
|
|
|
return []
|
2020-08-08 10:02:15 +02:00
|
|
|
elseif s:line_context ==# 'tag'
|
|
|
|
" Look Tags: completion
|
2015-06-10 22:00:07 +02:00
|
|
|
let tags = vimwiki#tags#get_tags()
|
2019-12-21 04:41:03 +01:00
|
|
|
if a:base !=? ''
|
2015-02-04 22:05:04 +01:00
|
|
|
call filter(tags,
|
2019-12-21 04:41:03 +01:00
|
|
|
\ 'v:val[:' . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
|
2015-02-04 22:05:04 +01:00
|
|
|
endif
|
2015-01-04 23:29:42 +01:00
|
|
|
return tags
|
2015-02-12 20:20:16 +01:00
|
|
|
elseif a:base !~# '#'
|
2020-08-08 10:02:15 +02:00
|
|
|
" Look Wiki: files
|
2018-11-05 22:36:25 +01:00
|
|
|
if a:base =~# '\m^wiki\d\+:'
|
|
|
|
let wikinumber = eval(matchstr(a:base, '\m^wiki\zs\d\+'))
|
2016-12-28 22:17:08 +01:00
|
|
|
if wikinumber >= vimwiki#vars#number_of_wikis()
|
2014-09-16 10:18:40 +02:00
|
|
|
return []
|
|
|
|
endif
|
2018-11-05 22:36:25 +01:00
|
|
|
let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*')
|
|
|
|
let scheme = matchstr(a:base, '\m^wiki\d\+:\ze')
|
2014-02-13 12:42:24 +01:00
|
|
|
elseif a:base =~# '^diary:'
|
2014-12-04 21:18:58 +01:00
|
|
|
let wikinumber = -1
|
2014-02-13 12:42:24 +01:00
|
|
|
let prefix = matchstr(a:base, '^diary:\zs.*')
|
|
|
|
let scheme = matchstr(a:base, '^diary:\ze')
|
2014-09-16 10:18:40 +02:00
|
|
|
else " current wiki
|
2017-01-07 21:51:15 +01:00
|
|
|
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
|
2014-02-13 12:42:24 +01:00
|
|
|
let prefix = a:base
|
|
|
|
let scheme = ''
|
|
|
|
endif
|
|
|
|
|
2020-05-26 20:05:42 +02:00
|
|
|
let links = vimwiki#base#get_wikilinks(wikinumber, 1, '')
|
2014-02-13 12:42:24 +01:00
|
|
|
let result = []
|
2014-12-04 21:18:58 +01:00
|
|
|
for wikifile in links
|
|
|
|
if wikifile =~ '^'.vimwiki#u#escape(prefix)
|
|
|
|
call add(result, scheme . wikifile)
|
2014-02-13 12:42:24 +01:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
return result
|
|
|
|
|
|
|
|
else
|
2020-08-08 10:02:15 +02:00
|
|
|
" Look Anchor: in the given wikifile
|
2014-02-13 12:42:24 +01:00
|
|
|
|
|
|
|
let segments = split(a:base, '#', 1)
|
2019-12-21 04:41:03 +01:00
|
|
|
let given_wikifile = segments[0] ==? '' ? expand('%:t:r') : segments[0]
|
2015-03-13 16:31:15 +01:00
|
|
|
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
|
|
|
|
let wikifile = link_infos.filename
|
2016-12-23 20:05:53 +01:00
|
|
|
let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index)
|
2014-08-14 13:08:24 +02:00
|
|
|
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
|
2014-02-13 12:42:24 +01:00
|
|
|
|
|
|
|
let filtered_anchors = []
|
|
|
|
let given_anchor = join(segments[1:], '#')
|
|
|
|
for anchor in anchors
|
2014-08-14 13:08:24 +02:00
|
|
|
if anchor =~# '^'.vimwiki#u#escape(given_anchor)
|
2014-02-13 12:42:24 +01:00
|
|
|
call add(filtered_anchors, segments[0].'#'.anchor)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
return filtered_anchors
|
2014-08-14 13:08:24 +02:00
|
|
|
|
2014-02-13 12:42:24 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2020-08-07 08:29:47 +02:00
|
|
|
" Set completion
|
2014-12-04 21:18:58 +01:00
|
|
|
setlocal omnifunc=Complete_wikifiles
|
2020-08-07 08:29:47 +02:00
|
|
|
if and(vimwiki#vars#get_global('emoji_enable'), 2) != 0
|
|
|
|
\ && &completefunc ==# ''
|
|
|
|
set completefunc=vimwiki#emoji#complete
|
|
|
|
endif
|
2014-02-13 12:42:24 +01:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Declare settings necessary for the automatic formatting of lists
|
2020-07-26 23:55:47 +02:00
|
|
|
" ------------------------------------------------
|
2013-07-08 11:37:35 +02:00
|
|
|
setlocal autoindent
|
|
|
|
setlocal nosmartindent
|
|
|
|
setlocal nocindent
|
2020-07-26 23:55:47 +02:00
|
|
|
|
|
|
|
" Set comments: to insert and format 'comments' or cheat
|
|
|
|
" Used to break blockquote prepending one on each new line (see: #915)
|
2020-08-09 22:14:31 +02:00
|
|
|
" B like blank character follow
|
|
|
|
" blockquotes
|
|
|
|
let comments = 'b:>'
|
|
|
|
for bullet in vimwiki#vars#get_syntaxlocal('bullet_types')
|
|
|
|
" task list
|
|
|
|
for point in vimwiki#vars#get_wikilocal('listsyms_list')
|
|
|
|
\ + [vimwiki#vars#get_wikilocal('listsym_rejected')]
|
|
|
|
let comments .= ',b:' . bullet . ' [' . point . ']'
|
|
|
|
endfor
|
|
|
|
" list
|
|
|
|
let comments .= ',b:' . bullet
|
|
|
|
endfor
|
|
|
|
let &l:comments = comments
|
2020-07-26 23:55:47 +02:00
|
|
|
|
|
|
|
" Set format options (:h fo-table)
|
2020-08-09 22:14:31 +02:00
|
|
|
" Disable autocomment because, vimwiki does it better
|
2013-07-08 11:37:35 +02:00
|
|
|
setlocal formatoptions-=c
|
|
|
|
setlocal formatoptions-=r
|
|
|
|
setlocal formatoptions-=o
|
|
|
|
setlocal formatoptions-=2
|
|
|
|
setlocal formatoptions+=n
|
2020-08-22 18:40:54 +02:00
|
|
|
" Used to join 'commented' lines (blockquote, list) (see: #915)
|
2020-07-26 23:55:47 +02:00
|
|
|
if v:version > 703
|
|
|
|
setlocal formatoptions+=j
|
|
|
|
endif
|
2013-07-08 11:37:35 +02:00
|
|
|
|
2020-07-31 00:07:50 +02:00
|
|
|
" Set commentstring %%%s
|
|
|
|
let &l:commentstring = vimwiki#vars#get_wikilocal('commentstring')
|
|
|
|
|
|
|
|
|
2020-06-04 18:33:12 +02:00
|
|
|
let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem')
|
2013-07-08 11:37:35 +02:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
|
|
|
" ------------------------------------------------
|
|
|
|
" Folding stuff
|
|
|
|
" ------------------------------------------------
|
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Get fold level for a list
|
2019-12-21 04:41:03 +01:00
|
|
|
function! VimwikiFoldListLevel(lnum) abort
|
2013-07-24 09:09:41 +02:00
|
|
|
return vimwiki#lst#fold_level(a:lnum)
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
|
|
|
|
2013-04-19 05:46:58 +02:00
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Get fold level for 1. line number
|
2019-12-21 04:41:03 +01:00
|
|
|
function! VimwikiFoldLevel(lnum) abort
|
2013-04-19 05:46:58 +02:00
|
|
|
let line = getline(a:lnum)
|
|
|
|
|
|
|
|
" Header/section folding...
|
2019-10-17 06:31:42 +02:00
|
|
|
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader') && !vimwiki#u#is_codeblock(a:lnum)
|
2013-04-19 05:46:58 +02:00
|
|
|
return '>'.vimwiki#u#count_first_sym(line)
|
|
|
|
" Code block folding...
|
2017-01-07 21:51:15 +01:00
|
|
|
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
2013-04-19 05:46:58 +02:00
|
|
|
return 'a1'
|
2017-01-07 21:51:15 +01:00
|
|
|
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
|
2013-04-19 05:46:58 +02:00
|
|
|
return 's1'
|
|
|
|
else
|
2019-12-21 04:41:03 +01:00
|
|
|
return '='
|
2013-04-19 05:46:58 +02:00
|
|
|
endif
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2013-04-19 05:46:58 +02:00
|
|
|
|
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Declare constants used by VimwikiFoldText
|
2013-04-19 05:46:58 +02:00
|
|
|
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
|
2019-12-21 04:41:03 +01:00
|
|
|
let s:ellipsis = (&encoding ==? 'utf-8') ? "\u2026" : '...'
|
2013-04-19 05:46:58 +02:00
|
|
|
let s:ell_len = strlen(s:ellipsis)
|
2019-12-21 04:41:03 +01:00
|
|
|
let s:newline = (&encoding ==? 'utf-8') ? "\u21b2 " : ' '
|
2013-04-19 05:46:58 +02:00
|
|
|
let s:tolerance = 5
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" unused: too naive
|
2019-12-21 04:41:03 +01:00
|
|
|
function! s:shorten_text_simple(text, len) abort
|
2013-04-19 05:46:58 +02:00
|
|
|
let spare_len = a:len - len(a:text)
|
|
|
|
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
|
|
|
|
2013-04-19 05:46:58 +02:00
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Shorten text
|
|
|
|
" Called: by VimwikiFoldText
|
2013-04-19 05:46:58 +02:00
|
|
|
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
|
|
|
|
" for long enough "text", the string's length is within s:tolerance of "len"
|
|
|
|
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
|
2020-06-04 23:29:26 +02:00
|
|
|
" Return: [string, spare]
|
2019-12-21 04:41:03 +01:00
|
|
|
function! s:shorten_text(text, len) abort
|
2015-07-07 21:54:57 +02:00
|
|
|
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
|
|
|
|
" trick here -- replace all non-spaces with dot, calculate lengths and
|
|
|
|
" indexes on it, then use original string to break at selected index.
|
|
|
|
let text_pattern = substitute(a:text, '\m\S', '.', 'g')
|
|
|
|
let spare_len = a:len - strlen(text_pattern)
|
2013-04-19 05:46:58 +02:00
|
|
|
if (spare_len + s:tolerance >= 0)
|
|
|
|
return [a:text, spare_len]
|
|
|
|
endif
|
|
|
|
" try to break on a space; assumes a:len-s:ell_len >= s:tolerance
|
|
|
|
let newlen = a:len - s:ell_len
|
2015-07-07 21:54:57 +02:00
|
|
|
let idx = strridx(text_pattern, ' ', newlen + s:tolerance)
|
2013-04-19 05:46:58 +02:00
|
|
|
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
|
2018-04-20 07:03:53 +02:00
|
|
|
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis, newlen - break_idx]
|
|
|
|
endfunction
|
2013-04-19 05:46:58 +02:00
|
|
|
|
|
|
|
|
2020-06-04 23:29:26 +02:00
|
|
|
" Fold text chapter
|
2019-12-21 04:41:03 +01:00
|
|
|
function! VimwikiFoldText() abort
|
2013-04-19 05:46:58 +02:00
|
|
|
let line = getline(v:foldstart)
|
|
|
|
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
|
|
|
let fold_len = v:foldend - v:foldstart + 1
|
|
|
|
let len_text = ' ['.fold_len.'] '
|
2017-01-07 21:51:15 +01:00
|
|
|
if line !~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
2013-04-19 05:46:58 +02:00
|
|
|
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
|
|
|
return main_text.len_text
|
|
|
|
else
|
|
|
|
" fold-text for code blocks: use one or two of the starting lines
|
|
|
|
let [main_text, spare_len] = s:shorten_text(main_text, 24)
|
|
|
|
let line1 = substitute(getline(v:foldstart+1), '^\s*', ' ', '')
|
|
|
|
let [content_text, spare_len] = s:shorten_text(line1, spare_len+20)
|
|
|
|
if spare_len > s:tolerance && fold_len > 3
|
|
|
|
let line2 = substitute(getline(v:foldstart+2), '^\s*', s:newline, '')
|
|
|
|
let [more_text, spare_len] = s:shorten_text(line2, spare_len+12)
|
|
|
|
let content_text .= more_text
|
|
|
|
endif
|
|
|
|
return main_text.len_text.content_text
|
|
|
|
endif
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
|
|
|
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
" ------------------------------------------------
|
|
|
|
" Commands
|
|
|
|
" ------------------------------------------------
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
command! -buffer Vimwiki2HTML
|
2014-10-23 12:18:28 +02:00
|
|
|
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
|
|
|
\ <bar>
|
2020-08-09 22:06:35 +02:00
|
|
|
\ let res = vimwiki#html#Wiki2HTML(
|
|
|
|
\ expand(vimwiki#vars#get_wikilocal('path_html')), expand('%'))
|
2014-10-23 12:18:28 +02:00
|
|
|
\ <bar>
|
2020-08-09 22:06:35 +02:00
|
|
|
\ if res != '' | call vimwiki#u#echo('HTML conversion is done, output: '
|
|
|
|
\ . expand(vimwiki#vars#get_wikilocal('path_html'))) | endif
|
|
|
|
|
2011-06-11 02:00:00 +02:00
|
|
|
command! -buffer Vimwiki2HTMLBrowse
|
2014-10-23 12:18:28 +02:00
|
|
|
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
|
|
|
\ <bar>
|
2012-06-07 02:00:00 +02:00
|
|
|
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
|
2016-12-22 19:55:20 +01:00
|
|
|
\ expand(vimwiki#vars#get_wikilocal('path_html')),
|
2012-06-07 02:00:00 +02:00
|
|
|
\ expand('%')))
|
2020-08-09 22:06:35 +02:00
|
|
|
|
2019-05-20 16:22:15 +02:00
|
|
|
command! -buffer -bang VimwikiAll2HTML
|
|
|
|
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')), <bang>0)
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2020-07-05 17:54:46 +02:00
|
|
|
command! -buffer VimwikiRss call vimwiki#html#diary_rss()
|
|
|
|
|
2014-02-18 14:47:42 +01:00
|
|
|
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
|
2014-02-13 12:42:24 +01:00
|
|
|
|
2019-02-28 04:45:39 +01:00
|
|
|
command! -buffer VimwikiNextTask call vimwiki#base#find_next_task()
|
2011-06-11 02:00:00 +02:00
|
|
|
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
|
|
|
|
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
|
2020-05-24 23:49:28 +02:00
|
|
|
command! -buffer VimwikiDeleteFile call vimwiki#base#delete_link()
|
|
|
|
command! -buffer VimwikiDeleteLink
|
|
|
|
\ call vimwiki#base#deprecate("VimwikiDeleteLink", "VimwikiDeleteFile") |
|
|
|
|
\ call vimwiki#base#delete_link()
|
2020-07-29 06:37:44 +02:00
|
|
|
command! -buffer -nargs=? -complete=customlist,vimwiki#base#complete_file
|
|
|
|
\ VimwikiRenameFile call vimwiki#base#rename_link(<f-args>)
|
2020-05-24 23:49:28 +02:00
|
|
|
command! -buffer VimwikiRenameLink
|
|
|
|
\ call vimwiki#base#deprecate("VimwikiRenameLink", "VimwikiRenameFile") |
|
|
|
|
\ call vimwiki#base#rename_link()
|
2018-02-16 17:47:32 +01:00
|
|
|
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1)
|
2011-06-11 02:00:00 +02:00
|
|
|
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
|
2018-06-26 21:38:55 +02:00
|
|
|
command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', <f-args>)
|
|
|
|
command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', <f-args>)
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
|
|
|
|
|
2018-02-16 17:47:32 +01:00
|
|
|
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tab', 0, 1)
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2020-05-17 19:14:08 +02:00
|
|
|
command! -buffer -nargs=? VimwikiGenerateLinks call vimwiki#base#generate_links(1, <f-args>)
|
2011-06-11 02:00:00 +02:00
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
|
|
|
|
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
|
|
|
|
|
2019-10-13 00:31:43 +02:00
|
|
|
command! -buffer -nargs=* VimwikiSearch call vimwiki#base#search(<q-args>)
|
|
|
|
command! -buffer -nargs=* VWS call vimwiki#base#search(<q-args>)
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2019-12-11 20:27:41 +01:00
|
|
|
command! -buffer -nargs=* -complete=customlist,vimwiki#base#complete_links_escaped
|
2014-11-06 22:02:37 +01:00
|
|
|
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
|
2010-08-24 02:00:00 +02:00
|
|
|
|
2020-08-08 10:01:31 +02:00
|
|
|
command! -buffer -range VimwikiCheckLinks call vimwiki#base#check_links(<range>, <line1>, <line2>)
|
2012-06-07 02:00:00 +02:00
|
|
|
|
|
|
|
" list commands
|
2014-01-06 14:11:16 +01:00
|
|
|
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
|
2018-02-15 18:38:39 +01:00
|
|
|
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo
|
|
|
|
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
|
|
|
|
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI
|
|
|
|
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
|
|
|
|
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo
|
|
|
|
\ call vimwiki#lst#change_marker_in_list(<f-args>)
|
2014-02-04 10:40:14 +01:00
|
|
|
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
2018-04-20 07:03:53 +02:00
|
|
|
command! -buffer -range VimwikiToggleRejectedListItem
|
|
|
|
\ call vimwiki#lst#toggle_rejected_cb(<line1>, <line2>)
|
2018-02-17 21:05:06 +01:00
|
|
|
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
|
|
|
|
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
|
2018-02-15 18:38:39 +01:00
|
|
|
command! -buffer -range -nargs=+ VimwikiListChangeLvl
|
|
|
|
\ call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
2014-01-06 14:11:16 +01:00
|
|
|
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
|
|
|
|
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
|
|
|
|
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
|
|
|
|
command! -buffer VimwikiRenumberAllLists call vimwiki#lst#adjust_whole_buffer()
|
|
|
|
command! -buffer VimwikiListToggle call vimwiki#lst#toggle_list_item()
|
2020-06-08 14:31:35 +02:00
|
|
|
command! -buffer -range VimwikiRemoveDone call vimwiki#lst#remove_done(1, "<range>", <line1>, <line2>)
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2010-02-23 01:00:00 +01:00
|
|
|
" table commands
|
2011-06-11 02:00:00 +02:00
|
|
|
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
|
2014-05-09 10:47:21 +02:00
|
|
|
command! -buffer -nargs=? VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq', <f-args>)
|
|
|
|
command! -buffer -nargs=? VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww', <f-args>)
|
2011-06-11 02:00:00 +02:00
|
|
|
command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left()
|
|
|
|
command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right()
|
2010-02-23 01:00:00 +01:00
|
|
|
|
2010-08-24 02:00:00 +02:00
|
|
|
" diary commands
|
2011-06-11 02:00:00 +02:00
|
|
|
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
|
|
|
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
2010-08-24 02:00:00 +02:00
|
|
|
|
2015-01-06 20:30:28 +01:00
|
|
|
" tags commands
|
2018-04-20 07:03:53 +02:00
|
|
|
command! -buffer -bang VimwikiRebuildTags call vimwiki#tags#update_tags(1, '<bang>')
|
2015-02-23 11:29:02 +01:00
|
|
|
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
2015-01-06 20:44:41 +01:00
|
|
|
\ VimwikiSearchTags VimwikiSearch /:<args>:/
|
2015-02-23 11:29:02 +01:00
|
|
|
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
2020-01-03 04:53:48 +01:00
|
|
|
\ VimwikiGenerateTagLinks call vimwiki#tags#generate_tags(1, <f-args>)
|
2020-05-24 23:49:28 +02:00
|
|
|
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
|
|
|
\ VimwikiGenerateTags
|
|
|
|
\ call vimwiki#base#deprecate("VimwikiGenerateTags", "VimwikiGenerateTagLinks") |
|
|
|
|
\ call vimwiki#tags#generate_tags(1, <f-args>)
|
2015-01-06 20:30:28 +01:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
|
|
|
|
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
|
|
|
|
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
" ------------------------------------------------
|
|
|
|
" Keybindings
|
|
|
|
" ------------------------------------------------
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
" mouse mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').mouse)
|
2010-01-20 01:00:00 +01:00
|
|
|
nmap <buffer> <S-LeftMouse> <NOP>
|
|
|
|
nmap <buffer> <C-LeftMouse> <NOP>
|
2018-04-20 07:03:53 +02:00
|
|
|
nnoremap <silent><buffer> <2-LeftMouse>
|
|
|
|
\ :call vimwiki#base#follow_link('nosplit', 0, 1, "\<lt>2-LeftMouse>")<CR>
|
2011-06-11 02:00:00 +02:00
|
|
|
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
|
|
|
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
|
|
|
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
|
|
|
endif
|
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
" <Plug> HTML definitions
|
2018-04-20 07:03:53 +02:00
|
|
|
nnoremap <script><buffer> <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
|
|
|
nnoremap <script><buffer> <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
" default HTML key mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').html)
|
|
|
|
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'h', '<Plug>Vimwiki2HTML')
|
|
|
|
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'hh', '<Plug>Vimwiki2HTMLBrowse')
|
|
|
|
endif
|
|
|
|
|
|
|
|
" <Plug> links definitions
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiFollowLink
|
|
|
|
\ :VimwikiFollowLink<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiSplitLink
|
|
|
|
\ :VimwikiSplitLink<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiVSplitLink
|
|
|
|
\ :VimwikiVSplitLink<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLink
|
|
|
|
\ :VimwikiNormalizeLink 0<CR>
|
|
|
|
vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisual
|
|
|
|
\ :<C-U>VimwikiNormalizeLink 1<CR>
|
|
|
|
vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisualCR
|
|
|
|
\ :<C-U>VimwikiNormalizeLink 1<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiTabnewLink
|
|
|
|
\ :VimwikiTabnewLink<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiGoBackLink
|
|
|
|
\ :VimwikiGoBackLink<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiNextLink
|
|
|
|
\ :VimwikiNextLink<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiPrevLink
|
|
|
|
\ :VimwikiPrevLink<CR>
|
2019-04-16 01:35:44 +02:00
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiGoto
|
|
|
|
\ :VimwikiGoto<CR>
|
2020-05-24 23:49:28 +02:00
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiDeleteFile
|
|
|
|
\ :VimwikiDeleteFile<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiRenameFile
|
|
|
|
\ :VimwikiRenameFile<CR>
|
2019-04-27 05:17:35 +02:00
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryNextDay
|
|
|
|
\ :VimwikiDiaryNextDay<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryPrevDay
|
|
|
|
\ :VimwikiDiaryPrevDay<CR>
|
|
|
|
|
|
|
|
" default links key mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').links)
|
|
|
|
call vimwiki#u#map_key('n', '<CR>', '<Plug>VimwikiFollowLink')
|
|
|
|
call vimwiki#u#map_key('n', '<S-CR>', '<Plug>VimwikiSplitLink')
|
|
|
|
call vimwiki#u#map_key('n', '<C-CR>', '<Plug>VimwikiVSplitLink')
|
|
|
|
call vimwiki#u#map_key('n', '+', '<Plug>VimwikiNormalizeLink')
|
|
|
|
call vimwiki#u#map_key('v', '+', '<Plug>VimwikiNormalizeLinkVisual')
|
|
|
|
call vimwiki#u#map_key('v', '<CR>', '<Plug>VimwikiNormalizeLinkVisualCR')
|
|
|
|
call vimwiki#u#map_key('n', '<D-CR>', '<Plug>VimwikiTabnewLink')
|
|
|
|
call vimwiki#u#map_key('n', '<C-S-CR>', '<Plug>VimwikiTabnewLink', 1)
|
|
|
|
call vimwiki#u#map_key('n', '<BS>', '<Plug>VimwikiGoBackLink')
|
|
|
|
call vimwiki#u#map_key('n', '<TAB>', '<Plug>VimwikiNextLink')
|
|
|
|
call vimwiki#u#map_key('n', '<S-TAB>', '<Plug>VimwikiPrevLink')
|
2019-04-16 01:35:44 +02:00
|
|
|
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'n', '<Plug>VimwikiGoto')
|
2020-05-24 23:49:28 +02:00
|
|
|
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'d', '<Plug>VimwikiDeleteFile')
|
|
|
|
call vimwiki#u#map_key('n', vimwiki#vars#get_global('map_prefix').'r', '<Plug>VimwikiRenameFile')
|
2019-04-27 05:17:35 +02:00
|
|
|
call vimwiki#u#map_key('n', '<C-Down>', '<Plug>VimwikiDiaryNextDay')
|
|
|
|
call vimwiki#u#map_key('n', '<C-Up>', '<Plug>VimwikiDiaryPrevDay')
|
|
|
|
endif
|
|
|
|
|
|
|
|
" <Plug> lists definitions
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiNextTask
|
|
|
|
\ :VimwikiNextTask<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem
|
|
|
|
\ :VimwikiToggleListItem<CR>
|
|
|
|
vnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem
|
|
|
|
\ :VimwikiToggleListItem<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiToggleRejectedListItem
|
|
|
|
\ :VimwikiToggleRejectedListItem<CR>
|
|
|
|
vnoremap <silent><script><buffer> <Plug>VimwikiToggleRejectedListItem
|
|
|
|
\ :VimwikiToggleRejectedListItem<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem
|
|
|
|
\ :VimwikiIncrementListItem<CR>
|
|
|
|
vnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem
|
|
|
|
\ :VimwikiIncrementListItem<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem
|
|
|
|
\ :VimwikiDecrementListItem<CR>
|
|
|
|
vnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem
|
|
|
|
\ :VimwikiDecrementListItem<CR>
|
2014-01-06 14:11:16 +01:00
|
|
|
inoremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
|
|
|
|
\ <C-O>:VimwikiListChangeLvl decrease 0<CR>
|
|
|
|
inoremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
|
|
|
|
\ <C-O>:VimwikiListChangeLvl increase 0<CR>
|
|
|
|
inoremap <silent><script><buffer> <Plug>VimwikiListNextSymbol
|
2019-04-27 05:17:35 +02:00
|
|
|
\ <C-O>:VimwikiListChangeSymbolI next<CR>
|
2014-01-06 14:11:16 +01:00
|
|
|
inoremap <silent><script><buffer> <Plug>VimwikiListPrevSymbol
|
2019-04-27 05:17:35 +02:00
|
|
|
\ <C-O>:VimwikiListChangeSymbolI prev<CR>
|
|
|
|
inoremap <silent><script><buffer> <Plug>VimwikiListToggle
|
|
|
|
\ <Esc>:VimwikiListToggle<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiRenumberList
|
|
|
|
\ :VimwikiRenumberList<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiRenumberAllLists
|
|
|
|
\ :VimwikiRenumberAllLists<CR>
|
|
|
|
noremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
|
|
|
|
\ :VimwikiListChangeLvl decrease 0<CR>
|
|
|
|
noremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
|
|
|
|
\ :VimwikiListChangeLvl increase 0<CR>
|
|
|
|
noremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlWholeItem
|
|
|
|
\ :VimwikiListChangeLvl decrease 1<CR>
|
|
|
|
noremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlWholeItem
|
|
|
|
\ :VimwikiListChangeLvl increase 1<CR>
|
|
|
|
noremap <silent><script><buffer> <Plug>VimwikiRemoveSingleCB
|
|
|
|
\ :VimwikiRemoveSingleCB<CR>
|
|
|
|
noremap <silent><script><buffer> <Plug>VimwikiRemoveCBInList
|
|
|
|
\ :VimwikiRemoveCBInList<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiListo
|
2020-05-17 20:07:16 +02:00
|
|
|
\ :<C-U>call vimwiki#u#count_exe('call vimwiki#lst#kbd_o()')<CR>
|
2019-04-27 05:17:35 +02:00
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiListO
|
2020-05-17 20:07:16 +02:00
|
|
|
\ :<C-U>call vimwiki#u#count_exe('call vimwiki#lst#kbd_O()')<CR>
|
2019-04-27 05:17:35 +02:00
|
|
|
|
|
|
|
" default lists key mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').lists)
|
|
|
|
call vimwiki#u#map_key('n', 'gnt', '<Plug>VimwikiNextTask')
|
|
|
|
call vimwiki#u#map_key('n', '<C-Space>', '<Plug>VimwikiToggleListItem')
|
|
|
|
call vimwiki#u#map_key('v', '<C-Space>', '<Plug>VimwikiToggleListItem', 1)
|
|
|
|
if has('unix')
|
|
|
|
call vimwiki#u#map_key('n', '<C-@>', '<Plug>VimwikiToggleListItem', 1)
|
|
|
|
call vimwiki#u#map_key('v', '<C-@>', '<Plug>VimwikiToggleListItem', 1)
|
2014-01-06 14:11:16 +01:00
|
|
|
endif
|
2019-04-27 05:17:35 +02:00
|
|
|
call vimwiki#u#map_key('n', 'glx', '<Plug>VimwikiToggleRejectedListItem')
|
|
|
|
call vimwiki#u#map_key('v', 'glx', '<Plug>VimwikiToggleRejectedListItem', 1)
|
|
|
|
call vimwiki#u#map_key('n', 'gln', '<Plug>VimwikiIncrementListItem')
|
|
|
|
call vimwiki#u#map_key('v', 'gln', '<Plug>VimwikiIncrementListItem', 1)
|
|
|
|
call vimwiki#u#map_key('n', 'glp', '<Plug>VimwikiDecrementListItem')
|
|
|
|
call vimwiki#u#map_key('v', 'glp', '<Plug>VimwikiDecrementListItem', 1)
|
|
|
|
call vimwiki#u#map_key('i', '<C-D>', '<Plug>VimwikiDecreaseLvlSingleItem')
|
|
|
|
call vimwiki#u#map_key('i', '<C-T>', '<Plug>VimwikiIncreaseLvlSingleItem')
|
|
|
|
call vimwiki#u#map_key('n', 'glh', '<Plug>VimwikiDecreaseLvlSingleItem', 1)
|
|
|
|
call vimwiki#u#map_key('n', 'gll', '<Plug>VimwikiIncreaseLvlSingleItem', 1)
|
|
|
|
call vimwiki#u#map_key('n', 'gLh', '<Plug>VimwikiDecreaseLvlWholeItem')
|
|
|
|
call vimwiki#u#map_key('n', 'gLH', '<Plug>VimwikiDecreaseLvlWholeItem', 1)
|
|
|
|
call vimwiki#u#map_key('n', 'gLl', '<Plug>VimwikiIncreaseLvlWholeItem')
|
|
|
|
call vimwiki#u#map_key('n', 'gLL', '<Plug>VimwikiIncreaseLvlWholeItem', 1)
|
|
|
|
call vimwiki#u#map_key('i', '<C-L><C-J>', '<Plug>VimwikiListNextSymbol')
|
|
|
|
call vimwiki#u#map_key('i', '<C-L><C-K>', '<Plug>VimwikiListPrevSymbol')
|
|
|
|
call vimwiki#u#map_key('i', '<C-L><C-M>', '<Plug>VimwikiListToggle')
|
|
|
|
call vimwiki#u#map_key('n', 'glr', '<Plug>VimwikiRenumberList')
|
|
|
|
call vimwiki#u#map_key('n', 'gLr', '<Plug>VimwikiRenumberAllLists')
|
|
|
|
call vimwiki#u#map_key('n', 'gLR', '<Plug>VimwikiRenumberAllLists', 1)
|
|
|
|
call vimwiki#u#map_key('n', 'gl', '<Plug>VimwikiRemoveSingleCB')
|
|
|
|
call vimwiki#u#map_key('n', 'gL', '<Plug>VimwikiRemoveCBInList')
|
|
|
|
call vimwiki#u#map_key('n', 'o', '<Plug>VimwikiListo')
|
|
|
|
call vimwiki#u#map_key('n', 'O', '<Plug>VimwikiListO')
|
2019-08-11 15:13:01 +02:00
|
|
|
|
2020-08-05 18:05:39 +02:00
|
|
|
" Handle case of existing VimwikiReturn mappings outside the <Plug> definition
|
|
|
|
" Note: Avoid interfering with popup/completion menu if it's active (#813)
|
2019-08-11 15:13:01 +02:00
|
|
|
if maparg('<CR>', 'i') !~# '.*VimwikiReturn*.'
|
|
|
|
if has('patch-7.3.489')
|
|
|
|
" expand iabbrev on enter
|
2020-08-05 18:05:39 +02:00
|
|
|
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<C-]><Esc>:VimwikiReturn 1 5<CR>'
|
2019-08-11 15:13:01 +02:00
|
|
|
else
|
2020-08-05 18:05:39 +02:00
|
|
|
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 1 5<CR>'
|
2019-08-11 15:13:01 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
if maparg('<S-CR>', 'i') !~# '.*VimwikiReturn*.'
|
2020-08-05 18:05:39 +02:00
|
|
|
inoremap <expr><silent><buffer> <S-CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 2 2<CR>'
|
2019-08-11 15:13:01 +02:00
|
|
|
endif
|
2019-04-27 05:17:35 +02:00
|
|
|
|
|
|
|
" change symbol for bulleted lists
|
|
|
|
for s:char in vimwiki#vars#get_syntaxlocal('bullet_types')
|
2019-05-25 04:41:12 +02:00
|
|
|
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
|
2019-04-27 05:17:35 +02:00
|
|
|
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
|
|
|
|
endif
|
2019-05-25 04:41:12 +02:00
|
|
|
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'<CR>')
|
2019-04-27 05:17:35 +02:00
|
|
|
exe 'noremap <silent><buffer> gL'.s:char.' :VimwikiChangeSymbolInListTo '.s:char.'<CR>'
|
|
|
|
endif
|
|
|
|
endfor
|
2014-07-30 21:26:07 +02:00
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
" change symbol for numbered lists
|
|
|
|
for s:typ in vimwiki#vars#get_syntaxlocal('number_types')
|
2019-05-25 04:41:12 +02:00
|
|
|
if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'<CR>')
|
2019-04-27 05:17:35 +02:00
|
|
|
exe 'noremap <silent><buffer> gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'<CR>'
|
|
|
|
endif
|
2019-05-25 04:41:12 +02:00
|
|
|
if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'<CR>')
|
2019-04-27 05:17:35 +02:00
|
|
|
exe 'noremap <silent><buffer> gL'.s:typ[0].' :VimwikiChangeSymbolInListTo '.s:typ.'<CR>'
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
" insert items in a list using langmap characters (see :h langmap)
|
|
|
|
if !empty(&langmap)
|
|
|
|
" Valid only if langmap is a comma separated pairs of chars
|
|
|
|
let s:l_o = matchstr(&langmap, '\C,\zs.\zeo,')
|
|
|
|
if s:l_o
|
2019-05-25 04:41:12 +02:00
|
|
|
exe 'nnoremap <silent><buffer> '.s:l_o.' :call vimwiki#lst#kbd_o()<CR>a'
|
2019-04-27 05:17:35 +02:00
|
|
|
endif
|
2014-01-06 14:11:16 +01:00
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
let s:l_O = matchstr(&langmap, '\C,\zs.\zeO,')
|
|
|
|
if s:l_O
|
2019-05-25 04:41:12 +02:00
|
|
|
exe 'nnoremap <silent><buffer> '.s:l_O.' :call vimwiki#lst#kbd_O()<CR>a'
|
2019-04-27 05:17:35 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2014-01-06 14:11:16 +01:00
|
|
|
|
2019-12-21 04:41:03 +01:00
|
|
|
function! s:CR(normal, just_mrkr) abort
|
2019-08-11 15:13:01 +02:00
|
|
|
let res = vimwiki#tbl#kbd_cr()
|
2019-12-21 04:41:03 +01:00
|
|
|
if res !=? ''
|
|
|
|
exe 'normal! ' . res . "\<Right>"
|
2019-08-11 15:13:01 +02:00
|
|
|
startinsert
|
|
|
|
return
|
2010-08-24 02:00:00 +02:00
|
|
|
endif
|
2013-07-08 11:37:35 +02:00
|
|
|
call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr)
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2010-08-24 02:00:00 +02:00
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
" insert mode table mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').table_mappings)
|
2019-05-25 04:41:12 +02:00
|
|
|
inoremap <expr><buffer> <Tab> vimwiki#tbl#kbd_tab()
|
|
|
|
inoremap <expr><buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
|
2014-01-06 14:11:16 +01:00
|
|
|
endif
|
2013-07-08 11:37:35 +02:00
|
|
|
|
2019-04-27 05:17:35 +02:00
|
|
|
" <Plug> table formatting definitions
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiTableAlignQ
|
|
|
|
\ :VimwikiTableAlignQ<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiTableAlignQ1
|
|
|
|
\ :VimwikiTableAlignQ 2<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiTableAlignW
|
|
|
|
\ :VimwikiTableAlignW<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiTableAlignW1
|
|
|
|
\ :VimwikiTableAlignW 2<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiTableMoveColumnLeft
|
|
|
|
\ :VimwikiTableMoveColumnLeft<CR>
|
|
|
|
nnoremap <silent><script><buffer> <Plug>VimwikiTableMoveColumnRight
|
|
|
|
\ :VimwikiTableMoveColumnRight<CR>
|
|
|
|
|
|
|
|
" default table formatting key mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').table_format)
|
|
|
|
call vimwiki#u#map_key('n', 'gqq', '<Plug>VimwikiTableAlignQ')
|
|
|
|
call vimwiki#u#map_key('n', 'gq1', '<Plug>VimwikiTableAlignQ1')
|
|
|
|
call vimwiki#u#map_key('n', 'gww', '<Plug>VimwikiTableAlignW')
|
|
|
|
call vimwiki#u#map_key('n', 'gw1', '<Plug>VimwikiTableAlignW1')
|
|
|
|
call vimwiki#u#map_key('n', '<A-Left>', '<Plug>VimwikiTableMoveColumnLeft')
|
|
|
|
call vimwiki#u#map_key('n', '<A-Right>', '<Plug>VimwikiTableMoveColumnRight')
|
|
|
|
endif
|
|
|
|
|
|
|
|
" <Plug> text object definitions
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjHeader
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjHeaderContent
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(1, 0, v:count1)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderContentV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(1, 0, v:count1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSub
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(0, 1, v:count1)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSubV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(0, 1, v:count1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSubContent
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(1, 1, v:count1)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjHeaderSubContentV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_header(1, 1, v:count1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjTableCell
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_cell(0, 0)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjTableCellV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_cell(0, 1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjTableCellInner
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_cell(1, 0)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjTableCellInnerV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_cell(1, 1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjColumn
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_col(0, 0)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjColumnV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjColumnInner
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjColumnInnerV
|
|
|
|
\ :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjListChildren
|
|
|
|
\ :<C-U>call vimwiki#lst#TO_list_item(0, 0)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjListChildrenV
|
|
|
|
\ :<C-U>call vimwiki#lst#TO_list_item(0, 1)<CR>
|
|
|
|
onoremap <silent><buffer> <Plug>VimwikiTextObjListSingle
|
|
|
|
\ :<C-U>call vimwiki#lst#TO_list_item(1, 0)<CR>
|
|
|
|
vnoremap <silent><buffer> <Plug>VimwikiTextObjListSingleV
|
|
|
|
\ :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
|
|
|
|
|
|
|
|
" default text object key mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').text_objs)
|
|
|
|
call vimwiki#u#map_key('o', 'ah', '<Plug>VimwikiTextObjHeader')
|
|
|
|
call vimwiki#u#map_key('v', 'ah', '<Plug>VimwikiTextObjHeaderV')
|
|
|
|
call vimwiki#u#map_key('o', 'ih', '<Plug>VimwikiTextObjHeaderContent')
|
|
|
|
call vimwiki#u#map_key('v', 'ih', '<Plug>VimwikiTextObjHeaderContentV')
|
|
|
|
call vimwiki#u#map_key('o', 'aH', '<Plug>VimwikiTextObjHeaderSub')
|
|
|
|
call vimwiki#u#map_key('v', 'aH', '<Plug>VimwikiTextObjHeaderSubV')
|
|
|
|
call vimwiki#u#map_key('o', 'iH', '<Plug>VimwikiTextObjHeaderSubContent')
|
|
|
|
call vimwiki#u#map_key('v', 'iH', '<Plug>VimwikiTextObjHeaderSubContentV')
|
|
|
|
call vimwiki#u#map_key('o', 'a\', '<Plug>VimwikiTextObjTableCell')
|
|
|
|
call vimwiki#u#map_key('v', 'a\', '<Plug>VimwikiTextObjTableCellV')
|
|
|
|
call vimwiki#u#map_key('o', 'i\', '<Plug>VimwikiTextObjTableCellInner')
|
|
|
|
call vimwiki#u#map_key('v', 'i\', '<Plug>VimwikiTextObjTableCellInnerV')
|
|
|
|
call vimwiki#u#map_key('o', 'ac', '<Plug>VimwikiTextObjColumn')
|
|
|
|
call vimwiki#u#map_key('v', 'ac', '<Plug>VimwikiTextObjColumnV')
|
|
|
|
call vimwiki#u#map_key('o', 'ic', '<Plug>VimwikiTextObjColumnInner')
|
|
|
|
call vimwiki#u#map_key('v', 'ic', '<Plug>VimwikiTextObjColumnInnerV')
|
|
|
|
call vimwiki#u#map_key('o', 'al', '<Plug>VimwikiTextObjListChildren')
|
|
|
|
call vimwiki#u#map_key('v', 'al', '<Plug>VimwikiTextObjListChildrenV')
|
|
|
|
call vimwiki#u#map_key('o', 'il', '<Plug>VimwikiTextObjListSingle')
|
|
|
|
call vimwiki#u#map_key('v', 'il', '<Plug>VimwikiTextObjListSingleV')
|
|
|
|
endif
|
|
|
|
|
|
|
|
" <Plug> header definitions
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel
|
|
|
|
\ :<C-U>call vimwiki#base#AddHeaderLevel(v:count)<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel
|
|
|
|
\ :<C-U>call vimwiki#base#RemoveHeaderLevel(v:count)<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiGoToParentHeader
|
|
|
|
\ :<C-u>call vimwiki#base#goto_parent_header()<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiGoToNextHeader
|
|
|
|
\ :<C-u>call vimwiki#base#goto_next_header()<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevHeader
|
|
|
|
\ :<C-u>call vimwiki#base#goto_prev_header()<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiGoToNextSiblingHeader
|
|
|
|
\ :<C-u>call vimwiki#base#goto_sibling(+1)<CR>
|
|
|
|
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader
|
|
|
|
\ :<C-u>call vimwiki#base#goto_sibling(-1)<CR>
|
|
|
|
|
|
|
|
" default header key mappings
|
|
|
|
if str2nr(vimwiki#vars#get_global('key_mappings').headers)
|
|
|
|
call vimwiki#u#map_key('n', '=', '<Plug>VimwikiAddHeaderLevel')
|
|
|
|
call vimwiki#u#map_key('n', '-', '<Plug>VimwikiRemoveHeaderLevel')
|
|
|
|
call vimwiki#u#map_key('n', ']u', '<Plug>VimwikiGoToParentHeader')
|
|
|
|
call vimwiki#u#map_key('n', '[u', '<Plug>VimwikiGoToParentHeader', 1)
|
|
|
|
call vimwiki#u#map_key('n', ']]', '<Plug>VimwikiGoToNextHeader')
|
|
|
|
call vimwiki#u#map_key('n', '[[', '<Plug>VimwikiGoToPrevHeader')
|
|
|
|
call vimwiki#u#map_key('n', ']=', '<Plug>VimwikiGoToNextSiblingHeader')
|
|
|
|
call vimwiki#u#map_key('n', '[=', '<Plug>VimwikiGoToPrevSiblingHeader')
|
2011-06-11 02:00:00 +02:00
|
|
|
endif
|
2014-02-18 14:47:42 +01:00
|
|
|
|
2010-02-23 01:00:00 +01:00
|
|
|
|
2016-12-22 19:12:03 +01:00
|
|
|
if vimwiki#vars#get_wikilocal('auto_export')
|
2014-11-11 13:52:18 +01:00
|
|
|
" Automatically generate HTML on page write.
|
2010-02-23 01:00:00 +01:00
|
|
|
augroup vimwiki
|
2014-11-11 13:52:18 +01:00
|
|
|
au BufWritePost <buffer>
|
2016-12-22 19:55:20 +01:00
|
|
|
\ call vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
|
2014-11-11 13:52:18 +01:00
|
|
|
\ expand('%'))
|
2010-02-23 01:00:00 +01:00
|
|
|
augroup END
|
|
|
|
endif
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2016-12-22 19:12:03 +01:00
|
|
|
if vimwiki#vars#get_wikilocal('auto_toc')
|
2014-11-11 13:52:18 +01:00
|
|
|
" Automatically update the TOC *before* the file is written
|
2010-02-23 01:00:00 +01:00
|
|
|
augroup vimwiki
|
2014-11-11 13:52:18 +01:00
|
|
|
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
|
2010-02-23 01:00:00 +01:00
|
|
|
augroup END
|
|
|
|
endif
|
2015-01-02 22:59:18 +01:00
|
|
|
|
2016-12-22 18:16:05 +01:00
|
|
|
if vimwiki#vars#get_wikilocal('auto_tags')
|
2015-01-02 22:59:18 +01:00
|
|
|
" Automatically update tags metadata on page write.
|
|
|
|
augroup vimwiki
|
2019-03-22 00:11:03 +01:00
|
|
|
au BufWritePre <buffer> call vimwiki#tags#update_tags(0, '')
|
2015-01-02 22:59:18 +01:00
|
|
|
augroup END
|
|
|
|
endif
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2019-03-22 00:11:03 +01:00
|
|
|
if vimwiki#vars#get_wikilocal('auto_generate_links')
|
|
|
|
" Automatically generate links *before* the file is written
|
|
|
|
augroup vimwiki
|
|
|
|
au BufWritePre <buffer> call vimwiki#base#generate_links(0)
|
|
|
|
augroup END
|
|
|
|
endif
|
|
|
|
|
|
|
|
if vimwiki#vars#get_wikilocal('auto_generate_tags')
|
|
|
|
" Automatically generate tags *before* the file is written
|
|
|
|
augroup vimwiki
|
|
|
|
au BufWritePre <buffer> call vimwiki#tags#generate_tags(0)
|
|
|
|
augroup END
|
|
|
|
endif
|