我正在尝试为VIM创建一个Python插件来检测当前项目是否是Android项目。不幸的是,我无法让它将布尔值返回到VIM。从VIM中调用插件只会输出任何结果。下面的代码使用print
命令,但我也尝试了vim.command("return {value}")
并在脚本中设置vim变量。有什么见解吗?在
我有一个包含这些内容的插件文件
if !has('python')
echo "Error: Required vim compiled with +python"
finish
endif
" Get local path for the script, so we can import other files
let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
let s:python_folder_path = s:script_folder_path . '/../python/'
" Start the python file in the scriptdir
function! s:startPyfile(fileName)
execute "pyfile " . s:python_folder_path . a:fileName
endfunction
command! Detect call Detect()
function! Detect()
call s:startPyfile("vim_detect.py")
endfunction
它叫维姆_检测.py里面有这个
^{pr2}$
正如其他人评论的那样,您的示例代码(您应该将其浓缩为一个最小的示例)实际上并没有被调用。我从Python返回结果的方法是设置一个Vim变量,如下所示:
对于布尔值,只需将
^{pr2}$0
/1
作为一个数字返回,简化了逻辑:相关问题 更多 >
编程相关推荐