# HG changeset patch # User Ludovic Chabant # Date 1469010171 -7200 # Node ID a6ef1c860d07a2afacba50ed6deab9b23c7de4cc # Parent ec57d6a1448651c329c6d5fac7d24d7ba79d8e25 Add support for custom root finders like `vim-projectroot`. diff -r ec57d6a14486 -r a6ef1c860d07 autoload/gutentags.vim --- a/autoload/gutentags.vim Wed Jul 20 12:11:13 2016 +0200 +++ b/autoload/gutentags.vim Wed Jul 20 12:22:51 2016 +0200 @@ -81,6 +81,10 @@ " 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 + return call(g:gutentags_project_root_finder, [a:path]) + endif + let l:path = gutentags#stripslash(a:path) let l:previous_path = "" let l:markers = g:gutentags_project_root[:] diff -r ec57d6a14486 -r a6ef1c860d07 doc/gutentags.txt --- a/doc/gutentags.txt Wed Jul 20 12:11:13 2016 +0200 +++ b/doc/gutentags.txt Wed Jul 20 12:22:51 2016 +0200 @@ -260,10 +260,26 @@ 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 + Defaults to `['/usr/local']`, which is the folder where Homebrew is known to create a Git directory by default on MacOS. + *gutentags_project_root_finder* +g:gutentags_project_root_finder + When a buffer is loaded, Gutentags uses a default + (internal) implementation to find that file's + project's root directory, using settings like + |g:gutentags_project_root|. When you specify + |g:gutentags_project_root_finder|, you can tell + Gutentags to use a custom implementation, such as + `vim-projectroot`. The value of this setting must be + the name of a function that takes a single string + argument (the path to the current buffer's file) and + returns a string value (the project's root directory). + Defaults to `''`. + Note: when set, the called implementation will most + likely ignore |g:gutentags_project_root|. + *gutentags_exclude* g:gutentags_exclude A list of file patterns to pass to the diff -r ec57d6a14486 -r a6ef1c860d07 plugin/gutentags.vim --- a/plugin/gutentags.vim Wed Jul 20 12:11:13 2016 +0200 +++ b/plugin/gutentags.vim Wed Jul 20 12:22:51 2016 +0200 @@ -32,6 +32,7 @@ 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_info = get(g:, 'gutentags_project_info', []) call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'})