From 01164c6d8bcfd635ff9c08aaff13d5e7112b2b2a Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Apr 2025 11:38:42 +0100 Subject: [PATCH] More plugin configuration --- lua/autocmd.lua | 9 +++ lua/keymap.lua | 19 ++++-- lua/plugins/codecompanion.lua | 2 + lua/plugins/copilot.lua | 2 +- lua/plugins/dashboard.lua | 10 ---- lua/plugins/edgy.lua | 101 ++++++++++++++++++++++++++++++++ lua/plugins/mini.lua | 15 ----- lua/plugins/neo-tree.lua | 19 ++++-- lua/plugins/neotest.lua | 21 +++++++ lua/plugins/oil.lua | 1 + lua/plugins/render_markdown.lua | 10 ++++ lua/plugins/snacks.lua | 24 ++++++++ lua/plugins/wakatime.lua | 4 ++ lua/plugins/yanky.lua | 9 +++ 14 files changed, 211 insertions(+), 35 deletions(-) delete mode 100644 lua/plugins/dashboard.lua create mode 100644 lua/plugins/edgy.lua create mode 100644 lua/plugins/neotest.lua create mode 100644 lua/plugins/render_markdown.lua create mode 100644 lua/plugins/snacks.lua create mode 100644 lua/plugins/wakatime.lua create mode 100644 lua/plugins/yanky.lua diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 20fec48..43710ec 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -32,4 +32,13 @@ vim.api.nvim_create_autocmd('TextChanged', { command = 'silent! wa', -- Save all files when text is changed }) +vim.api.nvim_create_autocmd("User", { + pattern = "OilActionsPost", + callback = function(event) + if event.data.actions.type == "move" then + Snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url) + end + end, +}) + require('helpers').edit_cf('a', '/lua/autocmd.lua') diff --git a/lua/keymap.lua b/lua/keymap.lua index 3900f5d..eab1f20 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -35,7 +35,7 @@ vim.keymap.set('n', '', 'J', { desc = 'Move window to the lower' }) vim.keymap.set('n', '', 'K', { desc = 'Move window to the upper' }) -- Overriding CTRL mappings because some of them are stupid -vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Git blame', { desc = 'Git blame' }) +vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Git blame', { desc = 'Git blame' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope lsp_document_symbols', { desc = 'Show symbols in current document' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope lsp_workspace_symbols', { desc = 'Show symbols in workspace' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope oldfiles', { desc = 'Show recently opened files' }) @@ -58,8 +58,17 @@ vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', function() end, { desc = 'Search within the whole project' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope quickfix', { desc = 'Show quickfix list' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope quickfixhistory', { desc = 'Show quickfix history' }) -vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'CodeCompanionActions', { desc = 'Open AI Actions' }) -vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'CodeCompanionChat', { desc = 'Open AI Chat' }) +vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'CodeCompanionChat Toggle', { desc = 'Open AI Actions' }) +vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'CodeCompanionActions', { desc = 'Open AI Actions' }) +vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', function() + require('snacks').scratch() +end, { desc = 'Open scratchpad' }) +vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', function() + require('snacks').scratch.select() +end, { desc = 'Open scratchpad buffers' }) +vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', function() + require('snacks').terminal.toggle() +end, { desc = 'Open terminal' }) -- Editing helpers vim.keymap.set('i', '', 'o', { desc = 'Add line below' }) @@ -78,10 +87,10 @@ vim.keymap.set('n', 'gaf', 'Git add %', { desc = 'Git add curre vim.keymap.set('n', 'gaa', 'Git add --all', { desc = 'Git add all unstaged changes' }) vim.keymap.set('n', 'gap', 'Git add --patch --all', { desc = 'Git add all unstaged changes interactively' }) vim.keymap.set('n', 'gb', 'Git blame', { desc = 'Git blame' }) -vim.keymap.set('n', 'gc', 'Git commit', { desc = 'Git commit' }) +vim.keymap.set('n', 'gcm', 'Git commit', { desc = 'Git commit' }) vim.keymap.set('n', 'gp', 'Git push', { desc = 'Git push' }) vim.keymap.set('n', 'gup', 'Git pull --rebase', { desc = 'Git pull --rebase' }) -vim.keymap.set('n', 'gs', 'Git status', { desc = 'Git status' }) +vim.keymap.set('n', 'gsb', 'Git status', { desc = 'Git status' }) vim.keymap.set('n', 'gd', 'Git diff', { desc = 'Git diff' }) vim.keymap.set('n', 'gl', 'Git log', { desc = 'Git log' }) vim.keymap.set('n', 'gun', 'Git reset -- %', { desc = 'Git unstage file' }) diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua index a0d17ae..f2df9c9 100644 --- a/lua/plugins/codecompanion.lua +++ b/lua/plugins/codecompanion.lua @@ -1,3 +1,5 @@ +require('helpers').edit_cf('pa', '/lua/plugins/avante.lua') + return { 'olimorris/codecompanion.nvim', opts = {}, diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua index 8e490ed..496abd0 100644 --- a/lua/plugins/copilot.lua +++ b/lua/plugins/copilot.lua @@ -1,3 +1,3 @@ return { - 'github/copilot.vim', + 'zbirenbaum/copilot.lua', } diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua deleted file mode 100644 index 857904f..0000000 --- a/lua/plugins/dashboard.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - 'nvimdev/dashboard-nvim', - event = 'VimEnter', - config = function() - require('dashboard').setup { - -- config - } - end, - dependencies = { {'nvim-tree/nvim-web-devicons'}} -} diff --git a/lua/plugins/edgy.lua b/lua/plugins/edgy.lua new file mode 100644 index 0000000..fa1bf3e --- /dev/null +++ b/lua/plugins/edgy.lua @@ -0,0 +1,101 @@ +return { + "folke/edgy.nvim", + event = "VeryLazy", + init = function() + vim.opt.laststatus = 3 + vim.opt.splitkeep = "screen" + end, + opts = { + bottom = { + -- toggleterm / lazyterm at the bottom with a height of 40% of the screen + { + ft = "toggleterm", + size = { height = 0.4 }, + -- exclude floating windows + filter = function(buf, win) + return vim.api.nvim_win_get_config(win).relative == "" + end, + }, + { + ft = "lazyterm", + title = "LazyTerm", + size = { height = 0.4 }, + filter = function(buf) + return not vim.b[buf].lazyterm_cmd + end, + }, + { + ft = "snack_terminal", + size = { height = 0.4 }, + title = "%{b:snacks_terminal.id}: %{b:term_title}", + filter = function(_buf, win) + return vim.w[win].snacks_win + and vim.w[win].snacks_win.position == pos + and vim.w[win].snacks_win.relative == "editor" + and not vim.w[win].trouble_preview + end, + }, + "Trouble", + { ft = "qf", title = "QuickFix" }, + { + ft = "help", + size = { height = 20 }, + -- only show help buffers + filter = function(buf) + return vim.bo[buf].buftype == "help" + end, + }, + { ft = "spectre_panel", size = { height = 0.4 } }, + }, + left = { + -- Neo-tree filesystem always takes half the screen height + { + title = "Neo-Tree", + ft = "neo-tree", + filter = function(buf) + return vim.b[buf].neo_tree_source == "filesystem" + end, + size = { height = 0.5 }, + }, + { + title = "Neo-Tree Git", + ft = "neo-tree", + filter = function(buf) + return vim.b[buf].neo_tree_source == "git_status" + end, + pinned = true, + collapsed = true, -- show window as closed/collapsed on start + open = "Neotree position=right git_status", + }, + { + title = "Neo-Tree Buffers", + ft = "neo-tree", + filter = function(buf) + return vim.b[buf].neo_tree_source == "buffers" + end, + pinned = true, + collapsed = true, -- show window as closed/collapsed on start + open = "Neotree position=top buffers", + }, + { + title = function() + local buf_name = vim.api.nvim_buf_get_name(0) or "[No Name]" + return vim.fn.fnamemodify(buf_name, ":t") + end, + ft = "Outline", + pinned = true, + open = "SymbolsOutlineOpen", + + }, + -- any other neo-tree windows + "neo-tree", + }, + right = { + { + title = 'Code Companion', + ft = 'codecompanion', + size = { width = 0.3 }, + } + } + }, +} diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 4438b30..9d94694 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -31,21 +31,6 @@ return { require('mini.splitjoin').setup() - local animate = require 'mini.animate' - animate.setup { - cursor = { - enable = false, - }, - resize = { - enable = true, - timing = animate.gen_timing.linear { duration = 50, unit = 'total' }, - }, - scroll = { - enable = true, - timing = animate.gen_timing.linear { duration = 50, unit = 'total' }, - }, - } - require('mini.map').setup() -- Simple and easy statusline. diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index fc19f28..ba019e0 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -13,8 +13,19 @@ return { keys = { { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, - opts = { - filesystem = { + + opts = function(_, opts) + local function on_move(data) + Snacks.rename.on_rename_file(data.source, data.destination) + end + local events = require("neo-tree.events") + opts.event_handlers = opts.event_handlers or {} + vim.list_extend(opts.event_handlers, { + { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_RENAMED, handler = on_move }, + }) + + opts.filesystem = { window = { mappings = { ['\\'] = 'close_window', @@ -23,6 +34,6 @@ return { filtered_items = { hide_dotfiles = false, }, - }, - }, + } + end, } diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua new file mode 100644 index 0000000..c89f8e7 --- /dev/null +++ b/lua/plugins/neotest.lua @@ -0,0 +1,21 @@ +return { + "nvim-neotest/neotest", + lazy = true, + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", + -- Adapters + 'V13Axel/neotest-pest', + -- "olimorris/neotest-phpunit", + }, + config = function() + require('neotest').setup({ + adapters = { + require('neotest-pest'), + -- require('neotest-phpunit'), + } + }) + end +} diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index db7f476..b77a1ab 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -1,6 +1,7 @@ -- Filesystem manager vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) + return { 'stevearc/oil.nvim', ---@module 'oil' diff --git a/lua/plugins/render_markdown.lua b/lua/plugins/render_markdown.lua new file mode 100644 index 0000000..6b7e546 --- /dev/null +++ b/lua/plugins/render_markdown.lua @@ -0,0 +1,10 @@ +return { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, + ft = { 'markdown', 'codecompanion' }, +} diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua new file mode 100644 index 0000000..e86d389 --- /dev/null +++ b/lua/plugins/snacks.lua @@ -0,0 +1,24 @@ +return { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + bigfile = { enabled = true }, + dashboard = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + notifier = { enabled = true }, + quickfile = { enabled = true }, + scope = { enabled = true }, + -- scroll = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + terminal = { enabled = true }, + scratch = { enabled = true }, + rename = { enabled = true }, + }, +} diff --git a/lua/plugins/wakatime.lua b/lua/plugins/wakatime.lua new file mode 100644 index 0000000..17861f6 --- /dev/null +++ b/lua/plugins/wakatime.lua @@ -0,0 +1,4 @@ +return { + 'wakatime/vim-wakatime', + lazy = false +} diff --git a/lua/plugins/yanky.lua b/lua/plugins/yanky.lua new file mode 100644 index 0000000..44cf837 --- /dev/null +++ b/lua/plugins/yanky.lua @@ -0,0 +1,9 @@ +-- For when I'm ready +return { + -- "gbprod/yanky.nvim", + -- opts = { + -- -- your configuration comes here + -- -- or leave it empty to use the default settings + -- -- refer to the configuration section below + -- }, +}