diff options
author | Soham Shanbhag <sohamshanbhag@users.noreply.github.com> | 2024-06-03 16:48:43 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 09:48:43 +0200 |
commit | 054a287dbe6fe4308d26ec593da2057641f2bb9b (patch) | |
tree | 522fd2f143226051da5ab3f279454581263d301b | |
parent | 3a1515bfee59710b4da9bfdf0fc4ecb5b13a00db (diff) | |
download | rneovim-054a287dbe6fe4308d26ec593da2057641f2bb9b.tar.gz rneovim-054a287dbe6fe4308d26ec593da2057641f2bb9b.tar.bz2 rneovim-054a287dbe6fe4308d26ec593da2057641f2bb9b.zip |
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).
-rw-r--r-- | runtime/ftplugin/arduino.lua | 1 | ||||
-rw-r--r-- | runtime/ftplugin/c.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/calender.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/ch.lua | 1 | ||||
-rw-r--r-- | runtime/ftplugin/cs.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/css.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/d.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/indent.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/objc.lua | 1 | ||||
-rw-r--r-- | runtime/ftplugin/xdefaults.lua | 2 | ||||
-rw-r--r-- | runtime/ftplugin/xs.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/runtime_spec.lua | 2 |
12 files changed, 12 insertions, 8 deletions
diff --git a/runtime/ftplugin/arduino.lua b/runtime/ftplugin/arduino.lua new file mode 100644 index 0000000000..f398d66a63 --- /dev/null +++ b/runtime/ftplugin/arduino.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '// %s' diff --git a/runtime/ftplugin/c.lua b/runtime/ftplugin/c.lua index 0ddbf09470..2695b642aa 100644 --- 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 index b4e68148f5..984111a08b 100644 --- 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 new file mode 100644 index 0000000000..f398d66a63 --- /dev/null +++ b/runtime/ftplugin/ch.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '// %s' diff --git a/runtime/ftplugin/cs.lua b/runtime/ftplugin/cs.lua index b4e68148f5..f398d66a63 100644 --- 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 index b4e68148f5..984111a08b 100644 --- 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 index b4e68148f5..f398d66a63 100644 --- 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 index b4e68148f5..f398d66a63 100644 --- 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 new file mode 100644 index 0000000000..f398d66a63 --- /dev/null +++ b/runtime/ftplugin/objc.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '// %s' diff --git a/runtime/ftplugin/xdefaults.lua b/runtime/ftplugin/xdefaults.lua index b4e68148f5..e54bf808b0 100644 --- 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 new file mode 100644 index 0000000000..f398d66a63 --- /dev/null +++ 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 index c6b0577ebe..f63363d6d9 100644 --- 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) |