Moops enhances the perl syntax by constructs such as:
class MyPkg::MyClass {
# ...
}
and adds the possibility to declare signatures for member functions by introducing the new keywords fun
and method
:
class MyPkg::MyClass {
method run(ArrayRef $ar){
}
}
I use vim and tag files to navigate my code base, but those new keywords are unknown to ctags
, so classes, functions and methods are not indexed. How can I improve the situation?
I can add regular expressions to ctags extending the built-in perl language like so:
or I can put them in my
~/.ctags
file (omitting the quotes)Assuming we have a small project:
With
MyPkg/MyClass.pm
:and
MyPkg/MyOtherClass.pm
:Note the alternate syntax here. The package name gets prepended to the class name resulting in
MyPkg::MyOtherClass
.Finally,
myscript.pl
:Calling
ctags
with the additional regex definitions mentioned above, the resulting tag file looks like this:This almost works:
MyPkg::MyClass
and pressingCTRL-]
vim can find the class definitionrun()
vim finds a definition for the functionBut, there are two problems here:
run()
vim cannot unambigously decide which function is called, as it lacks context; you have to decide for yourself (using:ts
)MyPkg::MyOtherClass
vim cannot find a tag at allSo, in conclusion, my best practise for
Moops
,vim
andctags
would be to always declare classes fully qualified.