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

Fix processing of autoTagsDir option #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

artem-kamyshev
Copy link

@artem-kamyshev artem-kamyshev commented Aug 20, 2017

Hello, craigemery

First of all, thanks for the plugin.

This commit fixes two issues with g:autotagTagsDir.

  1. I use ctags with fugurive plugin, so I place tags file into .git subdirectory. I've found out that though that this functionality is available in your plugin (via g:autotagTagsDir), it does not work. Here is a log, showing the reason (look at ..tst.cpp filename):
INFO:autotag_debug:source = "/home/kamyshev/workspace/personal/test-repo/tst.cpp"
INFO:autotag_debug:drive = "", file = "/home/kamyshev/workspace/personal/test-repo"
INFO:autotag_debug:testing tags_file "/home/kamyshev/workspace/personal/test-repo/.git/tags"
INFO:autotag_debug:Stripping tags for ..tst.cpp from tags file /home/kamyshev/workspace/personal/test-repo/.git/tags
  1. With this fixed, I've found out that it cannot open tags file if cwd in vim is not a root project directory.

Here is what I mean. Test project hierarchy is as following:

<rootdir>/.git/tags
<rootdir>/tst.cpp
<rootdir>/d1/x.h

When we call vim from <rootdir> everything is fine. When we call vim from <rootdir>/d1 (like this: cd <rootdir>/d1 && vim ./x.h), we get the following error:

WARNING:root:Traceback (most recent call last):
  File "/home/kamyshev/.vim/bundle/vim-autotag/plugin/autotag.py", line 270, in autotag
    at.rebuildTagFiles()
  File "/home/kamyshev/.vim/bundle/vim-autotag/plugin/autotag.py", line 261, in rebuildTagFiles
    self.updateTagsFile(tags_dir, tags_file, sources)
  File "/home/kamyshev/.vim/bundle/vim-autotag/plugin/autotag.py", line 255, in updateTagsFile
    for l in do_cmd(cmd, self.tags_dir or tags_dir):
  File "/home/kamyshev/.vim/bundle/vim-autotag/plugin/autotag.py", line 63, in do_cmd
    p = subprocess.Popen(cmd, cwd=cwd, **kw)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] Нет такого файла или каталога: '.git'

The reason is that though self.tags_dir does not contain a full path to tags file this value is used
as cwd argument when calling ctags application.

This commit fixes the following errors prevent this option from working:

1) ".." prefix is added when self.tags_dir is defined, but
a directory separator is not added after "..",
thus we get an errous filename: "..<source_file_name>"

2) self.tags_dir does not contain a full path to tags file, but is used
as cwd when calling ctags application.
This will fail when vim is called from any directory within
project hierarchy except the one for containing sefl.tags_dir
directly.
@craigemery
Copy link
Owner

I thought the parents = os.par * dir_count was to make a list of ".." that is then given to os.path.join() and os.path.join() puts in the os.sep bits. So I'm confused by this. I may try & replicate it with the new master & have a better look at the error.

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

Successfully merging this pull request may close these issues.

2 participants