changeset 155:4055c696a9b4

Merge pull request #85 from GitHub.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 11 Jan 2017 15:38:43 -0800
parents f915393ff68d (diff) e5f2be2fabd0 (current diff)
children 40153c7a1887
files
diffstat 4 files changed, 48 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/autoload/gutentags.vim	Sat Oct 29 01:11:02 2016 +0800
+++ b/autoload/gutentags.vim	Wed Jan 11 15:38:43 2017 -0800
@@ -4,6 +4,11 @@
 
 " Throw an exception message.
 function! gutentags#throw(message)
+    throw "gutentags: " . a:message
+endfunction
+
+" Throw an exception message and set Vim's error message variable.
+function! gutentags#throwerr(message)
     let v:errmsg = "gutentags: " . a:message
     throw v:errmsg
 endfunction
@@ -104,7 +109,7 @@
 " Finds the first directory with a project marker by walking up from the given
 " file path.
 function! gutentags#get_project_root(path) abort
-    if g:gutentags_project_root_finder
+    if g:gutentags_project_root_finder != ''
         return call(g:gutentags_project_root_finder, [a:path])
     endif
 
@@ -183,8 +188,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
@@ -354,7 +359,7 @@
             echom "gutentags: The tags file is already being updated, " .
                         \"please try again later."
         else
-            call gutentags#throw("Unknown queue mode: " . a:queue_mode)
+            call gutentags#throwerr("Unknown queue mode: " . a:queue_mode)
         endif
         return
     endif
--- a/autoload/gutentags/ctags.vim	Sat Oct 29 01:11:02 2016 +0800
+++ b/autoload/gutentags/ctags.vim	Wed Jan 11 15:38:43 2017 -0800
@@ -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
@@ -43,7 +44,8 @@
     if l:tags_file_exists && g:gutentags_ctags_check_tagfile
         let l:first_lines = readfile(a:tags_file, '', 1)
         if len(l:first_lines) == 0 || stridx(l:first_lines[0], '!_TAG_') != 0
-            call gutentags#throw("File ".a:tags_file." doesn't appear to be ".
+            call gutentags#throwerr(
+                        \"File ".a:tags_file." doesn't appear to be ".
                         \"a ctags file. Please delete it and run ".
                         \":GutentagsUpdate!.")
             return
--- a/doc/gutentags.txt	Sat Oct 29 01:11:02 2016 +0800
+++ b/doc/gutentags.txt	Wed Jan 11 15:38:43 2017 -0800
@@ -227,6 +227,18 @@
                         don't.
                         Defaults to 1.
 
+                                                *gutentags_dont_load*
+g:gutentags_dont_load
+                        Prevents Gutentags from loading at all on Vim startup.
+
+                        The difference between this and |gutentags_enabled| is
+                        that |gutentags_enabled| can be turned on and off in
+                        the same Vim session -- Gutentags as a plugin stays
+                        loaded and will keep track of what happened while it
+                        was disabled. However, |gutentags_dont_load| only
+                        works on Vim startup and will prevent Gutentags from
+                        loading at all, as if it wasn't there.
+
                                                 *gutentags_ctags_executable*
 g:gutentags_ctags_executable
                         Specifies the ctags executable to launch.
@@ -237,7 +249,7 @@
                         Specifies the ctags executable to launch for a project
                         of type {type}. See |gutentags_project_info| for more
                         information.
-                        IMPORTANT: piease see |gutentags-ctags-requirements|.
+                        IMPORTANT: please see |gutentags-ctags-requirements|.
                         Example: >
                          let g:gutentags_ctags_executable_ruby = 'foobar'
 <
@@ -387,15 +399,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	Sat Oct 29 01:11:02 2016 +0800
+++ b/plugin/gutentags.vim	Wed Jan 11 15:38:43 2017 -0800
@@ -4,6 +4,10 @@
 
 " Globals {{{
 
+if (&cp || get(g:, 'gutentags_dont_load', 0))
+    finish
+endif
+
 if v:version < 704
     echoerr "gutentags: this plugin requires vim >= 7.4."
     finish
@@ -11,7 +15,7 @@
 
 let g:gutentags_debug = get(g:, 'gutentags_debug', 0)
 
-if (exists('g:loaded_gutentags') || &cp) && !g:gutentags_debug
+if (exists('g:loaded_gutentags') && !g:gutentags_debug)
     finish
 endif
 if (exists('g:loaded_gutentags') && g:gutentags_debug)
@@ -24,15 +28,18 @@
 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
     let g:gutentags_project_root += ['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout']
 endif
-let g:gutentags_project_root_finder = ''
+
+let g:gutentags_project_root_finder = get(g:, 'gutentags_project_root_finder', '')
 
 let g:gutentags_project_info = get(g:, 'gutentags_project_info', [])
 call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'})