From 4ed51b3acb84e70ebf4979e508c7856f0f402f9e Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Fri, 15 May 2026 13:05:05 +0200 Subject: [PATCH] Adding my custom plugins --- lua/custom/plugins/beacon.lua | 9 +++ lua/custom/plugins/custom-init.lua | 52 +++++++++++++++++ lua/custom/plugins/harpoon.lua | 81 ++++++++++++++++++++++++++ lua/custom/plugins/local-highlight.lua | 18 ++++++ lua/custom/plugins/search-replace.lua | 30 ++++++++++ 5 files changed, 190 insertions(+) create mode 100644 lua/custom/plugins/beacon.lua create mode 100644 lua/custom/plugins/custom-init.lua create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/local-highlight.lua create mode 100644 lua/custom/plugins/search-replace.lua diff --git a/lua/custom/plugins/beacon.lua b/lua/custom/plugins/beacon.lua new file mode 100644 index 00000000..24b992b6 --- /dev/null +++ b/lua/custom/plugins/beacon.lua @@ -0,0 +1,9 @@ +return { + "danilamihailov/beacon.nvim", + version = "*", + config = function() + --require("beacon").setup({ + -- minimal_jump = 5, + --}) + end, +} diff --git a/lua/custom/plugins/custom-init.lua b/lua/custom/plugins/custom-init.lua new file mode 100644 index 00000000..4fb2e172 --- /dev/null +++ b/lua/custom/plugins/custom-init.lua @@ -0,0 +1,52 @@ +-- You can add your own plugins here or in other files in this directory! +-- I promise not to create any merge conflicts in this directory :) +-- +-- See the kickstart.nvim README for more information + +package.path = package.path .. ";?.lua" + +-- Set the blinking cursor settings +vim.o.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' + +-- Adjust the split that it makes sense +vim.opt.splitbelow = true +vim.opt.splitright = true + +-- Make sure, that when we exit nvim the previous cursor settings get restored +vim.cmd([[ + augroup RestoreCursorShapeOnExit + autocmd! + autocmd VimLeave * set guicursor=a:block20 + augroup END +]]) + +-- Adding relative line numbers +vim.opt.relativenumber = true + +-- Fix the cursor in the middle of windows when scrolling +vim.opt.scrolloff = 6 + +-- Remap for dealing with word wrap in v mode (see init.lua:284) +vim.keymap.set('v', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true}) +vim.keymap.set('v', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true}) + +-- Provide function and keymap binding to show not saved changes of current buffer +function showBufferDiff() +vim.cmd([[w !diff % - ]]) +end +-- ":vim.cmd([[w !diff % - ]])" +vim.keymap.set('n', 'pd', showBufferDiff, { expr = true, silent = true, desc = "Print diff between buffer and file"}) + + +-- Mimic the tmux config here. S for vertical split, v for horizontal: +-- - Remap for easier window control access +-- - Remap general the window control access to . +-- - Remap (swapping) particular "s" to "v" when entering window control access. +-- (Bear in mind that you have to release keys, and then press "s" or "v". +-- Otherwise the swapping of "s" and "v" does not work. +local map = vim.api.nvim_set_keymap +map('n', '', '', {noremap = false}) +map('n', 's', 'v', {noremap = true}) +map('n', 'v', 's', {noremap = true}) +return { +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..5d06373e --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,81 @@ +return { + -- {{{ Define the Harpoon lazy.vim specificaiton. + + "ThePrimeagen/harpoon", + enabled = true, + branch = "harpoon2", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + }, + + -- ----------------------------------------------------------------------- }}} + -- {{{ Define events to load Harpoon. + + keys = function() + local harpoon = require("harpoon") + local conf = require("telescope.config").values + + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() + end + + + return { + -- Harpoon marked files 1 through 4 + {"", function() harpoon:list():select(1) end, desc ="Harpoon buffer 1"}, + {"", function() harpoon:list():select(2) end, desc ="Harpoon buffer 2"}, + {"", function() harpoon:list():select(3) end, desc ="Harpoon buffer 3"}, + {"", function() harpoon:list():select(4) end, desc ="Harpoon buffer 4"}, + + -- Harpoon next and previous. + {"", function() harpoon:list():next() end, desc ="Harpoon next buffer"}, + {"", function() harpoon:list():prev() end, desc ="Harpoon prev buffer"}, + + -- Harpoon user interface. + {"ht", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, desc ="Harpoon Toggle Menu"}, + {"ha", function() harpoon:list():append() end, desc ="Harpoon add file"}, + + -- Use Telescope as Harpoon user interface. + {"hs", function() toggle_telescope(harpoon:list() )end, desc ="Show Harpoon window"}, + } + end, + + -- ----------------------------------------------------------------------- }}} + -- {{{ Use Harpoon defaults or my customizations. + + opts = function(_, opts) + opts.settings = { + save_on_toggle = false, + sync_on_ui_close = false, + save_on_change = true, + enter_on_sendcmd = false, + tmux_autoclose_windows = false, + excluded_filetypes = { "harpoon", "alpha", "dashboard", "gitcommit" }, + mark_branch = false, + key = function() + return vim.loop.cwd() + end + } + end, + + -- ----------------------------------------------------------------------- }}} + -- {{{ Configure Harpoon. + + config = function(_, opts) + require("harpoon").setup(opts) + end, + + -- ----------------------------------------------------------------------- }}} +} diff --git a/lua/custom/plugins/local-highlight.lua b/lua/custom/plugins/local-highlight.lua new file mode 100644 index 00000000..062f43be --- /dev/null +++ b/lua/custom/plugins/local-highlight.lua @@ -0,0 +1,18 @@ +return { + 'tzachar/local-highlight.nvim', + + dependencies = { + 'folke/snacks.nvim', + }, + + config = function() + require('local-highlight').setup { + file_types = { 'xyz' }, + highlight_single_match = false, + cw_hlgroup = 'Search', + insert_mode = true, + } + + vim.keymap.set('n', 'ph', vim.cmd.LocalHighlightToggle, { expr = false, silent = true, desc = 'Toggle local-highlight.nvim' }) + end, +} diff --git a/lua/custom/plugins/search-replace.lua b/lua/custom/plugins/search-replace.lua new file mode 100644 index 00000000..55ac8478 --- /dev/null +++ b/lua/custom/plugins/search-replace.lua @@ -0,0 +1,30 @@ +return { + 'roobert/search-replace.nvim', + config = function() + require('search-replace').setup { + -- optionally override defaults + default_replace_single_buffer_options = 'gcI', + default_replace_multi_buffer_options = 'egcI', + } + vim.keymap.set('v', '', 'SearchReplaceSingleBufferVisualSelection', opts) + vim.keymap.set('v', '', 'SearchReplaceWithinVisualSelection', opts) + vim.keymap.set('v', '', 'SearchReplaceWithinVisualSelectionCWord', opts) + + vim.keymap.set('n', 'rs', 'SearchReplaceSingleBufferSelections', { desc = '[s]elction list' }) + vim.keymap.set('n', 'ro', 'SearchReplaceSingleBufferOpen', { desc = '[o]pen' }) + vim.keymap.set('n', 'rw', 'SearchReplaceSingleBufferCWord', { desc = '[w]ord' }) + vim.keymap.set('n', 'rW', 'SearchReplaceSingleBufferCWORD', { desc = '[W]ORD' }) + vim.keymap.set('n', 're', 'SearchReplaceSingleBufferCExpr', { desc = '[e]xpr' }) + vim.keymap.set('n', 'rf', 'SearchReplaceSingleBufferCFile', { desc = '[f]ile' }) + + vim.keymap.set('n', 'rbs', 'SearchReplaceMultiBufferSelections', { desc = '[s]elction list' }) + vim.keymap.set('n', 'rbo', 'SearchReplaceMultiBufferOpen', { desc = '[o]pen' }) + vim.keymap.set('n', 'rbw', 'SearchReplaceMultiBufferCWord', { desc = '[w]ord' }) + vim.keymap.set('n', 'rbW', 'SearchReplaceMultiBufferCWORD', { desc = '[W]ORD' }) + vim.keymap.set('n', 'rbe', 'SearchReplaceMultiBufferCExpr', { desc = '[e]xpr' }) + vim.keymap.set('n', 'rbf', 'SearchReplaceMultiBufferCFile', { desc = '[f]ile' }) + + -- show the effects of a search / replace in a live preview window + vim.o.inccommand = 'split' + end, +}