-- Most of the code below is for easy reference to lazyvim shortcuts -- So, I can view and change them easily local Util = require("lazyvim.util") return { -- icons { "nvim-tree/nvim-web-devicons" }, -- Changes the Nvim root to git root { "airblade/vim-rooter", config = function() vim.g.rooter_cd_cmd = "tcd" -- Use tcd command to change the root end, }, -- File Explorer { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", keys = { { "e", ":Neotree filesystem toggle", desc = "Explorer NeoTree (root dir)", remap = true }, -- Change the rest if required { "fe", function() require("neo-tree.command").execute({ toggle = true, dir = Util.root() }) end, desc = "Explorer NeoTree (root dir)", }, { "fE", function() require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() }) end, desc = "Explorer NeoTree (cwd)", }, { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, { "ge", function() require("neo-tree.command").execute({ source = "git_status", toggle = true }) end, desc = "Git explorer", }, { "be", function() require("neo-tree.command").execute({ source = "buffers", toggle = true }) end, desc = "Buffer explorer", }, }, opts = { enable_git_status = true, filesystem = { bind_to_cwd = true, follow_current_file = { enabled = true, -- Highlight the current buffer leave_dirs_open = true, }, use_libuv_file_watcher = true, -- Sync file system changes filtered_items = { visible = true, show_hidden_count = true, hide_dotfile = false, hide_gitignore = false, }, }, window = { position = "left", width = 30, -- Saner window size mappings = { ["s"] = "open_split", -- Default vim keymap for horizontal split ["v"] = "open_vsplit", -- Default vim keymap for vertical split }, }, default_component_configs = { indent = { indent_size = 2, -- Compact tree display }, }, sources = { "filesystem", "buffers", "git_status", "document_symbols" }, open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, }, }, -- Search and replace in multiple files { "nvim-pack/nvim-spectre", keys = { { "sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)", }, }, }, -- Fuzzy finder of many things { "nvim-telescope/telescope.nvim", keys = { -- find { "ff", Util.telescope("files"), desc = "Find Files (root dir)" }, { "", Util.telescope("files"), desc = "Find Files (root dir)" }, { "fb", "Telescope buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, { "fc", Util.telescope.config_files(), desc = "Find Config File" }, { "fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, { "fr", "Telescope oldfiles", desc = "Recent" }, { "fR", Util.telescope("oldfiles", { cwd = vim.loop.cwd() }), desc = "Recent (cwd)" }, { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { ":", "Telescope command_history", desc = "Command History" }, -- git { "gc", "Telescope git_commits", desc = "commits" }, { "gs", "Telescope git_status", desc = "status" }, -- search { 's"', "Telescope registers", desc = "Registers" }, { "sa", "Telescope autocommands", desc = "Auto Commands" }, { "sb", "Telescope current_buffer_fuzzy_find", desc = "Buffer" }, { "sc", "Telescope command_history", desc = "Command History" }, { "sC", "Telescope commands", desc = "Commands" }, { "sd", "Telescope diagnostics bufnr=0", desc = "Document diagnostics" }, { "sD", "Telescope diagnostics", desc = "Workspace diagnostics" }, { "sg", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { "sG", Util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, { "sh", "Telescope help_tags", desc = "Help Pages" }, { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, { "sk", "Telescope keymaps", desc = "Key Maps" }, { "sM", "Telescope man_pages", desc = "Man Pages" }, { "sm", "Telescope marks", desc = "Jump to Mark" }, { "so", "Telescope vim_options", desc = "Options" }, { "sR", "Telescope resume", desc = "Resume" }, { "sw", Util.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" }, { "sW", Util.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, { "sw", Util.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" }, { "sW", Util.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, { "uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview", }, { "ss", function() require("telescope.builtin").lsp_document_symbols({ symbols = require("lazyvim.config").get_kind_filter(), }) end, desc = "Goto Symbol", }, { "sS", function() require("telescope.builtin").lsp_dynamic_workspace_symbols({ symbols = require("lazyvim.config").get_kind_filter(), }) end, desc = "Goto Symbol (Workspace)", }, }, }, -- Confusing hence disabled { "folke/flash.nvim", enabled = false }, -- EasyMotion is better { "easymotion/vim-easymotion" }, -- Adds and reads "keys" property in each plugins { "folke/which-key.nvim", opts = { plugins = { spelling = true }, defaults = { mode = { "n", "v" }, ["g"] = { name = "+goto" }, ["ys"] = { name = "+surround" }, ["]"] = { name = "+next" }, ["["] = { name = "+prev" }, [""] = { name = "+tabs" }, ["b"] = { name = "+buffer" }, ["c"] = { name = "+code" }, ["f"] = { name = "+file/find" }, ["g"] = { name = "+git" }, ["gh"] = { name = "+hunks" }, ["q"] = { name = "+quit/session" }, ["s"] = { name = "+search" }, ["u"] = { name = "+ui" }, ["w"] = { name = "+windows" }, ["x"] = { name = "+diagnostics/quickfix" }, }, }, }, -- Display undotree { "mbbill/undotree", config = function() vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) end, }, -- TODO: install gitblame plugin -- Highlights text that changed since last commit { "lewis6991/gitsigns.nvim", opts = { on_attach = function(buffer) local gs = package.loaded.gitsigns local function map(mode, l, r, desc) vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) end -- stylua: ignore start map("n", "ghp", gs.preview_hunk, "Preview Hunk") map("n", "gH", gs.preview_hunk, "Preview Hunk") map("n", "]h", gs.next_hunk, "Next Hunk") map("n", "[h", gs.prev_hunk, "Prev Hunk") end, }, }, -- Automatically highlights other instances of the word under cursor { "RRethy/vim-illuminate", config = function(_, opts) require("illuminate").configure(opts) local function map(key, dir, buffer) vim.keymap.set("n", key, function() require("illuminate")["goto_" .. dir .. "_reference"](false) end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer }) end map("]]", "next") map("[[", "prev") -- also set it after loading ftplugins, since a lot overwrite [[ and ]] vim.api.nvim_create_autocmd("FileType", { callback = function() local buffer = vim.api.nvim_get_current_buf() map("]]", "next", buffer) map("[[", "prev", buffer) end, }) end, keys = { { "]]", desc = "Next Reference" }, { "[[", desc = "Prev Reference" }, }, }, -- Remove Buffer { "echasnovski/mini.bufremove", keys = { { "br", function() if vim.bo.modified then vim.cmd.write() end require("mini.bufremove").delete(0) end, desc = "Save and remove Buffer", }, -- stylua: ignore { "bR", function() require("mini.bufremove").delete(0, true) end, desc = "Force Remove Buffer" }, }, }, -- Diagnostics lists { "folke/trouble.nvim", keys = { { "xx", "TroubleToggle document_diagnostics", desc = "Document Diagnostics (Trouble)" }, { "xX", "TroubleToggle workspace_diagnostics", desc = "Workspace Diagnostics (Trouble)" }, { "xL", "TroubleToggle loclist", desc = "Location List (Trouble)" }, { "xQ", "TroubleToggle quickfix", desc = "Quickfix List (Trouble)" }, { "[e", function() if require("trouble").is_open() then require("trouble").previous({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cprev) if not ok then vim.notify(err, vim.log.levels.ERROR) end end end, desc = "Previous trouble/quickfix item", }, { "]e", function() if require("trouble").is_open() then require("trouble").next({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cnext) if not ok then vim.notify(err, vim.log.levels.ERROR) end end end, desc = "Next trouble/quickfix item", }, }, }, -- Finds and lists all of the TODO, HACK, BUG, etc comment { "folke/todo-comments.nvim", -- stylua: ignore keys = { { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, { "xt", "TodoTrouble", desc = "Todo (Trouble)" }, { "xT", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme (Trouble)" }, { "st", "TodoTelescope", desc = "Todo" }, { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, }, }, -- UI Stuff ------------------------------------------------------------------------ -- Fancy-looking tabs, which include filetype icons and close buttons. { "akinsho/bufferline.nvim" }, -- Fancy Statusline { "nvim-lualine/lualine.nvim", opts = function() local lualine_require = require("lualine_require") lualine_require.require = require local icons = require("lazyvim.config").icons vim.o.laststatus = vim.g.lualine_laststatus return { options = { theme = "auto", globalstatus = true, disabled_filetypes = { statusline = { "dashboard", "alpha", "starter" } }, }, sections = { lualine_a = { "mode" }, lualine_b = { "branch" }, lualine_c = { Util.lualine.root_dir(), { "diagnostics", symbols = { error = icons.diagnostics.Error, warn = icons.diagnostics.Warn, info = icons.diagnostics.Info, hint = icons.diagnostics.Hint, }, }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, { Util.lualine.pretty_path() }, }, lualine_x = { -- stylua: ignore { function() return require("noice").api.status.command.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, color = Util.ui.fg("Statement"), }, -- stylua: ignore { function() return require("noice").api.status.mode.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, color = Util.ui.fg("Constant"), }, -- stylua: ignore { function() return " " .. require("dap").status() end, cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, color = Util.ui.fg("Debug"), }, { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.ui.fg("Special"), }, { "diff", symbols = { added = icons.git.added, modified = icons.git.modified, removed = icons.git.removed, }, source = function() local gitsigns = vim.b.gitsigns_status_dict if gitsigns then return { added = gitsigns.added, modified = gitsigns.changed, removed = gitsigns.removed, } end end, }, }, lualine_y = {}, lualine_z = { { "progress" }, { "location" } }, }, extensions = { "neo-tree", "lazy" }, } end, }, -- Better vim.ui { "stevearc/dressing.nvim" }, -- Better `vim.notify()` { "rcarriga/nvim-notify", keys = { { "un", function() require("notify").dismiss({ silent = true, pending = true }) end, desc = "Dismiss all Notifications", }, }, opts = { render = "wrapped-compact", -- Smaller popups timeout = 3000, max_height = function() return math.floor(vim.o.lines * 0.25) end, max_width = function() return math.floor(vim.o.columns * 0.5) end, on_open = function(win) vim.api.nvim_win_set_config(win, { zindex = 100 }) end, }, }, -- Completely replaces the UI for messages, cmdline and the popupmenu. { "folke/noice.nvim", opts = { routes = { { -- Show popup message when @recording macros view = "notify", filter = { event = "msg_showmode" }, }, { -- Direct some messages to bottom - obove lualine view = "mini", filter = { event = "msg_show", any = { { find = "%d+L, %d+B" }, { find = "; after #%d+" }, { find = "; before #%d+" }, -- Display delete, yank, jump notifications at bottom { find = "yanked" }, { find = "fewer lines" }, { find = "more lines" }, { find = "EasyMotion" }, -- This can be completely discarded { find = "Target key" }, { find = "search hit BOTTOM" }, { find = "lines to indent" }, { find = "lines indented" }, }, }, }, -- TODO: Some messages needs to suppressed completely. Figure out how??? }, presets = { bottom_search = true, command_palette = true, long_message_to_split = true, inc_rename = true, }, }, -- stylua: ignore keys = { { "", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" }, { "snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" }, { "snh", function() require("noice").cmd("history") end, desc = "Noice History" }, { "sna", function() require("noice").cmd("all") end, desc = "Noice All" }, { "snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" }, { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll forward", mode = {"i", "n", "s"} }, { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll backward", mode = {"i", "n", "s"}}, }, }, -- ui components { "MunifTanjim/nui.nvim" }, { "goolord/alpha-nvim", enabled = false }, { "akinsho/toggleterm.nvim", cmd = "ToggleTerm", build = ":ToggleTerm", keys = { -- NOTE: Do not use for terminals, there would be issue escaping -- F13 = Shift + F1 { "", "ToggleTerm direction=horizontal", desc = "Toggle horizontal terminal" }, }, opts = { open_mapping = [[]], direction = "horizontal", shade_filetypes = {}, hide_numbers = true, insert_mappings = true, terminal_mappings = true, start_in_insert = true, close_on_exit = true, float_opts = { border = "curved", }, }, }, { "mikesmithgh/kitty-scrollback.nvim", lazy = true, cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" }, event = { "User KittyScrollbackLaunch" }, version = "^3.0.0", opts = { status_window = { icons = { nvim = "" }, }, }, config = function() require("kitty-scrollback").setup() end, }, }