Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一个问题,读取 .ycm_extra_conf.py 中相应的编译参数设置到 ALE 出现的一个问题 #10

Open
hardboydu opened this issue Jul 23, 2018 · 0 comments

Comments

@hardboydu
Copy link

hardboydu commented Jul 23, 2018

" 取得本文件所在的目录
let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h')

" 定义一个命令用来加载文件
command! -nargs=1 LoadScript exec 'so '.s:home.'/'.'<args>'

" 将 vim-init 目录加入 runtimepath
exec 'set rtp+='.s:home

" 将 ~/.vim 目录加入 runtimepath (有时候 vim 不会自动帮你加入)
set rtp+=~/.vim

let g:devrte_vim_plug_path='/opt/devrte/runtime/vim-conf/vim-plug'

" 加载Skywind3000 的脚本
LoadScript vim-init/init.vim

python3 << EOF

import sys
import vim
import importlib

try:
	module = importlib.machinery.SourceFileLoader("aaa", "./.ycm_extra_conf.py").load_module()

	flags = module.FlagsForFile("a.cpp")["flags"]
	
	cflags   = vim.eval("g:ale_c_gcc_options")
	cppflags = vim.eval("g:ale_cpp_gcc_options")
	
	for flag in flags:
		if flag[0:2] == "-I":
			if flag.find("llvm") == -1:
				cflags   = cflags + " "
				cflags   = cflags + flag
				cppflags = cppflags + " "
				cppflags = cppflags + flag
	
	vim.command("let g:ale_c_gcc_options = '%s'"% cflags)
	vim.command("let g:ale_cpp_gcc_options = '%s'"% cppflags)

except Exception as e:
	exit

EOF

我写了上边这个脚本,就是用于读取 .ycm_extra_conf.py 的一些编译信息设置到ALE中,总是出现下边这个错误:

No module named 'ycm_core'

将 .ycm_extra_conf.py中import ycm_core 去掉就没有问题了

是我这个脚本先于YCM加载的原因吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant