# HG changeset patch # User Ludovic Chabant # Date 1484177923 28800 # Node ID 4055c696a9b4c60d698653a0e2c5507dcd488795 # Parent f915393ff68d9e436146845663ae7f76cf2b2707# Parent e5f2be2fabd00d61d42268dca5a4e77e2617fcf5 Merge pull request #85 from GitHub. diff -r e5f2be2fabd0 -r 4055c696a9b4 autoload/gutentags.vim --- 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 diff -r e5f2be2fabd0 -r 4055c696a9b4 autoload/gutentags/ctags.vim --- 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 diff -r e5f2be2fabd0 -r 4055c696a9b4 doc/gutentags.txt --- 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* diff -r e5f2be2fabd0 -r 4055c696a9b4 plugin/gutentags.vim --- 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'})