local leap_active = false vim.api.nvim_create_autocmd("User", { pattern = "LeapEnter", callback = function() leap_active = true end, }) vim.api.nvim_create_autocmd("User", { pattern = "LeapLeave", callback = function() leap_active = false end, }) local nvim_tree_root = nil return { { "willothy/nvim-cokeline", config = function() local hl = require("cokeline.hlgroups") local is_picking_focus = require('cokeline.mappings').is_picking_focus local is_picking_close = require('cokeline.mappings').is_picking_close local function has_diagnostics(buffer) return buffer.diagnostics.errors > 0 or buffer.diagnostics.warnings > 0 or buffer.diagnostics.infos > 0 or buffer.diagnostics.hints > 0 end require("cokeline").setup { show_if_buffers_are_at_least = 0, components = { { text = function(buffer) return buffer.is_first and (require "cokeline.sidebar".get_width("left") == 0 and "" or "│") or "▎" end, fg = function() return hl.get_hl_attr("WinSeparator", "fg") end, }, { text = function (buffer) return (is_picking_focus() or is_picking_close()) and " " .. buffer.pick_letter or "" end, fg = function () return hl.get_hl_attr("PrismiteYellow", "fg") end }, { text = function(buffer) return " " .. buffer.devicon.icon end, fg = function(buffer) return buffer.devicon.color end, }, { text = function(buffer) return buffer.unique_prefix end, fg = function() return hl.get_hl_attr("Comment", "fg") end, italic = true, }, { text = function(buffer) return buffer.filename end, }, { ---@param buffer Buffer text = function(buffer) return buffer.is_modified and " " or "" end, }, { text = function(buffer) return has_diagnostics(buffer) and " [" or "" end, fg = function() return hl.get_hl_attr("WinSeparator", "fg") end, }, { text = function(buffer) local errors = buffer.diagnostics.errors return errors > 0 and errors or "" end, fg = function () return hl.get_hl_attr("DiagnosticError", "fg") end }, { text = function (buffer) local bd = buffer.diagnostics return (bd.errors > 0 and (bd.warnings > 0 or bd.infos > 0 or bd.hints > 0)) and "|" or "" end, fg = function() return hl.get_hl_attr("WinSeparator", "fg") end, }, { text = function(buffer) local warnings = buffer.diagnostics.warnings return warnings > 0 and warnings or "" end, fg = function () return hl.get_hl_attr("DiagnosticWarn", "fg") end }, { text = function (buffer) local bd = buffer.diagnostics return (bd.warnings > 0 and (bd.infos > 0 or bd.hints > 0)) and "|" or "" end, fg = function() return hl.get_hl_attr("WinSeparator", "fg") end, }, { text = function(buffer) local infos = buffer.diagnostics.infos return infos > 0 and infos or "" end, fg = function () return hl.get_hl_attr("DiagnosticInfo", "fg") end }, { text = function (buffer) local bd = buffer.diagnostics return (bd.infos > 0 and bd.hints > 0) and "|" or "" end, fg = function() return hl.get_hl_attr("WinSeparator", "fg") end, }, { text = function(buffer) local hints = buffer.diagnostics.hints return hints > 0 and hints or "" end, fg = function () return hl.get_hl_attr("DiagnosticHint", "fg") end }, { text = function(buffer) return has_diagnostics(buffer) and "]" or "" end, fg = function() return hl.get_hl_attr("WinSeparator", "fg") end, }, { text = " " } }, buffers = { delete_on_right_click = false }, mappings = { disable_mouse = true }, sidebar = { components = { { text = function() local width = require("cokeline.sidebar").get_width("left") if #nvim_tree_root > width then return nvim_tree_root:sub(1, width - 2) .. "…" else return nvim_tree_root end end, bg = function() return hl.get_hl_attr("TabLineSel", "bg") end, }, { text = function() return string.rep( " ", math.max(0, require("cokeline.sidebar").get_width("left") - #nvim_tree_root) ) end, bg = function() return hl.get_hl_attr("TabLineSel", "bg") end }, } } } end, dependencies = { "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" }, }, { "folke/trouble.nvim", opts = {}, dependencies = { "nvim-tree/nvim-web-devicons" }, }, { "nvimdev/indentmini.nvim", config = true, opts = { char = "▏" } }, { "folke/noice.nvim", event = "VeryLazy", opts = { cmdline = { format = { cmdline = { icon = ":" }, }, }, lsp = { override = { ["vim.lsp.util.convert_input_to_markdown_lines"] = true, ["vim.lsp.util.stylize_markdown"] = true, ["cmp.entry.get_documentation"] = true, }, }, presets = { command_palette = true, long_message_to_split = true, inc_rename = false, lsp_doc_border = true, }, messages = { view_search = false, }, routes = { { filter = { event = "msg_show", kind = "", find = "Already at newest change", }, view = "mini", }, { filter = { event = "msg_show", kind = "", find = "Already at oldest change", }, view = "mini", }, { filter = { event = "msg_show", kind = "", find = "E486: Pattern not found:" }, view = "mini" }, -- normal search { filter = { event = "msg_show", kind = "", find = "E486: Pattern not found:" }, view = "mini" }, -- failed search { filter = { event = "msg_show", kind = "", find = "E486: Pattern not found:" }, view = "mini" }, -- undo { filter = { event = "msg_show", kind = "", find = "%d+ .+ line.?; before #%d+", }, view = "mini", }, { filter = { event = "msg_show", kind = "", find = "%d+ .+ line.?; before #%d+", }, view = "mini", }, -- redo { filter = { event = "msg_show", kind = "", find = "%d+ change; after #%d+", }, view = "mini" }, }, }, dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify", }, }, { "nvim-lualine/lualine.nvim", event = "VeryLazy", opts = { options = { section_separators = { left = "", right = "" }, component_separators = { left = "", right = "" }, fmt = function(str) return vim.trim(str) end, globalstatus = true, disabled_filetypes = { "NvimTree" }, }, sections = { lualine_a = { "mode", { function() return "[L]" end, cond = function () return leap_active end }, { function() local reg = vim.fn.reg_recording() if reg == "" then return "" end -- not recording return "[@" .. reg .. "]" end } }, lualine_b = { "filename" }, lualine_c = { "diagnostics", "diff" }, lualine_x = { { function () local noice_loaded, noice = pcall(require, "noice") if noice_loaded then return noice.api.status.command.get() else return "" end end, cond = function() local noice_loaded, noice = pcall(require, "noice") if noice_loaded then return noice.api.status.command.has() else return false end end } }, lualine_y = { "filetype" }, lualine_z = { "searchcount", "progress", "location" }, }, }, dependencies = { "nvim-tree/nvim-web-devicons", }, }, { "stevearc/dressing.nvim", config = true }, { "nvim-tree/nvim-tree.lua", opts = { sort_by = "case_sensitive", view = { width = 30, }, renderer = { root_folder_label = function() return ".." end, indent_markers = { enable = true, }, icons = { show = { folder_arrow = false, }, glyphs = { git = { unstaged = "-", staged = "+", unmerged = "", renamed = "󰏪", untracked = "", deleted = "󰆴", ignored = "", }, }, }, }, filters = { git_ignored = false, custom = { "^.git$", }, }, }, config = function(_, opts) local api = require("nvim-tree.api") local Event = api.events.Event api.events.subscribe(Event.Ready, function() nvim_tree_root = api.tree.get_nodes().absolute_path end) api.events.subscribe(Event.TreeRendered, function() nvim_tree_root = api.tree.get_nodes().absolute_path end) require("nvim-tree").setup(vim.tbl_extend("force", opts, { -- on_attach = function () -- local function opts(desc) -- return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } -- end -- -- local function edit_or_open() -- local node = api.tree.get_node_under_cursor() -- -- if node.nodes ~= nil then -- -- expand or collapse folder -- api.node.open.edit() -- else -- -- open file -- api.node.open.edit() -- -- Close the tree if file was opened -- api.tree.close() -- end -- end -- -- -- open as vsplit on current node -- local function vsplit_preview() -- local node = api.tree.get_node_under_cursor() -- -- if node.nodes ~= nil then -- -- expand or collapse folder -- api.node.open.edit() -- else -- -- open file as vsplit -- api.node.open.vertical() -- end -- -- -- Finally refocus on tree if it was lost -- api.tree.focus() -- end -- -- vim.keymap.set("n", "l", edit_or_open, opts("Edit Or Open")) -- vim.keymap.set("n", "h", api.tree.close, opts("Close")) -- end -- })) end, dependencies = { "nvim-tree/nvim-web-devicons", }, }, { "goolord/alpha-nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() require("alpha").setup(require "dash") end, }, }