Thanks.

On Sat, 2 Dec 2006, Marc Weber wrote:

On Fri, Dec 01, 2006 at 10:30:26AM -0600, Ben K. wrote:
Is there a way to make gf open "some.file" from this line?

        Include("/includes/some.file");

where the file is actually sitting under web server root, like

        /var/www/html/includes/some.file

I tried adding "/var/www/html" to the :set path but vim will not recognize
it. /var/www/html/; was the same. Basically I'm looking for a way to add
"prefixes".

On the same note, would it be possible to let gf open

        /var/www/html/includes/some.file

when I gf on this string

        http://somehost.com/includes/some.file

or by defining a new command (say wf)?

That's exactly where you can use my little script (which will isntall
some dependencies, too)

Just add this into your ftplgugin/filetype.vim file:

------ >8 ------ >8   filetype_sourced.vim  -- >8 ------ >8 ------ >8
noremap gf :call vl#ui#navigation#gfHandler#HandleGF()<cr>
call 
vl#ui#navigation#gfHandler#AddGFHandler("[matchstr(expand('<cWORD>'),'Include(\"\\zs[^\"].*\\ze\")')]")
------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8<

and source the installer file
http://www.mawercer.de/marcweber/vim/vimlib/installers/vimlib_gfhandler_installer_sourceme.vim
(Don't be afraid. The installer will ask for confirmation before doing
anything.)
I would suggest saving it to another directory (eg ~/.vimlib or
~/.vim_gf) and adding this folder to your runtimepath.
set runtimepath+=~/.vimlib
Then its easy to remove it again if you don't like it.
I think you can see that [matchstr ... does the interesting thing which
is getting the file from under the cursor by calling expand('<cWORD>')
and remvoving the Include text. You
have to adjust it the way you like. You have to write your own code
which removes /includes and adds /var/www/html/includes/ which would
look like this:
call 
vl#ui#navigation#gfHandler#AddGFHandler("['/var/www/html/includes'.matchstr(expand('<cWORD>'),'Include(\"/includes\\zs[^\"].*\\ze\")')]")

You can even add different include directories:
call vl#ui#navigation#gfHandler#AddGFHandler("['/var/www/html/includes1'....
call vl#ui#navigation#gfHandler#AddGFHandler("['/var/www/html/includes2'....
call vl#ui#navigation#gfHandler#AddGFHandler("['/var/www/html/includes3'....

Then you'll be asked which file to open if it doesn't exist.

Unfortunately the documentation
(http://www.mawercer.de/marcweber/vim/vimlib/docs/vl_ui_navigation_gfHandler_vim.html)
isn't up to date because vim segfaults while creating it and I don't
have the time to find the code causing it.

If something doesn't work drop me a mail.

HTH
Marc Weber


Regards,

Ben K.
Developer
http://benix.tamu.edu

Reply via email to