Fix: Vars.vim error in parsing: key not present (Issue #980)
This commit is contained in:
parent
11337f5b34
commit
4431caf7ff
@ -343,8 +343,8 @@ endfunction
|
|||||||
" Populate local variable <- user & default
|
" Populate local variable <- user & default
|
||||||
" Called: s:vimwiki#vars#init
|
" Called: s:vimwiki#vars#init
|
||||||
function! s:populate_wikilocal_options() abort
|
function! s:populate_wikilocal_options() abort
|
||||||
" Dev: if type is dict,
|
" TODO mutualise the g:vimwiki loop and the wiki_list
|
||||||
" -- the default dict gets extended and not replaced: keys are not deleted
|
" -- after tests on specific cases (format_tag and list_margin)
|
||||||
|
|
||||||
" Init local variable container
|
" Init local variable container
|
||||||
let g:vimwiki_wikilocal_vars = []
|
let g:vimwiki_wikilocal_vars = []
|
||||||
@ -415,8 +415,12 @@ function! s:populate_wikilocal_options() abort
|
|||||||
if exists('g:vimwiki_'.key)
|
if exists('g:vimwiki_'.key)
|
||||||
" Check type
|
" Check type
|
||||||
call s:check_users_value(key, g:vimwiki_{key}, default_values[key], 1)
|
call s:check_users_value(key, g:vimwiki_{key}, default_values[key], 1)
|
||||||
" Update if dict
|
" List margin
|
||||||
if default_values[key]['type'] == type({})
|
if key ==# 'list_margin'
|
||||||
|
let s:margin_set_by_user = 1
|
||||||
|
endif
|
||||||
|
" Extend Tag format
|
||||||
|
if key ==# 'tag_format'
|
||||||
let default_wiki_settings[key] = default_values[key].default
|
let default_wiki_settings[key] = default_values[key].default
|
||||||
call extend(default_wiki_settings[key], g:vimwiki_{key})
|
call extend(default_wiki_settings[key], g:vimwiki_{key})
|
||||||
" Set if other var
|
" Set if other var
|
||||||
@ -433,16 +437,17 @@ function! s:populate_wikilocal_options() abort
|
|||||||
for users_wiki_settings 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)
|
||||||
|
" Key present
|
||||||
if has_key(users_wiki_settings, key)
|
if has_key(users_wiki_settings, key)
|
||||||
call s:check_users_value(key, users_wiki_settings[key], default_values[key], 0)
|
call s:check_users_value(key, users_wiki_settings[key], default_values[key], 0)
|
||||||
|
" Set list margin
|
||||||
if key ==# 'list_margin'
|
if key ==# 'list_margin'
|
||||||
let s:margin_set_by_user = 1
|
let s:margin_set_by_user = 1
|
||||||
endif
|
endif
|
||||||
" Update if dict
|
" Extend Tag format
|
||||||
if default_values[key]['type'] == type({})
|
if key ==# 'tag_format'
|
||||||
let new_wiki_settings[key] = extend({}, default_values[key].default)
|
let new_wiki_settings[key] = extend({}, default_values[key].default)
|
||||||
let new_wiki_settings[key] = extend(new_wiki_settings.key, users_wiki_settings[key])
|
let new_wiki_settings[key] = extend(new_wiki_settings[key], users_wiki_settings[key])
|
||||||
" Set if other var
|
|
||||||
else
|
else
|
||||||
let new_wiki_settings[key] = users_wiki_settings[key]
|
let new_wiki_settings[key] = users_wiki_settings[key]
|
||||||
endif
|
endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Test comment string PR #946
|
# Test comment string PR #946
|
||||||
# TODO try default
|
# TODO try default
|
||||||
# TODO try editing other buffer
|
# TODO try editing other buffer
|
||||||
#Execute (default commenstring, ft vimwiki):
|
#Execute (default commenstring, ft vimwiki):
|
||||||
# AssertEqual &filetype[0], 't'
|
# AssertEqual &filetype[0], 't'
|
||||||
|
75
test/config_vars.vader
Normal file
75
test/config_vars.vader
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Test variable management (should be small)
|
||||||
|
# Issue #980
|
||||||
|
|
||||||
|
|
||||||
|
Given txt (txt):
|
||||||
|
txt
|
||||||
|
|
||||||
|
Execute (VimWei vars #980):
|
||||||
|
call CopyResources()
|
||||||
|
" Set
|
||||||
|
call UnloadVimwiki()
|
||||||
|
let wiki = {}
|
||||||
|
let wiki.name = 'ChenWei 🦊VimwikiMd @^%@!*#&^'
|
||||||
|
let wiki.path = $HOME . '/testmarkdown'
|
||||||
|
let wiki.ext = '.md'
|
||||||
|
let wiki.syntax = 'markdown'
|
||||||
|
let wiki.nested_syntaxes = {'python': 'python'}
|
||||||
|
|
||||||
|
" Make other tests crash
|
||||||
|
"let wiki.links_space_char = '_'
|
||||||
|
"let wiki.list_margin = 0
|
||||||
|
"let wiki.auto_toc = 1
|
||||||
|
"let wiki.auto_tags = 1
|
||||||
|
"let wiki.auto_generate_tags = 1
|
||||||
|
|
||||||
|
let g:vimwiki_list = [wiki]
|
||||||
|
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
|
||||||
|
let g:vimwiki_global_ext = 1
|
||||||
|
let g:vimwiki_autowriteall = 1
|
||||||
|
let g:vimwiki_auto_chdir = 1
|
||||||
|
let g:vimwiki_folding = 'expr'
|
||||||
|
call LoadVimwiki()
|
||||||
|
|
||||||
|
" Log
|
||||||
|
Log 'Path (Current): ' . getcwd()
|
||||||
|
Log 'File: (Buffer)' . @%
|
||||||
|
Log 'List (Wiki): ' . string(g:vimwiki_list)
|
||||||
|
Log ''
|
||||||
|
Log 'Local (Vars):'
|
||||||
|
Log g:vimwiki_wikilocal_vars
|
||||||
|
|
||||||
|
" Work
|
||||||
|
edit $HOME/testmarkdown/index.md
|
||||||
|
|
||||||
|
" Assert
|
||||||
|
AssertEqual '/home/vimtest/testmarkdown_cwd', getcwd() . '_cwd'
|
||||||
|
AssertEqual '0_wiki_nr', vimwiki#vars#get_bufferlocal('wiki_nr') . '_wiki_nr'
|
||||||
|
AssertEqual 'markdown_syntax', vimwiki#vars#get_wikilocal('syntax') . '_syntax'
|
||||||
|
AssertEqual '0_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
|
||||||
|
Log 'Path (Current): ' . getcwd()
|
||||||
|
Log 'File (Buffer):' . @%
|
||||||
|
bprevious
|
||||||
|
Log 'Path (Current): ' . getcwd()
|
||||||
|
Log 'File (Buffer):' . @%
|
||||||
|
bdelete index.md
|
||||||
|
|
||||||
|
" Clean
|
||||||
|
Log 'Clean up'
|
||||||
|
cd /testplugin
|
||||||
|
unlet g:vimwiki_list
|
||||||
|
unlet g:vimwiki_ext2syntax
|
||||||
|
unlet g:vimwiki_global_ext
|
||||||
|
unlet g:vimwiki_autowriteall
|
||||||
|
unlet g:vimwiki_auto_chdir
|
||||||
|
unlet g:vimwiki_folding
|
||||||
|
unlet wiki
|
||||||
|
Log 'Path (Current): ' . getcwd()
|
||||||
|
Log 'File (Buffer):' . @%
|
||||||
|
call ReloadVimwiki()
|
||||||
|
Log g:vimwiki_wikilocal_vars
|
||||||
|
|
||||||
|
Expect (txt):
|
||||||
|
txt
|
||||||
|
|
||||||
|
# vim: sw=2:foldlevel=30:foldmethod=indent:
|
@ -30,7 +30,7 @@ Execute (Configure: Set vimwiki list to markdown resource):
|
|||||||
Log "Declare my extension for temporary wiki"
|
Log "Declare my extension for temporary wiki"
|
||||||
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
|
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
|
||||||
|
|
||||||
Log "Reload vimwiki <- vader_setup.vader"
|
Log "Reload vimwiki"
|
||||||
nmapclear
|
nmapclear
|
||||||
|
|
||||||
" UNlet what can be
|
" UNlet what can be
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Link creation: my favorite (tinmarino)
|
# Link creation: my favorite (tinmarino)
|
||||||
# You know, when pressing Enter:
|
# You know, when pressing Enter:
|
||||||
# in mode normal, visual
|
# in mode normal, visual
|
||||||
# in OS windows, linux
|
# in OS windows, linux
|
||||||
# Seems easy but tests are reaaly needed here
|
# Seems easy but tests are reaaly needed here
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ Execute (Copy Wiki's Resources):
|
|||||||
|
|
||||||
Execute (Log):
|
Execute (Log):
|
||||||
Log 'Wiki Syntax'
|
Log 'Wiki Syntax'
|
||||||
|
call ReloadVimwiki()
|
||||||
|
AssertEqual '-1_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
|
||||||
|
|
||||||
Given (Void):
|
Given (Void):
|
||||||
|
|
||||||
|
29
test/vimrc
29
test/vimrc
@ -122,33 +122,52 @@
|
|||||||
call vimwiki#vars#set_bufferlocal('wiki_nr', 3)
|
call vimwiki#vars#set_bufferlocal('wiki_nr', 3)
|
||||||
|
|
||||||
" Verify syntax was set correctly
|
" Verify syntax was set correctly
|
||||||
Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn, 'ERROR: Vimwiki syntax not set correctly.'
|
Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn,
|
||||||
|
\ 'ERROR: Vimwiki syntax not set correctly: '
|
||||||
|
\ . 'Want: ' . a:vw_syn . ' '
|
||||||
|
\ . 'Have: ' . vimwiki#vars#get_wikilocal('syntax')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Reload plugin to change settings
|
function! UnloadVimwiki()
|
||||||
function! ReloadVimwiki()
|
|
||||||
" Clear mappings so plugin can be reloaded
|
" Clear mappings so plugin can be reloaded
|
||||||
" this is needed if running manually multiple times
|
" this is needed if running manually multiple times
|
||||||
nmapclear
|
nmapclear
|
||||||
|
|
||||||
" UNlet what can be
|
" UNlet what can be
|
||||||
|
" -- Note: getcompletion not present on vim7.3
|
||||||
for i in ['g:vimwiki_commentstring',
|
for i in ['g:vimwiki_commentstring',
|
||||||
\ 'b:did_ftplugin',
|
\ 'b:did_ftplugin',
|
||||||
\ 'g:loaded_vimwiki',
|
\ 'g:loaded_vimwiki',
|
||||||
\ 'g:vimwiki_global_vars',
|
\ 'g:vimwiki_global_vars',
|
||||||
\ 'g:vimwiki_wikilocal_vars',
|
\ 'g:vimwiki_wikilocal_vars',
|
||||||
\ 'g:vimwiki_syntax_variables',
|
\ 'g:vimwiki_syntax_variables',
|
||||||
|
\ 'g:vimwiki_list',
|
||||||
\ ]
|
\ ]
|
||||||
if exists(i)
|
if exists(i)
|
||||||
exe 'unlet ' . i
|
exe 'unlet ' . i
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
" Unlet ftplugin:
|
||||||
|
" -- Vader often staty in same buffer: [Vader-workbench]
|
||||||
|
if exists('b:did_ftplugin')
|
||||||
|
unlet b:did_ftplugin
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Source plugin
|
||||||
|
function! LoadVimwiki()
|
||||||
|
runtime! plugin/vimwiki.vim
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Reload plugin to change settings
|
||||||
|
function! ReloadVimwiki()
|
||||||
|
call UnloadVimwiki()
|
||||||
|
|
||||||
" Reset list
|
" Reset list
|
||||||
let g:vimwiki_list = g:vimwiki_list_vimrc
|
let g:vimwiki_list = g:vimwiki_list_vimrc
|
||||||
|
|
||||||
" Source plugin: Go
|
call LoadVimwiki()
|
||||||
runtime! plugin/vimwiki.vim
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReloadVars()
|
function! ReloadVars()
|
||||||
|
Loading…
Reference in New Issue
Block a user