-- maps.lua local maps = {} local function map(mode, lhs, rhs, opts) local options = { noremap = true } if opts then options = vim.tbl_extend('force', options, opts) end vim.api.nvim_set_keymap(mode, lhs, rhs, options) end function maps.toggleGoyo() map('n', '', ':Goyo', { noremap = false }) end function maps.term() -- Open and move to resized terminal map('n', 't', 'sj :terminal:res 5i', { noremap = false }) -- Enter normal mode in terminal map('t', 'ß', '') end function maps.telescope() map('n', 'ff', 'lua require(\'telescope.builtin\').git_files()') map('n', 'fg', 'lua require(\'telescope.builtin\').live_grep()') map('n', 'fb', 'lua require(\'telescope.builtin\').buffers()') map('n', 'fh', 'lua require(\'telescope.builtin\').help_tags()') end function maps.fixIndent() map('v', '<', '', '>gv') end function maps.moveByRow() -- When text is wrapped, move by terminal rows, not lines, unles a count is provided map('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'', { silent = true, expr = true }) map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', { silent = true, expr = true }) end function maps.centeredSearch() map('n', 'n', 'nzzzv') map('n', 'N', 'Nzzzv') end function maps.moveToWindow() map('t', 'ª', 'h') map('t', 'º', 'j') map('t', '∆', 'k') map('t', '@', 'l') map('i', 'ª', 'h') map('i', 'º', 'j') map('i', '∆', 'k') map('i', '@', 'l') map('n', 'ª', 'h') map('n', 'º', 'j') map('n', '∆', 'k') map('n', '@', 'l') end function maps.init() vim.g.mapleader = " " map('n', 'b', 'NvimTreeToggle') map('n', 'cc', 'Telescope colorscheme') maps.toggleGoyo() maps.term() maps.telescope() maps.fixIndent() maps.moveByRow() maps.centeredSearch() -- maps.moveToWindow() end return maps