Mercurial > vim-gutentags
changeset 127:db773e26e43b
Merge pull request #72 from GitHub.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 13 Jun 2016 19:15:17 -0700 |
parents | e2a43c03da79 (diff) 860558b2f9e8 (current diff) |
children | e673026faa56 |
files | |
diffstat | 4 files changed, 57 insertions(+), 89 deletions(-) [+] |
line wrap: on
line diff
--- a/autoload/gutentags.vim Sat Apr 09 15:22:10 2016 +0200 +++ b/autoload/gutentags.vim Mon Jun 13 19:15:17 2016 -0700 @@ -100,6 +100,15 @@ \1) call gutentags#throw("Marker found at root, aborting.") endif + for ign in g:gutentags_exclude_project_root + if l:proj_dir == ign + call gutentags#trace( + \"Ignoring project root '" . l:proj_dir . + \"' because it is in the list of ignored" . + \" projects.") + call gutentags#throw("Ignore project: " . l:proj_dir) + endif + endfor return l:proj_dir endif endfor @@ -119,7 +128,7 @@ let l:tag_path = gutentags#stripslash(a:root_dir) . '/' . a:filename if g:gutentags_cache_dir != "" " Put the tag file in the cache dir instead of inside the - " projet root. + " project root. let l:tag_path = g:gutentags_cache_dir . '/' . \tr(l:tag_path, '\/: ', '---_') let l:tag_path = substitute(l:tag_path, '/\-', '/', '') @@ -157,9 +166,11 @@ if g:gutentags_resolve_symlinks let l:buf_dir = fnamemodify(resolve(expand('%:p', 1)), ':p:h') endif - let b:gutentags_root = gutentags#get_project_root(l:buf_dir) + if !exists('b:gutentags_root') + let b:gutentags_root = gutentags#get_project_root(l:buf_dir) + endif if filereadable(b:gutentags_root . '/.notags') - call gutentags#trace("'notags' file found... no gutentags support.") + call gutentags#trace("'.notags' file found... no gutentags support.") return endif @@ -180,12 +191,12 @@ call call("gutentags#".module."#init", [b:gutentags_root]) endfor catch /^gutentags\:/ - call gutentags#trace("Can't figure out what tag file to use... no gutentags support.") + call gutentags#trace("No gutentags support for this buffer.") return endtry " We know what tags file to manage! Now set things up. - call gutentags#trace("Setting gutentags for buffer '" . bufname('%')) + call gutentags#trace("Setting gutentags for buffer '".bufname('%')."'") " Autocommands for updating the tags on save. let l:bn = bufnr('%')
--- a/autoload/gutentags/ctags.vim Sat Apr 09 15:22:10 2016 +0200 +++ b/autoload/gutentags/ctags.vim Mon Jun 13 19:15:17 2016 -0700 @@ -2,25 +2,11 @@ " Global Options {{{ -if !exists('g:gutentags_ctags_executable') - let g:gutentags_ctags_executable = 'ctags' -endif - -if !exists('g:gutentags_tagfile') - let g:gutentags_tagfile = 'tags' -endif - -if !exists('g:gutentags_auto_set_tags') - let g:gutentags_auto_set_tags = 1 -endif - -if !exists('g:gutentags_ctags_options_file') - let g:gutentags_ctags_options_file = '.gutctags' -endif - -if !exists('g:gutentags_ctags_check_tagfile') - let g:gutentags_ctags_check_tagfile = 0 -endif +let g:gutentags_ctags_executable = get(g:, 'gutentags_ctags_executable', 'ctags') +let g:gutentags_tagfile = get(g:, 'gutentags_tagfile', 'tags') +let g:gutentags_auto_set_tags = get(g:, 'gutentags_auto_set_tags', 1) +let g:gutentags_ctags_options_file = get(g:, 'gutentags_ctags_options_file', '.gutctags') +let g:gutentags_ctags_check_tagfile = get(g:, 'gutentags_ctags_check_tagfile', 0) " }}} @@ -40,7 +26,7 @@ endif " Check if the ctags executable exists. - if g:gutentags_enabled && executable(g:gutentags_ctags_executable) == 0 + if g:gutentags_enabled && executable(expand(g:gutentags_ctags_executable, 1)) == 0 let g:gutentags_enabled = 0 echoerr "Executable '".g:gutentags_ctags_executable."' can't be found. " \."Gutentags will be disabled. You can re-enable it by " @@ -156,11 +142,9 @@ let l:ftype = get(split(&filetype, '\.'), 0, '') let l:proj_info = gutentags#get_project_info(a:proj_dir) let l:type = get(l:proj_info, 'type', l:ftype) - if exists('g:gutentags_ctags_executable_{l:type}') - return g:gutentags_ctags_executable_{l:type} - else - return g:gutentags_ctags_executable - endif + let exepath = exists('g:gutentags_ctags_executable_{l:type}') + \ ? g:gutentags_ctags_executable_{l:type} : g:gutentags_ctags_executable + return expand(exepath, 1) endfunction function! s:process_options_file(proj_dir, path) abort
--- a/doc/gutentags.txt Sat Apr 09 15:22:10 2016 +0200 +++ b/doc/gutentags.txt Mon Jun 13 19:15:17 2016 -0700 @@ -243,6 +243,18 @@ the user-defined ones: ['.git', '.hg', '.bzr', '_darcs']. + *gutentags_exclude_project_root* +g:gutentags_exclude_project_root + A list of project roots to generally ignore. If a file + is opened inside one of those projects, Gutentags + won't be activated. This is similar to placing + a `.notags` file in the root of those projects, but + can be useful when you don't want to, or can't, place + such a file there. + Defaults to ['/usr/local'], which is the folder where + Homebrew is known to create a Git directory by default + on MacOS. + *gutentags_exclude* g:gutentags_exclude A list of file patterns to pass to the @@ -332,9 +344,11 @@ 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 + 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|). Defaults to "". *gutentags_define_advanced_commands*
--- a/plugin/gutentags.vim Sat Apr 09 15:22:10 2016 +0200 +++ b/plugin/gutentags.vim Mon Jun 13 19:15:17 2016 -0700 @@ -9,9 +9,7 @@ finish endif -if !exists('g:gutentags_debug') - let g:gutentags_debug = 0 -endif +let g:gutentags_debug = get(g:, 'gutentags_debug', 0) if (exists('g:loaded_gutentags') || &cp) && !g:gutentags_debug finish @@ -21,64 +19,27 @@ endif let g:loaded_gutentags = 1 -if !exists('g:gutentags_trace') - let g:gutentags_trace = 0 -endif - -if !exists('g:gutentags_fake') - let g:gutentags_fake = 0 -endif - -if !exists('g:gutentags_background_update') - let g:gutentags_background_update = 1 -endif - -if !exists('g:gutentags_pause_after_update') - let g:gutentags_pause_after_update = 0 -endif +let g:gutentags_trace = get(g:, 'gutentags_trace', 0) +let g:gutentags_fake = get(g:, 'gutentags_fake', 0) +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']) -if !exists('g:gutentags_enabled') - 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 - -if !exists('g:gutentags_project_root') - let g:gutentags_project_root = [] -endif +let g:gutentags_project_root = get(g:, 'gutentags_project_root', []) let g:gutentags_project_root += ['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout'] -if !exists('g:gutentags_project_info') - let g:gutentags_project_info = [] -endif +let g:gutentags_project_info = get(g:, 'gutentags_project_info', []) call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'}) call add(g:gutentags_project_info, {'type': 'ruby', 'file': 'Gemfile'}) -if !exists('g:gutentags_exclude') - let g:gutentags_exclude = [] -endif - -if !exists('g:gutentags_resolve_symlinks') - let g:gutentags_resolve_symlinks = 0 -endif - -if !exists('g:gutentags_generate_on_new') - let g:gutentags_generate_on_new = 1 -endif - -if !exists('g:gutentags_generate_on_missing') - let g:gutentags_generate_on_missing = 1 -endif - -if !exists('g:gutentags_generate_on_write') - let g:gutentags_generate_on_write = 1 -endif +let g:gutentags_exclude = get(g:, 'gutentags_exclude', []) +let g:gutentags_exclude_project_root = get(g:, 'gutentags_exclude_project_root', ['/usr/local']) +let g:gutentags_resolve_symlinks = get(g:, 'gutentags_resolve_symlinks', 0) +let g:gutentags_generate_on_new = get(g:, 'gutentags_generate_on_new', 1) +let g:gutentags_generate_on_missing = get(g:, 'gutentags_generate_on_missing', 1) +let g:gutentags_generate_on_write = get(g:, 'gutentags_generate_on_write', 1) if !exists('g:gutentags_cache_dir') let g:gutentags_cache_dir = '' @@ -89,9 +50,7 @@ let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':s?[/\\]$??') endif -if !exists('g:gutentags_define_advanced_commands') - let g:gutentags_define_advanced_commands = 0 -endif +let g:gutentags_define_advanced_commands = get(g:, 'gutentags_define_advanced_commands', 0) if g:gutentags_cache_dir != '' && !isdirectory(g:gutentags_cache_dir) call mkdir(g:gutentags_cache_dir, 'p')