3 ---@param component any -- actually a lualine.component
5 ---@param hl_group? string
7 function M.format(component, text, hl_group)
8 text = text:gsub("%%", "%%%%")
9 if not hl_group or hl_group == "" then
12 --- hl_cache is added here, not modified
13 ---@type table<string, string>
14 component.hl_cache = component.hl_cache or {}
15 local lualine_hl_group = component.hl_cache[hl_group]
16 if not lualine_hl_group then
17 local utils = require("lualine.utils.utils")
19 local gui = vim.tbl_filter(function(x) return x end, {
20 utils.extract_highlight_colors(hl_group, "bold") and "bold",
21 utils.extract_highlight_colors(hl_group, "italic") and "italic",
24 lualine_hl_group = component:create_hl({
25 fg = utils.extract_highlight_colors(hl_group, "fg"),
26 gui = #gui > 0 and table.concat(gui, ",") or nil,
27 }, "LV_" .. hl_group) --[[@as string]]
28 component.hl_cache[hl_group] = lualine_hl_group
30 return component:format_hl(lualine_hl_group) .. text .. component:get_default_hl()
33 function M.pretty_path()
39 modified_hl = "MatchParen", -- hl group when file is modified
41 readonly_icon = " ",
44 local path = vim.fn.expand("%:p") --[[@as string]]
50 path = require("lazy.core.util").norm(path)
51 local cwd = vim.uv.cwd()
53 if path:find(cwd, 1, true) == 1 then
54 path = path:sub(#cwd + 2)
57 local sep = package.config:sub(1, 1)
58 local parts = vim.split(path, "[\\/]")
60 if opts.length == 0 then
62 elseif #parts > opts.length then
63 parts = { parts[1], "…", unpack(parts, #parts - opts.length + 2, #parts) }
66 if vim.bo.modified then
67 parts[#parts] = parts[#parts] .. opts.modified_sign
68 parts[#parts] = M.format(self, parts[#parts], opts.modified_hl)
70 parts[#parts] = M.format(self, parts[#parts], opts.filename_hl)
75 dir = table.concat({ unpack(parts, 1, #parts - 1) }, sep)
76 dir = M.format(self, dir .. sep, opts.directory_hl)
80 if vim.bo.readonly then
81 readonly = M.format(self, opts.readonly_icon, opts.modified_hl)
83 return dir .. parts[#parts] .. readonly
89 { 'echasnovski/mini.clue',
90 -- NOTE: this caused some issue with unterminated mappings, i.e. <L>gc when there
91 -- is also <L>gcc. It would simply terminate early and not allow for next mapping.
95 { mode = 'n', keys = '<Leader>' },
96 { mode = 'x', keys = '<Leader>' },
98 { mode = 'n', keys = 'g' },
99 { mode = 'x', keys = 'g' },
101 { mode = 'n', keys = "'" },
102 { mode = 'n', keys = '`' },
103 { mode = 'x', keys = "'" },
104 { mode = 'x', keys = '`' },
106 { mode = 'n', keys = '<C-w>' },
108 { mode = 'n', keys = 'z' },
109 { mode = 'x', keys = 'z' },
112 { mode = 'n', keys = '<Leader>b', desc = '+Buffers' },
113 { mode = 'n', keys = '<Leader>c', desc = '+LSP' },
117 { "akinsho/bufferline.nvim",
120 { "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle Pin" },
121 { "<leader>bP", "<Cmd>BufferLineGroupClose ungrouped<CR>", desc = "Delete Non-Pinned Buffers" },
122 { "<leader>br", "<Cmd>BufferLineCloseRight<CR>", desc = "Delete Buffers to the Right" },
123 { "<leader>bl", "<Cmd>BufferLineCloseLeft<CR>", desc = "Delete Buffers to the Left" },
124 { "<S-h>", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
125 { "<S-l>", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
126 { "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
127 { "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
128 { "[B", "<cmd>BufferLineMovePrev<cr>", desc = "Move buffer prev" },
129 { "]B", "<cmd>BufferLineMoveNext<cr>", desc = "Move buffer next" },
131 ---@type BufferlineConfig
134 close_command = function(n) Snacks.bufdelete(n) end,
135 right_mouse_command = function(n) Snacks.bufdelete(n) end,
136 diagnostics = "nvim_lsp",
137 always_show_bufferline = false,
138 diagnostics_indicator = function(_, _, diag)
139 local icons = rmz.ui.icons.diagnostics
140 local ret = (diag.error and icons.Error .. diag.error .. " " or "")
141 .. (diag.warning and icons.Warn .. diag.warning or "")
148 highlight = "Directory",
152 ---@param opts bufferline.IconFetcherOpts
153 get_element_icon = function(opts)
154 return rmz.ui.icons.ft[opts.filetype]
159 { "nvim-lualine/lualine.nvim",
160 -- TODO: Things that were in vim but are missing
161 -- - git line add/mod/del ar next to branch name rather on right
162 -- - one status line per splits
163 -- - maybe a single one is OK too?
164 -- - I think I want a line stating wihch file is in the split though
165 -- - unix/dos eof markers
166 -- - really I only want to know if it's not unix
167 -- - filetype in text form. It's quite important to glance this quickly
170 vim.g.lualine_laststatus = vim.o.laststatus
171 if vim.fn.argc(-1) > 0 then
172 -- set an empty statusline till lualine loads
173 vim.o.statusline = " "
175 -- hide the statusline on the starter page
180 -- PERF: we don't need this lualine require madness 🤷
181 local lualine_require = require("lualine_require")
182 lualine_require.require = require
184 local icons = rmz.ui.icons
186 vim.o.laststatus = vim.g.lualine_laststatus
191 globalstatus = vim.o.laststatus == 3,
192 disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter", "snacks_dashboard" } },
195 lualine_a = { "mode" },
196 lualine_b = { "branch" },
202 error = icons.diagnostics.Error,
203 warn = icons.diagnostics.Warn,
204 info = icons.diagnostics.Info,
205 hint = icons.diagnostics.Hint,
208 { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
212 Snacks.profiler.status(),
215 function() return " " .. require("dap").status() end,
216 cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
217 color = function() return { fg = Snacks.util.color("Debug") } end,
221 require("lazy.status").updates,
222 cond = require("lazy.status").has_updates,
223 color = function() return { fg = Snacks.util.color("Special") } end,
228 added = icons.git.added,
229 modified = icons.git.modified,
230 removed = icons.git.removed,
233 local gitsigns = vim.b.gitsigns_status_dict
236 added = gitsigns.added,
237 modified = gitsigns.changed,
238 removed = gitsigns.removed,
245 { "progress", separator = " ", padding = { left = 1, right = 0 } },
246 { "location", padding = { left = 0, right = 1 } },
250 return " " .. os.date("%R")
254 inactive_sections = {
256 { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
260 extensions = { "neo-tree", "lazy", "fzf" },
263 local trouble = require("trouble")
264 local symbols = trouble.statusline({
268 filter = { range = true },
269 format = "{kind_icon}{symbol.name:Normal}",
270 hl_group = "lualine_c_normal",
272 table.insert(opts.sections.lualine_c, {
273 symbols and symbols.get,
275 return vim.b.trouble_lualine ~= false and symbols.has()
283 "echasnovski/mini.icons",
287 [".keep"] = { glyph = "", hl = "MiniIconsGrey" },
288 ["devcontainer.json"] = { glyph = "", hl = "MiniIconsAzure" },
291 dotenv = { glyph = "", hl = "MiniIconsYellow" },
295 -- TODO: try without this
296 -- see :h MiniIcons.mock_nvim_web_devicons()
297 package.preload["nvim-web-devicons"] = function()
298 require("mini.icons").mock_nvim_web_devicons()
299 return package.loaded["nvim-web-devicons"]
303 { "MunifTanjim/nui.nvim", lazy = true },
304 { "stevearc/dressing.nvim",
305 enabled = false, -- replaced by snacks.input
309 start_in_insert = false,
314 { "indent-blankline.nvim",
315 enabled = false, -- replaced by snacks.indent
317 { "echasnovski/mini.indentscope",
318 enabled = false, -- replaced by snacks.indent
319 version = false, -- wait till new 0.7.0 release to put it back on semver
321 opts = function (_, opts)
324 animation = require("mini.indentscope").gen_animation.linear({ duration = 10 })
329 { "SmiteshP/nvim-navic",
332 vim.g.navic_silence = true
333 rmz.lsp.on_attach(function(client, buffer)
334 if client.supports_method("textDocument/documentSymbol") then
335 require("nvim-navic").attach(client, buffer)
344 icons = rmz.ui.icons.kinds,
345 lazy_update_context = true,
349 { "nvim-lualine/lualine.nvim",
351 opts = function(_, opts)
352 if not vim.g.trouble_lualine then
353 table.insert(opts.sections.lualine_c, { "navic", color_correction = "dynamic" })