local map = vim.keymap.set local o = vim.opt local lazy = require("lazy") -- Search current word local searching_brave = function() vim.fn.system({ "xdg-open", "https://search.brave.com/search?q=" .. vim.fn.expand("") }) end map("n", "?", searching_brave, { noremap = true, silent = true, desc = "Search current word on brave search" }) -- Lazy options map("n", "l", "") map("n", "ll", "Lazy", { desc = "Lazy" }) -- stylua: ignore start map("n", "ld", function() vim.fn.system({ "xdg-open", "https://lazyvim.org" }) end, { desc = "LazyVim Docs" }) map("n", "lr", function() vim.fn.system({ "xdg-open", "https://github.com/LazyVim/LazyVim" }) end, { desc = "LazyVim Repo" }) map("n", "lx", "LazyExtras", { desc = "Extras" }) map("n", "lc", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" }) map("n", "lu", function() lazy.update() end, { desc = "Lazy Update" }) map("n", "lC", function() lazy.check() end, { desc = "Lazy Check" }) map("n", "ls", function() lazy.sync() end, { desc = "Lazy Sync" }) -- stylua: ignore end -- Disable LazyVim bindings map("n", "L", "") map("n", "fT", "") -- Identation map("n", "<", "<<", { desc = "Deindent" }) map("n", ">", ">>", { desc = "Indent" }) -- Save without formatting map("n", "", "noautocmd w", { desc = "Save without formatting" }) -- Cursor navigation on insert mode map("i", "", "", { desc = "Move cursor left" }) map("i", "", "", { desc = "Move cursor left" }) map("i", "", "", { desc = "Move cursor left" }) map("i", "", "", { desc = "Move cursor left" }) -- End of the word backwards map("n", "E", "ge") -- Increment/decrement map("n", "+", "") map("n", "-", "") -- Tabs map("n", "]", "tabnext", { desc = "Next Tab" }) map("n", "[", "tabprevious", { desc = "Previous Tab" }) map("n", "", "tabnext", { desc = "Next Tab" }) map("n", "", "tabprevious", { desc = "Previous Tab" }) for i = 1, 9 do map("n", "" .. i, "tabn " .. i .. "", { desc = "Tab " .. i }) end -- Buffers map("n", "bf", "bfirst", { desc = "First Buffer" }) map("n", "ba", "blast", { desc = "Last Buffer" }) -- Center the screen automatically map("n", "n", "nzzzv") map("n", "N", "Nzzzv") -- Toggle statusline map("n", "uS", function() if o.laststatus:get() == 0 then o.laststatus = 3 else o.laststatus = 0 end end, { desc = "Toggle Statusline" }) -- Toggle tabline map("n", "u", function() if o.showtabline:get() == 0 then o.showtabline = 2 else o.showtabline = 0 end end, { desc = "Toggle Tabline" }) -- Comment box map("n", "]/", "/\\S\\zs\\s*╭zt", { desc = "Next block comment" }) map("n", "[/", "?\\S\\zs\\s*╭zt", { desc = "Prev block comment" }) -- Plugin Info map("n", "cif", "LazyFormatInfo", { desc = "Formatting" }) map("n", "cic", "ConformInfo", { desc = "Conform" }) local linters = function() local linters_attached = require("lint").linters_by_ft[vim.bo.filetype] local buf_linters = {} if not linters_attached then vim.notify("No linters attached", vim.log.levels.WARN, { title = "Linter" }) return end for _, linter in pairs(linters_attached) do table.insert(buf_linters, linter) end local unique_client_names = table.concat(buf_linters, ", ") local linters = string.format("%s", unique_client_names) vim.notify(linters, vim.log.levels.INFO, { title = "Linter" }) end map("n", "ciL", linters, { desc = "Lint" }) map("n", "cir", "LazyRoot", { desc = "Root" }) -- U for redo map("n", "U", "", { desc = "Redo" }) -- Move to beginning/end of line map("n", "", "_", { desc = "First character of Line" }) map("n", "", "$", { desc = "Last character of Line" }) -- Copy whole text to clipboard map("n", "", ":%y+", { desc = "Copy whole text to clipboard", silent = true }) -- Motion map("c", "", "", { desc = "Start Of Line" }) map("i", "", "", { desc = "Start Of Line" }) map("i", "", "", { desc = "End Of Line" }) -- Select all text map("n", "", "ggG", { desc = "Select all text", silent = true, noremap = true }) -- Paste options map("i", "", '"', { desc = "Paste on insert mode" }) map("v", "p", '"_dP', { desc = "Paste without overwriting" }) -- Delete and change without yanking map({ "n", "x" }, "", '"_d', { desc = "Delete without yanking" }) map({ "n", "x" }, "", '"_c', { desc = "Change without yanking" }) -- Deleting without yanking empty line map("n", "dd", function() local is_empty_line = vim.api.nvim_get_current_line():match("^%s*$") if is_empty_line then return '"_dd' else return "dd" end end, { noremap = true, expr = true, desc = "Don't yank empty line to clipboard" }) -- Search inside visually highlighted text. Use `silent = false` for it to -- make effect immediately. map("x", "g/", "/\\%V", { silent = false, desc = "Search inside visual selection" }) -- Search visually selected text (slightly better than builtins in Neovim>=0.8) map("x", "*", [[y/\V=escape(@", '/\')]]) map("x", "#", [[y?\V=escape(@", '?\')]]) -- Dashboard map("n", "fd", function() if LazyVim.has("alpha-nvim") then require("alpha").start(true) elseif LazyVim.has("dashboard-nvim") then vim.cmd("Dashboard") end end, { desc = "Dashboard" })