mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	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).
This commit is contained in:
		
							
								
								
									
										1
									
								
								runtime/ftplugin/arduino.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								runtime/ftplugin/arduino.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
-- These are the default option values in Vim, but not in Nvim, so must be set explicitly.
 | 
					-- 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.define = '^\\s*#\\s*define'
 | 
				
			||||||
vim.bo.include = '^\\s*#\\s*include'
 | 
					vim.bo.include = '^\\s*#\\s*include'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
vim.bo.commentstring = '/*%s*/'
 | 
					vim.bo.commentstring = '/* %s */'
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								runtime/ftplugin/ch.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								runtime/ftplugin/ch.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
vim.bo.commentstring = '/*%s*/'
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
vim.bo.commentstring = '/*%s*/'
 | 
					vim.bo.commentstring = '/* %s */'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
vim.bo.commentstring = '/*%s*/'
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
vim.bo.commentstring = '/*%s*/'
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								runtime/ftplugin/objc.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								runtime/ftplugin/objc.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
vim.bo.commentstring = '/*%s*/'
 | 
					vim.bo.commentstring = '! %s'
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								runtime/ftplugin/xs.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								runtime/ftplugin/xs.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					vim.bo.commentstring = '// %s'
 | 
				
			||||||
@@ -406,7 +406,7 @@ describe('runtime:', function()
 | 
				
			|||||||
    eq('', eval('&commentstring'))
 | 
					    eq('', eval('&commentstring'))
 | 
				
			||||||
    eq('', eval('&omnifunc'))
 | 
					    eq('', eval('&omnifunc'))
 | 
				
			||||||
    exec('edit file.cpp')
 | 
					    exec('edit file.cpp')
 | 
				
			||||||
    eq('/*%s*/', eval('&commentstring'))
 | 
					    eq('// %s', eval('&commentstring'))
 | 
				
			||||||
    eq('ccomplete#Complete', eval('&omnifunc'))
 | 
					    eq('ccomplete#Complete', eval('&omnifunc'))
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user