dotfiles/.config/nvim/lua/keymaps.lua

46 lines
1.3 KiB
Lua

function map(mode, shortcut, command)
vim.keymap.set(mode, shortcut, command, { noremap = true, silent = true })
end
map('n', '<space>', '<nop>')
vim.g.mapleader = ','
-- buffers
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>')
-- tabs
map('n', '<M-S-Left>', ':tabprevious<cr>')
map('n', '<M-S-Right>', ':tabnext<cr>')
map('i', '<M-S-Left>', '<esc>:tabprevious<cr>')
map('i', '<M-S-Right>', '<esc>:tabnext<cr>')
-- remove word
map('n', '<M-BS>', 'db')
vim.cmd([[map! <M-BS> <C-W>]]) -- TODO: figure out how to do that with lua
map('n', '<C-Del>', 'dw')
map('i', '<C-Del>', '<C-O>dw')
-- move window without moving cursor
map('n', '<M-Up>', '<C-y>')
map('n', '<M-Down>', '<C-e>')
-- system clipboard
map('v', '<Leader>y', '"+y')
map('n', '<Leader>p', '"+p')
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)