Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display number of matches while searching #60

Open
jebaum opened this issue Feb 24, 2016 · 4 comments
Open

Display number of matches while searching #60

jebaum opened this issue Feb 24, 2016 · 4 comments

Comments

@jebaum
Copy link

jebaum commented Feb 24, 2016

I'd be interested in finding a way to display the number of matches while searching. Currently I use vim-anzu (vim-indexed-search also exists, but I don't use it) together with oblique, but that only shows me the number of matches / which match number I'm on after I've finished searching and am going through the matches.

Do you have a gut sense of how complex this addition would be, as well as if it's even possible? My two thoughts would be to somehow display the number of matches (with a couple characters of padding to prevent the screen area the user is actually typing into from moving) to the left of the / search prompt, e.g.:

[6 of 21] /searchin

The other option I can see, although I don't know if it's possible, is to update the statusline as the user types. I think that would be preferable if it can be done.

@junegunn
Copy link
Owner

It's going to be slow if the file is large and the slowness will be immediately noticeable since Vim works synchronously. We'll probably have to limit the scope of search. I'll see if it can be done easily when I get some time.

@jebaum
Copy link
Author

jebaum commented Feb 25, 2016

For some reason that slipped my mind. Do you know if it's possible to update the statusline from a neovim remote plugin, as well as if it's possible to tell when the user has entered a keystroke while in oblique's command line? I'd be interested in trying to implement that

@jebaum
Copy link
Author

jebaum commented Feb 25, 2016

Looked through the api, you can run ex commands and call vimscript functions from it, so I think it may be possible (assuming ui updates as a result of the commands run happen while the user is typing into the oblique's search). You're probably more familiar with it than I am, but I'm playing with this now

@jebaum
Copy link
Author

jebaum commented Feb 25, 2016

So it seems like oblique's command line blocks the UI from updating.

Starting a neovim instance and connecting to it with the python client and trying to run

nvim.command("set statusline='hi'", async=True)

doesn't update the statusline until you leave the oblique command line.

When you're in the typical command line mode or search mode (that is, immediately after pressing : or /), the statusline can be updated even as the user is typing.

Here is the stupid script I made to test this:

import neovim
import time

nvim = neovim.attach('socket', path='/tmp/nvim')

def myfunc():
    for i in range(1,20):
        nvim.command("set statusline='" + str(i) + "'", async=True)
        time.sleep(1)
    return

opened it up with ipython -i and ran myfunc() while typing. for whatever it's worth this also continues to work in insert mode. sometimes a cursor character flashes for a millisecond right next to where the statusline is being updated, but that's obviously a neovim bug.

pseudocl is pretty much black magic to me, so I have no clue whether or not this is something that can be fixed in pseudocl, or a limitation of vim/neovim that would have to be fixed on that end

I guess half the point of pseudocl is to allow for responding to every keypress the user makes in its command line from vimscript, which I guess can't be done otherwise. Still skimming the source of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants