commit 054a287dbe6fe4308d26ec593da2057641f2bb9b
parent 3a1515bfee59710b4da9bfdf0fc4ecb5b13a00db
Author: Soham Shanbhag <sohamshanbhag@users.noreply.github.com>
Date: Mon, 3 Jun 2024 16:48:43 +0900
feat(ftplugin): change 'commentstring' to `// %s` for C/C++ (#29085)
Problem: The default commentstring for C/C++ can lead to invalid code
when commenting and does not match the Nvim codebase.
Solution: Change commentstring to `// %s` as used by Neovim. Also
set all commentstrings that derive from the default C string explicitly
(and correctly).
Diffstat:
12 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/runtime/ftplugin/arduino.lua b/runtime/ftplugin/arduino.lua
@@ -0,0 +1 @@
+vim.bo.commentstring = '// %s'
diff --git a/runtime/ftplugin/c.lua b/runtime/ftplugin/c.lua
@@ -1,5 +1,5 @@
-- These are the default option values in Vim, but not in Nvim, so must be set explicitly.
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '// %s'
vim.bo.define = '^\\s*#\\s*define'
vim.bo.include = '^\\s*#\\s*include'
diff --git a/runtime/ftplugin/calender.lua b/runtime/ftplugin/calender.lua
@@ -1 +1 @@
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '/* %s */'
diff --git a/runtime/ftplugin/ch.lua b/runtime/ftplugin/ch.lua
@@ -0,0 +1 @@
+vim.bo.commentstring = '// %s'
diff --git a/runtime/ftplugin/cs.lua b/runtime/ftplugin/cs.lua
@@ -1 +1 @@
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '// %s'
diff --git a/runtime/ftplugin/css.lua b/runtime/ftplugin/css.lua
@@ -1 +1 @@
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '/* %s */'
diff --git a/runtime/ftplugin/d.lua b/runtime/ftplugin/d.lua
@@ -1 +1 @@
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '// %s'
diff --git a/runtime/ftplugin/indent.lua b/runtime/ftplugin/indent.lua
@@ -1 +1 @@
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '// %s'
diff --git a/runtime/ftplugin/objc.lua b/runtime/ftplugin/objc.lua
@@ -0,0 +1 @@
+vim.bo.commentstring = '// %s'
diff --git a/runtime/ftplugin/xdefaults.lua b/runtime/ftplugin/xdefaults.lua
@@ -1 +1 @@
-vim.bo.commentstring = '/*%s*/'
+vim.bo.commentstring = '! %s'
diff --git a/runtime/ftplugin/xs.lua b/runtime/ftplugin/xs.lua
@@ -0,0 +1 @@
+vim.bo.commentstring = '// %s'
diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua
@@ -406,7 +406,7 @@ describe('runtime:', function()
eq('', eval('&commentstring'))
eq('', eval('&omnifunc'))
exec('edit file.cpp')
- eq('/*%s*/', eval('&commentstring'))
+ eq('// %s', eval('&commentstring'))
eq('ccomplete#Complete', eval('&omnifunc'))
end)
end)