xolox / vim-easytags

Automated tag file generation and syntax highlighting of tags in Vim
http://peterodding.com/code/vim/easytags/
1.01k stars 109 forks source link

easytags fails to create "tags" file in current file dir #15

Closed Valloric closed 11 years ago

Valloric commented 13 years ago

In my vimrc I have

set tags=./tags,tags
let g:easytags_dynamic_files = 1

I now edit a file called foo/bar.cpp. There is no foo/tags file. In this case, easytags still uses ~/_vimtags. Instead, it should create the foo/tags file and use it.

If I manually create an empty foo/tags file, then easytags uses it without problems.

What I really want is for easytags to create the tags file if it doesn't exist, since in my tags variable I have clearly stated that I want to use this file. Also, the documentation for g:easytags_dynamic_files states that

If you've also enabled g:easytags_by_filetype the project specific tags file must exist, even if it's empty; otherwise g:easytags_by_filetype will take precedence.

which leads me to believe that if g:easytags_by_filetype is disabled, then with g:easytags_dynamic_files easytags should be creating the tags file I specified if it does not exist.

xolox commented 13 years ago

Hi Valloric,

Sorry for not replying earlier. I'm not sure whether to call this an implementation bug or a documentation bug: The problem is that the g:easytags_dynamic_files option uses Vim's tagfiles() function which only reports existing tags files. To enable the behavior you describe requires me to re-implement the tagfiles() function in Vim script and I'm not sure how easy/hard this is to do.

Valloric commented 13 years ago

Well it's some kind of bug ;)

I'm not well versed in vimscript, but how hard would it be to get the value of the 'tags' variable and just create the specified files if they don't exist?

I plan on getting better acquainted with vimscript in the coming months, so I'll work on this myself some time in the future if you can't find the time/are busy with other things. It's not huge issue.

Thanks for the plugin btw. It's awesome.

Valloric commented 13 years ago

I accidentally closed the issue. Sorry for the mixup, it's open now.

xolox commented 13 years ago

I agree that the documentation implied the file would be created. Hopefully the commit I just made (referenced above) correctly implements this behavior. I've also made the documentation a bit more explicit. Please confirm whether the code change solves the issue for you. Thanks!

Valloric commented 13 years ago

Just tested the new source, and yep, the tags file is now created. Thanks for the fix!

BTW, I LOVE your plugins!

xolox commented 13 years ago

I don't personally use project specific tags files so didn't think too much about the change earlier that makes the plug-in automatically create tags files, however another user just complained about the new behavior in issue #16; he wants the plug-in to use existing project specific tags files but not create them (and instead to fall back to the global tags file or a file type specific tags file).

The change I made just now (fae8ddd) requires you to set g:easytags_dynamic_files to 2 in order to make the plug-in create project specific tags files. I chose to restore the meaning of 1 for the sake of backwards compatibility / the principle of least surprise.

Valloric commented 13 years ago

An option is probably a good idea. I don't care what the default behavior is as long as I can configure it to behave the way I want it to. But make sure to document the option.

On Mon, Sep 5, 2011 at 20:52, xolox < reply@reply.github.com>wrote:

I don't personally use project specific tags files so didn't think too much about the change earlier that makes the plug-in automatically create tags files, however another user just complained about the new behavior in issue

16; he wants the plug-in to use existing project specific tags files but

not create them (and instead to fall back to the global tags file or a file type specific tags file).

The change I made just now (fae8ddd) requires you to set g:easytags_dynamic_files to 2 in order to make the plug-in create project specific tags files. I chose to restore the meaning of 1 for the sake of backwards compatibility / the principle of least surprise.

Reply to this email directly or view it on GitHub: https://github.com/xolox/vim-easytags/issues/15#issuecomment-2005534

xolox commented 11 years ago

Crap, that commit was in the wrong CWD (meant for vim-session). Nothing to see here, move along :-].