Yggdroot / LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Apache License 2.0
2.14k stars 178 forks source link

Use vim tag stack facility #413

Closed ttchin closed 4 years ago

ttchin commented 4 years ago

Describe your question, feature request, or bug.

Is it possible to use vim's original tag stack facility in LeaderF? For instance, I'd like to jump to a tag by pressing Ctrl + ] directly or open a source file by vim +t [tags] which is the original vim behaviour.

The settings in .vimrc could be:

set cscopetag " use cscope as tags command
set cscopeprg='gtags-cscope' " use gtags-cscope instead of cscope

Since LeaderF has automatically genreated the gtags files to the specified directory, how can I add this path to gtags-cscope?

Yggdroot commented 4 years ago

If you use Leaderf gtags, I don't think you need to use cscope.

ttchin commented 4 years ago

Leaderf gtags has been a part of my life for my daily work. :) Nevertheless, I think the vim tags command is still very helpful in some scenarios. Just as I demonstrated in the post, I'd like to jump to a specified location in a project's directory by vim +t [tag]. But in current workflow, I have to:

  1. open vim editor
  2. open leaderf rg, type the [tag]
  3. jump to the location

If leaderf could help to add project's gtags - generated to a specified cached directory - to cscope automatically, that would be very neat.

Yggdroot commented 4 years ago

The gtags files generated is under $HOME/.LfCache/gtags/%PATH%OF%YOUR%PROJECT/, where %PATH%OF%YOUR%PROJECT is replacing the / or \ in the path with %.

Suppose you have the following map,

noremap <C-]> :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR>

I think you can achieve the same effect as using cscope except that <C-T> can not be used, but you can use <C-O> instead.