parent
6b34e954e8
commit
e6d997867a
@ -18,8 +18,8 @@ function! s:vimwiki_get_known_syntaxes() " {{{
|
|||||||
let syntaxes[wiki.syntax] = 1
|
let syntaxes[wiki.syntax] = 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
" append map g:vimwiki_ext2syntax
|
" also consider the syntaxes from g:vimwiki_ext2syntax
|
||||||
for syn in values(g:vimwiki_ext2syntax)
|
for syn in values(vimwiki#vars#get_global('ext2syntax'))
|
||||||
let syntaxes[syn] = 1
|
let syntaxes[syn] = 1
|
||||||
endfor
|
endfor
|
||||||
return keys(syntaxes)
|
return keys(syntaxes)
|
||||||
@ -131,7 +131,7 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable
|
|||||||
call VimwikiSet('subdir', subdir, a:idx)
|
call VimwikiSet('subdir', subdir, a:idx)
|
||||||
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx)
|
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx)
|
||||||
|
|
||||||
if g:vimwiki_auto_chdir == 1
|
if vimwiki#vars#get_global('auto_chdir') == 1
|
||||||
exe 'lcd' VimwikiGet('path')
|
exe 'lcd' VimwikiGet('path')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -322,8 +322,8 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
|||||||
let link_infos.filename = root_dir . link_text
|
let link_infos.filename = root_dir . link_text
|
||||||
|
|
||||||
if vimwiki#path#is_link_to_dir(link_text)
|
if vimwiki#path#is_link_to_dir(link_text)
|
||||||
if g:vimwiki_dir_link != ''
|
if vimwiki#vars#get_global('dir_link') != ''
|
||||||
let link_infos.filename .= g:vimwiki_dir_link .
|
let link_infos.filename .= vimwiki#vars#get_global('dir_link') .
|
||||||
\ VimwikiGet('ext', link_infos.index)
|
\ VimwikiGet('ext', link_infos.index)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
@ -1745,6 +1745,7 @@ endfunction " }}}
|
|||||||
function! vimwiki#base#table_of_contents(create)
|
function! vimwiki#base#table_of_contents(create)
|
||||||
" collect new headers
|
" collect new headers
|
||||||
let is_inside_pre_or_math = 0 " 1: inside pre, 2: inside math, 0: outside
|
let is_inside_pre_or_math = 0 " 1: inside pre, 2: inside math, 0: outside
|
||||||
|
let numbering = vimwiki#vars#get_global('html_header_numbering')
|
||||||
let headers = []
|
let headers = []
|
||||||
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
||||||
for lnum in range(1, line('$'))
|
for lnum in range(1, line('$'))
|
||||||
@ -1784,11 +1785,11 @@ function! vimwiki#base#table_of_contents(create)
|
|||||||
endfor
|
endfor
|
||||||
let h_complete_id .= headers_levels[h_level-1][0]
|
let h_complete_id .= headers_levels[h_level-1][0]
|
||||||
|
|
||||||
if g:vimwiki_html_header_numbering > 0
|
if numbering > 0
|
||||||
\ && g:vimwiki_html_header_numbering <= h_level
|
\ && numbering <= h_level
|
||||||
let h_number = join(map(copy(headers_levels[
|
let h_number = join(map(copy(headers_levels[
|
||||||
\ g:vimwiki_html_header_numbering-1 : h_level-1]), 'v:val[1]'), '.')
|
\ numbering-1 : h_level-1]), 'v:val[1]'), '.')
|
||||||
let h_number .= g:vimwiki_html_header_numbering_sym
|
let h_number .= vimwiki#vars#get_global('html_header_numbering_sym')
|
||||||
let h_text = h_number.' '.h_text
|
let h_text = h_number.' '.h_text
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ function! s:get_position_links(link) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
fun! s:get_month_name(month) "{{{
|
fun! s:get_month_name(month) "{{{
|
||||||
return g:vimwiki_diary_months[str2nr(a:month)]
|
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
|
||||||
endfun "}}}
|
endfun "}}}
|
||||||
|
|
||||||
" Helpers }}}
|
" Helpers }}}
|
||||||
|
@ -1023,11 +1023,11 @@ function! s:process_tag_h(line, id) "{{{
|
|||||||
let h_number .= a:id[h_level-1][1]
|
let h_number .= a:id[h_level-1][1]
|
||||||
let h_complete_id .= a:id[h_level-1][0]
|
let h_complete_id .= a:id[h_level-1][0]
|
||||||
|
|
||||||
if g:vimwiki_html_header_numbering
|
if vimwiki#vars#get_global('html_header_numbering')
|
||||||
let num = matchstr(h_number,
|
let num = matchstr(h_number,
|
||||||
\ '^\(\d.\)\{'.(g:vimwiki_html_header_numbering-1).'}\zs.*')
|
\ '^\(\d.\)\{'.(vimwiki#vars#get_global('html_header_numbering')-1).'}\zs.*')
|
||||||
if !empty(num)
|
if !empty(num)
|
||||||
let num .= g:vimwiki_html_header_numbering_sym
|
let num .= vimwiki#vars#get_global('html_header_numbering_sym')
|
||||||
endif
|
endif
|
||||||
let h_text = num.' '.h_text
|
let h_text = num.' '.h_text
|
||||||
endif
|
endif
|
||||||
|
@ -29,7 +29,7 @@ function! s:wide_len(str) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" get str display width in vim ver < 7.2
|
" get str display width in vim ver < 7.2
|
||||||
if !g:vimwiki_CJK_length
|
if !vimwiki#vars#get_global('CJK_length')
|
||||||
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
|
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
|
||||||
else
|
else
|
||||||
let savemodified = &modified
|
let savemodified = &modified
|
||||||
|
@ -22,8 +22,8 @@ let b:undo_ftplugin = "setlocal ".
|
|||||||
|
|
||||||
setlocal commentstring=%%%s
|
setlocal commentstring=%%%s
|
||||||
|
|
||||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
||||||
let &l:conceallevel = g:vimwiki_conceallevel
|
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" GOTO FILE: gf {{{
|
" GOTO FILE: gf {{{
|
||||||
|
@ -75,7 +75,7 @@ function! s:setup_filetype() "{{{
|
|||||||
let path = expand('%:p:h')
|
let path = expand('%:p:h')
|
||||||
let idx = vimwiki#base#find_wiki(path)
|
let idx = vimwiki#base#find_wiki(path)
|
||||||
|
|
||||||
if idx == -1 && g:vimwiki_global_ext == 0
|
if idx == -1 && vimwiki#vars#get_global('global_ext') == 0
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
"XXX when idx = -1? (an orphan page has been detected)
|
"XXX when idx = -1? (an orphan page has been detected)
|
||||||
@ -86,11 +86,7 @@ function! s:setup_filetype() "{{{
|
|||||||
if idx == -1
|
if idx == -1
|
||||||
let ext = '.'.expand('%:e')
|
let ext = '.'.expand('%:e')
|
||||||
" lookup syntax using g:vimwiki_ext2syntax
|
" lookup syntax using g:vimwiki_ext2syntax
|
||||||
if has_key(g:vimwiki_ext2syntax, ext)
|
let syn = get(vimwiki#vars#get_global('ext2syntax'), ext, s:vimwiki_defaults.syntax)
|
||||||
let syn = g:vimwiki_ext2syntax[ext]
|
|
||||||
else
|
|
||||||
let syn = s:vimwiki_defaults.syntax
|
|
||||||
endif
|
|
||||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
||||||
let idx = len(g:vimwiki_list) - 1
|
let idx = len(g:vimwiki_list) - 1
|
||||||
call Validate_wiki_options(idx)
|
call Validate_wiki_options(idx)
|
||||||
@ -113,7 +109,7 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
|
|
||||||
" The buffer's file is not in the path and user *does NOT* want his wiki
|
" The buffer's file is not in the path and user *does NOT* want his wiki
|
||||||
" extension to be global -- Do not add new wiki.
|
" extension to be global -- Do not add new wiki.
|
||||||
if idx == -1 && g:vimwiki_global_ext == 0
|
if idx == -1 && vimwiki#vars#get_global('global_ext') == 0
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -123,11 +119,7 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
if idx == -1
|
if idx == -1
|
||||||
let ext = '.'.expand('%:e')
|
let ext = '.'.expand('%:e')
|
||||||
" lookup syntax using g:vimwiki_ext2syntax
|
" lookup syntax using g:vimwiki_ext2syntax
|
||||||
if has_key(g:vimwiki_ext2syntax, ext)
|
let syn = get(vimwiki#vars#get_global('ext2syntax'), ext, s:vimwiki_defaults.syntax)
|
||||||
let syn = g:vimwiki_ext2syntax[ext]
|
|
||||||
else
|
|
||||||
let syn = s:vimwiki_defaults.syntax
|
|
||||||
endif
|
|
||||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
||||||
let idx = len(g:vimwiki_list) - 1
|
let idx = len(g:vimwiki_list) - 1
|
||||||
call Validate_wiki_options(idx)
|
call Validate_wiki_options(idx)
|
||||||
@ -156,15 +148,16 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||||
" insist vimwiki folding here.
|
" insist vimwiki folding here.
|
||||||
if g:vimwiki_folding ==? 'expr'
|
let foldmethod = vimwiki#vars#get_global('folding')
|
||||||
|
if foldmethod ==? 'expr'
|
||||||
setlocal fdm=expr
|
setlocal fdm=expr
|
||||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||||
setlocal foldtext=VimwikiFoldText()
|
setlocal foldtext=VimwikiFoldText()
|
||||||
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
|
elseif foldmethod ==? 'list' || foldmethod ==? 'lists'
|
||||||
setlocal fdm=expr
|
setlocal fdm=expr
|
||||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||||
setlocal foldtext=VimwikiFoldText()
|
setlocal foldtext=VimwikiFoldText()
|
||||||
elseif g:vimwiki_folding ==? 'syntax'
|
elseif foldmethod ==? 'syntax'
|
||||||
setlocal fdm=syntax
|
setlocal fdm=syntax
|
||||||
setlocal foldtext=VimwikiFoldText()
|
setlocal foldtext=VimwikiFoldText()
|
||||||
else
|
else
|
||||||
@ -173,8 +166,8 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" And conceal level too.
|
" And conceal level too.
|
||||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
||||||
let &conceallevel = g:vimwiki_conceallevel
|
let &conceallevel = vimwiki#vars#get_global('conceallevel')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Set up menu
|
" Set up menu
|
||||||
@ -191,7 +184,7 @@ function! s:setup_buffer_reenter() "{{{
|
|||||||
if !exists("s:vimwiki_autowriteall")
|
if !exists("s:vimwiki_autowriteall")
|
||||||
let s:vimwiki_autowriteall = &autowriteall
|
let s:vimwiki_autowriteall = &autowriteall
|
||||||
endif
|
endif
|
||||||
let &autowriteall = g:vimwiki_autowriteall
|
let &autowriteall = vimwiki#vars#get_global('autowriteall')
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
||||||
@ -200,7 +193,7 @@ function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
|||||||
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
||||||
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
|
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
|
||||||
hi def VimwikiUnderline gui=underline
|
hi def VimwikiUnderline gui=underline
|
||||||
if g:vimwiki_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='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
|
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
|
||||||
endfor
|
endfor
|
||||||
@ -288,8 +281,8 @@ function! s:vimwiki_get_known_extensions() " {{{
|
|||||||
let extensions['.wiki'] = 1
|
let extensions['.wiki'] = 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
" append map g:vimwiki_ext2syntax
|
" append extensions from g:vimwiki_ext2syntax
|
||||||
for ext in keys(g:vimwiki_ext2syntax)
|
for ext in keys(vimwiki#vars#get_global('ext2syntax'))
|
||||||
let extensions[ext] = 1
|
let extensions[ext] = 1
|
||||||
endfor
|
endfor
|
||||||
return keys(extensions)
|
return keys(extensions)
|
||||||
@ -297,6 +290,12 @@ endfunction " }}}
|
|||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
|
" Initialization of Vimwiki starts here. Make sure everything below does not
|
||||||
|
" cause autoload/base to be loaded
|
||||||
|
|
||||||
|
call vimwiki#vars#init()
|
||||||
|
|
||||||
" CALLBACK functions "{{{
|
" CALLBACK functions "{{{
|
||||||
" User can redefine it.
|
" User can redefine it.
|
||||||
if !exists("*VimwikiLinkHandler") "{{{
|
if !exists("*VimwikiLinkHandler") "{{{
|
||||||
@ -362,44 +361,23 @@ let s:vimwiki_defaults.auto_tags = 0
|
|||||||
" DEFAULT options {{{
|
" DEFAULT options {{{
|
||||||
call s:default('list', [s:vimwiki_defaults])
|
call s:default('list', [s:vimwiki_defaults])
|
||||||
call s:default('use_mouse', 0)
|
call s:default('use_mouse', 0)
|
||||||
call s:default('folding', '')
|
|
||||||
call s:default('menu', 'Vimwiki')
|
call s:default('menu', 'Vimwiki')
|
||||||
call s:default('global_ext', 1)
|
|
||||||
call s:default('ext2syntax', {}) " syntax map keyed on extension
|
|
||||||
call s:default('hl_headers', 0)
|
|
||||||
call s:default('hl_cb_checked', 0)
|
|
||||||
call s:default('list_ignore_newline', 1)
|
call s:default('list_ignore_newline', 1)
|
||||||
call s:default('listsyms', ' .oOX')
|
call s:default('listsyms', ' .oOX')
|
||||||
call s:default('use_calendar', 1)
|
call s:default('use_calendar', 1)
|
||||||
call s:default('table_mappings', 1)
|
call s:default('table_mappings', 1)
|
||||||
call s:default('table_auto_fmt', 1)
|
call s:default('table_auto_fmt', 1)
|
||||||
call s:default('w32_dir_enc', '')
|
call s:default('w32_dir_enc', '')
|
||||||
call s:default('CJK_length', 0)
|
|
||||||
call s:default('dir_link', '')
|
|
||||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
|
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('user_htmls', '')
|
||||||
call s:default('autowriteall', 1)
|
|
||||||
call s:default('toc_header', 'Contents')
|
call s:default('toc_header', 'Contents')
|
||||||
|
|
||||||
call s:default('html_header_numbering', 0)
|
|
||||||
call s:default('html_header_numbering_sym', '')
|
|
||||||
call s:default('conceallevel', 2)
|
|
||||||
call s:default('url_maxsave', 15)
|
call s:default('url_maxsave', 15)
|
||||||
|
|
||||||
call s:default('diary_months',
|
|
||||||
\ {
|
|
||||||
\ 1: 'January', 2: 'February', 3: 'March',
|
|
||||||
\ 4: 'April', 5: 'May', 6: 'June',
|
|
||||||
\ 7: 'July', 8: 'August', 9: 'September',
|
|
||||||
\ 10: 'October', 11: 'November', 12: 'December'
|
|
||||||
\ })
|
|
||||||
|
|
||||||
call s:default('map_prefix', '<Leader>w')
|
call s:default('map_prefix', '<Leader>w')
|
||||||
|
|
||||||
call s:default('current_idx', 0)
|
call s:default('current_idx', 0)
|
||||||
|
|
||||||
call s:default('auto_chdir', 0)
|
|
||||||
|
|
||||||
" Scheme regexes should be defined even if syntax file is not loaded yet
|
" Scheme regexes should be defined even if syntax file is not loaded yet
|
||||||
" cause users should be able to <leader>w<leader>w without opening any
|
" cause users should be able to <leader>w<leader>w without opening any
|
||||||
" vimwiki file first
|
" vimwiki file first
|
||||||
@ -540,7 +518,7 @@ function! s:build_table_menu(topmenu)
|
|||||||
exe 'nmenu disable '.a:topmenu.'.Table'
|
exe 'nmenu disable '.a:topmenu.'.Table'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"XXX make sure anything below does not cause autoload/base to be loaded
|
|
||||||
if !empty(g:vimwiki_menu)
|
if !empty(g:vimwiki_menu)
|
||||||
call s:build_menu(g:vimwiki_menu)
|
call s:build_menu(g:vimwiki_menu)
|
||||||
call s:build_table_menu(g:vimwiki_menu)
|
call s:build_table_menu(g:vimwiki_menu)
|
||||||
|
@ -412,10 +412,10 @@ execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/'
|
|||||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
||||||
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/'
|
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/'
|
||||||
|
|
||||||
if g:vimwiki_hl_cb_checked == 1
|
if vimwiki#vars#get_global('hl_cb_checked') == 1
|
||||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '.
|
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '.
|
||||||
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
elseif g:vimwiki_hl_cb_checked == 2
|
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
|
||||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ execute 'syntax match VimwikiTag /'.g:vimwiki_rxTags.'/'
|
|||||||
|
|
||||||
" header groups highlighting "{{{
|
" header groups highlighting "{{{
|
||||||
|
|
||||||
if g:vimwiki_hl_headers == 0
|
if vimwiki#vars#get_global('hl_headers') == 0
|
||||||
" Strangely in default colorscheme Title group is not set to bold for cterm...
|
" Strangely in default colorscheme Title group is not set to bold for cterm...
|
||||||
if !exists("g:colors_name")
|
if !exists("g:colors_name")
|
||||||
hi Title cterm=bold
|
hi Title cterm=bold
|
||||||
|
Loading…
Reference in New Issue
Block a user