From bfc197705c11723f6c32aac5ac4b18780ee74bd3 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Wed, 13 Aug 2025 06:46:40 +0000 Subject: [PATCH 1/8] Basic setup after fastforward master branch. Activate nerd font, relativnumber and custom/plugins --- init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index b98ffc6198a..7ea96864217 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.o` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.o.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.o.relativenumber = true +vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = 'a' @@ -984,7 +984,7 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! From a701962f67f1285ae4621bfee867c5b27d5409f9 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Wed, 13 Aug 2025 07:13:54 +0000 Subject: [PATCH 2/8] Replacing colorscheme with cattpuccin, adding custom init.lua Custom init.lua will overwrite / extend stuff which is placed in the main init.lua --- init.lua | 42 +++++++++++++++---------------- lua/custom/plugins/cattpuccin.lua | 12 +++++++++ lua/custom/plugins/init.lua | 16 ++++++++++++ 3 files changed, 49 insertions(+), 21 deletions(-) create mode 100644 lua/custom/plugins/cattpuccin.lua diff --git a/init.lua b/init.lua index 7ea96864217..f23748a6679 100644 --- a/init.lua +++ b/init.lua @@ -876,27 +876,27 @@ require('lazy').setup({ }, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - config = function() - ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { - styles = { - comments = { italic = false }, -- Disable italics in comments - }, - } - - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' - end, - }, + -- { -- You can easily change to a different colorscheme. + -- -- Change the name of the colorscheme plugin below, and then + -- -- change the command in the config to whatever the name of that colorscheme is. + -- -- + -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + -- 'folke/tokyonight.nvim', + -- priority = 1000, -- Make sure to load this before all the other start plugins. + -- config = function() + -- ---@diagnostic disable-next-line: missing-fields + -- require('tokyonight').setup { + -- styles = { + -- comments = { italic = false }, -- Disable italics in comments + -- }, + -- } + -- + -- -- Load the colorscheme here. + -- -- Like many other themes, this one has different styles, and you could load + -- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. + -- vim.cmd.colorscheme 'tokyonight-night' + -- end, + -- }, -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, diff --git a/lua/custom/plugins/cattpuccin.lua b/lua/custom/plugins/cattpuccin.lua new file mode 100644 index 00000000000..bba8440a1c9 --- /dev/null +++ b/lua/custom/plugins/cattpuccin.lua @@ -0,0 +1,12 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + priority = 1001, + config = function() + require("catppuccin").setup({ + flavour = "mocha" + }) + vim.cmd.colorscheme "catppuccin" + end, +} + diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..cfdcf3c2c01 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,20 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information + +-- Set the blinking cursor settings +vim.o.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' + +-- 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 +]] + +-- Remap for dealing with word wrap in v mode +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 }) + return {} From d7f4fef5996c6a4f93416b28b4334fae85889053 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Wed, 13 Aug 2025 07:19:01 +0000 Subject: [PATCH 3/8] Adding nvim-tree --- lua/custom/plugins/init.lua | 4 +++ lua/custom/plugins/nvim-tree.lua | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 lua/custom/plugins/nvim-tree.lua diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index cfdcf3c2c01..fe02583e25d 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -3,6 +3,10 @@ -- -- See the kickstart.nvim README for more information +-- Disabled netrw plugin, because we will use nvim-tree +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + -- Set the blinking cursor settings vim.o.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' diff --git a/lua/custom/plugins/nvim-tree.lua b/lua/custom/plugins/nvim-tree.lua new file mode 100644 index 00000000000..13cefc27b2e --- /dev/null +++ b/lua/custom/plugins/nvim-tree.lua @@ -0,0 +1,50 @@ +return { + 'nvim-tree/nvim-tree.lua', + version = '*', + lazy = false, + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('nvim-tree').setup { + filters = { + dotfiles = true, + }, + } + -- Helper function to setup a custom keybindings when nvim-tree buffer is active + local function my_on_attach(bufnr) + local api = require 'nvim-tree.api' + + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- add/overwrite custom mappings + vim.keymap.set('n', '?', api.tree.toggle_help, opts 'Help') + end + + -- pass to setup along with your other options + require('nvim-tree').setup { + --- + on_attach = my_on_attach, + --- + } + + -- fix the width of nvim tree if once adjusted. + require('nvim-tree').setup { + actions = { + open_file = { + quit_on_open = false, -- important: don't quit tree immediately + resize_window = false, -- prevent auto-resizing + }, + }, + } + + -- Keybinding in "normal" vi mode + local anotherApi = require 'nvim-tree.api' + vim.keymap.set('n', 't', anotherApi.tree.toggle, { desc = 'Toogle nvim-tree' }) + end, +} From 4be9d4536a6a3635ba542c77099eedc8301c9bb6 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Wed, 13 Aug 2025 07:29:27 +0000 Subject: [PATCH 4/8] Adding smart-split and configure shortcuts in custom init.lua --- lua/custom/plugins/init.lua | 18 ++++ lua/custom/plugins/smart-split.lua | 132 +++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 lua/custom/plugins/smart-split.lua diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index fe02583e25d..6c1cc84211d 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -22,4 +22,22 @@ vim.cmd [[ 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/smart-split.lua b/lua/custom/plugins/smart-split.lua new file mode 100644 index 00000000000..00abbb3a1d8 --- /dev/null +++ b/lua/custom/plugins/smart-split.lua @@ -0,0 +1,132 @@ +return { + 'mrjones2014/smart-splits.nvim', + dependencies = { + 'pogyomo/submode.nvim', + }, + -- config = function() end, + config = function() + require('smart-splits').setup { + -- Ignored filetypes (only while resizing) + ignored_filetypes = { + 'nofile', + 'quickfix', + 'prompt', + }, + -- Ignored buffer types (only while resizing) + ignored_buftypes = { 'NvimTree' }, + -- the default number of lines/columns to resize by at a time + default_amount = 3, + -- Desired behavior when your cursor is at an edge and you + -- are moving towards that same edge: + -- 'wrap' => Wrap to opposite side + -- 'split' => Create a new split in the desired direction + -- 'stop' => Do nothing + -- function => You handle the behavior yourself + -- NOTE: If using a function, the function will be called with + -- a context object with the following fields: + -- { + -- mux = { + -- type:'tmux'|'wezterm'|'kitty' + -- current_pane_id():number, + -- is_in_session(): boolean + -- current_pane_is_zoomed():boolean, + -- -- following methods return a boolean to indicate success or failure + -- current_pane_at_edge(direction:'left'|'right'|'up'|'down'):boolean + -- next_pane(direction:'left'|'right'|'up'|'down'):boolean + -- resize_pane(direction:'left'|'right'|'up'|'down'):boolean + -- split_pane(direction:'left'|'right'|'up'|'down',size:number|nil):boolean + -- }, + -- direction = 'left'|'right'|'up'|'down', + -- split(), -- utility function to split current Neovim pane in the current direction + -- wrap(), -- utility function to wrap to opposite Neovim pane + -- } + -- NOTE: `at_edge = 'wrap'` is not supported on Kitty terminal + -- multiplexer, as there is no way to determine layout via the CLI + at_edge = 'wrap', + -- when moving cursor between splits left or right, + -- place the cursor on the same row of the *screen* + -- regardless of line numbers. False by default. + -- Can be overridden via function parameter, see Usage. + move_cursor_same_row = false, + -- whether the cursor should follow the buffer when swapping + -- buffers by default; it can also be controlled by passing + -- `{ move_cursor = true }` or `{ move_cursor = false }` + -- when calling the Lua function. + cursor_follows_swapped_bufs = false, + -- resize mode options + resize_mode = { + -- key to exit persistent resize mode + quit_key = '', + -- keys to use for moving in resize mode + -- in order of left, down, up' right + resize_keys = { 'h', 'j', 'k', 'l' }, + -- set to true to silence the notifications + -- when entering/exiting persistent resize mode + silent = false, + -- must be functions, they will be executed when + -- entering or exiting the resize mode + hooks = { + on_enter = nil, + on_leave = nil, + }, + }, + -- ignore these autocmd events (via :h eventignore) while processing + -- smart-splits.nvim computations, which involve visiting different + -- buffers and windows. These events will be ignored during processing, + -- and un-ignored on completed. This only applies to resize events, + -- not cursor movement events. + ignored_events = { + 'BufEnter', + 'WinEnter', + }, + -- enable or disable a multiplexer integration; + -- automatically determined, unless explicitly disabled or set, + -- by checking the $TERM_PROGRAM environment variable, + -- and the $KITTY_LISTEN_ON environment variable for Kitty + multiplexer_integration = nil, + -- disable multiplexer navigation if current multiplexer pane is zoomed + -- this functionality is only supported on tmux and Wezterm due to kitty + -- not having a way to check if a pane is zoomed + disable_multiplexer_nav_when_zoomed = true, + -- Supply a Kitty remote control password if needed, + -- or you can also set vim.g.smart_splits_kitty_password + -- see https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.remote_control_password + kitty_password = nil, + -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal' + log_level = 'info', + persistent_resize_mode = true, + } + + -- vim.keymap.set('n', 'r', require('smart-splits').start_resize_mode, { desc = 'Start resize mode' }) + vim.keymap.set('n', '', require('smart-splits').move_cursor_right, { desc = 'Move right' }) + vim.keymap.set('n', '', require('smart-splits').move_cursor_left, { desc = 'Move left' }) + vim.keymap.set('n', '', require('smart-splits').move_cursor_down, { desc = 'Move down' }) + vim.keymap.set('n', '', require('smart-splits').move_cursor_up, { desc = 'Move up' }) + + -- Resize + local submode = require 'submode' + submode.create('WinResize', { + mode = 'n', + enter = 'r', + leave = { '', 'q', '' }, + hook = { + on_enter = function() + vim.notify 'Use { h, j, k, l } or { , , , } to resize the window' + end, + on_leave = function() + vim.notify '' + end, + }, + default = function(register) + register('h', require('smart-splits').resize_left, { desc = 'Resize left' }) + register('j', require('smart-splits').resize_down, { desc = 'Resize down' }) + register('k', require('smart-splits').resize_up, { desc = 'Resize up' }) + register('l', require('smart-splits').resize_right, { desc = 'Resize right' }) + register('', require('smart-splits').resize_left, { desc = 'Resize left' }) + register('', require('smart-splits').resize_down, { desc = 'Resize down' }) + register('', require('smart-splits').resize_up, { desc = 'Resize up' }) + register('', require('smart-splits').resize_right, { desc = 'Resize right' }) + end, + }) + end, +} From 20e2b8840bbc4b2a8e847a8eda51389cc5bb9c22 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Wed, 13 Aug 2025 07:33:11 +0000 Subject: [PATCH 5/8] Adding fterm --- lua/custom/plugins/fterm.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lua/custom/plugins/fterm.lua diff --git a/lua/custom/plugins/fterm.lua b/lua/custom/plugins/fterm.lua new file mode 100644 index 00000000000..b5fd4382335 --- /dev/null +++ b/lua/custom/plugins/fterm.lua @@ -0,0 +1,25 @@ +return { + 'numToStr/FTerm.nvim', + config = function() + require('FTerm').setup({ + -- just keep the standard settings for now + }) + + -- Toggle FTerm + vim.keymap.set('n', '', 'lua require("FTerm").toggle()', { desc = "Toggle FTerm"}) + vim.keymap.set('t', '', 'lua require("FTerm").toggle()', { desc = "Toggle FTerm"}) + + -- Run commands + vim.keymap.set('n', 'l', 'lua require("FTerm").run("lazygit")', { desc = "Run FTerm lazygit"}) + + -- Scratch commands + vim.keymap.set('n', 'bd', 'lua require("FTerm").scratch({ cmd = "sh scripts/build.sh" })', { desc = "Scratch build.sh with default options"}) + vim.keymap.set('n', 'bc', 'lua require("FTerm").scratch({ cmd = "sh scripts/build.sh -cb" })', { desc = "Scratch build.sh with clean build option"}) + vim.keymap.set('n', 'bf', 'lua require("FTerm").scratch({ cmd = "sh scripts/build.sh -fb" })', { desc = "Scratch build.sh with fresh option"}) + vim.keymap.set('n', 'bn', 'lua require("FTerm").scratch({ cmd = "sh scripts/build.sh -nb" })', { desc = "Scratch build.sh with no build option"}) + + vim.keymap.set('n', 'cf', 'lua require("FTerm").scratch({ cmd = "sh scripts/checkformat.sh" })', { desc = "Scratch checkformat readonly"}) + vim.keymap.set('n', 'ca', 'lua require("FTerm").scratch({ cmd = "sh scripts/checkanalyzer.sh" })', { desc = "Scratch checkanalyzer"}) + end, +} + From e7bfa8455785d188cc2b6cb6d34217ebe7ef5567 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Wed, 13 Aug 2025 07:58:19 +0000 Subject: [PATCH 6/8] Try to fix blinking cursor. Probably neovim 0.11.2 has an issue --- lua/custom/plugins/init.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 6c1cc84211d..474a4774c3b 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -7,9 +7,6 @@ vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 --- Set the blinking cursor settings -vim.o.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' - -- Make sure, that when we exit nvim the previous cursor settings get restored vim.cmd [[ augroup RestoreCursorShapeOnExit @@ -18,6 +15,14 @@ vim.cmd [[ augroup END ]] +-- Set the blinking cursor settings +vim.api.nvim_create_autocmd('VimEnter', { + callback = function() + vim.notify 'Setting guicursor via VimEnter' + vim.opt.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' + end, +}) + -- Remap for dealing with word wrap in v mode 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 }) From 87db21c4b0fbbf35041b2049e7ee5607b58df743 Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Fri, 15 May 2026 13:02:58 +0200 Subject: [PATCH 7/8] Applying the current state, which is working with neovim 0.12.2 --- init.lua | 2 +- lua/custom/plugins/init.lua | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index f23748a6679..ec610920d5d 100644 --- a/init.lua +++ b/init.lua @@ -671,7 +671,7 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 474a4774c3b..da094b586a9 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -16,12 +16,7 @@ vim.cmd [[ ]] -- Set the blinking cursor settings -vim.api.nvim_create_autocmd('VimEnter', { - callback = function() - vim.notify 'Setting guicursor via VimEnter' - vim.opt.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' - end, -}) +vim.opt.guicursor = 'n-v:block,i:ver25,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250' -- Remap for dealing with word wrap in v mode vim.keymap.set('v', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) @@ -45,4 +40,11 @@ map('n', '', '', { noremap = false }) map('n', 's', 'v', { noremap = true }) map('n', 'v', 's', { noremap = true }) +-- Mapping for delete into black hole register in normal mode +-- and replace visual selection with yanked text (unnamed register) without losing it. +-- Example: yiw or yi" to yank some text => xiwP or xiw"P to replace. +-- => visual select and x to replace. +vim.keymap.set('n', 'x', '"_d', { desc = 'Delete to black hole register' }) +vim.keymap.set('v', 'x', '"_dP', { desc = 'Replace selection with yanked text' }) + return {} From 4ed51b3acb84e70ebf4979e508c7856f0f402f9e Mon Sep 17 00:00:00 2001 From: Thomas Dorsch Date: Fri, 15 May 2026 13:05:05 +0200 Subject: [PATCH 8/8] 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 00000000000..24b992b694d --- /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 00000000000..4fb2e1725c0 --- /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 00000000000..5d06373eeee --- /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 00000000000..062f43beb2f --- /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 00000000000..55ac84782fc --- /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, +}