vim YouCompleteMe到编译数据库文件夹的路径

vim YouCompleteMe到编译数据库文件夹的路径,vim,cmake,Vim,Cmake,因此,在加载编译_数据库时,我遇到了一个不太麻烦的小问题,该数据库是由.ycm_extra_conf.py中的cmake生成的 # Path to the compile_commands.json that is generated by cmake # (some how this doesn't work, if path is not explicit?) compilation_database_folder = '/home/user/programming/someproject/

因此,在加载编译_数据库时,我遇到了一个不太麻烦的小问题,该数据库是由.ycm_extra_conf.py中的cmake生成的

# Path to the compile_commands.json that is generated by cmake
# (some how this doesn't work, if path is not explicit?)
compilation_database_folder = '/home/user/programming/someproject/build'

在这里传递显式路径一点问题都没有,尽管我有点想指定项目根目录的相对路径。经过2小时的搜索和反复试验,我现在想要一些答案。有什么建议吗?

我想您知道.ycm\u extra\u conf.py文件的位置。因此,您可以获得与此文件相关的路径,如下所示:

os.path.dirname(os.path.abspath(__file__)) + "/build"

这将获取ycm配置文件的目录,并将构建目录添加到其中。如果您的目录位于此目录之上,请再次使用os.path.dirname

是的,就是这样。。。我想我应该开始学习一些python。