changeset 88:073e63cc0456

Add `gutentags_enabled_user_func` callback.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 24 Nov 2015 21:47:26 -0800
parents afe113047204
children 8bf96f9f649c
files autoload/gutentags.vim doc/gutentags.txt plugin/gutentags.vim
diffstat 3 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/autoload/gutentags.vim	Tue Nov 17 21:11:20 2015 -0800
+++ b/autoload/gutentags.vim	Tue Nov 24 21:47:26 2015 -0800
@@ -107,6 +107,14 @@
         return
     endif
 
+    " Let the user specify custom ways to disable Gutentags.
+    if g:gutentags_enabled_user_func != '' &&
+                \!call(g:gutentags_enabled_user_func, [expand('%:p')])
+        call gutentags#trace("Ignoring '" . bufname('%') . "' because of " .
+                    \"custom user function.")
+        return
+    endif
+
     " Try and find what tags file we should manage.
     call gutentags#trace("Scanning buffer '" . bufname('%') . "' for gutentags setup...")
     try
--- a/doc/gutentags.txt	Tue Nov 17 21:11:20 2015 -0800
+++ b/doc/gutentags.txt	Tue Nov 24 21:47:26 2015 -0800
@@ -339,6 +339,15 @@
                         maybe not what you want if the symlink itself is
                         part of the project.
                         Defaults to 0.
+                        
+                                            *gutentags_enabled_user_func*
+g:gutentags_enabled_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 open 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.
+                        Defaults to "".
 
                                             *gutentags_define_advanced_commands*
 g:gutentags_define_advanced_commands
--- a/plugin/gutentags.vim	Tue Nov 17 21:11:20 2015 -0800
+++ b/plugin/gutentags.vim	Tue Nov 24 21:47:26 2015 -0800
@@ -41,6 +41,10 @@
     let g:gutentags_enabled = 1
 endif
 
+if !exists('g:gutentags_enabled_user_func')
+    let g:gutentags_enabled_user_func = ''
+endif
+
 if !exists('g:gutentags_modules')
     let g:gutentags_modules = ['ctags']
 endif