-- -- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ -- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ -- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ -- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- -- File: mappings.lua -- Description: Key mapping configs -- Author: Kien Nguyen-Tuan -- is a space now local map = vim.keymap.set local cmd = vim.cmd vim.keymap.set("n", "b", ":Telescope buffers", { noremap = true, silent = true }) map("n", "", ":bprevious", { noremap = true, silent = true }) map("n", "", ":bnext", { noremap = true, silent = true }) map("n", "q", ":qa!", {}) -- Fast saving with and s map("n", "s", ":w", {}) -- Move around splits map("n", "wh", "h", { desc = "switch window left" }) map("n", "wj", "j", { desc = "switch window right" }) map("n", "wk", "k", { desc = "switch window up" }) map("n", "wl", "l", { desc = "switch window down" }) -- Reload configuration without restart nvim -- Or you don't want to use plenary.nvim, you can use this code -- function _G.reload_config() -- for name, _ in pairs(package.loaded) do -- if name:match("^me") then -- package.loaded[name] = nil -- end -- end -- dofile(vim.env.MYVIMRC) -- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) -- end function _G.reload_config() local reload = require("plenary.reload").reload_module reload("me", false) dofile(vim.env.MYVIMRC) vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) end map("n", "rr", _G.reload_config, { desc = "Reload configuration without restart nvim" }) -- Telescope local builtin = require "telescope.builtin" map("n", "ff", builtin.find_files, { desc = "Open Telescope to find files" }) map("n", "fg", builtin.live_grep, { desc = "Open Telescope to do live grep" }) map("n", "fb", builtin.buffers, { desc = "Open Telescope to list buffers" }) map("n", "fh", builtin.help_tags, { desc = "Open Telescope to show help" }) map("n", "fo", builtin.oldfiles, { desc = "Open Telescope to list recent files" }) map("n", "cm", builtin.git_commits, { desc = "Open Telescope to list git commits" }) -- NvimTree map("n", "n", ":NvimTreeToggle", { desc = "Toggle NvimTree sidebar" }) -- open/close map("n", "nr", ":NvimTreeRefresh", { desc = "Refresh NvimTree" }) -- refresh map("n", "nf", ":NvimTreeFindFile", { desc = "Search file in NvimTree" }) -- search file -- LSP map( "n", "gm", function() require("conform").format { lsp_fallback = true } end, { desc = "General Format file" } ) -- global lsp mappings map("n", "ds", vim.diagnostic.setloclist, { desc = "LSP Diagnostic loclist" }) -- Comment map("n", "mm", "gcc", { desc = "Toggle comment", remap = true }) map("v", "mm", "gc", { desc = "Toggle comment", remap = true }) -- Terminal map("n", "tt", function() local height = math.floor(vim.o.lines / 2) cmd("belowright split | resize " .. height .. " | terminal") end, { noremap = true, silent = true })