vim.g.mapleader = " " vim.keymap.set("n", "pv", vim.cmd.Ex) vim.keymap.set("n", "", ":Neotree right filesystem toggle") vim.keymap.set("v", "J", ":m '>+1gv=gv") vim.keymap.set("v", "K", ":m '<-2gv=gv") vim.keymap.set("n", "J", "mzJ`z") vim.keymap.set("n", "", "zz") vim.keymap.set("n", "", "zz") vim.keymap.set("n", "", "zz") vim.keymap.set("n", "", "zz") vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") vim.keymap.set("n", "", "") vim.keymap.set("n", "", "") -- terminal remaps vim.keymap.set("t", "", "", { noremap = true, silent = true }) -- vim.keymap.set("n", ";", ":vsplit term://left", { noremap = true, silent = true }) local term_buf = nil function toggleTerminal() -- If we already have a terminal buffer and it's hidden, reopen it if term_buf and vim.api.nvim_buf_is_valid(term_buf) then -- If the terminal is open in the current window, hide it if vim.api.nvim_get_current_buf() == term_buf then vim.cmd("close") else -- Otherwise, open the terminal buffer in a split at the bottom vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.25)) vim.api.nvim_set_current_buf(term_buf) vim.cmd("startinsert") end else -- If no terminal buffer exists, create a new one vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.25)) vim.cmd("terminal") vim.cmd("startinsert") term_buf = vim.api.nvim_get_current_buf() -- Store the terminal buffer ID end -- Check if the current buffer is a terminal end vim.keymap.set("n", "", toggleTerminal, { noremap = true, silent = true }) vim.keymap.set("v", "", toggleTerminal, { noremap = true, silent = true }) vim.keymap.set("i", "", toggleTerminal, { noremap = true, silent = true }) vim.keymap.set("t", "", toggleTerminal, { noremap = true, silent = true }) -- Terminal mode mappings (Alt + hjkl and Alt + Arrow Keys) vim.api.nvim_set_keymap('t', '', 'h', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'j', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'k', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'l', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'h', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'j', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'k', { noremap = true, silent = true }) vim.api.nvim_set_keymap('t', '', 'l', { noremap = true, silent = true }) -- Insert mode mappings (Alt + hjkl and Alt + Arrow Keys) vim.api.nvim_set_keymap('i', '', 'h', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'j', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'k', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'l', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'h', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'j', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'k', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', 'l', { noremap = true, silent = true }) -- Normal mode mappings (Alt + hjkl and Alt + Arrow Keys) vim.api.nvim_set_keymap('n', '', 'h', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'j', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'k', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'l', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'h', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'j', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'k', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'l', { noremap = true, silent = true }) -- swap between windows vim.keymap.set("n", "", "w") vim.keymap.set("v", "", "w") vim.keymap.set("i", "", "w") vim.api.nvim_set_keymap("t", "", "w", { noremap = true, silent = true }) -- greatest remap ever vim.keymap.set("x", "p", [["_dP]]) -- next greatest remap ever : asbjornHaland vim.keymap.set({"n", "v"}, "y", [["+y]]) vim.keymap.set("n", "Y", [["+Y]]) vim.keymap.set({"n", "v"}, "d", [["_d]]) -- This is going to get me cancelled vim.keymap.set("i", "", "") vim.keymap.set("n", "Q", "") vim.keymap.set("n", "f", vim.lsp.buf.format) vim.keymap.set("n", "", "cnextzz") vim.keymap.set("n", "", "cprevzz") vim.keymap.set("n", "k", "lnextzz") vim.keymap.set("n", "j", "lprevzz") vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) vim.keymap.set("n", "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', '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', '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' })