2021-02-24 20:52:43 +01:00
|
|
|
-- maps.lua
|
2021-11-26 23:38:04 +01:00
|
|
|
|
|
|
|
local maps = {}
|
|
|
|
|
2021-02-24 19:14:06 +01:00
|
|
|
local function map(mode, lhs, rhs, opts)
|
2022-10-18 17:42:03 +02:00
|
|
|
local options = { noremap = true }
|
|
|
|
if opts then options = vim.tbl_extend('force', options, opts) end
|
|
|
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
2021-02-24 19:14:06 +01:00
|
|
|
end
|
|
|
|
|
2021-11-26 23:38:04 +01:00
|
|
|
function maps.term()
|
|
|
|
-- Open and move to resized terminal
|
2022-10-18 17:42:03 +02:00
|
|
|
map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', { noremap = false })
|
2021-11-26 23:38:04 +01:00
|
|
|
-- Enter normal mode in terminal
|
|
|
|
map('t', 'ß<C-N>', '<C-\\><C-N>')
|
|
|
|
end
|
|
|
|
|
|
|
|
function maps.telescope()
|
|
|
|
map('n', '<Leader>ff', '<cmd>lua require(\'telescope.builtin\').git_files()<CR>')
|
|
|
|
map('n', '<Leader>fg', '<cmd>lua require(\'telescope.builtin\').live_grep()<CR>')
|
|
|
|
map('n', '<Leader>fb', '<cmd>lua require(\'telescope.builtin\').buffers()<CR>')
|
|
|
|
map('n', '<Leader>fh', '<cmd>lua require(\'telescope.builtin\').help_tags()<CR>')
|
|
|
|
end
|
|
|
|
|
|
|
|
function maps.fixIndent()
|
|
|
|
map('v', '<', '<gv')
|
|
|
|
map('v', '>', '>gv')
|
|
|
|
end
|
|
|
|
|
|
|
|
function maps.moveByRow()
|
|
|
|
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided
|
2022-10-18 17:42:03 +02:00
|
|
|
map('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'', { silent = true, expr = true })
|
|
|
|
map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', { silent = true, expr = true })
|
2021-11-26 23:38:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function maps.centeredSearch()
|
|
|
|
map('n', 'n', 'nzzzv')
|
|
|
|
map('n', 'N', 'Nzzzv')
|
|
|
|
end
|
|
|
|
|
|
|
|
function maps.init()
|
|
|
|
vim.g.mapleader = " "
|
|
|
|
|
2024-08-13 11:49:16 +02:00
|
|
|
-- map('n', '<leader>b', '<cmd>NvimTreeToggle<CR>')
|
|
|
|
map('n', '<leader>b', '<cmd>Lexplore | vert res 30<CR>')
|
2022-10-29 14:22:42 +02:00
|
|
|
map('n', '<leader>cc', '<cmd>Telescope colorscheme<CR>')
|
|
|
|
|
2021-11-26 23:38:04 +01:00
|
|
|
maps.term()
|
|
|
|
maps.telescope()
|
|
|
|
maps.fixIndent()
|
|
|
|
maps.moveByRow()
|
|
|
|
maps.centeredSearch()
|
|
|
|
end
|
|
|
|
|
|
|
|
return maps
|