diff --git a/README.md b/README.md index 6de342a..be7bf7d 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ nvim --headless "+Lazy! sync" +qa You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration. +### Docs + +* [Git in Neovim (Neogit + Diffview)](doc/git.md) + #### Example: Adding an autopairs plugin In the file: `lua/custom/plugins/autopairs.lua`, add: @@ -157,4 +161,3 @@ This requires: ```lua {'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } ``` - diff --git a/doc/git.md b/doc/git.md new file mode 100644 index 0000000..7ae6946 --- /dev/null +++ b/doc/git.md @@ -0,0 +1,62 @@ +# Git in Neovim (Neogit + Diffview) + +This config uses **Neogit** as the Git UI (replacing Fugitive) and **Diffview** for diffs + merge conflict resolution. + +## Entry points (this config) + +- `\gs` → open Neogit status +- `\gd` → open Diffview +- `\gD` → close Diffview +- `\gh` → Diffview file history +- `\hp` → preview hunk (Gitsigns) + +## Neogit: status, stage, commit + +Open status: `\gs` + +Common keys in the status buffer: + +- `s` stage item under cursor +- `S` stage all unstaged +- `u` unstage item under cursor +- `U` unstage all staged +- `x` discard item under cursor +- `` refresh +- `c` open commit popup (then pick an action) + +## Neogit: merge + rebase + +From Neogit status (`\gs`): + +- `m` opens the merge popup (merge actions) +- `r` opens the rebase popup (rebase actions, continue/abort when in progress) + +Neogit shows the available actions/keys in the popup window; follow those prompts. + +## Conflicts (Diffview) + +When you have conflicts, open Diffview: `\gd` and select a conflicted file. + +In Diffview’s merge tool: + +- Next/prev conflict: `]x` / `[x` +- Choose for the current conflict: + - `\co` = choose ours + - `\ct` = choose theirs + - `\cb` = choose base + - `\ca` = choose all (keep both) + - `dx` = delete conflict region + +After resolving: + +1. Save (`:w`) +2. Stage in Neogit (`\gs`, then `s`/`S`) +3. Use Neogit’s rebase popup (`r`) to continue, or commit (via `c`) if you’re finishing a merge. + +## Undo / back out + +- Undo an edit: `u` (redo: ``) +- Undo a conflict choice you just applied: `u` +- Discard file/hunk from Neogit status: `x` +- Abort an in-progress rebase/merge: use the `r`/`m` popup actions (Neogit will show “abort/continue” options when applicable). + diff --git a/lua/coldboot/plugins/init.lua b/lua/coldboot/plugins/init.lua index 76f7db9..9e6dfa6 100644 --- a/lua/coldboot/plugins/init.lua +++ b/lua/coldboot/plugins/init.lua @@ -2,8 +2,38 @@ -- if you are looking for vscode specific plugins look for the coldboot/vscode -- directory return { -- Git related plugins - 'tpope/vim-fugitive', - 'tpope/vim-rhubarb', -- Detect tabstop and shiftwidth automatically + { + 'NeogitOrg/neogit', + dependencies = { + 'nvim-lua/plenary.nvim', + 'sindrets/diffview.nvim', + }, + keys = { + { + 'gs', + function() + require('neogit').open() + end, + desc = '[G]it [S]tatus', + }, + }, + opts = { + kind = 'tab', + integrations = { + diffview = true, + }, + }, + }, + { + 'sindrets/diffview.nvim', + cmd = { 'DiffviewOpen', 'DiffviewClose', 'DiffviewFileHistory' }, + keys = { + { 'gd', 'DiffviewOpen', desc = '[G]it [D]iff view' }, + { 'gD', 'DiffviewClose', desc = '[G]it [D]iff close' }, + { 'gh', 'DiffviewFileHistory', desc = '[G]it file [H]istory' }, + }, + opts = {}, + }, 'tpope/vim-sleuth', -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. -- LSP Configuration is now in lua/coldboot/plugins/lsp.lua @@ -40,7 +70,7 @@ return { -- Git related plugins desc = 'Preview git hunk', }) - -- don't override the built-in and fugitive keymaps + -- don't override the built-in diff keymaps local gs = package.loaded.gitsigns vim.keymap.set({ 'n', 'v' }, ']c', function() if vim.wo.diff then