changeset 85:0424970d81f8

Add a `g:gutentags_resolve_symlinks` option to resolve symlinks at setup time.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 09 Oct 2015 15:28:39 -0700
parents 96bfe5c37f37
children 7872cc9bbc2d
files autoload/gutentags.vim doc/gutentags.txt plugin/gutentags.vim
diffstat 3 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/autoload/gutentags.vim	Wed Aug 26 22:21:19 2015 -0700
+++ b/autoload/gutentags.vim	Fri Oct 09 15:28:39 2015 -0700
@@ -110,7 +110,11 @@
     " Try and find what tags file we should manage.
     call gutentags#trace("Scanning buffer '" . bufname('%') . "' for gutentags setup...")
     try
-        let b:gutentags_root = gutentags#get_project_root(expand('%:p:h', 1))
+        let l:buf_dir = expand('%:p:h', 1)
+        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 filereadable(b:gutentags_root . '/.notags')
             call gutentags#trace("'notags' file found... no gutentags support.")
             return
--- a/doc/gutentags.txt	Wed Aug 26 22:21:19 2015 -0700
+++ b/doc/gutentags.txt	Fri Oct 09 15:28:39 2015 -0700
@@ -329,6 +329,17 @@
                         project. This is handy to keep tags files from
                         polluting many directories all across your computer.
 
+                                            *gutentags_resolve_symlinks*
+g:gutentags_resolve_symlinks
+                        When set to 1, Gutentags will resolve any symlinks in
+                        the current buffer's path in order to find the project
+                        it belongs to. This is what you want if you're editing
+                        a symlink located outside of the project, and it
+                        points to a file inside the project. However, this is
+                        maybe not what you want if the symlink itself is
+                        part of the project.
+                        Defaults to 0.
+
                                             *gutentags_define_advanced_commands*
 g:gutentags_define_advanced_commands
                         Defines some advanced commands like
--- a/plugin/gutentags.vim	Wed Aug 26 22:21:19 2015 -0700
+++ b/plugin/gutentags.vim	Fri Oct 09 15:28:39 2015 -0700
@@ -54,6 +54,10 @@
     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