Fix: register a default wiki if the user hasn't

Ref #440
Ref #441
This commit is contained in:
EinfachToll 2018-02-23 17:39:50 +01:00
parent 5a00028e6a
commit 02e8fb3108

View File

@ -206,13 +206,22 @@ function! s:populate_wikilocal_options()
let g:vimwiki_wikilocal_vars = [] let g:vimwiki_wikilocal_vars = []
let default_wiki_settings = {}
for key in keys(default_values)
if exists('g:vimwiki_'.key)
let default_wiki_settings[key] = g:vimwiki_{key}
else
let default_wiki_settings[key] = default_values[key]
endif
endfor
" set the wiki-local variables according to g:vimwiki_list (or the default settings) " set the wiki-local variables according to g:vimwiki_list (or the default settings)
if exists('g:vimwiki_list') if exists('g:vimwiki_list')
for users_options in g:vimwiki_list for users_wiki_settings in g:vimwiki_list
let new_wiki_settings = {} let new_wiki_settings = {}
for key in keys(default_values) for key in keys(default_values)
if has_key(users_options, key) if has_key(users_wiki_settings, key)
let new_wiki_settings[key] = users_options[key] let new_wiki_settings[key] = users_wiki_settings[key]
elseif exists('g:vimwiki_'.key) elseif exists('g:vimwiki_'.key)
let new_wiki_settings[key] = g:vimwiki_{key} let new_wiki_settings[key] = g:vimwiki_{key}
else else
@ -224,19 +233,17 @@ function! s:populate_wikilocal_options()
call add(g:vimwiki_wikilocal_vars, new_wiki_settings) call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
endfor endfor
else
" if the user hasn't registered any wiki, we register one wiki using the default values
let new_wiki_settings = deepcopy(default_wiki_settings)
let new_wiki_settings.is_temporary_wiki = 0
call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
endif endif
" default values for temporary wikis " default values for temporary wikis
let temporary_options_dict = {} let temporary_wiki_settings = deepcopy(default_wiki_settings)
for key in keys(default_values) let temporary_wiki_settings.is_temporary_wiki = 1
if exists('g:vimwiki_'.key) call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings)
let temporary_options_dict[key] = g:vimwiki_{key}
else
let temporary_options_dict[key] = default_values[key]
endif
endfor
let temporary_options_dict.is_temporary_wiki = 1
call add(g:vimwiki_wikilocal_vars, temporary_options_dict)
call s:validate_settings() call s:validate_settings()
endfunction endfunction