summaryrefslogtreecommitdiff
path: root/plugin/11_keymaps.lua
diff options
context:
space:
mode:
authorMohammad Reza Karimi <m.r.karimi.j@gmail.com>2026-01-20 15:55:27 -0500
committerMohammad Reza Karimi <m.r.karimi.j@gmail.com>2026-01-20 15:55:27 -0500
commitaa5717f00fd14430c80939a68d7107c26de6e554 (patch)
tree784e99d9b018e0554369c41cb33e2e195e28d3c6 /plugin/11_keymaps.lua
first commit
Diffstat (limited to 'plugin/11_keymaps.lua')
-rw-r--r--plugin/11_keymaps.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/plugin/11_keymaps.lua b/plugin/11_keymaps.lua
new file mode 100644
index 0000000..9dcd4f4
--- /dev/null
+++ b/plugin/11_keymaps.lua
@@ -0,0 +1,58 @@
+local map = function(mode, lhs, rhs, desc) vim.keymap.set(mode, lhs, rhs, { desc = desc }) end
+local nmap = function(lhs, rhs, desc) map("n", lhs, rhs, desc) end
+local mapleader = function(mode, suffix, rhs, desc) map(mode, "<Leader>" .. suffix, rhs, desc) end
+local nmapleader = function(suffix, rhs, desc) mapleader("n", suffix, rhs, desc) end
+
+map({ "n", "x" }, "gy", '"+y', "copy selection to clipboard")
+nmap("gY", '"+Y', "copy to clipboard till end of line")
+
+nmap("-", "<Cmd>Oil<CR>", "Explore")
+
+nmap("<C-J>", "<C-w>w", "switch to next window")
+nmap("<C-K>", "<C-w>W", "switch to prev window")
+
+nmap("<C-L>", [[<Cmd>nohlsearch<Bar>diffupdate<CR>]], "nohlsearch and diffupdate")
+nmap("<C-S-L>", [[<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>]], "default neovim <C-L>")
+
+nmapleader("cd", "<Cmd>lcd %:h<CR>", "lcd to the directory of current file")
+
+vim.keymap.set({ "n", "x" }, "j", [[v:count == 0 ? 'gj' : 'j']], { expr = true, buffer = 0 })
+vim.keymap.set({ "n", "x" }, "k", [[v:count == 0 ? 'gk' : 'k']], { expr = true, buffer = 0 })
+
+nmap("gK", "K", "use the keywordprg instead of hover")
+
+map('t', '<C-[>', [[<C-\><C-N>]], "go to normal mode from terminal mode")
+map('t', '<Esc>', '<Esc>', "map <Esc> to literal ESC in terminal mode")
+
+-- lua exec
+nmapleader("x", function()
+ local line = "lua " .. vim.api.nvim_get_current_line()
+ vim.api.nvim_command(line)
+ vim.api.nvim_input("<Down>")
+end, "execute lua line and go to next line")
+mapleader("x", "x", ":lua<CR>")
+nmap("<Leader><Leader>x", "<Cmd>luafile %<CR>")
+
+-- lsp and format
+nmapleader("e", "<Cmd>lua vim.diagnostic.open_float()<CR>")
+nmap("gd", "<Cmd>lua vim.lsp.buf.definition()<CR>")
+nmap("<C-f>", "<Cmd>lua require'conform'.format{async=true}<CR>")
+
+-- fzf
+nmap("<C-p>", "<Cmd>FzfLua files<CR>", "fzf: find files")
+nmap("<C-t>", "<Cmd>FzfLua resume<CR>", "fzf: resume")
+nmap("<C-\\>", "<Cmd>FzfLua buffers<CR>", "fzf: buffers")
+nmap("<C-/>", "<Cmd>FzfLua oldfiles<CR>", "fzf: oldfiles")
+
+nmapleader("fg", "<Cmd>FzfLua live_grep_native<CR>", "fzf: grep")
+nmapleader("fc", '<Cmd>FzfLua files prompt="Nvim Config>\\ " cwd=~/.config/nvim<CR>', "fzf: search config")
+nmapleader("fp", '<Cmd>lua FzfLua.files({cwd=vim.fn.stdpath("data").."/site/pack/core/opt/"})<CR>', "fzf: search plugins")
+nmapleader("fh", "<Cmd>FzfLua helptags<CR>", "fzf: help tags")
+nmapleader("fk", "<Cmd>FzfLua keymaps<CR>", "fzf: keymaps")
+map("n", "z=", "<Cmd>FzfLua spell_suggest<CR>", "fzf: suggest spelling")
+
+-- git
+nmapleader("gs", "<Cmd>Git<CR>", "git status")
+
+-- qf
+nmapleader("q", function() require("quicker").toggle() end, "Toggle quickfix list")