vim syntastic插件用法

syntastic插件用法

syntastic插件简介

  • syntastic是vim上比较老牌的一款语法检查插件了
  • github地址:https://github.com/scrooloose/syntastic.git

vim安装

  • 在配置文件.vimrc中添加插件:
    Plug 'scrooloose/syntastic'

在这里插入图片描述

syntastic配置:

" syntastic                                                                                                                                                                                                                                                                   
set statusline+=%#warningmsg#                                                                                                                                                                                                                                                 
set statusline+=%{SyntasticStatuslineFlag()}                                                                                                                                                                                                                                  
set statusline+=%*                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                              
let g:syntastic_always_populate_loc_list = 1                                                                                                                                                                                                                                  
let g:syntastic_auto_loc_list = 1                                                                                                                                                                                                                                             
let g:syntastic_check_on_open = 1                                                                                                                                                                                                                                             
let g:syntastic_check_on_wq = 0                                                                                                                                                                                                                                               
"设置error和warning的标志                                                                                                                                                                                                                                                     
let g:syntastic_enable_signs = 1                                                                                                                                                                                                                                              
let g:syntastic_error_symbol='?'                                                                                                                                                                                                                                              
let g:syntastic_warning_symbol='?'                                                                                                                                                                                                                                            
"no-unused-args 忽略不使用的参数                                                                                                                                                                                                                                              
"no-redefined 忽略重定义                                                                                                                                                                                                                                                      
"no-max-line-length 忽略每行最长的检测                                                                                                                                                                                                                                        
"ignore 542 551 忽略if条件的body为空(如...elseif ret == nil then end,then和end中间没有语句);忽略空语句(如;),如果用了;则成对出现该语法检测warning                                                                                                                           
"有语法错误的一行左侧栏会有S>标识,光标移动到改行,vim下发会给出提示。修改正确后保存,则该'S>'会消失。                                                                                                                                                                  
let g:syntastic_lua_checkers = ["/usr/bin/luac5.3.5", "luacheck"]                                                                                                                                                                                                             
let g:syntastic_lua_luacheck_args = "--codes --no-max-comment-line-length --ignore 542 551"                                                                                                                                                                                   
                                                                                                                                                                                                                                                                              
"c                                                                                                                                                                                                                                                                            
"let g:syntastic_c_compiler =['gcc', 'clang', 'make']                                                                                                                                                                                                                         
"let g:syntastic_c_compiler_options ='-Wpedantic -g'                                                                                                                                                                                                                          
let g:syntastic_c_compiler_options ='-std=gnu99'                                                                                                                                                                                                                              
let g:syntastic_c_include_dirs=['/usr/include/']                                                                                                                                                                                                                              
let g:syntastic_c_config_file='.syntastic_c_config_file'                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                              
"cpp                                                                                                                                                                                                                                                                          
let g:syntastic_cpp_include_dirs = ['/usr/include/']                                                                                                                                                                                                                          
let g:syntastic_cpp_remove_include_errors = 1                                                                                                                                                                                                                                 
let g:syntastic_cpp_check_header = 1                                                                                                                                                                                                                                          
let g:syntastic_cpp_compiler = 'clang++'                                                                                                                                                                                                                                      
let g:syntastic_cpp_compiler_options = '-std=c++11 -stdlib=libstdc++'                                                                                                                                                                                                         
" syntastic end                                           

在这里插入图片描述

vim错误提示lua-bson.c|3 col 17 error| fatal error: lua.h: No such file or directory如何解决?

  • 问题截图:
    在这里插入图片描述

  • 这里提示文件没有找到是因为lua.h头文件没有包含进来。

  • 不同的的项目有不同的配置,用到的lua版本也不一样。

  • 如果系统已经安装了lua并且lua.h被放到了/usr/include目录中那么因为.vimrc中配置了该路径就不会提示这个错误。

let g:syntastic_c_include_dirs=['/usr/include/']      
  • 如果系统没有安装lua,或者有自己的其他库需要包含怎么办?
    • 在配置文件中加入下面的配置,并且在项目根目录添加.syntastic_c_config_file这个文件
      let g:syntastic_c_config_file='.syntastic_c_config_file'  
  • .syntastic_c_config_file中添加lua的路径:./skynet/3rd/lua
-I./skynet/3rd/lua
  • 添加相关配置后不再提示错误:
    在这里插入图片描述
  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

打杂程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值