jhawthorn / fzy

:mag: A simple, fast fuzzy finder for the terminal
MIT License
2.98k stars 126 forks source link

[Idea] Server mode #31

Closed iazel closed 7 years ago

iazel commented 7 years ago

I keep thinking on how awesome would be to have a server mode to give a much better IPC so that it's easier to build plugins with this kind of functionality, eg: a nvim plugin.

My current plan is to use Unix Domain sockets and to provide 4 operations:

The buckets will be stored in memory for now, but next iterations could introduce a persisting operation.

Right now I think it would be easy to provide some custom protocol to build it on, like:

Search protocol:
1 Byte for OP
1 Byte for Bucket ID
N Byte for search term (up to 1024)
1 Null byte to signal termination

If succeeds, will respond with:
1 Null Byte for signaling Success
4 Byte Nr. of results
8 Byte Total nr. of searched strings
N Byte null byte separated results

If fails:
1 Non-Null Byte Error code

However I'm also considering to use msgpack for easier extensibility; the problem is that I've never used it and could take some time to start with xD

What do you think? Any suggestion? :)

KoFish commented 7 years ago

Implementing a easily parsable output-input schema would probably be a good thing. But I can't see any ups with IPC. The only thing I could see is that it would make it a lot easier to accidentally introduce memory leaks.

iazel commented 7 years ago

I think instead that IPC is pretty cool because you don't need to pass the input every time, saving quite some time for big and frequently used inputs (eg: all files in a big project repo) and open up to a possible pre-processing step that will make the algorithm computation even faster!

It's true it can introduce memory leaks, but I'm sure we can also fix them! ^^

jhawthorn commented 7 years ago

Hi @Iazel, thanks for the issue but I will not be implementing this. I intend to keep fzy minimal and unix-y.

You're also welcome to fork fzy and implement this yourself. choices.c and match.c should fix this usecase well and need minimal (if any) changes.