Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to generate tags for open windows or buffers only? #349

Open
lukelbd opened this issue Jul 25, 2023 · 3 comments
Open

Option to generate tags for open windows or buffers only? #349

lukelbd opened this issue Jul 25, 2023 · 3 comments

Comments

@lukelbd
Copy link

lukelbd commented Jul 25, 2023

Hi, thanks for this awesome plugin. Paired with fzf.vim :Tags command it makes project navigation extremely fast.

I was wondering if you would consider adding a configuration option to only generate tags for the currently open windows or buffers instead of whole directory trees. This would speed up tag selection for users that only want to work on a subset of some project (since it would remove irrelevant tags + minimize false positives). This could also help prevent new users from experiencing slowdowns if they haven't yet configured their "project" settings and open vim in a very large directory (e.g. $HOME). This happened to me several years ago and I gave up for a while before returning / reading the docs more carefully.

@eyalk11
Copy link

eyalk11 commented Sep 17, 2023

See #353

@lukelbd
Copy link
Author

lukelbd commented Sep 17, 2023

Thanks. I saw the g:gutentags_project_root_finder option in the docs and set to a custom function, but somehow I missed g:gutentags_file_list_command.

However it looks like g:gutentags_file_list_command only accepts shell commands. Could it be amended to also accept vim function references like g:gutentags_project_root_finder? Then one could easily set it to a function that returns open vim buffers or tabs. Or someone could add a separate g:gutentags_file_list_function option.

Maybe I'll try a PR sometime.

@eyalk11
Copy link

eyalk11 commented Sep 17, 2023

Arguably , you can save the results from vim to a file and do cat from that file.
This maybe helpful

function! GitF(regfilter,curfile) 
    if (a:curfile)

    let tmp=getcwd()
    :exe ":cd ". expand("%:p:h")
endif 
    let top = systemlist("git rev-parse --show-toplevel")[0]
    "echo top
    :exe ':cd '. top
    let a=systemlist("git ls-files --full-name" )
    :if len(a:regfilter)>0
    let a = filter(a,{idx,val -> (val =~ a:regfilter)})
    let a= map(a, {idx,fname -> fnamemodify(fname, ':p')})
    :endif 
    ":echo a
    :call writefile(a,'c:\temp\filelist.txt')
    try
        echohl Question
        let pattern = input("Search pattern: ")
        let pattern = escape(pattern,'"')
    finally
        echohl None
    endtry
    if (a:curfile)
    
    :exe ':cd '.tmp
endif 
    exec printf("Leaderf rg --filelist c:\\temp\\filelist.txt %s\"%s\"", pattern =~ '^\s*$' ? '' : '-e ', pattern )

endfunction




Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants