]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/editor.lua
zsh: rnr function to add a task to read-and-review urls
[dotfiles.git] / nvim / lua / plugins / editor.lua
1 ---@type LazySpec
2 return {
3 { "stevearc/oil.nvim",
4 opts = {
5 keymaps = {
6 ["g?"] = "actions.show_help",
7 ["<CR>"] = "actions.select",
8 ["<C-s>"] = "actions.select_vsplit",
9 ["<C-h>"] = false, -- used to be actions.select_split
10 ["<C-t>"] = "actions.select_tab",
11 ["<C-p>"] = "actions.preview",
12 ["<C-c>"] = "actions.close",
13 ["<C-l>"] = false, -- used to be actions.refresh
14 ["-"] = "actions.parent",
15 ["_"] = "actions.open_cwd",
16 ["`"] = "actions.cd",
17 ["~"] = "actions.tcd",
18 ["gs"] = "actions.change_sort",
19 ["gx"] = "actions.open_external",
20 ["g."] = "actions.toggle_hidden",
21 ["g\\"] = "actions.toggle_trash",
22 },
23 },
24 dependencies = {"nvim-tree/nvim-web-devicons"},
25 },
26 { "folke/trouble.nvim",
27 cmd = { "Trouble" },
28 opts = {
29 modes = {
30 lsp = {
31 win = { position = "right" },
32 },
33 },
34 },
35 keys = {
36 { "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)" },
37 { "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)" },
38 { "<leader>cs", "<cmd>Trouble symbols toggle<cr>", desc = "Symbols (Trouble)" },
39 { "<leader>cS", "<cmd>Trouble lsp toggle<cr>", desc = "LSP references/definitions/... (Trouble)" },
40 { "<leader>xL", "<cmd>Trouble loclist toggle<cr>", desc = "Location List (Trouble)" },
41 { "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", desc = "Quickfix List (Trouble)" },
42 {
43 "[q",
44 function()
45 if require("trouble").is_open() then
46 require("trouble").prev({ skip_groups = true, jump = true })
47 else
48 local ok, err = pcall(vim.cmd.cprev)
49 if not ok then
50 vim.notify(err, vim.log.levels.ERROR)
51 end
52 end
53 end,
54 desc = "Previous Trouble/Quickfix Item",
55 },
56 {
57 "]q",
58 function()
59 if require("trouble").is_open() then
60 require("trouble").next({ skip_groups = true, jump = true })
61 else
62 local ok, err = pcall(vim.cmd.cnext)
63 if not ok then
64 vim.notify(err, vim.log.levels.ERROR)
65 end
66 end
67 end,
68 desc = "Next Trouble/Quickfix Item",
69 },
70 },
71 },
72 { "folke/todo-comments.nvim",
73 -- Finds and lists all of the TODO, HACK, BUG, etc comment
74 -- in your project and loads them into a browsable list.
75 cmd = { "TodoTrouble"},
76 event = { "BufReadPost", "BufNewFile", "BufWritePre" },
77 -- stylua: ignore
78 keys = {
79 { "]t", function() require("todo-comments").jump_next() end, desc = "Next Todo Comment" },
80 { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous Todo Comment" },
81 { "<leader>xt", "<cmd>Trouble todo toggle<cr>", desc = "Todo (Trouble)" },
82 { "<leader>xT", "<cmd>Trouble todo toggle filter = {tag = {TODO,FIX,FIXME}}<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
83 },
84 opts = {}
85 },
86 { "nvim-mini/mini.hipatterns", -- highlight hex colours and other matched words
87 event = { "BufReadPost", "BufNewFile", "BufWritePre" },
88 opts = function()
89 local hi = require("mini.hipatterns")
90 return {
91 highlighters = {
92 hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
93 },
94 }
95 end,
96 },
97 { "nvim-mini/mini.operators", -- text edit operators
98 opts = {},
99 },
100 { "folke/flash.nvim",
101 -- Flash enhances the built-in search functionality by showing labels
102 -- at the end of each match, letting you quickly jump to a specific
103 -- location.
104 event = "VeryLazy",
105 vscode = true,
106 ---@type Flash.Config
107 opts = {},
108 -- stylua: ignore
109 keys = {
110 { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
111 { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
112 { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
113 { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
114 { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
115 },
116 },
117 { "lewis6991/gitsigns.nvim",
118 -- git signs highlights text that has changed since the list
119 -- git commit, and also lets you interactively stage & unstage
120 -- hunks in a commit.
121 event = { "BufReadPost", "BufNewFile", "BufWritePre" },
122 opts = {
123 signs = {
124 add = { text = "▎" },
125 change = { text = "▎" },
126 delete = { text = "" },
127 topdelete = { text = "" },
128 changedelete = { text = "▎" },
129 untracked = { text = "▎" },
130 },
131 signs_staged = {
132 add = { text = "▎" },
133 change = { text = "▎" },
134 delete = { text = "" },
135 topdelete = { text = "" },
136 changedelete = { text = "▎" },
137 },
138 on_attach = function(buffer)
139 local gs = package.loaded.gitsigns
140
141 local function map(mode, l, r, desc)
142 vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
143 end
144
145 -- stylua: ignore start
146 map("n", "]h", function()
147 if vim.wo.diff then
148 vim.cmd.normal({ "]c", bang = true })
149 else
150 gs.nav_hunk("next")
151 end
152 end, "Next Hunk")
153 map("n", "[h", function()
154 if vim.wo.diff then
155 vim.cmd.normal({ "[c", bang = true })
156 else
157 gs.nav_hunk("prev")
158 end
159 end, "Prev Hunk")
160 map("n", "]H", function() gs.nav_hunk("last") end, "Last Hunk")
161 map("n", "[H", function() gs.nav_hunk("first") end, "First Hunk")
162 map({ "n", "v" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
163 map({ "n", "v" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
164 map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
165 map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
166 map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
167 map("n", "<leader>ghp", gs.preview_hunk_inline, "Preview Hunk Inline")
168 map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
169 map("n", "<leader>ghB", function() gs.blame() end, "Blame Buffer")
170 map("n", "<leader>ghd", gs.diffthis, "Diff This")
171 map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
172 map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk")
173 Snacks.toggle({
174 name = "Git Signs",
175 get = function()
176 return require("gitsigns.config").config.signcolumn
177 end,
178 set = function(state)
179 require("gitsigns").toggle_signs(state)
180 end,
181 }):map("<leader>uG")
182 end,
183 },
184 },
185
186 -- TODO: currently unused plugins, check and enable/remove
187 { "MagicDuck/grug-far.nvim", enabled = false,
188 -- search/replace in multiple files
189 opts = { headerMaxWidth = 80 },
190 cmd = "GrugFar",
191 keys = {
192 {
193 "<leader>sr",
194 function()
195 local grug = require("grug-far")
196 local ext = vim.bo.buftype == "" and vim.fn.expand("%:e")
197 grug.open({
198 transient = true,
199 prefills = {
200 filesFilter = ext and ext ~= "" and "*." .. ext or nil,
201 },
202 })
203 end,
204 mode = { "n", "v" },
205 desc = "Search and Replace",
206 },
207 },
208 },
209 }