Skip to content

v0.3.0

Choose a tag to compare

@nmfirdausw nmfirdausw released this 19 Oct 15:14
· 28 commits to main since this release
93479f5

What's Changed

Features

Keymaps

Highlights

  • Default keymaps. Batu now ships a small set of keymaps that smooth over everyday editing.
  • Yours to change. The keymaps option skips, replaces or adds keymaps per mode and key, with any vim.keymap.set option.
  • Space as leader. A new leader option defaults to a space for <leader> and <localleader>.
  • Native. Plain vim.keymap.set calls, with no dependencies.

Default keymaps

Mode Key Action
x <, > Shift while keeping the selection
n, x j, k, <Down>, <Up> Move by visual line when wrapped, by count otherwise
x J, K Move the selected lines down or up
x p Paste over the selection without overwriting the register
n Y Yank to the end of the line
n <C-d>, <C-u>, n, N Keep the cursor centered

Usage

require("batu").setup({
  leader = ",",
  keymaps = {
    x = { [">"] = false },                                 -- skip a default
    n = {
      ["<leader>w"] = { "<cmd>write<CR>", desc = "Save" }, -- add your own
    },
  },
})
Option Value Effect
keymaps true (default) Apply Batu's default keymaps
false Apply none
a table Apply the defaults, plus your own and changes to them. Each value is false to skip, a string or function to replace the right-hand side, or { rhs, desc = "...", ... }
leader " " (default) Use space for <leader> and <localleader>
another string Use that key instead
false Leave them alone

How it works

leader is set first in setup(), before any mapping is defined, so Batu's keymaps and the ones you add through keymaps use it. Batu never overrides a leader you have already set, so vim.g.mapleader = "," before setup() still wins. Your own <leader> mappings pick it up only if you define them after setup().

Upgrading

Unlike v0.2.0, existing configs will notice this release. keymaps and leader are on by default, so setup() now maps the keys above and sets the leader to a space if you haven't set one.

  • To keep your current setup, use setup({ keymaps = false, leader = false }).
  • To drop one keymap, set it to false, for example keymaps = { x = { p = false } }.
  • If you map any of these keys yourself after setup(), your mapping wins.

Full Changelog: v0.2.0...v0.3.0