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 do not write to the g:easytags_file #75

Open suxpert opened 10 years ago

suxpert commented 10 years ago

I have g:easytags_dynamic_files = 1 while setting g:easytags_file to ~/.vim/$USER.tags in my vimrc. According to the manual, I set tags to ./tags;,tags,/usr/include/tags in my vimrc in order to use the './tags' file first if it exists. the /usr/include/tags is global tags file, a little large.

Now if I open some file in a folder that do not have a tags file, easytags complains that /usr/include/tags isn't writable:

easytags.vim 3.4.3: The tags file /usr/include/tags isn't writable! (at function xolox#easytags#autoload..xolox#easytags#get_tagsfile, line 29)

I have set g:easytags_file variable, so why does easytags use my /usr/include/tags files instead of the g:easytags_file?

suxpert commented 10 years ago

I don't know how to set easytags to meet my need, but I've modified the function for a different logic: if g:easytags_dynamic_files is 3, then: if there's a "dynamic tag file" (default is ./tags;), use it as the tag file; if it does not exist, use the global g:easytags_file, do NOT write any other tag files.

In case it is useful, here is the patch:

diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index b639bbf..0a70a3e 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -734,6 +734,14 @@ function! xolox#easytags#get_tagsfile() " {{{2
       call xolox#misc#msg#warn("easytags.vim %s: Dynamic tags files enabled but %s not writable so falling back.", g:xolox#easytags#version, directory)
       let tagsfile = ''
     endif
+  elseif dynamic_files == 3
+    if !exists('g:easytags_dynamic_tag')
+      let g:easytags_dynamic_tag = './tags;'
+    endif
+    let tagsfile = xolox#misc#option#eval_tags(g:easytags_dynamic_tag, 1)
+    if filewritable(tagsfile) != 1
+      let tagsfile = ''
+    endif
   endif
   " Check if a file type specific tags file is useful?
   let applicable_filetypes = xolox#easytags#select_supported_filetypes(&ft)