]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/ui.lua
f317aaf44a3e5ce6e575a7a251d1f1245ded3417
[dotfiles.git] / nvim / lua / plugins / ui.lua
1 ---@type LazySpec
2 return {
3 { 'echasnovski/mini.clue',
4 -- NOTE: this caused some issue with unterminated mappings, i.e. <L>gc when there
5 -- is also <L>gcc. It would simply terminate early and not allow for next mapping.
6 version = '*',
7 opts = {
8 triggers = {
9 { mode = 'n', keys = '<Leader>' },
10 { mode = 'x', keys = '<Leader>' },
11 -- `g` key
12 { mode = 'n', keys = 'g' },
13 { mode = 'x', keys = 'g' },
14 -- Marks
15 { mode = 'n', keys = "'" },
16 { mode = 'n', keys = '`' },
17 { mode = 'x', keys = "'" },
18 { mode = 'x', keys = '`' },
19 -- Window commands
20 { mode = 'n', keys = '<C-w>' },
21 -- `z` key
22 { mode = 'n', keys = 'z' },
23 { mode = 'x', keys = 'z' },
24 },
25 clues = {
26 { mode = 'n', keys = '<Leader>b', desc = '+Buffers' },
27 { mode = 'n', keys = '<Leader>c', desc = '+LSP' },
28 },
29 },
30 },
31 { "akinsho/bufferline.nvim",
32 event = "VeryLazy",
33 keys = {
34 { "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle Pin" },
35 { "<leader>bP", "<Cmd>BufferLineGroupClose ungrouped<CR>", desc = "Delete Non-Pinned Buffers" },
36 { "<leader>br", "<Cmd>BufferLineCloseRight<CR>", desc = "Delete Buffers to the Right" },
37 { "<leader>bl", "<Cmd>BufferLineCloseLeft<CR>", desc = "Delete Buffers to the Left" },
38 { "<S-h>", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
39 { "<S-l>", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
40 { "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
41 { "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
42 { "[B", "<cmd>BufferLineMovePrev<cr>", desc = "Move buffer prev" },
43 { "]B", "<cmd>BufferLineMoveNext<cr>", desc = "Move buffer next" },
44 },
45 ---@type BufferlineConfig
46 opts = {
47 options = {
48 close_command = function(n) Snacks.bufdelete(n) end,
49 right_mouse_command = function(n) Snacks.bufdelete(n) end,
50 diagnostics = "nvim_lsp",
51 always_show_bufferline = false,
52 diagnostics_indicator = function(_, _, diag)
53 local icons = LazyVim.config.icons.diagnostics
54 local ret = (diag.error and icons.Error .. diag.error .. " " or "")
55 .. (diag.warning and icons.Warn .. diag.warning or "")
56 return vim.trim(ret)
57 end,
58 offsets = {
59 {
60 filetype = "man",
61 text = "Man page",
62 highlight = "Directory",
63 text_align = "left",
64 },
65 },
66 ---@param opts bufferline.IconFetcherOpts
67 get_element_icon = function(opts)
68 return LazyVim.config.icons.ft[opts.filetype]
69 end,
70 },
71 },
72 },
73 { "nvim-lualine/lualine.nvim",
74 -- TODO: Things that were in vim but are missing
75 -- - git line add/mod/del ar next to branch name rather on right
76 -- - one status line per splits
77 -- - maybe a single one is OK too?
78 -- - I think I want a line stating wihch file is in the split though
79 -- - unix/dos eof markers
80 -- - really I only want to know if it's not unix
81 -- - filetype in text form. It's quite important to glance this quickly
82 event = "VeryLazy",
83 init = function()
84 vim.g.lualine_laststatus = vim.o.laststatus
85 if vim.fn.argc(-1) > 0 then
86 -- set an empty statusline till lualine loads
87 vim.o.statusline = " "
88 else
89 -- hide the statusline on the starter page
90 vim.o.laststatus = 0
91 end
92 end,
93 opts = function()
94 -- PERF: we don't need this lualine require madness 🤷
95 local lualine_require = require("lualine_require")
96 lualine_require.require = require
97
98 local icons = LazyVim.config.icons
99
100 vim.o.laststatus = vim.g.lualine_laststatus
101
102 local opts = {
103 options = {
104 theme = "auto",
105 globalstatus = vim.o.laststatus == 3,
106 disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter", "snacks_dashboard" } },
107 },
108 sections = {
109 lualine_a = { "mode" },
110 lualine_b = { "branch" },
111
112 lualine_c = {
113 {
114 "diagnostics",
115 symbols = {
116 error = icons.diagnostics.Error,
117 warn = icons.diagnostics.Warn,
118 info = icons.diagnostics.Info,
119 hint = icons.diagnostics.Hint,
120 },
121 },
122 { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
123 { LazyVim.lualine.pretty_path() },
124 },
125 lualine_x = {
126 Snacks.profiler.status(),
127 -- stylua: ignore
128 {
129 function() return " " .. require("dap").status() end,
130 cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
131 color = function() return { fg = Snacks.util.color("Debug") } end,
132 },
133 -- stylua: ignore
134 {
135 require("lazy.status").updates,
136 cond = require("lazy.status").has_updates,
137 color = function() return { fg = Snacks.util.color("Special") } end,
138 },
139 {
140 "diff",
141 symbols = {
142 added = icons.git.added,
143 modified = icons.git.modified,
144 removed = icons.git.removed,
145 },
146 source = function()
147 local gitsigns = vim.b.gitsigns_status_dict
148 if gitsigns then
149 return {
150 added = gitsigns.added,
151 modified = gitsigns.changed,
152 removed = gitsigns.removed,
153 }
154 end
155 end,
156 },
157 },
158 lualine_y = {
159 { "progress", separator = " ", padding = { left = 1, right = 0 } },
160 { "location", padding = { left = 0, right = 1 } },
161 },
162 lualine_z = {
163 function()
164 return " " .. os.date("%R")
165 end,
166 },
167 },
168 extensions = { "neo-tree", "lazy", "fzf" },
169 }
170
171 local trouble = require("trouble")
172 local symbols = trouble.statusline({
173 mode = "symbols",
174 groups = {},
175 title = false,
176 filter = { range = true },
177 format = "{kind_icon}{symbol.name:Normal}",
178 hl_group = "lualine_c_normal",
179 })
180 table.insert(opts.sections.lualine_c, {
181 symbols and symbols.get,
182 cond = function()
183 return vim.b.trouble_lualine ~= false and symbols.has()
184 end,
185 })
186
187 return opts
188 end,
189 },
190 {
191 "echasnovski/mini.icons",
192 lazy = true,
193 opts = {
194 file = {
195 [".keep"] = { glyph = "󰊢", hl = "MiniIconsGrey" },
196 ["devcontainer.json"] = { glyph = "", hl = "MiniIconsAzure" },
197 },
198 filetype = {
199 dotenv = { glyph = "", hl = "MiniIconsYellow" },
200 },
201 },
202 init = function()
203 -- TODO: try without this
204 -- see :h MiniIcons.mock_nvim_web_devicons()
205 package.preload["nvim-web-devicons"] = function()
206 require("mini.icons").mock_nvim_web_devicons()
207 return package.loaded["nvim-web-devicons"]
208 end
209 end,
210 },
211 { "MunifTanjim/nui.nvim", lazy = true },
212 { "stevearc/dressing.nvim",
213 enabled = false, -- replaced by snacks.input
214 lazy = true,
215 opts = {
216 input = {
217 start_in_insert = false,
218 insert_only = false,
219 },
220 },
221 },
222 { "indent-blankline.nvim",
223 enabled = false, -- replaced by snacks.indent
224 },
225 { "echasnovski/mini.indentscope",
226 enabled = false, -- replaced by snacks.indent
227 version = false, -- wait till new 0.7.0 release to put it back on semver
228 event = "LazyFile",
229 opts = function (_, opts)
230 return {
231 draw = {
232 animation = require("mini.indentscope").gen_animation.linear({ duration = 10 })
233 }
234 }
235 end,
236 },
237 { "SmiteshP/nvim-navic",
238 lazy = true,
239 init = function()
240 vim.g.navic_silence = true
241 LazyVim.lsp.on_attach(function(client, buffer)
242 if client.supports_method("textDocument/documentSymbol") then
243 require("nvim-navic").attach(client, buffer)
244 end
245 end)
246 end,
247 opts = function()
248 return {
249 separator = " ",
250 highlight = true,
251 depth_limit = 5,
252 icons = LazyVim.config.icons.kinds,
253 lazy_update_context = true,
254 }
255 end,
256 },
257 { "nvim-lualine/lualine.nvim",
258 optional = true,
259 opts = function(_, opts)
260 if not vim.g.trouble_lualine then
261 table.insert(opts.sections.lualine_c, { "navic", color_correction = "dynamic" })
262 end
263 end,
264 },
265 }