From 269dd747b6e61842856031ca14ac26ee884ede4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 2 Apr 2023 23:01:48 +0800 Subject: [PATCH] refactor(defaults)!: change default 'commentstring' value to empty (#22862) --- runtime/doc/news.txt | 2 ++ runtime/doc/options.txt | 2 +- runtime/doc/vim_diff.txt | 1 + runtime/ftplugin/c.lua | 1 + runtime/ftplugin/calender.lua | 1 + runtime/ftplugin/css.lua | 1 + runtime/ftplugin/indent.lua | 1 + runtime/ftplugin/xdefaults.lua | 1 + src/nvim/options.lua | 2 +- test/functional/api/buffer_updates_spec.lua | 2 +- test/functional/legacy/window_cmd_spec.lua | 1 + test/functional/ui/fold_spec.lua | 7 +++++-- test/old/testdir/setup.vim | 1 + 13 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 runtime/ftplugin/c.lua create mode 100644 runtime/ftplugin/calender.lua create mode 100644 runtime/ftplugin/css.lua create mode 100644 runtime/ftplugin/indent.lua create mode 100644 runtime/ftplugin/xdefaults.lua diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 7b71b53b29..3ef6451ef9 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -66,6 +66,8 @@ The following changes may require adaptations in user config or plugins. change is that language-specific highlight groups need to be renamed from `@foo.help` to `@foo.vimdoc`. +• The default value of 'commentstring' is now empty instead of "/*%s*/". + ============================================================================== NEW FEATURES *news-features* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 36c02fa3cb..096b334cda 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1390,7 +1390,7 @@ A jump table for the options with a short description can be found at |Q_op|. insert a space. *'commentstring'* *'cms'* *E537* -'commentstring' 'cms' string (default "/*%s*/") +'commentstring' 'cms' string (default "") local to buffer A template for a comment. The "%s" in the value is replaced with the comment text. Currently only used to add markers for folding, see diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index cd93e4d17a..d6ad9107b3 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -34,6 +34,7 @@ Defaults *nvim-defaults* - 'backspace' defaults to "indent,eol,start" - 'backupdir' defaults to .,~/.local/state/nvim/backup// (|xdg|), auto-created - 'belloff' defaults to "all" +- 'commentstring' defaults to "" - 'compatible' is always disabled - 'complete' excludes "i" - 'directory' defaults to ~/.local/state/nvim/swap// (|xdg|), auto-created diff --git a/runtime/ftplugin/c.lua b/runtime/ftplugin/c.lua new file mode 100644 index 0000000000..b4e68148f5 --- /dev/null +++ b/runtime/ftplugin/c.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '/*%s*/' diff --git a/runtime/ftplugin/calender.lua b/runtime/ftplugin/calender.lua new file mode 100644 index 0000000000..b4e68148f5 --- /dev/null +++ b/runtime/ftplugin/calender.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '/*%s*/' diff --git a/runtime/ftplugin/css.lua b/runtime/ftplugin/css.lua new file mode 100644 index 0000000000..b4e68148f5 --- /dev/null +++ b/runtime/ftplugin/css.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '/*%s*/' diff --git a/runtime/ftplugin/indent.lua b/runtime/ftplugin/indent.lua new file mode 100644 index 0000000000..b4e68148f5 --- /dev/null +++ b/runtime/ftplugin/indent.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '/*%s*/' diff --git a/runtime/ftplugin/xdefaults.lua b/runtime/ftplugin/xdefaults.lua new file mode 100644 index 0000000000..b4e68148f5 --- /dev/null +++ b/runtime/ftplugin/xdefaults.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '/*%s*/' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 7be8f568b5..dffebcf14e 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -413,7 +413,7 @@ return { alloced=true, redraw={'curswant'}, varname='p_cms', - defaults={if_true="/*%s*/"} + defaults={if_true=""} }, { full_name='compatible', abbreviation='cp', diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index 25b838a4af..80e29c1ff2 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -75,7 +75,7 @@ local function reopenwithfolds(b) local tick = reopen(b, origlines) -- use markers for folds, make all folds open by default - command('setlocal foldmethod=marker foldlevel=20') + command('setlocal foldmethod=marker foldlevel=20 commentstring=/*%s*/') -- add a fold command('2,4fold') diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua index 0e9775060d..c7b5878b92 100644 --- a/test/functional/legacy/window_cmd_spec.lua +++ b/test/functional/legacy/window_cmd_spec.lua @@ -116,6 +116,7 @@ describe('splitkeep', function() -- oldtest: Test_splitkeep_fold() it('does not scroll when window has closed folds', function() exec([[ + set commentstring=/*%s*/ set splitkeep=screen set foldmethod=marker set number diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index c8a3397a86..96e28c1978 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2032,8 +2032,11 @@ describe("folded lines", function() end) it('multibyte fold markers work #20438', function() - meths.win_set_option(0, 'foldmethod', 'marker') - meths.win_set_option(0, 'foldmarker', '«,»') + exec([[ + setlocal foldmethod=marker + setlocal foldmarker=«,» + setlocal commentstring=/*%s*/ + ]]) insert([[ bbbbb bbbbb diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim index 25ac2d1239..473c7c7510 100644 --- a/test/old/testdir/setup.vim +++ b/test/old/testdir/setup.vim @@ -1,6 +1,7 @@ if exists('s:did_load') " Align Nvim defaults to Vim. set backspace= + set commentstring=/*%s*/ set complete=.,w,b,u,t,i set directory& set directory^=.