Thursday, September 19, 2013

VIM: Project.vim and ctags

Strange i could not found my function definition...?
Ahh.. I see, the function declaration is in a file with *.inc
extention, PHP is what i am using and working with
frontaccounting (to be short, will called as FA) .
So i search my FA a .vimprj/ inside the working directory.
Aha! No .vimprj/ that is why no tags file created. So i create
the .vimprj/ on the root directory of FA, remember the
"/" trailing of .vimprj to remind you that its a directory.

So i type,
And new separated window created inside my GVim.
I hit my keyboard with \C (create new project) and
supplied 3 inputs, the root of my FA project directory,
the CD=. and the filters "*.php *.inc *.html *.php*".
After a few seconds the project tree created. Lets get
to work.

Bla bla bla, what! I hit my keyboard with g] which means
"go to declaration", in this case is the declaration of
a function that where my current cursor pointing at,
nothing happened. So tried to
Nahh... the debug message throws something like
... C++-Kind=... Well its a PHP scope why c++ being
detected by my ctags? Ok, i realized that my .vimprj/
still has nothing inside so i add a file called mysettings.vim

And copy paste of my other PHP project mysettings.vim,

let g:indexer_disableCtagsWarning = 1

let g:indexer_ctagsCommandLineOptions = " --exclude='*.sql' --exclude='*.js'
--exclude='*.css' --PHP-kinds=+cf --fields=+iaS --extra=+q
--regex-PHP='/(abstract class |class ) ([^ ]*)/\\1/c/'
--regex-PHP='/interface ([^ ]*)/\\1/c/'
--regex-PHP='/(public |static |abstract |protected |private )+function.*([^ ()]*)/\\2/f/'
--regex-PHP='/define[(].([a-zA-Z0-9_]*)/\\1/f/' "

Save the file, done! I restarted GVim, and hit g] at my function name.
Arrghhh.. nothing happened, again??? And i hit
Still it showed me C++-kind, let me think.. After several googling
and "man ctags" i ended up with

let g:indexer_disableCtagsWarning = 1

let g:indexer_ctagsCommandLineOptions = " --langdef=PHP
--exclude='*.sql' --exclude='*.js' --exclude='*.css'
--PHP-kinds=+cf --fields=+iaS --extra=+q
--regex-PHP='/(abstract class |class ) ([^ ]*)/\\1/c/'
--regex-PHP='/interface ([^ ]*)/\\1/c/'
--regex-PHP='/(public |static |abstract |protected |private )+function.*([^ ()]*)/\\2/f/'
--regex-PHP='/define[(].([a-zA-Z0-9_]*)/\\1/f/' -h '.inc' "

I've added with langmap, langdef and -h option. Save and restart my
GVim, hurray.. it works my function declaration inside *.inc is now
there in the ~/.vimprojects_tag/frontaccounting. And if i g] it jumps
to the source file where function declaration is in.

Happy Vim-ing..

No comments: