Hi,
wow, this is awesome. And flattering ;) I inspired a plugin by Hari ;)

It works great, exactly what I was looking for. Incidentally I just
yesterday managed to compile and install vim7.

The only thing, that's not optimal for me right now, is the generating
of the tags file. The proposed shell command, which is also in the
head of the plugin, puts the complete (relative) filename as tag into
the tags file. But I would rather only search for the filenames only
(without the directory in which the files are located).

A line in the tags file should look like

.htaccess      /home/benjamin/public_html/.htaccess 1

instead of

/home/benjamin/public_html/.htaccess      /home/benjamin/public_html/.htaccess 1


I know this may generate a lot of duplicates, which is problematic for
the file selection popup, which only shows the filename and not the
directory in which the file is located.

So this might be "feature request": Show the complete path of the
files that are presented in the popup.

Ragarding the shell snippet: Seems like I must learn awk ;)

Thanks for the plugin ....

Cheers

Benjamin

On 5/12/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote:

Actually, I started with the below idea, and created a plugin that works
more or less like what the OP wanted. It uses the Vim completion
mechanism to bringup a popup dialog with matching filenames. Works best
when you have a dedicated tags file the way I originaly proposed (see
the script header). Can anyone try the attached plugin and give me
feedback?

--
Thanks,
Hari

On Wed, 10 May 2006 at 1:54pm, Hari Krishna Dara wrote:

>
> On Wed, 10 May 2006 at 8:10am, Benjamin Reitzammer wrote:
>
> > Hi,
> >
> > thanks a lot, for all your responses. And for being so blazingly fast.
> > Just like vim itself ;)
> >
> > Using a tags file is the closest to the described functionality I was
> > looking for. Although I must say that having to press the <tab> key to
> > request a completion is not nearly as nice as having a list
> > automatically update.
> >
> > Yakov said, getting something like this in vim would be quite hard, but
> > I think, that I might give it a shot nonetheless. You sure will hear
> > about it, if I do so.
> >
> > Thanks again for being so helpful
> >
> > Cheers
> >
> > Benjamin
>
> If you go with the tag file approach, it is not that hard to cook up
> something quickly, without having to press tab. Here is something very
> unpolished, but shows the approach (code copied from my execmap.vim
> plugin):
>
> function! LookupFile()
>   " Open a new buffer to show the results.
>   new
>   redraw
>
>   " Generate a line with spaces to clear the previous message.
>   let i = 1
>   let clearLine = "\r"
>   while i < &columns
>     let clearLine = clearLine . ' '
>     let i = i + 1
>   endwhile
>
>   let str = ""
>   call Prompt(str)
>   let breakLoop = 0
>   let accepted = 0
>   while !breakLoop
>     try
>       let char = getchar()
>     catch /^Vim:Interrupt$/
>       let char = "\<Esc>"
>     endtry
>     if char == '^\d\+$' || type(char) == 0
>       let char = nr2char(char)
>     endif " It is the ascii code.
>     if char == "\<BS>"
>       let str = strpart(str, 0, strlen(str) - 1)
>     elseif char == "\<Esc>"
>       let breakLoop = 1
>     elseif char == "\<CR>"
>       let accepted = 1
>       let breakLoop = 1
>     else
>       let str = str . char
>     endif
>
>     " Show the matches for what is typed so far.
>     silent! 1,$delete
>     let _tags = &tags
>     set tags=/tmp/tags
>     try
>       let tags = taglist(str)
>     finally
>       let &tags = _tags
>     endtry
>     for ta in tags
>       "Why does this generates syntax errors?
>       "silent put =ta["filename"]
>       call append('$', ta["filename"])
>     endfor
>     redraw
>
>     echon clearLine
>     call Prompt(str)
>   endwhile
> endfunction
>
> function! Prompt(str)
>   echon "\rLookup file containg: " . a:str
> endfunction
>
> If you call LookupFile(), it brings an empty buffer and prompts you to
> enter a string. Entering each character makes the buffer show all the
> matching filenames. What you sould do in addition is to:
> - Avoid hardcoding the tags file.
> - Don't lookup tags for each entered character, but only after a short
>   delay (this could be tricky). This may not be important thought.
> - When user finds the file, make it easy to open it (like pressing O on it,
>   or even opening the file right-away if there is only one match).
> - Use a scratch buffer to show results and reuse one buffer. I have
>   numerous examples in my all my plugins (selectbuf, breakpts etc.)
> - Plugginize it, creating maps etc. to invoke the function. Again, if
>   you don't have much experience, there are several that you can follow.
>   You can look at my plugins, I try to follow all the plugin writing
>   rules that Vim doc lists.
>
>

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Reply via email to