Enabling Ctags Tree Wide for GCC

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Enabling Ctags Tree Wide for GCC

Nicholas Krause
Greetings,

I was wondering what is the easiest way to allow source tree wide ctags.
There doesn't

seem to be a make x command for it nor any real documentation online and
it would

be nice to have.


Thanks,

Nick

Reply | Threaded
Open this post in threaded view
|

Re: Enabling Ctags Tree Wide for GCC

Andreas Schwab
On Sep 11 2019, Nicholas Krause <[hidden email]> wrote:

> I was wondering what is the easiest way to allow source tree wide
> ctags.

There is make TAGS, which uses etags.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Ctags Tree Wide for GCC

Nicholas Krause

On 9/11/19 2:30 AM, Andreas Schwab wrote:
> On Sep 11 2019, Nicholas Krause <[hidden email]> wrote:
>
>> I was wondering what is the easiest way to allow source tree wide
>> ctags.
> There is make TAGS, which uses etags.
>
> Andreas.
>
Andreas,


Is there no way to build it for vim as thats what I would prefer to stay
with.


Anyhow thanks,


Nick

Reply | Threaded
Open this post in threaded view
|

Re: Enabling Ctags Tree Wide for GCC

Hi-Angel
On Wed, 11 Sep 2019 at 09:55, Nicholas Krause <[hidden email]> wrote:
>
>
> On 9/11/19 2:30 AM, Andreas Schwab wrote:
> > On Sep 11 2019, Nicholas Krause <[hidden email]> wrote:
> >
> >> I was wondering what is the easiest way to allow source tree wide
> >> ctags.
> > There is make TAGS, which uses etags.

Note: over time on the internet appeared quite a few different "ctags"
projects (exuberant ctags universal ctags, anjuta-ctags, you named
it), AFAIK the currently maintained and developed project with the
most number of supported languages is universal ctags, so I recommend
using it.

> Is there no way to build it for vim as thats what I would prefer to stay
> with.

(disclaimer: I'm just a random reader of the ML)

Using ctags with any project is as simple as `ctags -R` in base
directory of sources (add -e option if you use Emacs).

There's no need for any complex setup, because the "tags" format is
very dumb. It's just "tag name" (e.g. name of a function, struct,
macro), line number, and the whole line where that name is defined.
So, in particular, if you have 2 functions foo() defined, and you jump
to a tag "foo()", there's no way a text editor can figure out which
one "foo()" is that you wanted, so it would either jump to the first
occurrence (vim does that, you need to use :tn :tp to navigate
further) or present you with a list of occurences (Emacs does this).

So, I doubt there's a "make tags" command, because it's one symbol
bigger than "ctags -R" ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Ctags Tree Wide for GCC

Hi-Angel
On Wed, 11 Sep 2019 at 12:50, Hi-Angel <[hidden email]> wrote:

>
> On Wed, 11 Sep 2019 at 09:55, Nicholas Krause <[hidden email]> wrote:
> >
> >
> > On 9/11/19 2:30 AM, Andreas Schwab wrote:
> > > On Sep 11 2019, Nicholas Krause <[hidden email]> wrote:
> > >
> > >> I was wondering what is the easiest way to allow source tree wide
> > >> ctags.
> > > There is make TAGS, which uses etags.
>
> Note: over time on the internet appeared quite a few different "ctags"
> projects (exuberant ctags universal ctags, anjuta-ctags, you named
> it), AFAIK the currently maintained and developed project with the
> most number of supported languages is universal ctags, so I recommend
> using it.
>
> > Is there no way to build it for vim as thats what I would prefer to stay
> > with.
>
> (disclaimer: I'm just a random reader of the ML)
>
> Using ctags with any project is as simple as `ctags -R` in base
> directory of sources (add -e option if you use Emacs).
>
> There's no need for any complex setup, because the "tags" format is
> very dumb. It's just "tag name" (e.g. name of a function, struct,
> macro), line number, and the whole line where that name is defined.
> So, in particular, if you have 2 functions foo() defined, and you jump
> to a tag "foo()", there's no way a text editor can figure out which
> one "foo()" is that you wanted, so it would either jump to the first
> occurrence (vim does that, you need to use :tn :tp to navigate
> further) or present you with a list of occurences (Emacs does this).
>
> So, I doubt there's a "make tags" command, because it's one symbol
> bigger than "ctags -R" ;-)

Worth noting btw, that ctags are a great thing if you want to quickly
dive in to a project, and you're okay with their downsides, such as
not being able to resolve foo() as in example. This even especially
emphasized by the fact my local Universal Ctags support 100 (!!!)
languages (`ctags --list-languages | wc -l`)

But in the long run, if you work with a project a lot, I'd recommend
looking at setting up an LSP server. All modern editors support it,
including vim and emacs (some natively, some through extensions). It
doesn't have the downsides of tags format, and can also provide you
with things like completion or error highlighting as you type.
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Ctags Tree Wide for GCC

Martin Liška-2
In reply to this post by Nicholas Krause
On 9/11/19 7:02 AM, Nicholas Krause wrote:

> Greetings,
>
> I was wondering what is the easiest way to allow source tree wide ctags. There doesn't
>
> seem to be a make x command for it nor any real documentation online and it would
>
> be nice to have.
>
>
> Thanks,
>
> Nick
>

Hi.

Please do not use ctags. It has very poor coverage for any C++ codebase.
I prefer to use clangd (with -background-index) instead with vim-lsp
(Language Server Protocol for VIM).

https://clang.llvm.org/extra/clangd/Installation.html

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Ctags Tree Wide for GCC

Eric Gallager
In reply to this post by Nicholas Krause
On 9/11/19, Nicholas Krause <[hidden email]> wrote:

> Greetings,
>
> I was wondering what is the easiest way to allow source tree wide ctags.
> There doesn't
>
> seem to be a make x command for it nor any real documentation online and
> it would
>
> be nice to have.
>

ISTR this topic coming up 2 years ago:
https://gcc.gnu.org/ml/gcc/2017-09/msg00266.html

>
> Thanks,
>
> Nick
>
>