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

不能生成 Gtags 数据文件 #359

Closed
4 tasks
daocang opened this issue Sep 12, 2019 · 16 comments
Closed
4 tasks

不能生成 Gtags 数据文件 #359

daocang opened this issue Sep 12, 2019 · 16 comments
Labels

Comments

@daocang
Copy link

daocang commented Sep 12, 2019

  • vim or neovim?

    • [
  • [x ] vim

    • neovim
  • Output of vim --version or nvim --version:

  • Output of :echo has("python"):

  • Output of :echo has("python3"): 1

  • Output of :echo &pythondll(only vim, not neovim):

  • Output of :echo &pythonthreedll(only vim, not neovim): x

  • Output of :py print(sys.version):

  • Output of :py3 print(sys.version): 1

  • Output of :echo g:Lf_Debug_Cmd:

  • Output of :echo g:Lf_FilesFromCache:

  • Operating system:

    • Linux
    • Mac OS X
    • [ x] Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:

Describe your question, feature request, or bug.

不论是自动还是手动执行::Leaderf gtags --update,指定目录下都没有gtags数据文件生成。其它功能一切正常。leaderf tag ,leaderf function 能正常执行。问题与issues354#基本相同
let g:Lf_GtagsAutoGenerate = 1
let g:Lf_GtagsSource = 2
let g:Lf_GtagsfilesCmd = {
\ '.git': 'git ls-files --recurse-submodules',
\ '.hg': 'hg files',
\ 'default': 'rg --no-messages --files'
}
let g:Lf_GtagsAcceptDotfiles = 0
let g:Lf_GtagsSkipUnreadable = 0
"let g:Lf_GtagsSkipSymlink = ''
let g:Lf_Gtagslabel='native-pygments'
let g:Lf_Gtagsconf=$vim.'/gtags/share/gtags/gtags.conf'

另:gutentags.vim 功能执行正常
顺便报一个问题:工作目录路径如果包含上标字符,leaderf function 功能执行失败

@Yggdroot
Copy link
Owner

如果不成功,应该会有错误信息报出来,:message 看看有什么错误信息。

@daocang
Copy link
Author

daocang commented Sep 12, 2019

:leaderf gtags --update
:message
简体中文维护者 @*
当前打开的文件信息

没有特殊提示

leaderf用着非常顺手!谢谢

@Yggdroot
Copy link
Owner

想起来了,如果路径有非ASCII字符,不要使用g:Lf_GtagsfilesCmd

@Yggdroot
Copy link
Owner

Yggdroot commented Sep 13, 2019

#312 差不多

@daocang
Copy link
Author

daocang commented Sep 13, 2019

测试路径无非ASCII字符
let g:Lf_GtagsSource = 0 也试过,失败

@Yggdroot
Copy link
Owner

顺便报一个问题:工作目录路径如果包含上标字符,leaderf function 功能执行失败

ctags在windows上有bug,识别不出test²这样的路径。

我觉得如果不生成gtags数据库,应该会有错误信息打印出来,没有错误信息很奇怪。

可以在这个函数里加一些打印,看看当:Leaderf gtags --update时都做了些什么。

def _update(self, filename, single_update, auto):
if filename == "":
return
if self._gtagsconf == '' and os.name == 'nt':
self._gtagsconf = os.path.normpath(os.path.join(self._which("gtags.exe"), "..", "share", "gtags", "gtags.conf"))
root, dbpath, exists = self._root_dbpath(filename)
if not filename.startswith(root):
return
self._updateLibGtags(dbpath)
if single_update:
if exists:
cmd = 'cd {}"{}" && gtags {}{}{}{}--gtagslabel {} --single-update "{}" "{}"'.format(self._cd_option, root,
self._accept_dotfiles, self._skip_unreadable, self._skip_symlink,
'--gtagsconf %s ' % self._gtagsconf if self._gtagsconf else "",
self._gtagslabel, filename, dbpath)
env = os.environ
env["GTAGSFORCECPP"] = ""
subprocess.Popen(cmd, shell=True, env=env)
elif not auto:
self._executeCmd(root, dbpath)
elif self._isVersionControl(filename):
if not exists:
self._executeCmd(root, dbpath)

@daocang
Copy link
Author

daocang commented Sep 17, 2019

LeaderF是VIM上极好用的插件,后期用户肯定会慢慢更多,从功能完整性考虑,应该加上功能调试,给个选项开关。

@Yggdroot
Copy link
Owner

LeaderF是VIM上极好用的插件,后期用户肯定会慢慢更多,从功能完整性考虑,应该加上功能调试,给个选项开关。

调试功能基本有了,常出问题的点基本都有exception或log记录,只是这个问题太corner了。

原因找到了,对于test²这样的路径,Windows上有问题,好多命令都会识别成test2,这个太奇怪了。
而且对于Python2,如果当前路径是test²

import os
print(os.getcwd())

打印出来的竟然是test2
例如在d:\test²下执行gtags命令,

D:\test² > gtags
gtags: directory 'D:/test2' not found.

话说你如果使用的是Python3,应该能看到报错信息,什么错误信息都没有,难道使用的是Python2?
echo g:Lf_PythonVersion输出是什么?

@daocang
Copy link
Author

daocang commented Sep 18, 2019

Python3.7.4

@daocang
Copy link
Author

daocang commented Sep 18, 2019

gtags 是正常路径也没有文件生成,tags、func 是test²路径下有提示出错

@Yggdroot
Copy link
Owner

正常路径也没有生成就奇怪了。你加些打印看看。

@Yggdroot
Copy link
Owner

def _update(self, filename, single_update, auto):
if filename == "":
return
if self._gtagsconf == '' and os.name == 'nt':
self._gtagsconf = os.path.normpath(os.path.join(self._which("gtags.exe"), "..", "share", "gtags", "gtags.conf"))
root, dbpath, exists = self._root_dbpath(filename)
if not filename.startswith(root):
lfCmd("let g:Lf_Debug_Gtags = '%s'" % escQuote(str((filename, root))))
return

435行打印出来了,说明filename.startswith(root) 是False, 你的文件名和路径有非ASCII字符吗?

@daocang
Copy link
Author

daocang commented Sep 18, 2019

:echo g:Lf_Debug_Gtags
D:/.project/test.c D:\.project

@daocang
Copy link
Author

daocang commented Sep 18, 2019

经作者排查,是 set shellslash 设置问题,取消这个设置项就正常了,感谢!

Yggdroot added a commit that referenced this issue Sep 18, 2019
@Yggdroot
Copy link
Owner

修好了。

@daocang
Copy link
Author

daocang commented Sep 18, 2019

修好了。

能正常使用了。

@Yggdroot Yggdroot added the bug label Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants