feat(cd): optionally complete from zoxide's database
`cd` completes from FileGenerator, which reads one directory: the one you are standing in. So `cd proj` only ever resolves when proj happens to be a child of the current directory, and returns nothing at all otherwise -- including for directories visited constantly. That is the opposite of what cd is normally reached for, and it reads as completion being broken rather than as a scope limit. zoxide.extend-cd routes `cd` through the generator `z` already uses, so local children are offered first and zoxide's frecency database fills in everything else, reachable by name from anywhere. Off by default: it shells out to zoxide, and offering absolute paths from outside the current directory is a real change in what `cd` proposes. The query is also cached for two seconds. Generators run on every keystroke and `zoxide query -l` is a subprocess costing ~11ms here, which is the whole redraw budget; the list only changes when the user changes directory, so the window costs nothing. This applies to `z` and `zi` too, which were paying it per keystroke already.
This commit is contained in:
@@ -78,6 +78,21 @@ type KeybindingsConfig struct {
|
||||
NavigateRight string `toml:"navigate-right"`
|
||||
}
|
||||
|
||||
type ZoxideConfig struct {
|
||||
// ExtendCd adds zoxide's frecency database to `cd` completions.
|
||||
//
|
||||
// Without it `cd` only offers direct children of the current directory,
|
||||
// because that is all the file generator walks -- so `cd proj` finds
|
||||
// nothing unless you are already standing in the parent. With it, any
|
||||
// directory zoxide has seen is reachable by name from anywhere, which is
|
||||
// what `cd` is usually wanted for.
|
||||
//
|
||||
// Off by default: it shells out to zoxide, and the suggestions are absolute
|
||||
// paths from outside the current directory, which is a real change in what
|
||||
// `cd` offers.
|
||||
ExtendCd bool `toml:"extend-cd"`
|
||||
}
|
||||
|
||||
type SuggestOnEmptyConfig struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
DebounceMS int `toml:"debounce_ms"`
|
||||
@@ -127,6 +142,7 @@ type Config struct {
|
||||
Git GitConfig `toml:"git"`
|
||||
Updater UpdaterConfig `toml:"updater"`
|
||||
AI AIConfig `toml:"ai"`
|
||||
Zoxide ZoxideConfig `toml:"zoxide"`
|
||||
Keybindings KeybindingsConfig `toml:"keybindings"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user