2022-03-09 19:03:04 +01:00
|
|
|
local helpers = require("my.helpers")
|
2022-04-04 01:10:26 +02:00
|
|
|
local arpeggio = require("my.plugins.arpeggio")
|
2022-03-09 19:03:04 +01:00
|
|
|
|
2022-01-30 19:10:57 +01:00
|
|
|
local M = {}
|
|
|
|
|
2022-01-31 21:41:13 +01:00
|
|
|
function M.map(mode, lhs, rhs, opts)
|
2022-07-19 20:19:36 +02:00
|
|
|
if string.len(mode) > 1 then
|
|
|
|
for i = 1, #mode do
|
|
|
|
local c = mode:sub(i, i)
|
|
|
|
M.map(c, lhs, rhs, opts)
|
2022-04-04 01:10:26 +02:00
|
|
|
end
|
2022-07-19 20:19:36 +02:00
|
|
|
else
|
|
|
|
local options = helpers.mergeTables(opts, { noremap = true })
|
|
|
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
|
|
|
end
|
2022-01-30 19:10:57 +01:00
|
|
|
end
|
|
|
|
|
2022-01-31 21:54:22 +01:00
|
|
|
function M.mapSilent(mode, lhs, rhs, opts)
|
2022-07-19 20:19:36 +02:00
|
|
|
local options = helpers.mergeTables(opts, { silent = true })
|
|
|
|
M.map(mode, lhs, rhs, options)
|
2022-01-31 21:54:22 +01:00
|
|
|
end
|
|
|
|
|
2022-01-30 19:10:57 +01:00
|
|
|
function M.setup()
|
2022-07-27 10:00:25 +02:00
|
|
|
M.map("n", "qq", ":wq<cr>") -- Save and quit
|
2022-04-04 01:10:26 +02:00
|
|
|
|
2022-07-19 20:19:36 +02:00
|
|
|
-- Create chords
|
|
|
|
if arpeggio ~= nil then
|
2022-08-08 16:25:54 +02:00
|
|
|
arpeggio.chord("n", "vs", "<C-w>v") -- Create vertical split
|
2022-07-19 20:19:36 +02:00
|
|
|
arpeggio.chord("n", "vs", "<C-w>v") -- Create vertical split
|
|
|
|
arpeggio.chord("n", "ji", ":w<cr>") -- Saving
|
|
|
|
arpeggio.chord("i", "jk", "<Esc>") -- Remap Esc to jk
|
|
|
|
arpeggio.chord("inv", "<Leader>a", "<C-6><cr>") -- Rebind switching to the last pane using leader+a
|
|
|
|
arpeggio.chord("nv", "cp", "\"+") -- Press cp to use the global clipboard
|
2022-07-27 10:00:25 +02:00
|
|
|
arpeggio.chord("n", "rw", ":%s/<C-r><C-w>/") -- Press rw to rename word under cursor
|
2022-07-19 20:19:36 +02:00
|
|
|
end
|
2022-05-10 14:28:36 +02:00
|
|
|
|
2022-07-19 20:19:36 +02:00
|
|
|
return M
|
2022-01-30 20:19:35 +01:00
|
|
|
end
|
|
|
|
|
2022-02-01 00:06:48 +01:00
|
|
|
return M
|