GithubHelp home page GithubHelp logo

Comments (8)

ludovicchabant avatar ludovicchabant commented on August 19, 2024

Why do you want Gutentags to generate tags only for a few repos? Is it because most of the repos are too big, or don't contain code, or something?

from vim-gutentags.

goweol avatar goweol commented on August 19, 2024

from vim-gutentags.

ludovicchabant avatar ludovicchabant commented on August 19, 2024

Can you try this quick patch?

diff --git a/autoload/gutentags.vim b/autoload/gutentags.vim
--- a/autoload/gutentags.vim
+++ b/autoload/gutentags.vim
@@ -107,6 +107,12 @@
         return
     endif

+    " Let the user specify custom ways to disable Gutentags.
+    if g:gutentags_enabled_user_func != '' &&
+                \!call(g:gutentags_enabled_user_func, expand('%:p'))
+        return
+    endif
+
     " Try and find what tags file we should manage.
     call gutentags#trace("Scanning buffer '" . bufname('%') . "' for gutentags setup...")
     try
diff --git a/plugin/gutentags.vim b/plugin/gutentags.vim
--- a/plugin/gutentags.vim
+++ b/plugin/gutentags.vim
@@ -41,6 +41,10 @@
     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

It lets you specify the name of a function in g:gutentags_enabled_user_func. This function will get called with the path to each new buffer, and if it returns 0 (or some other false value), Gutentags will be disable for that buffer. You could make that function compare the given path to a list of white-listed repos, or check for the existence of a tags file, or something.

from vim-gutentags.

goweol avatar goweol commented on August 19, 2024

I tried with a simple func:

func! GutenTagsGenCheck(file)
  "call gutentags#trace(gutentags#get_project_root(a:file))
  return 0
endfunc
let g:gutentags_enabled_user_func = 'GutenTagsGenCheck'

And I've got an error:

Error detected while processing function gutentags#setup_gutentags:
line 14:
E714: List required

Thanks

from vim-gutentags.

ludovicchabant avatar ludovicchabant commented on August 19, 2024

Woops sorry, typo in the code calling your custom function. Put square brackets around the second parameter:

      \!call(g:gutentags_enabled_user_func, [expand('%:p')])

from vim-gutentags.

goweol avatar goweol commented on August 19, 2024

Now it worked fine as I expected.

    func! MyGutentagsFunc(file)
      let tag_file = gutentags#get_project_root(a:file).'/tags'
      return filereadable(tag_file)
    endfunc
    let g:gutentags_enabled_user_func = 'MyGutentagsFunc'

Thanks!

from vim-gutentags.

goweol avatar goweol commented on August 19, 2024

With old MyGutentagsFunc(), I saw an error message when I run 'vim' without filename.

Error detected while processing function gutentags#setup_gutentags[14]..MyGutent
agsFunc[1]..gutentags#get_project_root[17]..gutentags#throw:
line    2:
E605: Exception not caught: gutentags: Can't figure out what tag file to use for
: 

So that, I changed it like below. Does it correct? Is there any other way?

    func! MyGutentagsFunc(file)
      try
        let tag_file = gutentags#get_project_root(a:file).'/tags'
        return filereadable(tag_file)
      catch
        return 0
      endtry
    endfunc

from vim-gutentags.

ludovicchabant avatar ludovicchabant commented on August 19, 2024

Ok I submitted the patch (see a844f08).

A try...catch is probably a good idea, but when I run vim with no arguments the callback doesn't get called for me (because the default buffer is not a writable file). Maybe you have Vim setup to open something by default?

from vim-gutentags.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.