;; Custom keymappings. (local opts {:noremap true :silent true}) (local mappings [;;Remap space as leader key ["" : : {}] ;; Normal ;; ;; Better window navigation [:n : :h {}] [:n : :j {}] [:n : :k {}] [:n : :l {}] ;; Resize with arrows [:n : ":resize -2" {}] [:n : ":resize +2" {}] [:n : ":vertical resize -2" {}] [:n : ":vertical resize +2" {}] ;; Visual ;; ;; Stay in indent mode [:v "<" :" :>gv {}] ;; Visual Block ;; ;; Move text up and down [:x :J ":move '>+1gv-gv" {}] [:x :K ":move '<-2gv-gv" {}] ;; Move text up and down [:v : ":m .+1==" {}] [:v : ":m .-2==" {}] [:v :p "\"_dP" {}] ;; Splits [:n : :split {}] [:n : :vsplit {}] ;; Buf navigation [:n : :bprev {}] [:n : :bnext {}] ;; Jump half a page and centralize the view [:n : :zz {}] [:n : :zz {}] ;; Close window [:n :Q ":q" {}] ;; Remove highlighted search [:n : :nohlsearch {}] ;; Force refresh [:n :mj ":e" {:desc :Refresh}] ;; Remap jump next [:n : : {}]]) (each [_ mapping (ipairs mappings)] (match mapping [mode key cmd desc] (vim.api.nvim_set_keymap mode key cmd (vim.tbl_extend :force opts desc))))