Skip to content

Commit

Permalink
feat: motions plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 28, 2021
1 parent c7f8496 commit f989fcf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/which-key/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function M.invoke(results)
end

-- Register builtin plugins
local builtin = { "marks", "registers", "text-objects", "operators" }
local builtin = { "marks", "registers", "text-objects", "operators", "motions" }
for _, name in pairs(builtin) do M.register("which-key.plugins." .. name, name) end

return M
37 changes: 37 additions & 0 deletions lua/which-key/plugins/motions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local M = {}

M.name = "motions"

local motions = {
["h"] = "Left",
["j"] = "Down",
["k"] = "Up",
["l"] = "Right",
["w"] = "Next word",
["%"] = "Matching character: '()', '{}', '[]'",
["b"] = "Previous word",
["e"] = "Next end of word",
["ge"] = "Previous end of word",
["0"] = "Start of line",
["^"] = "Start of line (non-blank)",
["$"] = "End of line",
["f"] = "Move to next char",
["F"] = "Move to previous char",
["t"] = "Move before next char",
["T"] = "Move before previous char",
["gg"] = "First line",
["G"] = "Last line",
["{"] = "Previous empty line",
["}"] = "Next empty line",
}

function M.setup(wk)

local ops = require("which-key.plugins.operators")
for op, _ in pairs(ops.operators) do wk.register(motions, { mode = "n", prefix = op }) end

wk.register(motions, { mode = "v", prefix = "" })
wk.register(motions, { mode = "n", prefix = "" })
end

return M

0 comments on commit f989fcf

Please sign in to comment.