@ -530,7 +530,7 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
|
||||
" if current wiki is temporary -- was added by an arbitrary wiki file then do
|
||||
" not search wiki files in subdirectories. Or it would hang the system if
|
||||
" wiki file was created in $HOME or C:/ dirs.
|
||||
if VimwikiGet('temp', wiki_nr)
|
||||
if vimwiki#vars#get_wikilocal('temp', wiki_nr)
|
||||
let pattern = '*'.ext
|
||||
else
|
||||
let pattern = '**/*'.ext
|
||||
@ -1290,13 +1290,13 @@ endfunction " }}}
|
||||
|
||||
" vimwiki#base#goto_index
|
||||
function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
if a:wnum > len(g:vimwiki_list)
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in your Vimwiki settings!'
|
||||
return
|
||||
endif
|
||||
|
||||
" usually a:wnum is greater then 0 but with the following command it is == 0:
|
||||
" vim -n -c "exe 'VimwikiIndex' | echo g:vimwiki_current_idx"
|
||||
" vim -n -c ":VimwikiIndex"
|
||||
if a:wnum > 0
|
||||
let idx = a:wnum - 1
|
||||
else
|
||||
@ -1309,12 +1309,11 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
|
||||
call Validate_wiki_options(idx)
|
||||
call vimwiki#base#edit_file(cmd,
|
||||
\ vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('index', idx).
|
||||
\ vimwiki#vars#get_wikilocal('ext', idx),
|
||||
\ '')
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
let index_file = vimwiki#vars#get_wikilocal('path', idx).
|
||||
\ vimwiki#vars#get_wikilocal('index', idx).
|
||||
\ vimwiki#vars#get_wikilocal('ext', idx)
|
||||
|
||||
call vimwiki#base#edit_file(cmd, index_file, '')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#delete_link
|
||||
|
@ -125,17 +125,21 @@ function! s:populate_wikilocal_options()
|
||||
|
||||
if exists('g:vimwiki_list')
|
||||
for users_options in g:vimwiki_list
|
||||
let new_options_dict = {}
|
||||
let new_wiki_settings = {}
|
||||
for key in keys(default_values)
|
||||
if has_key(users_options, key)
|
||||
let new_options_dict[key] = users_options[key]
|
||||
let new_wiki_settings[key] = users_options[key]
|
||||
elseif exists('g:vimwiki_'.key)
|
||||
let new_options_dict[key] = g:vimwiki_{key}
|
||||
let new_wiki_settings[key] = g:vimwiki_{key}
|
||||
else
|
||||
let new_options_dict[key] = default_values[key]
|
||||
let new_wiki_settings[key] = default_values[key]
|
||||
endif
|
||||
endfor
|
||||
call add(g:vimwiki_wikilocal_vars, new_options_dict)
|
||||
|
||||
" is it a temporary wiki? No, it's not.
|
||||
let new_wiki_settings.temp = 0
|
||||
|
||||
call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
|
||||
endfor
|
||||
endif
|
||||
|
||||
@ -148,26 +152,27 @@ function! s:populate_wikilocal_options()
|
||||
let temporary_options_dict[key] = default_values[key]
|
||||
endif
|
||||
endfor
|
||||
call add(g:vimwiki_wikilocal_vars, default_values)
|
||||
let temporary_options_dict.temp = 1
|
||||
call add(g:vimwiki_wikilocal_vars, temporary_options_dict)
|
||||
|
||||
call s:validate_options()
|
||||
call s:validate_settings()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:validate_options()
|
||||
for options_dict in g:vimwiki_wikilocal_vars
|
||||
let options_dict['path'] = s:normalize_path(options_dict['path'])
|
||||
function! s:validate_settings()
|
||||
for wiki_settings in g:vimwiki_wikilocal_vars
|
||||
let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
|
||||
|
||||
let path_html = options_dict['path_html']
|
||||
let path_html = wiki_settings['path_html']
|
||||
if !empty(path_html)
|
||||
let options_dict['path_html'] = s:normalize_path(path_html)
|
||||
let wiki_settings['path_html'] = s:normalize_path(path_html)
|
||||
else
|
||||
let options_dict['path_html'] = s:normalize_path(
|
||||
\ substitute(options_dict['path'], '[/\\]\+$', '', '').'_html/')
|
||||
let wiki_settings['path_html'] = s:normalize_path(
|
||||
\ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/')
|
||||
endif
|
||||
|
||||
let options_dict['template_path'] = s:normalize_path(options_dict['template_path'])
|
||||
let options_dict['diary_rel_path'] = s:normalize_path(options_dict['diary_rel_path'])
|
||||
let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path'])
|
||||
let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path'])
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
@ -241,6 +246,15 @@ function! vimwiki#vars#set_wikilocal(key, value, wiki_nr)
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#add_temporary_wiki(settings)
|
||||
let new_temp_wiki_settings = copy(g:vimwiki_wikilocal_vars[-1])
|
||||
for [key, value] in items(a:settings)
|
||||
let new_temp_wiki_settings[key] = value
|
||||
endfor
|
||||
call insert(g:vimwiki_wikilocal_vars, new_temp_wiki_settings, -1)
|
||||
call s:validate_settings()
|
||||
endfunction
|
||||
|
||||
" number of registered wikis + temporary
|
||||
function! vimwiki#vars#number_of_wikis()
|
||||
return len(g:vimwiki_wikilocal_vars) - 1
|
||||
|
Reference in New Issue
Block a user