Use new access functions for global variables -- part 2

Ref #256
This commit is contained in:
EinfachToll 2016-12-21 21:28:48 +01:00
parent e6d997867a
commit 49bdf7fa47
9 changed files with 37 additions and 52 deletions

View File

@ -1771,7 +1771,7 @@ function! vimwiki#base#table_of_contents(create)
endif
let h_level = vimwiki#u#count_first_sym(line_content)
let h_text = vimwiki#u#trim(matchstr(line_content, g:vimwiki_rxHeader))
if h_text ==# g:vimwiki_toc_header " don't include the TOC's header itself
if h_text ==# vimwiki#vars#get_global('toc_header') " don't include the TOC's header itself
continue
endif
let headers_levels[h_level-1] = [h_text, headers_levels[h_level-1][1]+1]
@ -1811,7 +1811,7 @@ function! vimwiki#base#table_of_contents(create)
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
call vimwiki#base#update_listing_in_buffer(lines, g:vimwiki_toc_header, links_rx,
call vimwiki#base#update_listing_in_buffer(lines, vimwiki#vars#get_global('toc_header'), links_rx,
\ 1, a:create)
endfunction
"}}}

View File

@ -157,7 +157,7 @@ function! s:delete_html_files(path) "{{{
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
for fname in htmlfiles
" ignore user html files, e.g. search.html,404.html
if stridx(g:vimwiki_user_htmls, fnamemodify(fname, ":t")) >= 0
if stridx(vimwiki#vars#get_global('user_htmls'), fnamemodify(fname, ":t")) >= 0
continue
endif
@ -933,7 +933,7 @@ function! s:process_tag_list(line, lists) "{{{
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
let processed = 1
elseif in_list && a:line =~# '^\s\+\S\+'
if g:vimwiki_list_ignore_newline
if vimwiki#vars#get_global('list_ignore_newline')
call add(lines, a:line)
else
call add(lines, '<br />'.a:line)
@ -1005,7 +1005,7 @@ function! s:process_tag_h(line, id) "{{{
let h_id = s:safe_html_anchor(h_text)
let centered = (a:line =~# '^\s')
if h_text !=# g:vimwiki_toc_header
if h_text !=# vimwiki#vars#get_global('toc_header')
let a:id[h_level-1] = [h_text, a:id[h_level-1][1]+1]

View File

@ -1499,7 +1499,7 @@ function! vimwiki#lst#setup_marker_infos() "{{{
endif
"the user can set the listsyms as string, but vimwiki needs a list
let g:vimwiki_listsyms_list = split(g:vimwiki_listsyms, '\zs')
let g:vimwiki_listsyms_list = split(vimwiki#vars#get_global('listsyms'), '\zs')
endfunction "}}}
function! vimwiki#lst#TO_list_item(inner, visual) "{{{

View File

@ -324,7 +324,7 @@ command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
" COMMANDS }}}
" KEYBINDINGS {{{
if g:vimwiki_use_mouse
if vimwiki#vars#get_global('use_mouse')
nmap <buffer> <S-LeftMouse> <NOP>
nmap <buffer> <C-LeftMouse> <NOP>
nnoremap <silent><buffer> <2-LeftMouse> :call vimwiki#base#follow_link("nosplit", "\<lt>2-LeftMouse>")<CR>
@ -335,13 +335,13 @@ endif
if !hasmapto('<Plug>Vimwiki2HTML')
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'h <Plug>Vimwiki2HTML'
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'h <Plug>Vimwiki2HTML'
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'hh <Plug>Vimwiki2HTMLBrowse'
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'hh <Plug>Vimwiki2HTMLBrowse'
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
@ -408,13 +408,13 @@ nnoremap <silent><script><buffer>
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
if !hasmapto('<Plug>VimwikiDeleteLink')
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'d <Plug>VimwikiDeleteLink'
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'d <Plug>VimwikiDeleteLink'
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
if !hasmapto('<Plug>VimwikiRenameLink')
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'r <Plug>VimwikiRenameLink'
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'r <Plug>VimwikiRenameLink'
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
@ -553,7 +553,7 @@ endfor
function! s:CR(normal, just_mrkr) "{{{
if g:vimwiki_table_mappings
if vimwiki#vars#get_global('table_mappings')
let res = vimwiki#tbl#kbd_cr()
if res != ""
exe "normal! " . res . "\<Right>"
@ -574,7 +574,7 @@ if !hasmapto('VimwikiReturn', 'i')
endif
"Table mappings
if g:vimwiki_table_mappings
if vimwiki#vars#get_global('table_mappings')
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif

View File

@ -65,8 +65,8 @@ function! s:setup_buffer_leave() "{{{
let &autowriteall = s:vimwiki_autowriteall
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
if vimwiki#vars#get_global('menu') != ""
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction "}}}
@ -171,8 +171,8 @@ function! s:setup_buffer_enter() "{{{
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
if vimwiki#vars#get_global('menu') != ""
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction "}}}
@ -360,21 +360,6 @@ let s:vimwiki_defaults.auto_tags = 0
" DEFAULT options {{{
call s:default('list', [s:vimwiki_defaults])
call s:default('use_mouse', 0)
call s:default('menu', 'Vimwiki')
call s:default('list_ignore_newline', 1)
call s:default('listsyms', ' .oOX')
call s:default('use_calendar', 1)
call s:default('table_mappings', 1)
call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
call s:default('user_htmls', '')
call s:default('toc_header', 'Contents')
call s:default('url_maxsave', 15)
call s:default('map_prefix', '<Leader>w')
call s:default('current_idx', 0)
@ -420,7 +405,7 @@ augroup vimwiki
exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
if g:vimwiki_table_auto_fmt
if vimwiki#vars#get_global('table_auto_fmt')
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
@ -452,43 +437,43 @@ command! VimwikiDiaryGenerateLinks
" MAPPINGS {{{
if !hasmapto('<Plug>VimwikiIndex')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'w <Plug>VimwikiIndex'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'w <Plug>VimwikiIndex'
endif
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabIndex')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'t <Plug>VimwikiTabIndex'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'t <Plug>VimwikiTabIndex'
endif
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'s <Plug>VimwikiUISelect'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'s <Plug>VimwikiUISelect'
endif
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
if !hasmapto('<Plug>VimwikiDiaryIndex')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'i <Plug>VimwikiDiaryIndex'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'i <Plug>VimwikiDiaryIndex'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'<Leader>w <Plug>VimwikiMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote')
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
exe 'nmap <silent><unique> '.vimwiki#vars#get_global('map_prefix').'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
endif
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :VimwikiMakeYesterdayDiaryNote<CR>
@ -519,14 +504,14 @@ function! s:build_table_menu(topmenu)
endfunction
if !empty(g:vimwiki_menu)
call s:build_menu(g:vimwiki_menu)
call s:build_table_menu(g:vimwiki_menu)
if !empty(vimwiki#vars#get_global('menu'))
call s:build_menu(vimwiki#vars#get_global('menu'))
call s:build_table_menu(vimwiki#vars#get_global('menu'))
endif
" }}}
" CALENDAR Hook "{{{
if g:vimwiki_use_calendar
if vimwiki#vars#get_global('use_calendar')
let g:calendar_action = 'vimwiki#diary#calendar_action'
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
endif

View File

@ -344,10 +344,10 @@ let s:options = ' contained transparent contains=NONE'
"
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
" VimwikiLinkRest group is left undefined if link shortening is not desired
if exists("+conceallevel") && g:vimwiki_url_maxsave > 0
if exists("+conceallevel") && vimwiki#vars#get_global('url_maxsave') > 0
let s:options .= s:conceal
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.s:options
\.'\%([/#?]\w\|\S\{'.vimwiki#vars#get_global('url_maxsave').'}\)`'.' cchar=~'.s:options
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description
@ -464,8 +464,8 @@ syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlac
syntax match VimwikiPlaceholderParam /\s.*/ contained
" html tags
if g:vimwiki_valid_html_tags != ''
let s:html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
if vimwiki#vars#get_global('valid_html_tags') != ''
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'

View File

@ -79,7 +79,7 @@ let g:vimwiki_rxListDefine = '::\(\s\|$\)'
call vimwiki#lst#setup_marker_infos()
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text

View File

@ -76,7 +76,7 @@ let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
call vimwiki#lst#setup_marker_infos()
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text

View File

@ -57,7 +57,7 @@ let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
call vimwiki#lst#setup_marker_infos()
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*'
" Preformatted text