The missing tab completion for xplr input buffer.
This plugin is intended to be used as a library for other potential plugins or custom hacks.
- Path completion
- Command completion
- Message completion
- Multi source completion
- Partial completion
- Better API
-
Add the following line in
~/.config/xplr/init.lua
local home = os.getenv("HOME") package.path = home .. "/.config/xplr/plugins/?/init.lua;" .. home .. "/.config/xplr/plugins/?.lua;" .. package.path
-
Clone the plugin
mkdir -p ~/.config/xplr/plugins git clone https://github.com/sayanarijit/completion.xplr ~/.config/xplr/plugins/completion
-
Require the module in
~/.config/xplr/init.lua
require("completion").setup() -- Exposed functions: -- - xplr.fn.custom.completion.complete_path -- - xplr.fn.custom.completion.complete_command
Switch to completion mode (look at the tab
key)
-- Path completion
xplr.config.modes.builtin.go_to.key_bindings.on_key.p = {
help = "go to path",
messages = {
"PopMode",
{ SwitchModeCustom = "go_to_path" },
{ SetInputBuffer = "" },
}
}
xplr.config.modes.custom.go_to_path = {
name = "go to path",
key_bindings = {
on_key = {
enter = {
messages = {
"FocusPathFromInput",
"PopMode",
},
},
esc = {
help = "cancel",
messages = { "PopMode" },
},
tab = {
help = "complete",
messages = {
{ CallLuaSilently = "custom.completion.complete_path" },
},
},
["ctrl-c"] = {
help = "terminate",
messages = { "Terminate" },
},
backspace = {
help = "remove last character",
messages = { "RemoveInputBufferLastCharacter" },
},
["ctrl-u"] = {
help = "remove line",
messages = { { SetInputBuffer = "" } },
},
["ctrl-w"] = {
help = "remove last word",
messages = { "RemoveInputBufferLastWord" },
},
},
default = {
messages = {
"BufferInputFromKey"
},
},
},
}