nvim-config/lua/plugins/config/git.lua
dlond f81cab2da3 refactor: Complete modular migration from kickstart.nvim
Major architectural overhaul to transform the flat kickstart.nvim structure
  into a maintainable, modular configuration while preserving upstream sync capability.

  ## Structure Changes
  - Migrated from flat `lua/custom/` to organized `lua/core/` and `lua/plugins/`
  - Separated plugin specs from configs: `lua/plugins/spec/` and `lua/plugins/config/`
  - Complex configs (LSP, Debug) now use directory structure with sub-modules:
    - `lsp/init.lua`, `lsp/servers.lua`, `lsp/keymaps.lua`
    - `debug/init.lua`, `debug/adapters.lua`, `debug/keymaps.lua`

  ## Core Improvements
  - Created dedicated core modules: options, keymaps, autocmds, bootstrap, health
  - Added comprehensive health check (`lua/core/health.lua`) for diagnostics
  - Simplified init.lua to just orchestrate module loading
  - Better separation of concerns throughout

  ## Plugin Updates
  - Fixed Blink.cmp configuration (removed invalid fuzzy options)
  - Integrated Copilot with Blink.cmp for unified completion experience
  - Added autopairs and indent-line from kickstart examples
  - Optimized for Nix development environments (removed venv assumptions)

  ## Documentation
  - Updated README with modular structure and kickstart sync instructions
  - Created comprehensive KEYBIND_ANALYSIS.md with all mappings
  - Added modular.txt help documentation
  - Created TODO_TEST.md checklist for testing

  ## Benefits
  - Easier to maintain and extend
  - Clean separation allows upstream kickstart merges without conflicts
  - Scalable architecture for adding new languages/tools
  - Better code organization and discoverability

  All kickstart functionality preserved while gaining modularity and maintainability.
2025-09-02 13:23:53 +12:00

69 lines
No EOL
2.4 KiB
Lua

-- Git Configuration
local M = {}
function M.setup_gitsigns()
require('gitsigns').setup({
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
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
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'Git [s]tage hunk' })
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'Git [r]eset hunk' })
map('v', '<leader>hs', function()
gitsigns.stage_hunk({vim.fn.line('.'), vim.fn.line('v')})
end, { desc = 'Git [s]tage hunk' })
map('v', '<leader>hr', function()
gitsigns.reset_hunk({vim.fn.line('.'), vim.fn.line('v')})
end, { desc = 'Git [r]eset hunk' })
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'Git [S]tage buffer' })
map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'Git [u]ndo stage hunk' })
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'Git [R]eset buffer' })
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'Git [p]review hunk' })
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'Git [b]lame line' })
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'Git [d]iff against index' })
map('n', '<leader>hD', function()
gitsigns.diffthis('@')
end, { desc = 'Git [D]iff against last commit' })
-- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
map('n', '<leader>tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' })
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Select git hunk' })
end,
})
end
return M