Open kha-dinh opened 3 years ago
acknowledged, although this might take me a bit since this package is scoring very low among my priorities
Is there a ggtags command that does this? something like ggtags-find-header-file
?
Here is the function ggtags-find-tag-dwim
from ggtags
(defun ggtags-find-tag-dwim (name &optional what)
"Find NAME by context.
If point is at a definition tag, find references, and vice versa.
If point is at a line that matches `ggtags-include-pattern', find
the include file instead.
When called interactively with a prefix arg, always find
definition tags."
(interactive
(let ((include (and (not current-prefix-arg) (ggtags-include-file))))
(ggtags-ensure-project)
(if include (list include 'include)
(list (ggtags-read-tag 'definition current-prefix-arg)
(and current-prefix-arg 'definition)))))
(ggtags-check-project) ; For `ggtags-current-project-root' below.
(cond
((eq what 'include)
(ggtags-find-file name))
((or (eq what 'definition)
(not buffer-file-name)
(not (ggtags-project-has-refs (ggtags-find-project)))
(not (ggtags-project-file-p buffer-file-name)))
(ggtags-find-definition name))
(t (ggtags-find-tag
(format "--from-here=%d:%s"
(line-number-at-pos)
;; Note `ggtags-find-tag' binds `default-directory' to
;; project root.
(shell-quote-argument
(ggtags-project-relative-file buffer-file-name)))
"--" (shell-quote-argument name)))))
this was implemented recently in global-tags.el
, so now I'm clear on what to do here
Feel free to use global-tags.el
in the meantime.
I hardly advice you switch to global-tags.el
and ivy-xref
EDIT: AY CHIHUAHUA... counsel-gtags--read-tag
is a macro! I'm definitely not touching that (most likely that things will break
Leaving open in case someone else will do a PR (or if @kha-dinh has solved by other means)
Right now it only finds either definition or reference.
In ggtags, dwim also finds header files when pointing to the include section. It would be nice to have something similar.