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", "i" }, "", "noautocmd w", { desc = "Save Without Formatting" }) -- Increment/decrement map("n", "+", "") map("n", "-", "") -- Buffers map("n", "bf", "bfirst", { desc = "First Buffer" }) map("n", "ba", "blast", { desc = "Last Buffer" }) map("n", "", "e #", { desc = "Switch to Other Buffer" }) -- Toggle statusline map("n", "uS", function() if o.laststatus:get() == 0 then o.laststatus = 3 else o.laststatus = 0 end end, { desc = "Toggle Statusline" }) -- 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 LazyVim.warn("No linters attached", { 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) LazyVim.notify(linters, { title = "Linter" }) end map("n", "ciL", linters, { desc = "Lint" }) map("n", "cir", "LazyRoot", { desc = "Root" }) -- Copy whole text to clipboard map("n", "", ":%y+", { desc = "Copy Whole Text to Clipboard", silent = true }) -- Select all text map("n", "", "ggG", { desc = "Select all Text", silent = true, noremap = true }) -- Delete and change without yanking map({ "n", "x" }, "", '"_d', { desc = "Delete Without Yanking" }) map({ "n", "x" }, "", '"_c', { desc = "Change Without Yanking" }) -- Dashboard map("n", "fd", function() if LazyVim.has("snacks.nvim") then Snacks.dashboard() elseif LazyVim.has("alpha-nvim") then require("alpha").start(true) elseif LazyVim.has("dashboard-nvim") then vim.cmd("Dashboard") end end, { desc = "Dashboard" }) -- Spelling map("n", "!", "zg", { desc = "Add Word to Dictionary" }) map("n", "@", "zug", { desc = "Remove Word from Dictionary" }) -- Terminal Stuff if not LazyVim.has("floaterm.nvim") or not LazyVim.has("toggleterm.nvim") then local lazyterm = function() Snacks.terminal(nil, { size = { width = 0.8, height = 0.8 }, cwd = LazyVim.root() }) end map("n", "ft", lazyterm, { desc = "Terminal (Root Dir)" }) map("n", "fT", function() Snacks.terminal(nil, { size = { width = 0.8, height = 0.8 }, cwd = vim.fn.getcwd() }) end, { desc = "Terminal (cwd)" }) map("n", [[]], lazyterm, { desc = "Terminal (Root Dir)" }) map("t", [[]], "close", { desc = "Hide Terminal" }) end -- Git map("n", "ghb", Snacks.git.blame_line, { desc = "Blame Line" }) -- Windows Split map("n", "_", "s", { desc = "Split Window Below", remap = true }) map("n", "\\", "v", { desc = "Split Window Right", remap = true }) -- Center when scrolling if Snacks.scroll.enabled then map("n", "", function() vim.wo.scrolloff = 999 vim.defer_fn(function() vim.wo.scrolloff = 8 end, 500) return "" end, { expr = true }) map("n", "", function() vim.wo.scrolloff = 999 vim.defer_fn(function() vim.wo.scrolloff = 8 end, 500) return "" end, { expr = true }) end -- Select first option for spelling map("n", "S", "1z=", { desc = "Spelling (First Option)" })