Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

sayanarijit/completion.xplr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

completion.xplr

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.

TODO

  • Path completion
  • Command completion
  • Message completion
  • Multi source completion
  • Partial completion
  • Better API

Installation

Install manually

  • 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

Use Case

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"
      },
    },
  },
}

About

The missing tab completion for xplr input buffer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages