YouCompleterMe:No semantic completer exists for filetypes:['cpp']

在vim中使用YouCompleteMe插件补全CPP遇到的问题


 YCM是vim的一款基于语义的智能补全插件。之前按照博客Ubuntu 16.04 64位安装YouCompleteMe给vim安装了YCM插件,安装过程可能出现了一些问题,当时没太在意,在python补全上也没出现啥问题。然而今天在编写CPP时,使用Ctrl+J实现跳转到定义时,提示错误: 
 ValueError: No semantic completer exists for filetypes: ['CPP'] 
 不支持对cpp的语义补全!最开始想到的是cpp的库路径没设置好,去找配置文件.ycm_extra_conf.py,在路径~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/下,执行命令 
 vim .ycm_extra_conf.py 
 参照上面的博客进行设置,问题仍没有解决。好的,没办法按照教程重新装一遍,在安装编译Clang时果然出现了问题,直接卡在94%不动了!如下图所示: 
  自动编译安装Clang
   
  等待许久,系统变得十分卡顿。Ctrl+C终止编译,重新编译了几次,还是编译不过!在StackOverFlow寻求帮助,有人说是因为在虚拟机中内存耗光,增加交换空间即可,想想好像是这样,在编译过程中用top命令查看,果然在编译到94%时,内存所剩无几。 
  那么,就增加一些交换空间吧~,编写脚本addswapfile.sh如下:

#!/bin/sh
# size of swapfile in megabytes  
swapsize=512

# does the swap file already exist?  
grep -q "swapfile" /etc/fstab

# if not then create it  
if [ $? -ne 0 ]; then  
    echo 'swapfile not found. Adding swapfile.'  
    fallocate -l ${swapsize}M /swapfile  
    chmod 600 /swapfile  
    mkswap /swapfile  
    swapon /swapfile  
    echo '/swapfile none swap defaults 0 0' >> /etc/fstab  
else  
    echo 'swapfile found. No changes made.'  
fi
# output results to terminal  
cat /proc/swaps  
cat /proc/meminfo | grep Swap

这下我们编译成功了! 
这里写图片描述

在vim中编写cpp代码,代码补全,跳转功能正常,问题解决!如果swap内存不再需要,可删除掉,编写delswapfile.sh,运行即可。

#!/bin/sh

# does the swap file exist?  
grep -q "swapfile" /etc/fstab

# if it does then remove it  
if [ $? -eq 0 ]; then  
    echo 'swapfile found. Removing swapfile.'  
    sed -i '/swapfile/d' /etc/fstab  
    echo "3" > /proc/sys/vm/drop_caches  
    swapoff -a  
    rm -f /swapfile  
else  
    echo 'No swapfile found. No changes made.'  
fi

# output results to terminal  
cat /proc/swaps  

cat /proc/meminfo | grep Swap 自己试了下,可能我能存不够吧,直接else echo 'No swapfile found. No changes made.' 没什么效果

猜你喜欢

转载自blog.csdn.net/weixin_40539892/article/details/80576653