martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 260 forks source link

:cd unusable? #1166

Closed mralusw closed 4 months ago

mralusw commented 4 months ago

Problem

So I type :cd <TAB>. This brings up a completion list that includes all directories in the current directory, plus all files (nice!), then

Steps to reproduce

No response

vis version (vis -v)

g5cd6d03 +curses +lua +acl +selinux (the one at commit message "fix bug report template", nice to know this is being taken care of)

Terminal name/version

Gnome Terminator

$TERM environment variable

xterm-256color

ninewise commented 4 months ago

It's true that the built-in file selector is very primitive, and not a good fit for :cd.

If you want something fancier, I'd advice adding a variant of the following snippet to your visrc:


vis:command_register("rcd", function(argv, force, cur_win, selection, range)
    handle = io.popen('f="$(mktemp)"; st -e ranger --choosedir="$f" --show-only-dirs; cat "$f"')
    local output = handle:read()
    handle:close()
    vis:command('cd '..output)
end)
mralusw commented 4 months ago

Still, not being able to pick a final directory is a bug, not a case of not enough polishing. However primitive the built-in selector is, it must have some switch (or some key binding) to allow me to pick a directory instead of a file.

If you have a workaround for this bug (like rcd), it should be something that replaces the buggy command.