X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/c4b190f4d9decd70fb423e2b6263c1f7faf13259..2553a453d0845bedcc8a1fd219913e25d7d443f9:/nvim/lua/plugins/editor.lua diff --git a/nvim/lua/plugins/editor.lua b/nvim/lua/plugins/editor.lua index 3ee014b..7938053 100644 --- a/nvim/lua/plugins/editor.lua +++ b/nvim/lua/plugins/editor.lua @@ -1,97 +1,6 @@ ----@type LazyPluginSpec +---@type LazySpec return { - { - "nvim-telescope/telescope.nvim", - keys = { - { "fF", LazyVim.pick("files", { cwd = false }), desc = "Find Files (cwd)" }, - -- from lazyvim - { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, - { "/", LazyVim.pick("live_grep"), desc = "Grep (root dir)" }, - { ":", "Telescope command_history", desc = "Command History" }, - { "", LazyVim.pick("files"), desc = "Find Files (root dir)" }, - { "", false }, - -- find - { "fb", "Telescope buffers sort_lastused=true", desc = "Buffers" }, - -- { "ff", LazyVim.pick("files"), desc = "Find Files (root dir)" }, - { "ff", false }, -- fswitch - { "fF", LazyVim.pick("files", { cwd = false }), desc = "Find Files (cwd)" }, - { "fr", "Telescope oldfiles", desc = "Recent" }, - { "fR", LazyVim.pick("oldfiles", { cwd = vim.loop.cwd() }), desc = "Recent (cwd)" }, - -- git - -- { "gc", "Telescope git_commits", desc = "commits" }, - { "gc", false }, - -- { "gs", "Telescope git_status", desc = "status" }, - { "gs", false }, - -- search - { "sa", "Telescope autocommands", desc = "Auto Commands" }, - { "sb", "Telescope current_buffer_fuzzy_find", desc = "Buffer" }, - { "sc", "Telescope command_history", desc = "Command History" }, - { "sC", "Telescope commands", desc = "Commands" }, - { "sd", "Telescope diagnostics bufnr=0", desc = "Document diagnostics" }, - { "sD", "Telescope diagnostics", desc = "Workspace diagnostics" }, - { "sg", LazyVim.pick("live_grep"), desc = "Grep (root dir)" }, - { "sG", LazyVim.pick("live_grep", { cwd = false }), desc = "Grep (cwd)" }, - { "sh", "Telescope help_tags", desc = "Help Pages" }, - { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, - { "sk", "Telescope keymaps", desc = "Key Maps" }, - { "sM", "Telescope man_pages", desc = "Man Pages" }, - { "sm", "Telescope marks", desc = "Jump to Mark" }, - { "so", "Telescope vim_options", desc = "Options" }, - { "sR", "Telescope resume", desc = "Resume" }, - { "sw", LazyVim.pick("grep_string"), desc = "Word (root dir)" }, - { "sW", LazyVim.pick("grep_string", { cwd = false }), desc = "Word (cwd)" }, - { "uC", LazyVim.pick("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, - -- { - -- "ss", - -- LazyVim.pick("lsp_document_symbols", { - -- symbols = { - -- "Class", - -- "Function", - -- "Method", - -- "Constructor", - -- "Interface", - -- "Module", - -- "Struct", - -- "Trait", - -- "Field", - -- "Property", - -- }, - -- }), - -- desc = "Goto Symbol", - -- }, - { "ss", false }, -- use for snippets below - { - "sS", - LazyVim.pick("lsp_dynamic_workspace_symbols", { - symbols = { - "Class", - "Function", - "Method", - "Constructor", - "Interface", - "Module", - "Struct", - "Trait", - "Field", - "Property", - }, - }), - desc = "Goto Symbol (Workspace)", - }, - }, - }, - { - "benfowler/telescope-luasnip.nvim", - dependencies = { - "telescope.nvim", - }, - config = function() - require("telescope").load_extension("luasnip") - end, - keys = { { "ss", "Telescope luasnip", desc = "Snippets" } }, - }, - { - "stevearc/oil.nvim", + { "stevearc/oil.nvim", opts = { keymaps = { ["g?"] = "actions.show_help", @@ -114,28 +23,248 @@ return { }, dependencies = {"nvim-tree/nvim-web-devicons"}, }, - { - "neo-tree.nvim", - enabled = false, - lazy = false, + { "folke/trouble.nvim", + cmd = { "Trouble" }, opts = { - filesystem = { - -- TODO: review these - bind_to_cwd = false, - follow_current_file = { - enabled = false, + modes = { + lsp = { + win = { position = "right" }, }, }, }, - keys = function() - local NeoTree = function(args) - return function() - require("neo-tree.command").execute(args) + keys = { + { "xx", "Trouble diagnostics toggle", desc = "Diagnostics (Trouble)" }, + { "xX", "Trouble diagnostics toggle filter.buf=0", desc = "Buffer Diagnostics (Trouble)" }, + { "cs", "Trouble symbols toggle", desc = "Symbols (Trouble)" }, + { "cS", "Trouble lsp toggle", desc = "LSP references/definitions/... (Trouble)" }, + { "xL", "Trouble loclist toggle", desc = "Location List (Trouble)" }, + { "xQ", "Trouble qflist toggle", desc = "Quickfix List (Trouble)" }, + { + "[q", + function() + if require("trouble").is_open() then + require("trouble").prev({ skip_groups = true, jump = true }) + else + local ok, err = pcall(vim.cmd.cprev) + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = "Previous Trouble/Quickfix Item", + }, + { + "]q", + function() + if require("trouble").is_open() then + require("trouble").next({ skip_groups = true, jump = true }) + else + local ok, err = pcall(vim.cmd.cnext) + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = "Next Trouble/Quickfix Item", + }, + }, + }, + { "folke/todo-comments.nvim", + -- Finds and lists all of the TODO, HACK, BUG, etc comment + -- in your project and loads them into a browsable list. + cmd = { "TodoTrouble", "TodoTelescope" }, + event = "LazyFile", + -- stylua: ignore + keys = { + { "]t", function() require("todo-comments").jump_next() end, desc = "Next Todo Comment" }, + { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous Todo Comment" }, + { "xt", "Trouble todo toggle", desc = "Todo (Trouble)" }, + { "xT", "Trouble todo toggle filter = {tag = {TODO,FIX,FIXME}}", desc = "Todo/Fix/Fixme (Trouble)" }, + { "st", "TodoTelescope", desc = "Todo" }, + { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, + }, + opts = {} + }, + { "folke/flash.nvim", + -- Flash enhances the built-in search functionality by showing labels + -- at the end of each match, letting you quickly jump to a specific + -- location. + event = "VeryLazy", + vscode = true, + ---@type Flash.Config + opts = {}, + -- stylua: ignore + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + }, + }, + { "lewis6991/gitsigns.nvim", + -- git signs highlights text that has changed since the list + -- git commit, and also lets you interactively stage & unstage + -- hunks in a commit. + event = "LazyFile", + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + signs_staged = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + }, + on_attach = function(buffer) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) end + + -- stylua: ignore start + map("n", "]h", function() + if vim.wo.diff then + vim.cmd.normal({ "]c", bang = true }) + else + gs.nav_hunk("next") + end + end, "Next Hunk") + map("n", "[h", function() + if vim.wo.diff then + vim.cmd.normal({ "[c", bang = true }) + else + gs.nav_hunk("prev") + end + end, "Prev Hunk") + map("n", "]H", function() gs.nav_hunk("last") end, "Last Hunk") + map("n", "[H", function() gs.nav_hunk("first") end, "First Hunk") + map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") + map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") + map("n", "ghS", gs.stage_buffer, "Stage Buffer") + map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") + map("n", "ghR", gs.reset_buffer, "Reset Buffer") + map("n", "ghp", gs.preview_hunk_inline, "Preview Hunk Inline") + map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") + map("n", "ghB", function() gs.blame() end, "Blame Buffer") + map("n", "ghd", gs.diffthis, "Diff This") + map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") + Snacks.toggle({ + name = "Git Signs", + get = function() + return require("gitsigns.config").config.signcolumn + end, + set = function(state) + require("gitsigns").toggle_signs(state) + end, + }):map("uG") + end, + }, + }, + + -- TODO: currently unused plugins, check and enable/remove + { "MagicDuck/grug-far.nvim", enabled = false, + -- search/replace in multiple files + opts = { headerMaxWidth = 80 }, + cmd = "GrugFar", + keys = { + { + "sr", + function() + local grug = require("grug-far") + local ext = vim.bo.buftype == "" and vim.fn.expand("%:e") + grug.open({ + transient = true, + prefills = { + filesFilter = ext and ext ~= "" and "*." .. ext or nil, + }, + }) + end, + mode = { "n", "v" }, + desc = "Search and Replace", + }, + }, + }, + { "folke/which-key.nvim", + -- which-key helps you remember key bindings by showing a popup + -- with the active keybindings of the command you started typing. + -- TODO: replace with mini.clue + event = "VeryLazy", + opts_extend = { "spec" }, + opts = { + preset = "helix", + defaults = {}, + spec = { + { + mode = { "n", "v" }, + { "", group = "tabs" }, + { "c", group = "code" }, + { "d", group = "debug" }, + { "dp", group = "profiler" }, + { "f", group = "file/find" }, + { "g", group = "git" }, + { "gh", group = "hunks" }, + { "q", group = "quit/session" }, + { "s", group = "search" }, + { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, + { "x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } }, + { "[", group = "prev" }, + { "]", group = "next" }, + { "g", group = "goto" }, + { "gs", group = "surround" }, + { "z", group = "fold" }, + { + "b", + group = "buffer", + expand = function() + return require("which-key.extras").expand.buf() + end, + }, + { + "w", + group = "windows", + proxy = "", + expand = function() + return require("which-key.extras").expand.win() + end, + }, + -- better descriptions + { "gx", desc = "Open with system app" }, + }, + }, + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Keymaps (which-key)", + }, + { + "", + function() + require("which-key").show({ keys = "", loop = true }) + end, + desc = "Window Hydra Mode (which-key)", + }, + }, + config = function(_, opts) + local wk = require("which-key") + wk.setup(opts) + if not vim.tbl_isempty(opts.defaults) then + LazyVim.warn("which-key: opts.defaults is deprecated. Please use opts.spec instead.") + wk.register(opts.defaults) end - return { - { "fe", NeoTree({ toggle = true, dir = vim.loop.cwd() }) }, - } end, }, }