local set = vim.keymap.set local k = vim.keycode local f = require "custom.f" local fn = f.fn -- Basic movement keybinds, these make navigating splits easy for me set("n", "", "") set("n", "", "") set("n", "", "") set("n", "", "") set("n", "x", ".lua", { desc = "Execute the current line" }) set("n", "x", "source %", { desc = "Execute the current file" }) -- Toggle hlsearch if it's on, otherwise just do "enter" set("n", "", function() ---@diagnostic disable-next-line: undefined-field if vim.v.hlsearch == 1 then vim.cmd.nohl() return "" else return k "" end end, { expr = true }) -- Normally these are not good mappings, but I have left/right on my thumb -- cluster, so navigating tabs is quite easy this way. set("n", "", "gT") set("n", "", "gt") -- There are builtin keymaps for this now, but I like that it shows -- the float when I navigate to the error - so I override them. set("n", "]d", fn(vim.diagnostic.jump, { count = 1, float = true })) set("n", "[d", fn(vim.diagnostic.jump, { count = -1, float = true })) -- These mappings control the size of splits (height/width) set("n", "", "5<") set("n", "", "5>") set("n", "", "+") set("n", "", "-") set("n", "", function() if vim.opt.diff:get() then vim.cmd [[normal! ]c]] else vim.cmd [[m .+1==]] end end) set("n", "", function() if vim.opt.diff:get() then vim.cmd [[normal! [c]] else vim.cmd [[m .-2==]] end end) set("n", "tt", function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = 0 }, { bufnr = 0 }) end) vim.api.nvim_set_keymap("n", "t", "PlenaryTestFile", { noremap = false, silent = false }) set("n", "j", function(...) local count = vim.v.count if count == 0 then return "gj" else return "j" end end, { expr = true }) set("n", "k", function(...) local count = vim.v.count if count == 0 then return "gk" else return "k" end end, { expr = true })