Looking for the best approach here.

Some background at the top, and at the bottom is a 6 step process which I believe Vim does 1-4 already. Just seems to be missing the 5 and 6.



In my Flex MXML ftplugin, I set the following:

setlocal includeexpr=substitute(v:fname,'\\.','/','g')
setlocal suffixesadd+=.mxml
setlocal suffixesadd+=.as

I also added a public function so that you can do something like this:

    autocmd bufread */MyDirectory/*
\ let buildFile = substitute(fnamemodify(expand("<afile>"), ':p:h'), 'MyDirectory\zs.*', '', '')| \ if exists("*AddSearchPath_".&ft) | call AddSearchPath_{&ft}(buildFile.'/src') | endif

Net result, once I edit a *.as or *.mxml file, and I run:
setlocal path
path=C:\MyDirectory\src\plus\some\more


This means, when I am on an import statement, I can simply hit gf (get file):
import plus.some.more.MyEvent;

This will first search for MyEvent.(mxml|as), if it can't find it, it uses the includeexpr above and then tries again searching the path looking for:
plus\some\more\MyEvent.as

Which it finds and opens:
C:\MyDirectory\plus\some\more\MyEvent.as


This is all terrific.

But the actual code that uses MyEvent looks like this:
                    var d.MyEvent = new MyEvent();

What I really want to do is use gf while my cursor is on the word "MyEvent".

Right now, this leads to a not found.

If I change the setlocal path to this:
path=C:\MyDirectory\src\plus\some\more\**

Then it finds it, but since it is called "path", you don't really want to put /** on to the end of it, since it really isn't a path anymore.

I thought about using the findfile() function:
:echo findfile('MyEvent', &path)

This _only_ works when /** is on the path.


Also, I might also want to extend includeexpr, to call a function and use findfile() myself by modifying the &path and placing the /** on the end of each item in the comma separated list. There are times in this case, where I might want to check my tags file if findfile() returned nothing. Just ideas, but looking for flexibility.

So in the end, I am just looking for the _right way_ to do this in Vim that would not potentially mess up some of the other Vim bits and pieces that might rely on &path being in an _expected_ format.


So, what I really want I guess is the following:
1.  gf - look for the file in current directory (already does this)
2.  gf - look for the file in current path (already does this)
3. gf - look for the file in current path after manipulating the name (already does this, suffixexadd) 4. gf - look for the file in current path after manipulating the filename path (already does this, includeexpr)
5.  findfile() - pass a flag to recursively search the path (new)
6. gf - if includeexpr is not found, call a function and perform more enhanced searching (new, let me use findfile() or taglist() and return the file I want opened).


Any ideas?

Thanks,
Dave

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to