HiPhish / info.vim

Browse info files from Vim (mirror)
https://gitlab.com/HiPhish/info.vim
MIT License
40 stars 6 forks source link

Add support for looking up non-Node indices #7

Open mburz opened 3 years ago

mburz commented 3 years ago

Info supports looking up indices that are not Nodes. For a list of what indices you could look up you could run info --apropos=

I added support for this on my fork, but it's more of a crud quick hack than something nice, hence I won't be creating a PR, but you could look at it here: https://github.com/mburz/info.vim

HiPhish commented 3 years ago

Do you have an example of how to use that? If it is useful I would like to add it.

I added support for this on my fork, but it's more of a crud quick hack

So is everything in info.vim to be honest. Standalone Info is not meant to used a library, and I have been stretching it pretty far. In my opinion the only solution is to either extend standalone info, or instead implement a minimal "info file server" that only serves Info files instead of being a full-fledged reader.

I want to go for the latter, the Info format is well documented. Vim script however is a pain to work with, so here is my plan instead: write a Lua library which allows reading and analyzing Info files, then using that library as a dependency write a new Info reader plugin for Neovim. This would mean no Vim support though. But having the core of the plugin as a standalone Lua library would allow other people to use the library as well, so Vim users could maybe build something on top of that.

I have been tweaking my Neovim configuration for Lua the last two days, setting up the language server and stuff. It's looking good now.

mburz commented 3 years ago

I use this normally from the visual mode: select something in order to look it up, or for words by just pressing K on top of them (normal mode). For instance I could select a single atom such as . or : and press K to open and jump to the info entry for that one.

By using my fork, you could use the following command to jump to the entry for : in the bash manual: Info bash : Item To do the same from the command line would be: info bash :

The way this works is as follows: info indexes the entries from all nodes that contain Index in their title, e.g. info bash -n 'Builtin Index' See info_indices_of_file_buffer from the source code of info in the texinfo repo.

The format is pretty simple it consists of an entry, the node where is could be found and the line from the node: ss-selected-201103-003009

Lua would be a solution overall, but nvim is not an option for me, it's not available on too many systems I have to deal with.

HiPhish commented 3 years ago

That does sound pretty useful. I will have to try to add it.

Lua would be a solution overall, but nvim is not an option for me, it's not available on too many systems I have to deal with.

Yes, that was why I originally made the plugin for both Vim and Neovim. I should be possible use the Lua library to write a standalone application, similar to standalone Info, which can process requests and return data as JSON or something. A Vim plugin could use that one through Vim's job control. Would that be better for you?

mburz commented 3 years ago

Really appreciate trying it to make it work for me, thank you. Think that would work, but sounds like quite a bit of work on your side, I would keep it as simple as possible. Maybe read up the indexed entries and cache them somewhere and just navigate to the right node + line based on them.