Formatting and small refactorings
This commit is contained in:
parent
f48dce6f1d
commit
5419fad3f7
@ -1,12 +1,31 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: stuff concerning Vimwiki's state
|
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
" ------------------------------------------------------------------------------------------------
|
||||||
|
" This file provides functions to manage the various state variables which are needed during a
|
||||||
|
" Vimwiki session.
|
||||||
|
" They consist of:
|
||||||
|
"
|
||||||
|
" - global variables. These are stored in the dict g:vimwiki_global_vars. They consist mainly of
|
||||||
|
" 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
|
||||||
|
" dictionaries. One dict for every registered wiki. The last dictionary contains default values
|
||||||
|
" (used for temporary wikis).
|
||||||
|
"
|
||||||
|
" - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and
|
||||||
|
" other stuff which is needed for highlighting.
|
||||||
|
"
|
||||||
|
" - buffer-local variables. They are stored as buffer variables directly (b:foo)
|
||||||
|
|
||||||
|
" As a developer, you should, if possible, only use the get_ and set_ functions for these types of
|
||||||
|
" variables, not the underlying dicts!
|
||||||
|
" ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
" copy the user's settings from variables of the form g:vimwiki_<option> into g:vimwiki_global_vars
|
|
||||||
" (or set a default value)
|
|
||||||
function! s:populate_global_variables()
|
function! s:populate_global_variables()
|
||||||
|
|
||||||
let g:vimwiki_global_vars = {
|
let g:vimwiki_global_vars = {
|
||||||
\ 'CJK_length': 0,
|
\ 'CJK_length': 0,
|
||||||
\ 'auto_chdir': 0,
|
\ 'auto_chdir': 0,
|
||||||
@ -42,37 +61,39 @@ function! s:populate_global_variables()
|
|||||||
\ 'w32_dir_enc': '',
|
\ 'w32_dir_enc': '',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
" 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(g:vimwiki_global_vars)
|
for key in keys(g:vimwiki_global_vars)
|
||||||
if exists('g:vimwiki_'.key)
|
if exists('g:vimwiki_'.key)
|
||||||
let g:vimwiki_global_vars[key] = g:vimwiki_{key}
|
let g:vimwiki_global_vars[key] = g:vimwiki_{key}
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" non-configurable global variables
|
" non-configurable global variables:
|
||||||
|
|
||||||
" Scheme regexes should be defined even if syntax file is not loaded yet cause users should be
|
" Scheme regexes must be defined even if syntax file is not loaded yet cause users should be
|
||||||
" able to <leader>w<leader>w without opening any vimwiki file first
|
" able to <leader>w<leader>w without opening any vimwiki file first
|
||||||
let g:vimwiki_global_vars['schemes'] = 'wiki\d\+,diary,local'
|
let g:vimwiki_global_vars.schemes = 'wiki\d\+,diary,local'
|
||||||
let g:vimwiki_global_vars['web_schemes1'] = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'.
|
let g:vimwiki_global_vars.web_schemes1 = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'.
|
||||||
\ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp'
|
\ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp'
|
||||||
let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel'
|
let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel'
|
||||||
|
|
||||||
let rx_schemes = '\%('.
|
let rx_schemes = '\%('.
|
||||||
\ join(split(g:vimwiki_global_vars['schemes'], '\s*,\s*'), '\|').'\|'.
|
\ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'.
|
||||||
\ join(split(g:vimwiki_global_vars['web_schemes1'], '\s*,\s*'), '\|').'\|'.
|
\ join(split(g:vimwiki_global_vars.web_schemes1, '\s*,\s*'), '\|').'\|'.
|
||||||
\ join(split(web_schemes2, '\s*,\s*'), '\|').
|
\ join(split(web_schemes2, '\s*,\s*'), '\|').
|
||||||
\ '\)'
|
\ '\)'
|
||||||
|
|
||||||
let g:vimwiki_global_vars['rxSchemeUrl'] = rx_schemes.':.*'
|
let g:vimwiki_global_vars.rxSchemeUrl = rx_schemes.':.*'
|
||||||
let g:vimwiki_global_vars['rxSchemeUrlMatchScheme'] = '\zs'.rx_schemes.'\ze:.*'
|
let g:vimwiki_global_vars.rxSchemeUrlMatchScheme = '\zs'.rx_schemes.'\ze:.*'
|
||||||
let g:vimwiki_global_vars['rxSchemeUrlMatchUrl'] = rx_schemes.':\zs.*\ze'
|
let g:vimwiki_global_vars.rxSchemeUrlMatchUrl = rx_schemes.':\zs.*\ze'
|
||||||
|
|
||||||
" match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme
|
" match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme
|
||||||
" http://tools.ietf.org/html/rfc3986
|
" http://tools.ietf.org/html/rfc3986
|
||||||
let rxWebProtocols =
|
let rxWebProtocols =
|
||||||
\ '\%('.
|
\ '\%('.
|
||||||
\ '\%('.
|
\ '\%('.
|
||||||
\ '\%('.join(split(g:vimwiki_global_vars['web_schemes1'], '\s*,\s*'), '\|').'\):'.
|
\ '\%('.join(split(g:vimwiki_global_vars.web_schemes1, '\s*,\s*'), '\|').'\):'.
|
||||||
\ '\%(//\)'.
|
\ '\%(//\)'.
|
||||||
\ '\)'.
|
\ '\)'.
|
||||||
\ '\|'.
|
\ '\|'.
|
||||||
@ -105,20 +126,20 @@ function! s:populate_global_variables()
|
|||||||
" non-Ascii characters
|
" non-Ascii characters
|
||||||
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
||||||
|
|
||||||
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix . g:vimwiki_global_vars.rxWikiLinkUrl .
|
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix .
|
||||||
\ g:vimwiki_global_vars.rx_wikilink_separator
|
\ g:vimwiki_global_vars.rxWikiLinkUrl . g:vimwiki_global_vars.rx_wikilink_separator
|
||||||
let g:vimwiki_global_vars.rx_wikilink_suffix1 = g:vimwiki_global_vars.rx_wikilink_suffix
|
let g:vimwiki_global_vars.rx_wikilink_suffix1 = g:vimwiki_global_vars.rx_wikilink_suffix
|
||||||
|
|
||||||
let g:vimwiki_global_vars.rxWikiInclPrefix = '{{'
|
let g:vimwiki_global_vars.rxWikiInclPrefix = '{{'
|
||||||
let g:vimwiki_global_vars.rxWikiInclSuffix = '}}'
|
let g:vimwiki_global_vars.rxWikiInclSuffix = '}}'
|
||||||
let g:vimwiki_global_vars.rxWikiInclSeparator = '|'
|
let g:vimwiki_global_vars.rxWikiInclSeparator = '|'
|
||||||
" '{{__LinkUrl__}}'
|
" '{{__LinkUrl__}}'
|
||||||
let g:vimwiki_global_vars.WikiInclTemplate1 = g:vimwiki_global_vars.rxWikiInclPrefix . '__LinkUrl__'.
|
let g:vimwiki_global_vars.WikiInclTemplate1 = g:vimwiki_global_vars.rxWikiInclPrefix
|
||||||
\ g:vimwiki_global_vars.rxWikiInclSuffix
|
\ .'__LinkUrl__'. g:vimwiki_global_vars.rxWikiInclSuffix
|
||||||
" '{{__LinkUrl____LinkDescription__}}'
|
" '{{__LinkUrl____LinkDescription__}}'
|
||||||
let g:vimwiki_global_vars.WikiInclTemplate2 = g:vimwiki_global_vars.rxWikiInclPrefix . '__LinkUrl__'.
|
let g:vimwiki_global_vars.WikiInclTemplate2 = g:vimwiki_global_vars.rxWikiInclPrefix
|
||||||
\ '__LinkDescription__'.
|
\ . '__LinkUrl__' . g:vimwiki_global_vars.rxWikiInclSeparator . '__LinkDescription__'
|
||||||
\ g:vimwiki_global_vars.rxWikiInclSuffix
|
\ . g:vimwiki_global_vars.rxWikiInclSuffix
|
||||||
|
|
||||||
let valid_chars = '[^\\\}]'
|
let valid_chars = '[^\\\}]'
|
||||||
let g:vimwiki_global_vars.rxWikiInclUrl = valid_chars.'\{-}'
|
let g:vimwiki_global_vars.rxWikiInclUrl = valid_chars.'\{-}'
|
||||||
@ -145,26 +166,17 @@ function! s:populate_global_variables()
|
|||||||
|
|
||||||
" default colors when headers of different levels are highlighted differently
|
" default colors when headers of different levels are highlighted differently
|
||||||
" not making it yet another option; needed by ColorScheme autocommand
|
" not making it yet another option; needed by ColorScheme autocommand
|
||||||
let g:vimwiki_global_vars.hcolor_guifg_light = ['#aa5858', '#507030', '#1030a0', '#103040', '#505050', '#636363']
|
let g:vimwiki_global_vars.hcolor_guifg_light = ['#aa5858', '#507030', '#1030a0', '#103040'
|
||||||
let g:vimwiki_global_vars.hcolor_ctermfg_light = ['DarkRed', 'DarkGreen', 'DarkBlue', 'Black', 'Black', 'Black']
|
\ , '#505050', '#636363']
|
||||||
let g:vimwiki_global_vars.hcolor_guifg_dark = ['#e08090', '#80e090', '#6090e0', '#c0c0f0', '#e0e0f0', '#f0f0f0']
|
let g:vimwiki_global_vars.hcolor_ctermfg_light = ['DarkRed', 'DarkGreen', 'DarkBlue', 'Black'
|
||||||
let g:vimwiki_global_vars.hcolor_ctermfg_dark = ['Red', 'Green', 'Blue', 'White', 'White', 'White']
|
\ , 'Black', 'Black']
|
||||||
|
let g:vimwiki_global_vars.hcolor_guifg_dark = ['#e08090', '#80e090', '#6090e0', '#c0c0f0'
|
||||||
|
\ , '#e0e0f0', '#f0f0f0']
|
||||||
|
let g:vimwiki_global_vars.hcolor_ctermfg_dark = ['Red', 'Green', 'Blue', 'White', 'White'
|
||||||
|
\ , 'White']
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:normalize_path(path) "{{{
|
|
||||||
" trim trailing / and \ because otherwise resolve() doesn't work quite right
|
|
||||||
let path = substitute(a:path, '[/\\]\+$', '', '')
|
|
||||||
if path !~# '^scp:'
|
|
||||||
return resolve(expand(path)).'/'
|
|
||||||
else
|
|
||||||
return path.'/'
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
|
|
||||||
" g:vimwiki_wikilocal_vars is a list of dictionaries. One dict for every registered wiki. The last
|
|
||||||
" dictionary contains default values (used for temporary wikis)
|
|
||||||
function! s:populate_wikilocal_options()
|
function! s:populate_wikilocal_options()
|
||||||
let default_values = {
|
let default_values = {
|
||||||
\ 'auto_export': 0,
|
\ 'auto_export': 0,
|
||||||
@ -246,6 +258,17 @@ function! s:validate_settings()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:normalize_path(path) "{{{
|
||||||
|
" trim trailing / and \ because otherwise resolve() doesn't work quite right
|
||||||
|
let path = substitute(a:path, '[/\\]\+$', '', '')
|
||||||
|
if path !~# '^scp:'
|
||||||
|
return resolve(expand(path)).'/'
|
||||||
|
else
|
||||||
|
return path.'/'
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
|
||||||
function! vimwiki#vars#populate_syntax_vars(syntax)
|
function! vimwiki#vars#populate_syntax_vars(syntax)
|
||||||
if !exists('g:vimwiki_syntax_variables')
|
if !exists('g:vimwiki_syntax_variables')
|
||||||
let g:vimwiki_syntax_variables = {}
|
let g:vimwiki_syntax_variables = {}
|
||||||
@ -264,33 +287,53 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
|
|||||||
if g:vimwiki_syntax_variables[a:syntax].symH
|
if g:vimwiki_syntax_variables[a:syntax].symH
|
||||||
" symmetric headers
|
" symmetric headers
|
||||||
for i in range(1,6)
|
for i in range(1,6)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] = repeat(header_symbol, i).' __Header__ '.repeat(header_symbol, i)
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] =
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'.header_symbol.'\{'.i.'}\s*$'
|
\ repeat(header_symbol, i).' __Header__ '.repeat(header_symbol, i)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'.header_symbol.'\{'.i.'}\s*$'
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] = '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'.header_symbol.'\{1,'.i.'}\s*$'
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
||||||
|
\ .header_symbol.'\{'.i.'}\s*$'
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
|
||||||
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
||||||
|
\ .header_symbol.'\{'.i.'}\s*$'
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
|
||||||
|
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
||||||
|
\ .header_symbol.'\{1,'.i.'}\s*$'
|
||||||
endfor
|
endfor
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxHeader = '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze\1\s*$'
|
let g:vimwiki_syntax_variables[a:syntax].rxHeader =
|
||||||
|
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze\1\s*$'
|
||||||
else
|
else
|
||||||
" asymmetric
|
" asymmetric
|
||||||
for i in range(1,6)
|
for i in range(1,6)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] = repeat(header_symbol, i).' __Header__'
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] =
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
\ repeat(header_symbol, i).' __Header__'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] = '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*$'
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
|
||||||
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
|
||||||
|
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*$'
|
||||||
endfor
|
endfor
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxHeader = '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*\ze$'
|
let g:vimwiki_syntax_variables[a:syntax].rxHeader =
|
||||||
|
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*\ze$'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxPreStart = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreStart
|
let g:vimwiki_syntax_variables[a:syntax].rxPreStart =
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxPreEnd = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreEnd.'\s*$'
|
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreStart
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax].rxPreEnd =
|
||||||
|
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreEnd.'\s*$'
|
||||||
|
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxMathStart = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathStart
|
let g:vimwiki_syntax_variables[a:syntax].rxMathStart =
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxMathEnd = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$'
|
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathStart
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax].rxMathEnd =
|
||||||
|
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$'
|
||||||
|
|
||||||
" list stuff
|
" list stuff
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rx_bullet_chars = '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+'
|
let g:vimwiki_syntax_variables[a:syntax].rx_bullet_chars =
|
||||||
|
\ '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+'
|
||||||
|
|
||||||
let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars = g:vimwiki_syntax_variables[a:syntax].recurring_bullets ? g:vimwiki_syntax_variables[a:syntax].bullet_types : []
|
let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars =
|
||||||
|
\ g:vimwiki_syntax_variables[a:syntax].recurring_bullets
|
||||||
|
\ ? g:vimwiki_syntax_variables[a:syntax].bullet_types : []
|
||||||
|
|
||||||
let g:vimwiki_syntax_variables[a:syntax].number_kinds = []
|
let g:vimwiki_syntax_variables[a:syntax].number_kinds = []
|
||||||
let g:vimwiki_syntax_variables[a:syntax].number_divisors = ''
|
let g:vimwiki_syntax_variables[a:syntax].number_divisors = ''
|
||||||
@ -304,9 +347,11 @@ 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 = join( map(g:vimwiki_syntax_variables[a:syntax].bullet_types,
|
let g:vimwiki_syntax_variables[a:syntax].rxListBullet =
|
||||||
\'vimwiki#u#escape(v:val).repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)'
|
\ join( map(g:vimwiki_syntax_variables[a:syntax].bullet_types,
|
||||||
\ ) , '\|')
|
\'vimwiki#u#escape(v:val).'
|
||||||
|
\ .'repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)'
|
||||||
|
\ ) , '\|')
|
||||||
else
|
else
|
||||||
"regex that matches nothing
|
"regex that matches nothing
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxListBullet = '$^'
|
let g:vimwiki_syntax_variables[a:syntax].rxListBullet = '$^'
|
||||||
@ -319,7 +364,8 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
|
|||||||
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[type[0]] .
|
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[type[0]] .
|
||||||
\ vimwiki#u#escape(type[1]) . '\|'
|
\ vimwiki#u#escape(type[1]) . '\|'
|
||||||
endfor
|
endfor
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[g:vimwiki_syntax_variables[a:syntax].number_types[-1][0]].
|
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .=
|
||||||
|
\ char_to_rx[g:vimwiki_syntax_variables[a:syntax].number_types[-1][0]].
|
||||||
\ vimwiki#u#escape(g:vimwiki_syntax_variables[a:syntax].number_types[-1][1]) . '\)'
|
\ vimwiki#u#escape(g:vimwiki_syntax_variables[a:syntax].number_types[-1][1]) . '\)'
|
||||||
else
|
else
|
||||||
"regex that matches nothing
|
"regex that matches nothing
|
||||||
@ -327,21 +373,34 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"the user can set the listsyms as string, but vimwiki needs a list
|
"the user can set the listsyms as string, but vimwiki needs a list
|
||||||
let g:vimwiki_syntax_variables[a:syntax].listsyms_list = split(vimwiki#vars#get_global('listsyms'), '\zs')
|
let g:vimwiki_syntax_variables[a:syntax].listsyms_list =
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\('.g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s'
|
\ split(vimwiki#vars#get_global('listsyms'), '\zs')
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxListItem = g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
|
let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB =
|
||||||
|
\ '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\('
|
||||||
|
\ .g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s'
|
||||||
|
let g:vimwiki_syntax_variables[a:syntax].rxListItem =
|
||||||
|
\ g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB
|
||||||
|
\ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
|
||||||
if g:vimwiki_syntax_variables[a:syntax].recurring_bullets
|
if g:vimwiki_syntax_variables[a:syntax].recurring_bullets
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\['.g:vimwiki_syntax_variables[a:syntax].listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*'
|
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
|
||||||
|
\ '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\['
|
||||||
|
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[4].'\]\s.*\%(\n\%(\1\%('
|
||||||
|
\ .g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*'
|
||||||
else
|
else
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|'.g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\['.g:vimwiki_syntax_variables[a:syntax].listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
|
||||||
|
\ '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|'
|
||||||
|
\ . g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\['
|
||||||
|
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
|
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
|
||||||
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
|
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
|
||||||
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
|
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxWeblink = '\<'. g:vimwiki_global_vars.rxWeblinkUrl . '\S*'
|
let g:vimwiki_syntax_variables[a:syntax].rxWeblink =
|
||||||
|
\ '\<'. g:vimwiki_global_vars.rxWeblinkUrl . '\S*'
|
||||||
" 0a) match URL within URL
|
" 0a) match URL within URL
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchUrl = g:vimwiki_syntax_variables[a:syntax].rxWeblink
|
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchUrl =
|
||||||
|
\ g:vimwiki_syntax_variables[a:syntax].rxWeblink
|
||||||
" 0b) match DESCRIPTION within URL
|
" 0b) match DESCRIPTION within URL
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchDescr = ''
|
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchDescr = ''
|
||||||
|
|
||||||
@ -361,16 +420,20 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
|
|||||||
let g:vimwiki_syntax_variables[a:syntax].rxWikiLink = g:vimwiki_global_vars.rx_wikilink_prefix.
|
let g:vimwiki_syntax_variables[a:syntax].rxWikiLink = g:vimwiki_global_vars.rx_wikilink_prefix.
|
||||||
\ g:vimwiki_global_vars.rxWikiLinkUrl.'\%('.g:vimwiki_global_vars.rx_wikilink_separator.
|
\ g:vimwiki_global_vars.rxWikiLinkUrl.'\%('.g:vimwiki_global_vars.rx_wikilink_separator.
|
||||||
\ g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
|
\ g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxAnyLink = g:vimwiki_syntax_variables[a:syntax].rxWikiLink.'\|'.
|
let g:vimwiki_syntax_variables[a:syntax].rxAnyLink =
|
||||||
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.g:vimwiki_syntax_variables[a:syntax].rxWeblink
|
\ g:vimwiki_syntax_variables[a:syntax].rxWikiLink.'\|'.
|
||||||
|
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.g:vimwiki_syntax_variables[a:syntax].rxWeblink
|
||||||
" b) match URL within [[URL|DESCRIPTION]]
|
" b) match URL within [[URL|DESCRIPTION]]
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxWikiLinkMatchUrl = g:vimwiki_global_vars.rx_wikilink_prefix.
|
let g:vimwiki_syntax_variables[a:syntax].rxWikiLinkMatchUrl =
|
||||||
\ '\zs'. g:vimwiki_global_vars.rxWikiLinkUrl.'\ze\%('. g:vimwiki_global_vars.rx_wikilink_separator.
|
\ g:vimwiki_global_vars.rx_wikilink_prefix . '\zs'. g:vimwiki_global_vars.rxWikiLinkUrl
|
||||||
\ g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
|
\ .'\ze\%('. g:vimwiki_global_vars.rx_wikilink_separator
|
||||||
|
\ . g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
|
||||||
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxWikiLinkMatchDescr = g:vimwiki_global_vars.rx_wikilink_prefix.
|
let g:vimwiki_syntax_variables[a:syntax].rxWikiLinkMatchDescr =
|
||||||
\ g:vimwiki_global_vars.rxWikiLinkUrl . g:vimwiki_global_vars.rx_wikilink_separator.'\%('.
|
\ g:vimwiki_global_vars.rx_wikilink_prefix . g:vimwiki_global_vars.rxWikiLinkUrl
|
||||||
\ '\zs'. g:vimwiki_global_vars.rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_global_vars.rx_wikilink_suffix
|
\ . g:vimwiki_global_vars.rx_wikilink_separator.'\%(\zs'
|
||||||
|
\ . g:vimwiki_global_vars.rxWikiLinkDescr. '\ze\)\?'
|
||||||
|
\ . g:vimwiki_global_vars.rx_wikilink_suffix
|
||||||
|
|
||||||
if a:syntax ==# 'markdown'
|
if a:syntax ==# 'markdown'
|
||||||
call s:populate_extra_markdown_vars()
|
call s:populate_extra_markdown_vars()
|
||||||
@ -516,9 +579,10 @@ function! s:populate_extra_markdown_vars()
|
|||||||
|
|
||||||
let mkd_syntax.rxMkdRef = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
|
let mkd_syntax.rxMkdRef = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
|
||||||
\ mkd_syntax.rxWeblink0
|
\ mkd_syntax.rxWeblink0
|
||||||
let mkd_syntax.rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_global_vars.rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'.
|
let mkd_syntax.rxMkdRefMatchDescr =
|
||||||
\ mkd_syntax.rxWeblink0
|
\ '\[\zs'.g:vimwiki_global_vars.rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'. mkd_syntax.rxWeblink0
|
||||||
let mkd_syntax.rxMkdRefMatchUrl = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
|
let mkd_syntax.rxMkdRefMatchUrl =
|
||||||
|
\ '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
|
||||||
\ mkd_syntax.rxWeblink0.'\ze'
|
\ mkd_syntax.rxWeblink0.'\ze'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ To remap one of these keys, either put it in your .vimrc like this >
|
|||||||
or, the better way, put it in a file .vim/ftplugin/vimwiki.vim like this >
|
or, the better way, put it in a file .vim/ftplugin/vimwiki.vim like this >
|
||||||
:nmap <silent><buffer> <Leader>wc <Plug>Vimwiki2HTML
|
:nmap <silent><buffer> <Leader>wc <Plug>Vimwiki2HTML
|
||||||
|
|
||||||
The latter has the advantage that the mapping is local to viwiki buffers in
|
The latter has the advantage that the mapping is local to Vimwiki buffers in
|
||||||
every case.
|
every case.
|
||||||
|
|
||||||
Also note that some keys work in normal mode as well as in visual mode. If you
|
Also note that some keys work in normal mode as well as in visual mode. If you
|
||||||
@ -814,7 +814,7 @@ which opens up a popup menu with all the wiki files starting with "ind".
|
|||||||
When |vimwiki-option-maxhi| equals 1, a distinct highlighting style is used to
|
When |vimwiki-option-maxhi| equals 1, a distinct highlighting style is used to
|
||||||
identify wikilinks whose targets are not found.
|
identify wikilinks whose targets are not found.
|
||||||
|
|
||||||
Interwiki:~
|
Interwiki~
|
||||||
|
|
||||||
If you maintain more than one wiki, you can create interwiki links between
|
If you maintain more than one wiki, you can create interwiki links between
|
||||||
them by adding a numbered prefix "wikiX:" in front of a link: >
|
them by adding a numbered prefix "wikiX:" in front of a link: >
|
||||||
@ -825,15 +825,11 @@ or: >
|
|||||||
The number behind "wiki" is in the range 0..N-1 and identifies the destination
|
The number behind "wiki" is in the range 0..N-1 and identifies the destination
|
||||||
wiki in |g:vimwiki_list|.
|
wiki in |g:vimwiki_list|.
|
||||||
|
|
||||||
Diary:~
|
Diary~
|
||||||
|
|
||||||
The "diary:" scheme is used to concisely link to diary entries: >
|
The "diary:" scheme is used to link to diary entries: >
|
||||||
[[diary:2012-03-05]]
|
[[diary:2012-03-05]]
|
||||||
|
|
||||||
This scheme precludes explicit inclusion of |vimwiki-option-diary_rel_path|,
|
|
||||||
and is most useful on subwiki pages to avoid links such as: >
|
|
||||||
[[../../diary/2012-03-05]]
|
|
||||||
|
|
||||||
Anchors~
|
Anchors~
|
||||||
|
|
||||||
A wikilink, interwiki link or diary link can be followed by a '#' and the name
|
A wikilink, interwiki link or diary link can be followed by a '#' and the name
|
||||||
|
@ -238,7 +238,8 @@ command! -buffer Vimwiki2HTML
|
|||||||
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
|
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
|
||||||
\ expand('%'))
|
\ expand('%'))
|
||||||
\ <bar>
|
\ <bar>
|
||||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: ' . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
|
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
|
||||||
|
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
|
||||||
command! -buffer Vimwiki2HTMLBrowse
|
command! -buffer Vimwiki2HTMLBrowse
|
||||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||||
\ <bar>
|
\ <bar>
|
||||||
@ -281,11 +282,15 @@ command! -buffer VimwikiCheckLinks call vimwiki#base#check_links()
|
|||||||
|
|
||||||
" list commands
|
" list commands
|
||||||
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
|
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
|
||||||
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
|
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo
|
||||||
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
|
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
|
||||||
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call vimwiki#lst#change_marker_in_list(<f-args>)
|
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>)
|
||||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
||||||
command! -buffer -range -nargs=+ VimwikiListChangeLvl call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
command! -buffer -range -nargs=+ VimwikiListChangeLvl
|
||||||
|
\ call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
||||||
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
|
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
|
||||||
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
|
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
|
||||||
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
|
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
|
||||||
|
@ -49,7 +49,9 @@ function! s:create_temporary_wiki()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" this is called when Vim opens a new buffer with a known wiki extension
|
" This function is called when Vim opens a new buffer with a known wiki
|
||||||
|
" extension. Both when the buffer has never been opened in this session and
|
||||||
|
" when it has.
|
||||||
function! s:setup_new_wiki_buffer() "{{{
|
function! s:setup_new_wiki_buffer() "{{{
|
||||||
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
if wiki_nr == -1 " it's not in a known wiki directory
|
if wiki_nr == -1 " it's not in a known wiki directory
|
||||||
@ -82,52 +84,16 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" 'autowriteall' is a global Vim option, so in order to change it only for
|
|
||||||
" Vimwiki buffers, we need to set it here (when the cursor enters the buffer)
|
|
||||||
" and reset it when the cursor leaves the buffer
|
|
||||||
let s:vimwiki_autowriteall_saved = &autowriteall
|
|
||||||
let &autowriteall = vimwiki#vars#get_global('autowriteall')
|
|
||||||
|
|
||||||
if &filetype == ''
|
if &filetype == ''
|
||||||
setfiletype vimwiki
|
setfiletype vimwiki
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" The settings foldmethod, foldexpr and foldtext are local to window. Thus in
|
call s:set_global_options()
|
||||||
" a new tab with the same buffer folding is reset to vim defaults. So we
|
|
||||||
" insist vimwiki folding here.
|
|
||||||
let foldmethod = vimwiki#vars#get_global('folding')
|
|
||||||
if foldmethod ==? 'expr'
|
|
||||||
setlocal foldmethod=expr
|
|
||||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
|
||||||
setlocal foldtext=VimwikiFoldText()
|
|
||||||
elseif foldmethod ==? 'list' || foldmethod ==? 'lists'
|
|
||||||
setlocal foldmethod=expr
|
|
||||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
|
||||||
setlocal foldtext=VimwikiFoldText()
|
|
||||||
elseif foldmethod ==? 'syntax'
|
|
||||||
setlocal foldmethod=syntax
|
|
||||||
setlocal foldtext=VimwikiFoldText()
|
|
||||||
else
|
|
||||||
setlocal foldmethod=manual
|
|
||||||
normal! zE
|
|
||||||
endif
|
|
||||||
|
|
||||||
" And conceal level too.
|
call s:set_windowlocal_options()
|
||||||
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
|
||||||
let &conceallevel = vimwiki#vars#get_global('conceallevel')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" lcd as well
|
|
||||||
if vimwiki#vars#get_global('auto_chdir')
|
|
||||||
exe 'lcd' vimwiki#vars#get_wikilocal('path')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Set up menu
|
|
||||||
if vimwiki#vars#get_global('menu') !=# ''
|
|
||||||
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
|
||||||
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
||||||
" on colorscheme change because they are not linked to Vim-predefined groups
|
" on colorscheme change because they are not linked to Vim-predefined groups
|
||||||
hi def VimwikiBold term=bold cterm=bold gui=bold
|
hi def VimwikiBold term=bold cterm=bold gui=bold
|
||||||
@ -136,7 +102,10 @@ function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
|||||||
hi def VimwikiUnderline gui=underline
|
hi def VimwikiUnderline gui=underline
|
||||||
if vimwiki#vars#get_global('hl_headers') == 1
|
if vimwiki#vars#get_global('hl_headers') == 1
|
||||||
for i in range(1,6)
|
for i in range(1,6)
|
||||||
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.vimwiki#vars#get_global('hcolor_guifg_'.&bg)[i-1].' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[i-1].' term=bold cterm=bold'
|
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='
|
||||||
|
\ . vimwiki#vars#get_global('hcolor_guifg_'.&bg)[i-1]
|
||||||
|
\ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[i-1]
|
||||||
|
\ .' term=bold cterm=bold'
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@ -156,6 +125,50 @@ function! s:vimwiki_get_known_extensions() " {{{
|
|||||||
return keys(extensions)
|
return keys(extensions)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
|
||||||
|
" Set settings which are global for Vim, but should only be executed for
|
||||||
|
" Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer
|
||||||
|
" and reset when the cursor leaves the buffer.
|
||||||
|
function! s:set_global_options()
|
||||||
|
let s:vimwiki_autowriteall_saved = &autowriteall
|
||||||
|
let &autowriteall = vimwiki#vars#get_global('autowriteall')
|
||||||
|
|
||||||
|
if vimwiki#vars#get_global('menu') !=# ''
|
||||||
|
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Set settings which are local to a window. In a new tab they would be reset to
|
||||||
|
" Vim defaults. So we enforce our settings here when the cursor enters a
|
||||||
|
" Vimwiki buffer.
|
||||||
|
function! s:set_windowlocal_options()
|
||||||
|
let foldmethod = vimwiki#vars#get_global('folding')
|
||||||
|
if foldmethod ==? 'expr'
|
||||||
|
setlocal foldmethod=expr
|
||||||
|
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||||
|
setlocal foldtext=VimwikiFoldText()
|
||||||
|
elseif foldmethod ==? 'list' || foldmethod ==? 'lists'
|
||||||
|
setlocal foldmethod=expr
|
||||||
|
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||||
|
setlocal foldtext=VimwikiFoldText()
|
||||||
|
elseif foldmethod ==? 'syntax'
|
||||||
|
setlocal foldmethod=syntax
|
||||||
|
setlocal foldtext=VimwikiFoldText()
|
||||||
|
else
|
||||||
|
setlocal foldmethod=manual
|
||||||
|
normal! zE
|
||||||
|
endif
|
||||||
|
|
||||||
|
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
||||||
|
let &conceallevel = vimwiki#vars#get_global('conceallevel')
|
||||||
|
endif
|
||||||
|
|
||||||
|
if vimwiki#vars#get_global('auto_chdir')
|
||||||
|
exe 'lcd' vimwiki#vars#get_wikilocal('path')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
@ -201,8 +214,8 @@ endif
|
|||||||
augroup vimwiki
|
augroup vimwiki
|
||||||
autocmd!
|
autocmd!
|
||||||
for s:ext in s:known_extensions
|
for s:ext in s:known_extensions
|
||||||
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()'
|
|
||||||
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 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()'
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user