Feature: Add option g:vimwiki_commentstring to disable vimwiki commentstring (PR #946 from @BirgerNi )

This commit is contained in:
BirgerNi 2020-07-31 00:04:43 +02:00 committed by GitHub
parent 66a294d76f
commit 0a5a33af19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 4 deletions

View File

@ -1467,7 +1467,11 @@ that the > syntax allow empty lines to signal multiple paragraphs.
A line that starts with %% is a comment. A line that starts with %% is a comment.
E.g.: > E.g.: >
%% this text would not be in HTML %% this text would not be in HTML
<
The default commentstring can be changed or disabled with
|g:vimwiki_commentstring| so an alternative commentstring can be set, e.g.:
<!-- This may be a comment too -->
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
5.11. Horizontal line *vimwiki-syntax-hr* 5.11. Horizontal line *vimwiki-syntax-hr*
@ -3548,6 +3552,23 @@ take care when using it. Any plugin that uses a set filetype will be enabled.
The default is `[ ]` The default is `[ ]`
------------------------------------------------------------------------------
*g:vimwiki_commentstring*
An option to change the default commentstring. Use
let g:vimwiki_commentstring = '<!--%s-->'
for html-style comments. Use
let g:vimwiki_commentstring = ""
to not set commentstring by vimwiki.
The default is %%%s.
============================================================================== ==============================================================================
13. Getting help *vimwiki-help* 13. Getting help *vimwiki-help*
@ -3676,7 +3697,7 @@ Contributors and their Github usernames in roughly chronological order:
- Rafael Castillo (@eltrufas) - Rafael Castillo (@eltrufas)
- Reiner Herrmann (@reinerh) - Reiner Herrmann (@reinerh)
- Ryan Winograd - Ryan Winograd
- Birger Niklas (@BirgerNi)
============================================================================== ==============================================================================
16. Changelog *vimwiki-changelog* 16. Changelog *vimwiki-changelog*
@ -3688,6 +3709,7 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from
https://github.com/vimwiki-backup/vimwiki/issues. https://github.com/vimwiki-backup/vimwiki/issues.
New:~ New:~
* PR #946: Add option |g:vimwiki_commentstring| to customize commentstring
* Issue #940: Render table header inside thead element and rest under * Issue #940: Render table header inside thead element and rest under
tbody element if table header specified in wiki tbody element if table header specified in wiki
* PR #811: Feature: Added handling of absolute path to vimwiki (with //) * PR #811: Feature: Added handling of absolute path to vimwiki (with //)

View File

@ -9,8 +9,12 @@ if exists('b:did_ftplugin')
endif endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer 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 setlocal commentstring=%%%s
elseif g:vimwiki_commentstring != ""
let &l:commentstring=g:vimwiki_commentstring
endif
if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel') if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel')
let &l:conceallevel = vimwiki#vars#get_global('conceallevel') let &l:conceallevel = vimwiki#vars#get_global('conceallevel')

29
test/commentstring.vader Normal file
View File

@ -0,0 +1,29 @@
Include: vader_includes/vader_setup.vader
After (clean up):
if exists('g:vimwiki_commentstring')
unlet g:vimwiki_commentstring
endif
if exists('b:did_ftplugin')
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):
set ft=vimwiki
AssertEqual '%%%s', &commentstring
Execute (html commentstring):
let g:vimwiki_commentstring='<!-- %s -->'
set ft=vimwiki
AssertEqual '<!-- %s -->', &commentstring
Include: vader_includes/vader_teardown.vader