changeset 132:a6ef1c860d07

Add support for custom root finders like `vim-projectroot`.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Jul 2016 12:22:51 +0200
parents ec57d6a14486
children 6f15299869fc
files autoload/gutentags.vim doc/gutentags.txt plugin/gutentags.vim
diffstat 3 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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[:]
--- 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
--- 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'})