win-nvim/lua/zak/remap.lua

129 lines
5.5 KiB
Lua

vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("n", "<C-n>", ":Neotree right filesystem reveal toggle<CR>")
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-]>", "<C-d>zz")
vim.keymap.set("n", "<C-[>", "<C-u>zz")
vim.keymap.set("n", "<C-}>", "<C-}>zz")
vim.keymap.set("n", "<C-{>", "<C-{>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set("n", "<tab>", "<nop>")
vim.keymap.set("n", "<C-m>", "<C-6>")
-- terminal remaps
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true, silent = true })
-- vim.keymap.set("n", "<leader>;", ":vsplit term://left<CR><A-Right><CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<C-k>", function ()
vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.25))
vim.cmd("terminal")
vim.cmd("startinsert")
end, { noremap = true, silent = true })
-- Terminal mode mappings (Alt + hjkl and Alt + Arrow Keys)
vim.api.nvim_set_keymap('t', '<A-h>', '<C-\\><C-N><C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-j>', '<C-\\><C-N><C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-k>', '<C-\\><C-N><C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-l>', '<C-\\><C-N><C-w>l', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-Left>', '<C-\\><C-N><C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-Down>', '<C-\\><C-N><C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-Up>', '<C-\\><C-N><C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('t', '<A-Right>', '<C-\\><C-N><C-w>l', { noremap = true, silent = true })
-- Insert mode mappings (Alt + hjkl and Alt + Arrow Keys)
vim.api.nvim_set_keymap('i', '<A-h>', '<C-\\><C-N><C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-j>', '<C-\\><C-N><C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-k>', '<C-\\><C-N><C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-l>', '<C-\\><C-N><C-w>l', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-Left>', '<C-\\><C-N><C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-Down>', '<C-\\><C-N><C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-Up>', '<C-\\><C-N><C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', '<A-Right>', '<C-\\><C-N><C-w>l', { noremap = true, silent = true })
-- Normal mode mappings (Alt + hjkl and Alt + Arrow Keys)
vim.api.nvim_set_keymap('n', '<A-h>', '<C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-j>', '<C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-k>', '<C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-l>', '<C-w>l', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-Left>', '<C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-Down>', '<C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-Up>', '<C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-Right>', '<C-w>l', { noremap = true, silent = true })
-- swap between windows
vim.keymap.set("n", "<A-m>", "<C-w>w")
vim.keymap.set("v", "<A-m>", "<C-w>w")
vim.keymap.set("i", "<A-m>", "<C-w>w")
vim.api.nvim_set_keymap("t", "<A-m>", "<C-\\><C-O><C-w>w", { noremap = true, silent = true })
-- greatest remap ever
vim.keymap.set("x", "<leader>p", [["_dP]])
-- next greatest remap ever : asbjornHaland
vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])
vim.keymap.set("n", "<leader>Y", [["+Y]])
vim.keymap.set({"n", "v"}, "<leader>d", [["_d]])
-- This is going to get me cancelled
vim.keymap.set("i", "<C-c>", "<Esc>")
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
vim.keymap.set("n", "<A-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<A-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("n", "<leader>so", function()
vim.cmd("so")
end)
-- Function to get config directory based on OS
local function get_config_dir()
if vim.fn.has('win32') == 1 then
return vim.fn.stdpath('config')
else
return '~/.config/nvim'
end
end
-- Create the mapping
vim.keymap.set('n', '<leader>cd', function()
-- Get the config directory
local config_dir = get_config_dir()
-- Change to the config directory
vim.cmd('cd ' .. config_dir)
-- Open file explorer in the config directory
vim.cmd('Ex ' .. config_dir)
end, { desc = 'Jump to Neovim config directory' })
vim.keymap.set('n', '<leader>z', function()
require("zen-mode").toggle({
window = {
width = .65, -- width will be 85% of the editor width
options = {}
},
plugins = {
options = {
enabled = true,
ruler = true, -- disables the ruler text in the cmd line area
showcmd = true, -- disables the command in the last line of the screen
-- you may turn on/off statusline in zen mode by setting 'laststatus'
-- statusline will be shown only if 'laststatus' == 3
laststatus = 3,
}
}
})
end, { desc = 'Zen Mode' })