changeset 141:7bc4df0225d1

Add support for specifying buffer-specific tagfiles.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 22 Sep 2016 22:14:17 -0700
parents 95092f4fbc4b
children 513bcd0a1f90
files autoload/gutentags.vim autoload/gutentags/ctags.vim doc/gutentags.txt plugin/gutentags.vim
diffstat 4 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/autoload/gutentags.vim	Thu Sep 22 21:06:58 2016 -0700
+++ b/autoload/gutentags.vim	Thu Sep 22 22:14:17 2016 -0700
@@ -183,8 +183,8 @@
     endif
 
     " Let the user specify custom ways to disable Gutentags.
-    if g:gutentags_enabled_user_func != '' &&
-                \!call(g:gutentags_enabled_user_func, [expand('%:p')])
+    if g:gutentags_init_user_func != '' &&
+                \!call(g:gutentags_init_user_func, [expand('%:p')])
         call gutentags#trace("Ignoring '" . bufname('%') . "' because of " .
                     \"custom user function.")
         return
--- a/autoload/gutentags/ctags.vim	Thu Sep 22 21:06:58 2016 -0700
+++ b/autoload/gutentags/ctags.vim	Thu Sep 22 22:14:17 2016 -0700
@@ -17,8 +17,9 @@
 
 function! gutentags#ctags#init(project_root) abort
     " Figure out the path to the tags file.
+    let l:tagfile = getbufvar("", 'gutentags_tagfile', g:gutentags_tagfile)
     let b:gutentags_files['ctags'] = gutentags#get_cachefile(
-                \a:project_root, g:gutentags_tagfile)
+                \a:project_root, l:tagfile)
 
     " Set the tags file for Vim to use.
     if g:gutentags_auto_set_tags
--- a/doc/gutentags.txt	Thu Sep 22 21:06:58 2016 -0700
+++ b/doc/gutentags.txt	Thu Sep 22 22:14:17 2016 -0700
@@ -387,15 +387,23 @@
                         part of the project.
                         Defaults to 0.
                         
-                                            *gutentags_enabled_user_func*
-g:gutentags_enabled_user_func
+                                            *gutentags_init_user_func*
+g:gutentags_init_user_func
                         When set to a non-empty string, it is expected to be
                         the name of a function that will be called when a file
                         is opened in a project. The function gets passed the
                         path of the file and if it returns 0, Gutentags won't
                         be enabled for that file.
-                        You can use this also to manually set `b:gutentags_root`
-                        (see |gutentags_project_root|).
+
+                        You can use this to manually set buffer-local
+                        settings:
+                        
+                        * `b:gutentags_tagfile` (see |gutentags_tagfile|).
+
+                        This setting was previously called 
+                        `gutentags_enabled_user_func`. The old setting is
+                        still used as a fallback.
+
                         Defaults to "".
 
                                             *gutentags_define_advanced_commands*
--- a/plugin/gutentags.vim	Thu Sep 22 21:06:58 2016 -0700
+++ b/plugin/gutentags.vim	Thu Sep 22 22:14:17 2016 -0700
@@ -24,9 +24,11 @@
 let g:gutentags_background_update = get(g:, 'gutentags_background_update', 1)
 let g:gutentags_pause_after_update = get(g:, 'gutentags_pause_after_update', 0)
 let g:gutentags_enabled = get(g:, 'gutentags_enabled', 1)
-let g:gutentags_enabled_user_func = get(g:, 'gutentags_enabled_user_func', '')
 let g:gutentags_modules = get(g:, 'gutentags_modules', ['ctags'])
 
+let g:gutentags_init_user_func = get(g:, 'gutentags_init_user_func', 
+            \get(g:, 'gutentags_enabled_user_func', ''))
+
 let g:gutentags_add_default_project_roots = get(g:, 'gutentags_add_default_project_roots', 1)
 let g:gutentags_project_root = get(g:, 'gutentags_project_root', [])
 if g:gutentags_add_default_project_roots