xolox / vim-easytags

Automated tag file generation and syntax highlighting of tags in Vim
http://peterodding.com/code/vim/easytags/
1.01k stars 109 forks source link

Perl Highlighting #97

Closed JessicaKMcIntosh closed 9 years ago

JessicaKMcIntosh commented 9 years ago

I was missing Highlighting in Perl as other languages have. The following addition to "autoload/xolox/easytags.vim" will take care of this.

" Perl. {{{2

call xolox#easytags#define_tagkind({
      \ 'filetype': 'perl',
      \ 'hlgroup': 'perlFunctionTag',
      \ 'tagkinds': '[s]',
      \ 'pattern_prefix': '\%(\<sub\s\+\)\@<!\<'})

highlight def link perlFunctionTag Operator

Thanks for the awesome work.

xolox commented 9 years ago

Thanks for the suggestion, I just added the code you suggested and released it as version 3.7. Also, glad to hear you like the plug-in :-). Happy Vimming!

khrt commented 9 years ago

I think it's better to disable this highlighting until it will be fixed. Because it highlights not only subroutines from your tags file, but also variable names and even Perl operators such as if and etc, of course if you had sub if {} in your tags file and as a result it brakes syntax highlighting.

Sorry for my creepy English (=

JessicaKMcIntosh commented 9 years ago

Try modifying the patter_prefix line to read as below. It will only match if the text is not preceded by 'sub' and is prefixed by either a '>' for methods, '&' for old style procedure calls and a space for modern procedure calls.

So the following would never match:

sub error
$error
%error

While the following will match:

SOMETHING->error
&error
error

Change: \ 'pattern_prefix': '\%(\<sub\s\+\)\@<!\%(>\|\s\|&\)\@<=\<'})

If highlighting the name in a sub declaration doesn't matter to you (personal preference) then the it can be shortened to the following: \ 'pattern_prefix': '\%(>\|\s\|&\)\@<=\<'})

khrt commented 9 years ago

@JessicaKMcIntosh, thank you. It helped me.

JessicaKMcIntosh commented 9 years ago

Just found that procedures at the beginning of the line were not highlighting. The following corrects that. I think this is all cases.

\ 'pattern_prefix': '\%(\<sub\s\+\)\@<!\%(>\|\s\|&\|^\)\@<=\<'})

xolox commented 9 years ago

@khrt: Thanks for reporting the issue!

@JessicaKMcIntosh: Thanks for the follow up, I've updated the Perl support as you suggested.

Happy Vimming!