| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  | " vim compiler file | 
					
						
							|  |  |  | " Compiler:	cppcheck (C++ static checker) | 
					
						
							|  |  |  | " Maintainer:   Vincent B. (twinside@free.fr) | 
					
						
							| 
									
										
										
										
											2024-11-19 22:41:14 +01:00
										 |  |  | " Last Change:  2024 Nov 19 by @Konfekt | 
					
						
							| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-06 20:14:49 +01:00
										 |  |  | if exists("current_compiler") | finish | endif | 
					
						
							| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  | let current_compiler = "cppcheck" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let s:cpo_save = &cpo | 
					
						
							| 
									
										
										
										
											2024-11-06 20:14:49 +01:00
										 |  |  | set cpo&vim | 
					
						
							| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-17 20:54:00 +02:00
										 |  |  | let s:slash = has('win32')? '\' : '/' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  | if !exists('g:c_cppcheck_params') | 
					
						
							|  |  |  |   let g:c_cppcheck_params = '--verbose --force --inline-suppr' | 
					
						
							|  |  |  |         \ ..' '..'--enable=warning,style,performance,portability,information,missingInclude' | 
					
						
							|  |  |  |         \ ..' '..(executable('getconf') ? '-j' .. systemlist('getconf _NPROCESSORS_ONLN')[0] : '') | 
					
						
							|  |  |  |   let s:undo_compiler = 'unlet! g:c_cppcheck_params' | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let &l:makeprg = 'cppcheck --quiet' | 
					
						
							|  |  |  |       \ ..' --template="{file}:{line}:{column}: {severity}: [{id}] {message} {callstack}"' | 
					
						
							| 
									
										
										
										
											2024-10-17 20:54:00 +02:00
										 |  |  |       \ ..' '..get(b:, 'c_cppcheck_params', get(g:, 'c_cppcheck_params', (&filetype ==# 'cpp' ? ' --language=c++' : ''))) | 
					
						
							| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  |       \ ..' '..get(b:, 'c_cppcheck_includes', get(g:, 'c_cppcheck_includes', | 
					
						
							|  |  |  |       \	          (filereadable('compile_commands.json') ? '--project=compile_commands.json' : | 
					
						
							| 
									
										
										
										
											2024-10-17 20:54:00 +02:00
										 |  |  |       \           (!empty(glob('*'..s:slash..'compile_commands.json', 1, 1)) ? '--project='..glob('*'..s:slash..'compile_commands.json', 1, 1)[0] : | 
					
						
							|  |  |  |       \	          (empty(&path) ? '' : '-I')..join(map(filter(split(&path, ','), 'isdirectory(v:val)'),'shellescape(v:val)'), ' -I'))))) | 
					
						
							| 
									
										
										
										
											2024-11-19 22:41:14 +01:00
										 |  |  | exe 'CompilerSet makeprg='..escape(&l:makeprg, ' \|"') | 
					
						
							| 
									
										
										
										
											2024-10-05 17:09:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | CompilerSet errorformat= | 
					
						
							|  |  |  |   \%f:%l:%c:\ %tarning:\ %m, | 
					
						
							|  |  |  |   \%f:%l:%c:\ %trror:\ %m, | 
					
						
							|  |  |  |   \%f:%l:%c:\ %tnformation:\ %m, | 
					
						
							|  |  |  |   \%f:%l:%c:\ %m, | 
					
						
							|  |  |  |   \%.%#\ :\ [%f:%l]\ %m | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exe get(s:, 'undo_compiler', '') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let &cpo = s:cpo_save | 
					
						
							|  |  |  | unlet s:cpo_save |