HiPhish / info.vim

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

Use `info://...` for buffer name #10

Open tomtomjhj opened 1 year ago

tomtomjhj commented 1 year ago

Thanks for nice plugin!

Currently, info.vim uses info:... format for buffer names. I suggest changing it to the standard info://... format, following many other plugins, e.g. fugitive://, man://, fern://.

Vim always interprets a filename that starts with scheme:// as an absolute path, so it removes ambiguity. For example, there can be a file named info:... in cwd. This is why :h Cmd-event recommends this format. This also allows ignoring the info buffers in :oldfiles with set viminfo+=rinfo://.

HiPhish commented 1 year ago

I'm afraid I don't quite follow. Can you please give me an example (even if it is contrived) where my scheme could be a problem? The reason I went with for example info:make.info#Top instead of info://make.info#Top is that the former is the URI scheme proposed by GNU Texinfo for Info files without path. See info:texinfo.info#Info%20Files (or :Info texinfo Info\ Files).

I would prefer to remain compatible with this suggestion because it is supported by Emacs as well (principle of lease surprise). However, I think pragmatism trumps least surprise, Vim is not Emacs.

Truth be told, I don't like working on this plugin anymore. It is far too complicated for Vim script and it relies on standalone info to render the text. I would prefer to just rewrite it in Lua for Neovim only and use lpeg (which will be included with Neovim 0.10) to parse the Info files directly and render them myself. But Info files are often compressed, I don't know how I would deal with those. So far standalone info has been giving me support for them for free.

tomtomjhj commented 1 year ago

Can you please give me an example (even if it is contrived) where my scheme could be a problem?

For example, user may want to edit the file named info:info.vim in the cwd.

touch info:info.vim
vim info:info.vim # shows the info page for info.vim

With the current scheme, info.vim cannot tell whether the user wants the file or the info page. On the other hand, vim unambiguously interprets info://... as an absolute path.

v:oldfiles records the file names (among many other things) of the recently edited buffers. For example, if you edit, ~/.vimrc, :oldfiles will display /home/user/.vimrc (after you rerun vim).

In some cases, you may want to exclude some files from v:oldfiles, especially when they are temporary files or not real files, e.g. /tmp/*, fugitive://* (git commit, blob, ..), man:// (man page), and info pages. This can be done with :h viminfo-r (or :h shada-r), but this only filters the filename by the prefix of the file name.

With info:info.vim scheme, the filename recorded in v:oldfiles will be /path/to/cwd/info:info.vim. Therefore, it cannot be ignored from :oldfiles. With info://info:info.vim scheme, exactly info://info:info.vim is recorded in v:oldfiles, so you can filter it out with set viminfo+=rinfo://.

So I think info:// scheme is more practical, but I do understand the advantage of info: scheme's compatibility.

Truth be told, I don't like working on this plugin anymore. It is far too complicated for Vim script and it relies on standalone info to render the text.

Fair enough :upside_down_face: