2022-08-08 01:41:01 +02:00
|
|
|
function map(mode, shortcut, command)
|
2022-08-08 11:07:10 +02:00
|
|
|
vim.keymap.set(mode, shortcut, command, { noremap = true, silent = true })
|
2022-08-08 01:41:01 +02:00
|
|
|
end
|
|
|
|
|
2022-08-08 15:13:31 +02:00
|
|
|
map('n', '<space>', '<nop>')
|
|
|
|
|
2022-08-08 19:12:09 +02:00
|
|
|
vim.g.mapleader = ','
|
|
|
|
|
2022-08-09 11:47:21 +02:00
|
|
|
-- buffers
|
2022-08-08 20:05:40 +02:00
|
|
|
map('n', '<Leader>b', ':buffers<CR>:buffer<Space>')
|
|
|
|
map('n', '<M-Left>', ':bprevious<cr>')
|
|
|
|
map('n', '<M-Right>', ':bnext<cr>')
|
|
|
|
map('i', '<M-Left>', '<esc>:bprevious<cr>')
|
|
|
|
map('i', '<M-Right>', '<esc>:bnext<cr>')
|
|
|
|
|
2022-08-09 11:47:21 +02:00
|
|
|
-- tabs
|
2022-08-08 20:05:40 +02:00
|
|
|
map('n', '<M-S-Left>', ':tabprevious<cr>')
|
2022-08-08 19:12:09 +02:00
|
|
|
map('n', '<M-S-Right>', ':tabnext<cr>')
|
2022-08-08 20:05:40 +02:00
|
|
|
map('i', '<M-S-Left>', '<esc>:tabprevious<cr>')
|
|
|
|
map('i', '<M-S-Right>', '<esc>:tabnext<cr>')
|
2022-08-08 18:10:10 +02:00
|
|
|
|
2022-08-09 11:47:21 +02:00
|
|
|
-- remove word
|
2022-08-08 20:05:40 +02:00
|
|
|
map('n', '<M-BS>', 'db')
|
2022-08-08 18:10:10 +02:00
|
|
|
vim.cmd([[map! <M-BS> <C-W>]]) -- TODO: figure out how to do that with lua
|
2022-08-08 20:05:40 +02:00
|
|
|
map('n', '<C-Del>', 'dw')
|
|
|
|
map('i', '<C-Del>', '<C-O>dw')
|
2022-08-09 11:24:22 +02:00
|
|
|
|
2022-08-09 11:47:21 +02:00
|
|
|
-- move window without moving cursor
|
2022-08-09 11:24:22 +02:00
|
|
|
map('n', '<M-Up>', '<C-y>')
|
|
|
|
map('n', '<M-Down>', '<C-e>')
|
2022-08-09 11:47:21 +02:00
|
|
|
|
|
|
|
-- system clipboard
|
|
|
|
map('v', '<Leader>y', '"+y')
|
|
|
|
map('n', '<Leader>p', '"+p')
|
2022-08-09 12:25:47 +02:00
|
|
|
|
|
|
|
map('n', '<Home>', -- toggle between beginning of line and beginning of text
|
|
|
|
function()
|
|
|
|
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
|
|
if (col == 0) then
|
|
|
|
-- TODO: figure out which function that calls
|
|
|
|
vim.api.nvim_feedkeys('^', 'n', false)
|
|
|
|
else
|
|
|
|
vim.api.nvim_win_set_cursor(0, { row, 0 })
|
|
|
|
end
|
|
|
|
end)
|