Is there a vim plugin that shows Moose attributes in Tag_List?

I am editing packages that use Moose, and I was wondering if there is a plugin for creating Moose attributes in the tag list.

For example, in the following code, the options attribute is not displayed in Tag_List, but print_out_site does:

 use Moose; use MooseX::AttributeHelpers; ... has 'options' => ( metaclass => 'Collection::Hash', isa => 'HashRef[Str]', is => 'ro', provides => { exists => 'exists', get => 'get', set => 'set', }, ); ... sub print_out_site { my $self = shift; my $key = shift; $self->fasta_out_fh->print(">", $key, "\n"); $self->fasta_out_fh->print($self->sites->{$key}, "\n"); } 
+6
vim perl moose taglist
source share
2 answers

Add line

 --regex-perl=/has '(.*)' => \(/\1/a,attribute,moose attributes/ 

before ~ ​​/ .ctags, and it should appear. You may need to set up regular expression to avoid false matches in other files or to accommodate different formatting of attribute declarations in other files.

This extends ctags in such a way that when analyzing perl files, a different type of regexp tag is detected.

Then you need to tell the taglist plugin about the new tag type by adding it to the vimrc file:

 let tlist_perl_settings='perl;c:constant;l:label;p:package;s:subroutine;a:attribute' 
+5
source share

Jeff, I tried my code, but it didn’t work for me with the syntax you use. Could this be a version issue? I am using exuberant ctags version 5.8.
I also changed the regex a bit because quotation marks are optional and you can allow spaces (but nothing more) preceding the has keyword.
Here is what worked for me. I created the $ HOME / .ctags file (it didn’t exist yet, otherwise just add it) with the following line:

 --regex-perl=/^\s*has\s+['"]?([0-9a-zA-Z_]+)/\1/a,attribute/ 

Then added a line to .vimrc, as you suggested

 let tlist_perl_settings='perl;c:constant;l:label;p:package;s:subroutine;a:attribute' 

Now it lists my attributes in Moose modules.

In addition, it’s also useful for me to have information about the parent class, roles and used modules displayed in the taglist, so here is my complete $ HOME / .ctags file:

 --regex-perl=/^\s*has\s+['"]?([0-9a-zA-Z_]+)/\1/a,attribute/ --regex-perl=/^\s*with\s+(['"])(.+)\1/\2/r,role/ --regex-perl=/^\s*extends\s+(['"])(.+)\1/\2/e,extends/ --regex-perl=/^\s*use\s+([^ ;]+)/\1/u,use/ 

and this is what I have .vimrc (you can change the order of tags in a taglist simply by changing the order in tlist_par_settings):

 let tlist_perl_settings='perl;u:use;p:package;r:role;e:extends;c:constant;a:attribute;s:subroutine;l:label' let Tlist_Show_One_File = 1 

Due to the additional content, I find it useful to use the Tlist_Show_One_File parameter, which causes the taglist to show only the tags of the currently selected file.
To temporarily hide some tags, you can always move the cursor to the tag name and press "zc" (and "zo" to open it again).

+5
source share

All Articles