diff --git a/nvim/init.lua b/nvim/init.lua index f873b82..30b4372 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -4,6 +4,7 @@ -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' +vim.opt.cmdheight = 0 -- Set to true if you have a Nerd Font installed and selected in the terminal vim.g.have_nerd_font = true @@ -72,6 +73,24 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +-- quickfix to search and replace +vim.api.nvim_create_user_command('SearchAndReplace', function() + -- Prompt for the first string (the one to replace) + local stringOne = vim.fn.input('Enter the string to replace: ') + -- Prompt for the second string (the replacement) + local stringTwo = vim.fn.input('Enter the replacement string: ') + + -- Perform the search and replace in the quickfix list + vim.cmd('cfdo %s/' .. stringOne .. '/' .. stringTwo .. '/g | update') + + -- Optionally close the buffers + vim.cmd('bd') +end, {}) + +-- Map R to the LadderR command +vim.api.nvim_set_keymap('n', 'R', ':SearchAndReplace', { noremap = true, silent = true }) + + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -151,25 +170,6 @@ require('lazy').setup({ -- keys can be used to configure plugin behavior/loading/etc. -- -- Use `opts = {}` to force a plugin to be loaded. - -- { - -- 'akinsho/bufferline.nvim', - -- opts = { - -- options = { - -- mode = "buffers", - -- themable = true, - -- color_icons = true, - -- offsets = { - -- { - -- filetype = "neo-tree", - -- text = "File Explorer", - -- text_align = "left", - -- separator = true, - -- } - -- }, - -- - -- }, - -- }, - -- }, -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following Lua: @@ -861,10 +861,11 @@ require('lazy').setup({ -- require 'kickstart.plugins.lint', require 'kickstart.plugins.autopairs', require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- My plugins require 'kickstart.plugins.bufferline', + -- require 'kickstart.plugins.bottomline' -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 913f07f..e0ec29a 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -35,5 +35,6 @@ "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "tokyonight.nvim": { "branch": "main", "commit": "efd1417aa01af618426fe1cf507c5458090458f2" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, - "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" } + "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }, + "winline.nvim": { "branch": "main", "commit": "3f9eb95237ef8c5e66944f27891608c12079b27c" } } diff --git a/nvim/lua/kickstart/plugins/bottomline.lua b/nvim/lua/kickstart/plugins/bottomline.lua new file mode 100644 index 0000000..946ebb8 --- /dev/null +++ b/nvim/lua/kickstart/plugins/bottomline.lua @@ -0,0 +1,45 @@ +-- bottomline + +return { + 'mnjm/winline.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', + 'nvim-tree/nvim-web-devicons' + }, + config = function() + require('winline').setup { + -- Enable winline + enable = true, + + -- Minimal components for a status line that feels like a command line + components = { + left = { + {'mode'}, -- Shows the current mode (Normal, Insert, etc.) + }, + right = { + {'line_col'}, -- Show line and column numbers + }, + }, + + -- Disable separators and reduce padding for a minimal look + options = { + separators = true, -- No separators between components + padding = 0, -- Minimal padding for a compact look + }, + + -- Make it look cohesive with the command line + colors = { + active = '#282c34', -- Dark background for the active window + inactive = '#3e4451', -- Slightly lighter background for inactive windows + }, + } + + -- Set Neovim options to make the command line always visible and match the style + vim.opt.cmdheight = 0 -- Always show the command line + vim.cmd [[ + highlight StatusLine guibg=#282c34 guifg=#abb2bf + highlight CmdLine guibg=#282c34 guifg=#abb2bf + ]] + end, +} + diff --git a/nvim/lua/kickstart/plugins/bufferline.lua b/nvim/lua/kickstart/plugins/bufferline.lua index c4b7de2..74d79b1 100644 --- a/nvim/lua/kickstart/plugins/bufferline.lua +++ b/nvim/lua/kickstart/plugins/bufferline.lua @@ -1,27 +1,29 @@ -- bufferline + return { 'akinsho/bufferline.nvim', version = '*', dependencies = { 'nvim-tree/nvim-web-devicons', }, - opts = { - options = { - mode = "buffers", - themable = true, - color_icons = true, - offsets = { - { - filetype = "neo-tree", - text = "File Explorer", - text_align = "left", - separator = true, - } - }, - }, - }, config = function() + require('bufferline').setup { + options = { + mode = "buffers", + themable = true, + color_icons = true, + offsets = { + { + filetype = "neo-tree", + text = "File Explorer", + text_align = "left", + separator = true, + } + }, + } + } + -- Keymaps for bufferline vim.keymap.set('n', '', 'BufferLineCyclePrev', { silent = true }) vim.keymap.set('n', '', 'BufferLineCycleNext', { silent = true }) diff --git a/nvim/lua/kickstart/plugins/gitsigns.lua b/nvim/lua/kickstart/plugins/gitsigns.lua new file mode 100644 index 0000000..4bcc70f --- /dev/null +++ b/nvim/lua/kickstart/plugins/gitsigns.lua @@ -0,0 +1,61 @@ +-- Adds git related signs to the gutter, as well as utilities for managing changes +-- NOTE: gitsigns is already included in init.lua but contains only the base +-- config. This will add also the recommended keymaps. + +return { + { + 'lewis6991/gitsigns.nvim', + opts = { + on_attach = function(bufnr) + local gitsigns = require 'gitsigns' + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal { ']c', bang = true } + else + gitsigns.nav_hunk 'next' + end + end, { desc = 'Jump to next git [c]hange' }) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal { '[c', bang = true } + else + gitsigns.nav_hunk 'prev' + end + end, { desc = 'Jump to previous git [c]hange' }) + + -- Actions + -- visual mode + map('v', 'hs', function() + gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'stage git hunk' }) + map('v', 'hr', function() + gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'reset git hunk' }) + -- normal mode + map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) + map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', 'hD', function() + gitsigns.diffthis '@' + end, { desc = 'git [D]iff against last commit' }) + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) + end, + }, + }, +}