-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
add support for GNU Global? #191
Comments
+1 |
1 similar comment
+1 |
I think fuzzy find symbol reference of gtags (or some other provider) is also very useful feature. |
Well, it's not difficult to script myself if #144 is implemented. Likewise the ctags support will be unnecessary then |
GNU Global support is great. But I think ctags support is a fundamental need though~ |
usage:
Leaderf[!] gtags [-h] [--remove] [--recall]
Leaderf[!] gtags --update [--gtagsconf <FILE>] [--gtagslabel <LABEL>] [--accept-dotfiles]
[--skip-unreadable] [--skip-symlink [<TYPE>]] [--gtagslibpath <PATH> [<PATH> ...]]
Leaderf[!] gtags [--current-buffer | --all-buffers | --all] [--result <FORMAT>] [COMMON_OPTIONS]
Leaderf[!] gtags -d <PATTERN> [--auto-jump [<TYPE>]] [-i] [--literal] [--path-style <FORMAT>] [-S <DIR>]
[--append] [--match-path] [--gtagsconf <FILE>] [--gtagslabel <LABEL>] [COMMON_OPTIONS]
Leaderf[!] gtags -r <PATTERN> [--auto-jump [<TYPE>]] [-i] [--literal] [--path-style <FORMAT>] [-S <DIR>]
[--append] [--match-path] [--gtagsconf <FILE>] [--gtagslabel <LABEL>] [COMMON_OPTIONS]
Leaderf[!] gtags -s <PATTERN> [-i] [--literal] [--path-style <FORMAT>] [-S <DIR>] [--append]
[--match-path] [--gtagsconf <FILE>] [--gtagslabel <LABEL>] [COMMON_OPTIONS]
Leaderf[!] gtags -g <PATTERN> [-i] [--literal] [--path-style <FORMAT>] [-S <DIR>] [--append]
[--match-path] [--gtagsconf <FILE>] [--gtagslabel <LABEL>] [COMMON_OPTIONS]
Leaderf[!] gtags --by-context [-i] [--literal] [--path-style <FORMAT>] [-S <DIR>] [--append]
[--match-path] [--gtagsconf <FILE>] [--gtagslabel <LABEL>] [COMMON_OPTIONS]
[COMMON_OPTIONS]: [--reverse] [--stayOpen] [--input <INPUT> | --cword]
[--top | --bottom | --left | --right | --belowright | --aboveleft | --fullScreen]
[--nameOnly | --fullPath | --fuzzy | --regexMode] [--nowrap]
optional arguments:
-h, --help show this help message and exit
specific arguments:
--update Create tag files if tag files do not exist, update the tag files otherwise.
--remove Remove the tag files generated.
--accept-dotfiles Accept files and directories whose names begin with a dot. By default, gtags
ignores them.
--skip-unreadable Skip unreadable files.
--gtagsconf <FILE> Set environment variable GTAGSCONF to <FILE>.
--gtagslabel <LABEL> Set environment variable GTAGSLABEL to <LABEL>.
--skip-symlink [<TYPE>]
Skip symbolic links. If type is 'f' then skip only symbolic links for file, else
if 'd' then skip only symbolic links for directory. The default value of type is
'a' (all symbolic links).
--gtagslibpath <PATH> [<PATH> ...]
Specify the paths to search for library functions.
-d <PATTERN>, --definition <PATTERN>
Show locations of definitions.
-r <PATTERN>, --reference <PATTERN>
Show reference to a symbol which has definitions.
-s <PATTERN>, --symbol <PATTERN>
Show reference to a symbol which has no definition.
-g <PATTERN>, --grep <PATTERN>
Show all lines which match to the <PATTERN>.
--by-context Decide tag type by context at cursor position. If the context is a definition of
the pattern then use -r, else if there is at least one definition of the pattern
then use -d, else use -s. Regular expression is not allowed for pattern.
-i, --ignore-case Ignore case distinctions in the pattern.
--literal Execute literal search instead of regular expression search.
--path-style <FORMAT>
Show path names using <FORMAT>, which may be one of: `relative`, `absolute`,
`shorter`, `abslib` or `through`. `relative` means relative path. `absolute`
means absolute path. `shorter` means the shorter one of relative and absolute
path. `abslib` means absolute path for libraries (GTAGSLIBPATH) and relative path
for the rest. `through` means the relative path from the project root directory
(internal format of GPATH). The default is `relative`.
-S <DIR>, --scope <DIR>
Show only tags which exist under <DIR> directory.
--recall Recall last search. If the result window is closed, reopen it.
--match-path Match the file path when fuzzy searching.
--append Append to the previous search results.
--current-buffer Show tags in current buffer.
--all-buffers Show tags in all listed buffers.
--all Show tags in the whole project.
--result <FORMAT> Show result using format, which may be one of: `ctags`(default), `ctags-x`,
`ctags-mod`.
--auto-jump [<TYPE>] Jump to the tag directly when there is only one match. <TYPE> can be 'h', 'v' or
't', which mean jump to a horizontally, vertically split window, or a new tabpage
respectively. If <TYPE> is omitted, jump to a position in current window.
common arguments:
--reverse show results in bottom-up order
--stayOpen don't quit LeaderF after accepting an entry
--input <INPUT> specifies INPUT as the pattern inputted in advance
--cword current word under cursor is inputted in advance
--top the LeaderF window is at the top of the screen
--bottom the LeaderF window is at the bottom of the screen
--left the LeaderF window is at the left of the screen
--right the LeaderF window is at the right of the screen
--belowright the LeaderF window is at the belowright of the screen
--aboveleft the LeaderF window is at the aboveleft of the screen
--fullScreen the LeaderF window takes up the full screen
--nameOnly LeaderF is in NameOnly mode by default
--fullPath LeaderF is in FullPath mode by default
--fuzzy LeaderF is in Fuzzy mode by default
--regexMode LeaderF is in Regex mode by default
--nowrap long lines in the LeaderF window won't wrap
--next Jump to the next result.
--previous Jump to the previous result.
If [!] is given, enter normal mode directly. |
@Yggdroot Thanks for implementing this feature. |
Can |
@xaljer No. LeaderF can manage the gtags files very well. |
so Leaderf can auto update tags when file is changed? that sounds great. I do not find an option to specify location of tag file. where are gtags files, and can i change it? |
@xaljer the tag file is in the cache folder you set and of course you can change it. So far my experience with gtags feature is excellent. Despite the lack of several other cscope interface query methods such as include hierarchy, leaderf functions even better than gutentags. Haven't test and don't know if leaderf can update the database on writeout, but otherwise a single line vimscript can achieve this. |
@xaljer Yes, tags can be updated automatically when a file is changed if @linusboyle Some features of cscope will be implemented in the future. |
I think it would be more convenient for |
Jump to the tag directly when there is only one match.
Jump to the tag directly when there is only one match.
@xaljer Now you can add |
@Yggdroot BTW, Now that LeaderF has evolved into a powerful tag management tool, I'm wondering if it's possible to simulate the quickfix list. As leaderf stores the location info and it would be nice to have something like |
@Yggdroot , Thank you:-) |
In normal mode, you can use |
I think it's not so convenient to navigate to the leaderf window and use jk
to jump. If the window is closed I will have to open it manually, which is
annoying. If leaderf can provide a mean to jump without opening the window
it would be nice
Yggdroot <[email protected]> 于 2019年4月30日周二 上午9:56写道:
… @Yggdroot <https://github.com/Yggdroot> BTW, Now that LeaderF has evolved
into a powerful tag management tool, I'm wondering if it's possible to
simulate the quickfix list. As leaderf stores the location info and it
would be nice to have something like :leaderfnext and leaderfprevious,
especially dealing with tags.
In normal mode, you can use j, k to navigate the result, I don't think
:leaderfnext and leaderfprevious are necessary.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#191 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AH74VQILYDDZ27PMFZXSCOTPS6RORANCNFSM4FMEN4RQ>
.
|
@linusboyle Now
|
I'm having an issue to navigate to code in a different location (as library). Assume my username is 'john' and I have two directories with their respective GTAGS file
I wrote a small script to produce $GTAGSLIBPATH. So, "echo $GTAGSLIBPATH" on my machine outputs "/home/john/.LfCache/gtags/%home%john%foo:/home/john/.LfCache/gtags/%home%john%bar" Now, when I'm in "foo/" and look up symbols in foo, everything works beautifully. But when I tried looking up symbol in "bar/", path in result is wrong. Let me explain:
/home/john/.LfCache/gtags/%john%bar%/two.c The part "%john%bar%/two.c" seems correct. The line number in "two.c" is also correct. But |
@haihualuo I think you have misunderstood the meaning of $GTAGSLIBPATH, as described in https://www.gnu.org/software/global/globaldoc_toc.html.
If you use LeaderF, you don't have to manage gtags by yourself, LeaderF can help to do it.
All what you need to do is:
|
The description appears to align with my understanding. My operations are as follows:
After that, I could see two sets of gtag files under appropriate .LfCache/gtags subdirectories.
I actually have many source trees, not just foo, bar in the example. It is more convenient for me to generate respective gtags files by going to each individual source trees, then point GTAGSLIBPATH to those trees. I expect the environment variable would be picked up by gtags and in turn by Leaderf that uses gtags, so I could locate symbol/references in any tree from anywhere. What is the difference between specifying all the source trees in GTABSLIBPATH vs. having them specified in multiple "--gtagslibpath x", "--gtagslibpath y", "--gtagslibpath z" ... fashion? Another observation is that finding symbols in tree B while I'm in tree A kind of works already, Leaderf did return the "semi-correct" path, but it is escaped with % and appended to the cache directory. |
Given source tree A, B and C, is it required that while in tree A, lib points to only {B, C}, while in tree B, lib points only to {A, C} and so forth? I previously tried gutentags / gutentags_plus with exporting {A, B, C} as gtagslibpath (i.e. no matter which tree I'm in, the lib value is always {A, B, C}) and it worked for me, i.e. in any tree, I can always precisely locate symbols/references in the other 2 trees. |
$GTAGSLIBPATH is a global environment variable, LeaderF does not use or read it. However gtags will respect the value of it. $GTAGSLIBPATH indicates the paths of the source code, so there is
To specify multiple paths, the usage is
I find I have already answered this question. PS: If you have run |
Understand. But one major benefit of Leaderf+gtags / gutentags / gutentags_plus is that the G*TAGS files are located centrally at a different location, away from source tree. In Leaderf, I have: let g:Lf_CacheDirectory = expand('~/.cache/leaderf') So all the GTAGS files are there. AFAIK, GTAGSLIBPATH must points to directories that contains these GTAGS file. It is not required that such location is part of source tree (otherwise the major benefit would not be possible). Therefore, I set the value of GTAGSLIBPATH to "~/.cache/leaderf/gtags/%some_tree%" - that is my real config vs. "foo/bar" are just examples in my previous comment. Btw, I found Leaderf superior to gutentags/gutentags_plus. But when using gutentags/gutentags_plus, I set up my GTAGSLIBPATH exactly the same way - it points to ~/.cache/tags/my_source_tree[1234..], while I have following: let g:gutentags_cache_dir = expand('~/.cache/tags') ... and my source trees are in /my/source/tree[1234...] (gutentags uses "_" vs. "%")
As described above, it is not the case for gutentags/gutentags_plus.
That is a good point. |
I don't think so. You can try $GTAGSLIBPATH in command line(run gtags command in command line).
Because LeaderF does not have any logic to specifically handle $GTAGSLIBPATH, just leave it as it is. So the error demonstrates |
I did an experiment - I simply updated my script to point GTAGSLIBPATH to 'foo' and 'bar', which are 2 different source trees. Notice that there are no GTAGS file there; those GTAGS files are saved in ~/.LfCache/gtags/%some_path% per 'g:Lf_CacheDirectory' config. The experiment failed - in tree A, Leaderf + gtags cannot locate symbols from tree B. I verified the respective GTAGS are fine - I can locate everything in A from tree A and everything in B from tree B. I think this experiment is fairly reproducible, but if it works for you, I'd like to learn the differences in our steps ...
"Is wrong" meaning? The entry in GTAGSLIBPATH must contain both GTAGS file and source code?
That I am not sure. |
Yes. |
Thanks. You are partially correct. I could use GTAGSLIBPATH to locate library symbols without GTAGS in the library directory. The following works:
I have no intention to drag on the environment variable. The main reason I brought it up is it seems to work with gutentags (with GTAGS file and source code completely separate), so I was hoping the same setup can work under Leaderf ... I will check "--gtagslibpath". The main challenge there is "x y z" could be different when we clone the same repo to different physical directories (sometimes necessary & faster than switching between branches in the same place). |
Suppose the full path of |
Stand corrected. I checked again. One use case for separating source tree and related GTAGS file is you may not have write permission to source tree. This is achieved via https://lists.gnu.org/archive/html/help-global/2015-07/msg00001.html. But this seems convoluted and my original purpose is not to separate GTAGS and source tree, mainly to take advantage of that as offered by the tool. |
g:Lf_Ctags
doesn't work for gtags,no matter what I set it to be,gtags
orglobal
orgtags-cscope
.It seems only ctags is supported right now. Anyway,I can use cscope and just lack some fuzzy and regex things,but maybe you can enhance this great plugin?The text was updated successfully, but these errors were encountered: