Commit graph

49 commits

Author SHA1 Message Date
9e857d4b29 feat(fugitive): line position tracking for keymaps
When pressing `du`/`dU` from a hunk line in the fugitive status buffer
(after expanding with `=`), the unified diff now opens at the
corresponding line instead of line 1.

Implementation:
- `fugitive.get_hunk_position()` returns @@ header and offset when on a hunk line
- `commands.find_hunk_line()` finds matching @@ header in diff buffer
- `commands.gdiff_file()` accepts optional `hunk_position` and jumps after opening

Also updates @phanen's README credit for the previous two fixes.

Closes #65
2026-02-05 00:27:35 -05:00
c51d625dc6 fix(parser): detect filetype from existing buffer
Files detected via shebang or modeline (e.g., `build` with `#!/bin/bash`)
weren't getting syntax highlighting because `vim.filetype.match()` only
does filename-based detection.

Now `get_ft_from_filename()` first checks if a buffer already exists for
the file and uses its detected filetype. This requires knowing the repo
root to construct the full path, so:

- `parse_buffer()` reads `b:diffs_repo_root` or `b:git_dir` (fugitive)
- `commands.lua` sets `b:diffs_repo_root` on diff buffers it creates

Co-authored-by: phanen <phanen@qq.com>
2026-02-05 00:13:32 -05:00
980bedc8a6 fix(parser): emit hunks for files with unknown filetypes
Previously, hunks were discarded entirely if vim.filetype.match()
returned nil. This meant files with unrecognized extensions got no
highlighting at all - not even the basic green/red backgrounds for
added/deleted lines.

Remove the (current_lang or current_ft) condition from flush_hunk()
so all hunks are collected. highlight_hunk() already handles the
case where ft/lang are nil by skipping syntax highlighting but still
applying background colors.

Co-authored-by: phanen <phanen@qq.com>
2026-02-04 23:51:15 -05:00
9ed0639005 fix(fugitive): handle renamed files correctly
Parse both old and new filenames from rename lines (R old -> new).
When diffing staged renames, use old filename as base to correctly
show content changes rather than treating the file as entirely new.

Also adds comprehensive tests for filename edge cases:
- Double extensions, hyphens, underscores, dotfiles
- Deep nested paths, complex renames
- Documents known limitation with filenames containing ' -> '
2026-02-04 23:12:30 -05:00
6072dd0156 feat(fugitive): add section header and untracked file support
Section headers (Staged/Unstaged) now show all diffs in that section,
matching fugitive's behavior. Untracked files show as all-added diffs.
Deleted files show as all-removed diffs.

Also handles edge cases:
- Empty new/old content for deleted/new files
- Section header detection returns is_header flag
2026-02-04 22:39:07 -05:00
9289f33639 feat(fugitive): add status buffer keymaps for unified diffs
Adds du/dU keymaps to fugitive's :Git status buffer for opening unified
diffs instead of side-by-side diffs:
- du opens horizontal split (mirrors dd)
- dU opens vertical split (mirrors dv)

Parses status buffer lines to extract filename and detect section
(staged/unstaged/untracked). For staged files, diffs index vs HEAD.
For unstaged files, diffs working tree vs index.

Configurable via vim.g.diffs.fugitive.horizontal/vertical (set to
false to disable).
2026-02-04 22:23:21 -05:00
ea60ab8d01 feat(commands): add gdiff_file for diffing arbitrary paths
Adds gdiff_file() which can diff any file path (not just current buffer)
with support for staged vs unstaged changes:
- staged=true diffs index against HEAD
- staged=false diffs working tree against index
- Falls back to HEAD if file not in index (for untracked comparison)
2026-02-04 22:23:13 -05:00
85080514b6 feat(git): add index and working tree content retrieval
Adds functions for accessing git index content and working tree files:
- get_index_content() retrieves file from staging area via :0:path
- get_working_content() reads file directly from disk
- file_exists_in_index() checks if file is staged
- file_exists_at_revision() checks if file exists at given revision
2026-02-04 22:23:09 -05:00
045a9044b5 feat: add :Gdiff, :Gvdiff, :Ghdiff commands for unified diff view
Compares current buffer against any git revision (default HEAD), opens result
with full diffs.nvim syntax highlighting. Follows fugitive convention:
:Gdiff/:Gvdiff open vertical split, :Ghdiff opens horizontal split.
2026-02-04 19:52:17 -05:00
a25f1e9d84 feat: treesitter highlighting for diff headers
Apply treesitter highlighting to diff metadata lines (diff --git, index,
---, +++) using the diff language parser. Header info is attached only
to the first hunk of each file to avoid duplicate highlighting.

Based on PR #52 by @phanen with fixes:
- header_lines now only contains diff metadata, not hunk content
- header info attached only to first hunk per file
- removed arbitrary hunk count restriction
2026-02-04 15:11:35 -05:00
2b38874699 feat(config): use vim.g over .setup() 2026-02-03 16:18:55 -05:00
f71b0f54c5 fix: remove useless enabled flag 2026-02-03 02:50:25 -05:00
dc45dd66ec fix highlights 2026-02-03 01:21:57 -05:00
188de47d77 feat: docs update (vim-fugitive is optional) 2026-02-03 01:07:37 -05:00
67116f38bc feat: rename everything 2026-02-02 22:09:13 -05:00
Barrett Ruth
1ab85b698d
Merge branch 'main' into feat/deslop 2026-02-02 21:09:54 -05:00
Barrett Ruth
d3b48ab3d9
Merge branch 'main' into feat/diffsplit 2026-02-02 21:08:48 -05:00
1dd62373b6 feat: cleanup ci tests 2026-02-02 21:05:25 -05:00
f865c894a5 fix(config): remove useless config option 2026-02-02 18:05:31 -05:00
52bc53e4b5 feat: qol oss improvements 2026-02-02 17:01:22 -05:00
686b02b790 feat: update autocmds for git filetypes with fugiive:/// bufnames 2026-02-02 16:46:58 -05:00
e2a62a6aa5 feat: doc updates and cleanups 2026-02-02 16:39:37 -05:00
9b700ce869 feat: diffsplit support 2026-02-02 16:37:51 -05:00
339171fe27 fix: short circuit logic 2026-02-02 15:47:16 -05:00
548c5386ab feat(vim): syntax highlighting 2026-02-02 15:42:15 -05:00
2c330732bb feat(highlight): vim highlight fallback 2026-02-02 15:28:58 -05:00
69943a09c4 feat: cleanup config options 2026-02-02 15:18:25 -05:00
71938e6cfe fix(ci): diagnostics 2026-02-02 14:10:15 -05:00
bbc120b5de cleanup 2026-02-02 14:06:58 -05:00
e25fb0f297 fix(ci): typing 2026-02-02 14:04:24 -05:00
dabf2e2cc9 feat: highlight improvemnets 2026-02-02 13:53:43 -05:00
6a64a380b0 conceal back to level 1 2026-02-02 13:26:19 -05:00
3aa7d1d6f8 feat: use conceal overlay 2026-02-02 13:22:22 -05:00
ea8a2cbaa9 feat: rename param 2026-02-02 01:07:59 -05:00
851cdb0214 fix race condition 2026-02-02 01:00:40 -05:00
d7537e93d0 feat: fix highlighting 2026-02-02 00:57:41 -05:00
b3e687c954 fix: proper background higlights 2026-02-02 00:35:08 -05:00
935eb8f7ed feat: highlights, debug fixes, and config validation 2026-02-02 00:22:44 -05:00
00bf84cb05 feat: highlights 2026-02-01 23:17:20 -06:00
3b0e90a46e feat: fix bug 2026-02-01 23:45:16 -05:00
8f5e8e3b17 fix(test): hopefully they work 2026-02-01 23:41:59 -05:00
655e032471 feat: remove unused vars 2026-02-01 23:12:05 -05:00
d974567a8d documentation 2026-02-01 22:57:04 -05:00
e5ebf3b3ec feat: more config options 2026-02-01 19:35:19 -05:00
8d8a09635c fix: correct ci 2026-02-01 19:03:52 -05:00
0e86f45c39 feat: add some config options 2026-02-01 18:52:00 -05:00
ae727159b9 feat: debug option 2026-02-01 17:44:28 -05:00
29f9a5f7e4 feat: luacats annotations 2026-02-01 17:38:58 -05:00
21b8cfb470 feat: add the entire plugin 2026-02-01 17:38:32 -05:00