61 lines
1.7 KiB
Lua
61 lines
1.7 KiB
Lua
|
-- maps.lua
|
||
|
|
||
|
local maps = {}
|
||
|
|
||
|
function maps.term()
|
||
|
vim.api.nvim_set_keymap('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i',
|
||
|
{ noremap = false, desc = "Open and move to terminal" })
|
||
|
vim.api.nvim_set_keymap('t', 'ß<C-N>', '<C-\\><C-N>', { noremap = true, desc = "Enter normal mode in terminal" })
|
||
|
end
|
||
|
|
||
|
function maps.fixIndent()
|
||
|
vim.api.nvim_set_keymap('v', '<', '<gv', { noremap = true, desc = "Remove identation level" })
|
||
|
vim.api.nvim_set_keymap('v', '>', '>gv', { noremap = true, desc = "Add identation level" })
|
||
|
end
|
||
|
|
||
|
function maps.moveByRow()
|
||
|
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided
|
||
|
vim.api.nvim_set_keymap('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'',
|
||
|
{ silent = true, expr = true, desc = "Go down 1 line" })
|
||
|
vim.api.nvim_set_keymap('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'',
|
||
|
{ silent = true, expr = true, desc = "Go up 1 line" })
|
||
|
end
|
||
|
|
||
|
function maps.centeredSearch()
|
||
|
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', { noremap = true, desc = "Search next" })
|
||
|
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', { noremap = true, desc = "Search previous" })
|
||
|
end
|
||
|
|
||
|
function maps.init()
|
||
|
vim.g.mapleader = " "
|
||
|
|
||
|
vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Lexplore | vert res 30<CR>',
|
||
|
{ noremap = true, desc = "Open file explorer" })
|
||
|
|
||
|
maps.term()
|
||
|
maps.fixIndent()
|
||
|
maps.moveByRow()
|
||
|
maps.centeredSearch()
|
||
|
end
|
||
|
|
||
|
return {
|
||
|
"folke/which-key.nvim",
|
||
|
event = "VeryLazy",
|
||
|
keys = {
|
||
|
{
|
||
|
"<leader>?",
|
||
|
function()
|
||
|
require("which-key").show({ global = false })
|
||
|
end,
|
||
|
desc = "Buffer Local Keymaps (which-key)",
|
||
|
},
|
||
|
},
|
||
|
config = function()
|
||
|
require("which-key").setup({
|
||
|
preset = "helix"
|
||
|
})
|
||
|
local wk = require("which-key")
|
||
|
maps.init()
|
||
|
end
|
||
|
}
|