descriptionA plugin for the vis editor
ownerrepo.or.cz@soba23.anonaddy.me
last changeWed, 11 Oct 2023 02:34:36 +0000 (11 10:34 +0800)
content tags
add:
readme

gf, <C-w>f, :find, and :sfind, similar to those in vim. They can jump to file, file:123, file:/regex/, or file#L123 locations.

<C-o> will go back to the previous location in the jump stack.

The default search path is the same as in vim - .,/usr/include,,.
Additional file extensions to check for are borrowed from the built-in filetype.lua (according to the current syntax).

Extra support is provided for a few languages[1] so include statements like from urllib import request, response and require"pl.comprehension" get translated to valid paths.
Also, for these languages, you don't have to put the cursor on the module name exactly, anywhere within the statement will do.
(Well, in the Python example above, if you want to go to the second module, you will have to be on its name.)

[1]: C, C++, TCL, Perl, Lua, Moonscript, and Python, currently. There's also a hook function that can be used to register external handlers. vis-parkour uses it for Scheme and Fennel.

Differences with vim

The plugin's commands work like vim's gf and gF combined - they recognize line specs after the filename, and search in path and infer file extensions.
Another difference is that the count argument is used for stripping directories off the filepath, not for searching deeper in path:

--- a/dir/file.txt
+++ b/dir/file.txt

1gf will try to open dir/file.txt, and 2gf - file.txt.

Configuration

A window can have custom search path depending on its syntax and/or the directory its file is under, via "workspaces":

require'vis-goto-file'.workspaces = {
    ["/absolute/path"] = {
        ansi_c = {"./include", "/opt/mips-linux-musl/include"},
        lua = {"/usr/share/lua/5.4"},
        {"/usr/include"}
    },
}

The workspace-specific directories will replace /usr/include in the default search path. (But "." and "" will always be first and last, respectively.)
The deeper a workspace root (/absolute/path in the example above) is, the earlier its directories are included in the search path.
If you have no use for multiple workspaces, just define one with "/" as root and put any customizations there.

These directories could be computed as well. This tends to make visrc.lua look rather messy, so it could be pulled out into a separate file:

require'vis-goto-file'.workspaces = require'vis-goto-file.example'

You can see a few more elaborate examples in the included example file.

shortlog
2023-10-11 Georgi KirilovSquash commitsmaster
heads
6 months ago master