diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index d93ef6a..bfa3177 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -361,6 +361,7 @@ function! s:populate_wikilocal_options() abort \ 'auto_toc': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'automatic_nested_syntaxes': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'base_url': {'type': type(''), 'default': '', 'min_length': 1}, + \ 'commentstring': {'type': type(''), 'default': '%%%s'}, \ 'css_name': {'type': type(''), 'default': 'style.css', 'min_length': 1}, \ 'custom_wiki2html': {'type': type(''), 'default': ''}, \ 'custom_wiki2html_args': {'type': type(''), 'default': ''}, diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 7c7cc74..97a2e08 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -9,13 +9,6 @@ if exists('b:did_ftplugin') endif let b:did_ftplugin = 1 " Don't load another plugin for this buffer -" Enable/disable commentstring %%%s -if !exists('g:vimwiki_commentstring') - setlocal commentstring=%%%s -elseif g:vimwiki_commentstring != "" - let &l:commentstring=g:vimwiki_commentstring -endif - if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel') let &l:conceallevel = vimwiki#vars#get_global('conceallevel') endif @@ -142,6 +135,10 @@ if v:version > 703 setlocal formatoptions+=j endif +" Set commentstring %%%s +let &l:commentstring = vimwiki#vars#get_wikilocal('commentstring') + + let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem') diff --git a/test/commentstring.vader b/test/commentstring.vader index 9d8ccc9..a216cef 100644 --- a/test/commentstring.vader +++ b/test/commentstring.vader @@ -1,4 +1,13 @@ -Include: vader_includes/vader_setup.vader +# Test comment string PR #946 +# TODO try default +# TODO try editing other buffer +#Execute (default commenstring, ft vimwiki): +# AssertEqual &filetype[0], 't' +# AssertEqual '/*%s*/', &commentstring + + +Given txt (txt): + txt After (clean up): if exists('g:vimwiki_commentstring') @@ -8,22 +17,16 @@ After (clean up): unlet b:did_ftplugin endif -Execute (default commentstring): - AssertEqual '/*%s*/', &commentstring - -Execute (default commenstring, ft vimwiki): - let g:vimwiki_commentstring="" - set ft=vimwiki - AssertEqual '/*%s*/', &commentstring - Execute (default vimwiki commentstring): + call vimwiki#vars#init() set ft=vimwiki AssertEqual '%%%s', &commentstring Execute (html commentstring): let g:vimwiki_commentstring='' + call vimwiki#vars#init() set ft=vimwiki AssertEqual '', &commentstring -Include: vader_includes/vader_teardown.vader - +Expect (void): + txt