]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/ui.lua
fc905d786ad93cd75ff967c2e47ee05bca6cd3ec
[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 LazyVim.lualine.root_dir(),
114 {
115 "diagnostics",
116 symbols = {
117 error = icons.diagnostics.Error,
118 warn = icons.diagnostics.Warn,
119 info = icons.diagnostics.Info,
120 hint = icons.diagnostics.Hint,
121 },
122 },
123 { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
124 { LazyVim.lualine.pretty_path() },
125 },
126 lualine_x = {
127 Snacks.profiler.status(),
128 -- stylua: ignore
129 {
130 function() return " " .. require("dap").status() end,
131 cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
132 color = function() return { fg = Snacks.util.color("Debug") } end,
133 },
134 -- stylua: ignore
135 {
136 require("lazy.status").updates,
137 cond = require("lazy.status").has_updates,
138 color = function() return { fg = Snacks.util.color("Special") } end,
139 },
140 {
141 "diff",
142 symbols = {
143 added = icons.git.added,
144 modified = icons.git.modified,
145 removed = icons.git.removed,
146 },
147 source = function()
148 local gitsigns = vim.b.gitsigns_status_dict
149 if gitsigns then
150 return {
151 added = gitsigns.added,
152 modified = gitsigns.changed,
153 removed = gitsigns.removed,
154 }
155 end
156 end,
157 },
158 },
159 lualine_y = {
160 { "progress", separator = " ", padding = { left = 1, right = 0 } },
161 { "location", padding = { left = 0, right = 1 } },
162 },
163 lualine_z = {
164 function()
165 return " " .. os.date("%R")
166 end,
167 },
168 },
169 extensions = { "neo-tree", "lazy", "fzf" },
170 }
171
172 local trouble = require("trouble")
173 local symbols = trouble.statusline({
174 mode = "symbols",
175 groups = {},
176 title = false,
177 filter = { range = true },
178 format = "{kind_icon}{symbol.name:Normal}",
179 hl_group = "lualine_c_normal",
180 })
181 table.insert(opts.sections.lualine_c, {
182 symbols and symbols.get,
183 cond = function()
184 return vim.b.trouble_lualine ~= false and symbols.has()
185 end,
186 })
187
188 return opts
189 end,
190 },
191 {
192 "echasnovski/mini.icons",
193 lazy = true,
194 opts = {
195 file = {
196 [".keep"] = { glyph = "󰊢", hl = "MiniIconsGrey" },
197 ["devcontainer.json"] = { glyph = "", hl = "MiniIconsAzure" },
198 },
199 filetype = {
200 dotenv = { glyph = "", hl = "MiniIconsYellow" },
201 },
202 },
203 init = function()
204 -- TODO: try without this
205 -- see :h MiniIcons.mock_nvim_web_devicons()
206 package.preload["nvim-web-devicons"] = function()
207 require("mini.icons").mock_nvim_web_devicons()
208 return package.loaded["nvim-web-devicons"]
209 end
210 end,
211 },
212 { "MunifTanjim/nui.nvim", lazy = true },
213 { "stevearc/dressing.nvim",
214 enabled = false, -- replaced by snacks.input
215 lazy = true,
216 opts = {
217 input = {
218 start_in_insert = false,
219 insert_only = false,
220 },
221 },
222 },
223 { "indent-blankline.nvim",
224 enabled = false, -- replaced by snacks.indent
225 },
226 { "echasnovski/mini.indentscope",
227 enabled = false, -- replaced by snacks.indent
228 version = false, -- wait till new 0.7.0 release to put it back on semver
229 event = "LazyFile",
230 opts = function (_, opts)
231 return {
232 draw = {
233 animation = require("mini.indentscope").gen_animation.linear({ duration = 10 })
234 }
235 }
236 end,
237 },
238 { "SmiteshP/nvim-navic",
239 lazy = true,
240 init = function()
241 vim.g.navic_silence = true
242 LazyVim.lsp.on_attach(function(client, buffer)
243 if client.supports_method("textDocument/documentSymbol") then
244 require("nvim-navic").attach(client, buffer)
245 end
246 end)
247 end,
248 opts = function()
249 return {
250 separator = " ",
251 highlight = true,
252 depth_limit = 5,
253 icons = LazyVim.config.icons.kinds,
254 lazy_update_context = true,
255 }
256 end,
257 },
258 { "nvim-lualine/lualine.nvim",
259 optional = true,
260 opts = function(_, opts)
261 if not vim.g.trouble_lualine then
262 table.insert(opts.sections.lualine_c, { "navic", color_correction = "dynamic" })
263 end
264 end,
265 },
266 }