Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Perl ctags How To

by learnedbyerror (Monk)
on Jan 10, 2021 at 16:29 UTC ( #11126709=perlquestion: print w/replies, xml ) Need Help??

learnedbyerror has asked for the wisdom of the Perl Monks concerning the following question:

Hell Wise Monks!

The village idiot is back seeking your assistance. I am interested in using ctags as part of my perl development environment in vim. I have considered it from time to time over the years but have never invested the time and effort to see it through. My interest is stronger now than it has been in the past; however, my Google searches are returning some very dated responses with a few exceptions. So, I thought I would ask an open ended question here.

For those of you that use ctags for your perl development in vim or other editors, what do you recommend?

  • What do you use to create your tag files - Exuberant ctags 5.8, Universal-ctags, some other perl script or module
  • What entries do you recommend for ~/.ctags
  • Do you use it to index your whole @INC? If so, how?

Thanks in advance for sharing your wisdom

The village idiot -- lbe

Replies are listed 'Best First'.
Re: Perl ctags How To
by Fletch (Chancellor) on Jan 10, 2021 at 18:35 UTC

    Meandering not definitive answer; I don't regularly use tags (if I'm looking for something I'll use ripgrep) but . . .

    When I've created tags files in the past I usually used exuberant; worked pretty well with the large codebase at $work. I'd also toyed very briefly with GNU global and the emacs interface for same. I had the following perl additions for constant things and Moose-y attributes.

    --regex-perl=/Readonly::[a-zA-Z0-9_]+ my [\$@%]([a-zA-Z0-9_]+)/\1/C,Re +adonly:: constant/ --regex-perl=/use constant ([A-Z][a-zA-Z0-9_]+)/\1/c,use constant/ --regex-perl=/has[[:space:]]+([[:alnum:]_]+)[[:space:]]*=>/\1/M,moose +attribute/e

    Most "modern" IDEs have moved to using a "language server" to implement the language-specific parsing and symbol lookup and what not; there's Perl::LanguageServer which I've run once or twice with the emacs module (you mention the inferior editor so this article comes up on a search but I can't vouch for it) so you might see if that maybe scratches the need for which you've been using tags.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Thanks for your response Monk Emacs. I am also investigate the Language Server. Like you, I also use ripgrep and the silver searcher as well.

      I hope that you recover soon from your addiction :)


Re: Perl ctags How To
by choroba (Archbishop) on Jan 10, 2021 at 22:17 UTC
    Sorry for the impudent answer, I use Emacs instead of vim. It uses an etags file which is different to ctags, but I guess the information contained in it is the same, just formatted differently. Here's how I generate the file: - it supports some Moo* and similar sugar (e.g. "has", "alias", "method", but support for "handles" is still missing). Feel free to modify it to your liking.

    I run it in the root directory of any larger project I work with. To get documentation on CPAN modules, I use perldoc (integrated into Emacs, of course, so I can just press a key combination on a module name and get the documentation). I rarely need to read the source of the CPAN modules, but if I need it, I use perldoc -l or perldoc -m. It hasn't happened enough times to bother me to find out whether Emacs supports it (and implement it if not).

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      Oh Lordy, two Emacs addicts in a row :). Nonetheless, thanks for your guidance. I will review it with an eye toward vim!


Re: Perl ctags How To
by shmem (Chancellor) on Jan 10, 2021 at 19:33 UTC
    Do you use it to index your whole @INC? If so, how?

    I like to be able to jump right into library source files to see what happens there. So I do

    qwurx [shmem] ~/some_repo > mdkdir INC qwurx [shmem] ~/some_repo > cd INC qwurx [shmem] ~/some_repo/INC > perl -E 'for (@INC) { ($n=$_)=~s{/}{} +g; symlink $_, $n}' qwurx [shmem] ~/some_repo/INC > cd .. qwurx [shmem] ~/some_repo > ctags -R

    Then I add INC and tags to .gitignore and done.

    Yes, I am using 00B7 MIDDLE DOT as path separator, because expanding a dot to oblique is just a matter of perspective reading the vim file info.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      Thank you for the advice. I like the symlink trick. I have used it before for other things and had not considered it in this case.


Re: Perl ctags How To
by kcott (Bishop) on Jan 11, 2021 at 05:48 UTC

      Thanks for linking to Damian's presentation. I have watched this several times and as much as I respect him for all that he has done for perl, he and I have different editing styles. This is probably because my brain is but a fraction of the size of his :) Nonetheless, I do have some of his recommendations in my .vimrc today.

      Thanks, lbe

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11126709]
Approved by haukex
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2021-04-18 23:04 GMT
Find Nodes?
    Voting Booth?

    No recent polls found