-- vim: foldmethod=marker -- stylua: ignore start 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, "" .. 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("-", "Oil", "Explore") nmap("", "w", "switch to next window") nmap("", "W", "switch to prev window") nmap("", [[nohlsearchdiffupdate]], "nohlsearch and diffupdate") nmap("", [[nohlsearchdiffupdatenormal! ]], "default neovim ") nmapleader("cd", "lcd %:h", "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", "", [[]], "go to normal mode from terminal mode") map("t", "", "", "map to literal ESC in terminal mode") -- stylua: ignore end -- lua exec {{{ nmapleader("x", function() local line = "lua " .. vim.api.nvim_get_current_line() vim.api.nvim_command(line) vim.api.nvim_input("") end, "execute lua line and go to next line") mapleader("x", "x", ":lua") nmap("x", "luafile %") -- }}} -- lsp and format {{{ nmapleader("e", "lua vim.diagnostic.open_float()") nmap("gd", "lua vim.lsp.buf.definition()") nmap("", "lua require'conform'.format{async=true}") -- }}} -- fzf {{{ -- stylua: ignore start nmap("", "FzfLua files", "fzf: find files") nmap("", "FzfLua resume", "fzf: resume") nmap("", "FzfLua buffers", "fzf: buffers") nmap("", "FzfLua oldfiles", "fzf: oldfiles") nmapleader("fg", "FzfLua live_grep", "fzf: grep") nmapleader("fc", "FzfLua files cwd=~/.config/nvim", "fzf: search config") nmapleader("fp", "FzfLua files cwd=~/.local/share/nvim/site/pack/core/opt", "fzf: search plugins") nmapleader("fh", "FzfLua helptags", "fzf: help tags") nmapleader("fk", "FzfLua keymaps", "fzf: keymaps") -- stylua: ignore end -- }}} -- fzf misc {{{ map("n", "z=", "FzfLua spell_suggest", "fzf: suggest spelling") vim.keymap.set("i", "", function() vim.cmd([[packadd fzf-lua]]) require("fzf-lua").complete_file({ cmd = "rg --files", winopts = { preview = { hidden = true } }, }) end, { silent = true, desc = "fzf: complete file" }) -- }}} -- git nmapleader("gs", "Git", "git status") -- qf -- stylua: ignore start nmapleader("q", function() require("quicker").toggle() end, "Toggle quickfix list") -- stylua: ignore end