Commit graph

222 commits

Author SHA1 Message Date
cc947167c3 fix(highlight): use hl_group instead of line_hl_group for diff backgrounds
line_hl_group bg occupies a separate rendering channel from hl_group in
Neovim's extmark system, causing character-level bg-only highlights to be
invisible regardless of priority. Switching to hl_group + hl_eol ensures
all backgrounds compete in the same channel.

Also reorders priorities (Normal 198 < line bg 199 < syntax 200 < char
bg 201), bumps char-level blend alpha from 0.4 to 0.7 for visibility,
and adds debug logging throughout the intra pipeline.
2026-02-06 18:31:10 -05:00
f1c13966ba fix(highlight): use diffAdded/diffRemoved fg for char-level backgrounds
The previous 70% alpha blend of DiffAdd bg was nearly identical to the
40% line-level blend, making char-level highlights invisible. Now blends
the bright diffAdded/diffRemoved foreground color (same base as line
number fg) into the char-level bg, matching GitHub/VSCode intensity.

Also bumps intra.max_lines default from 200 to 500.
2026-02-06 14:43:23 -05:00
63b6e7d4c6 fix(ci): add jit to luarc globals for lua-language-server
jit is a standard LuaJIT global (like vim), needed by lib.lua for
platform detection via jit.os and jit.arch.
2026-02-06 13:58:30 -05:00
997bc49f8b feat(highlight): add character-level intra-line diff highlighting
Line-level backgrounds (DiffsAdd/DiffsDelete) now get a second tier:
changed characters within modified lines receive an intense background
overlay (DiffsAddText/DiffsDeleteText at 70% alpha vs 40% for lines).
Treesitter foreground colors show through since the extmarks only set bg.

diff.lua extracts contiguous -/+ change groups from hunk lines and diffs
each group byte-by-byte using vim.diff(). An optional libvscodediff FFI
backend (lib.lua) auto-downloads the .so from codediff.nvim releases and
falls back to native if unavailable.

New config: highlights.intra.{enabled, algorithm, max_lines}. Gated by
max_lines (default 200) to avoid stalling on huge hunks. Priority 201
sits above treesitter (200) so the character bg always wins.

Closes #60
2026-02-06 13:53:58 -05:00
Barrett Ruth
294cbad749
Merge pull request #71 from barrettruth/fix/filetype-from-file-content
fix(parser): detect filetype from file content (shebang/modeline)
2026-02-05 01:13:40 -05:00
33c58c7498 fix(parser): detect filetype from file content (shebang/modeline)
When a file has no extension but contains a shebang (e.g., `#!/bin/bash`),
filetype detection now reads the first 10 lines from disk and uses
`vim.filetype.match({ filename, contents })` for content-based detection.

This enables syntax highlighting for files like `build` scripts that rely
on shebang detection, even when the file isn't open in a buffer.

Detection order:
1. Existing buffer's filetype (already implemented in #69)
2. File content (shebang/modeline) - NEW
3. Filename extension only

Also adds `filetype on` to test helpers to ensure `vim.g.ft_ignore_pat`
is set, which is required for shell detection.
2026-02-05 01:08:43 -05:00
Barrett Ruth
0e6871b167
Merge pull request #70 from barrettruth/feat/hunk-line-position
feat(fugitive): line position tracking for keymaps
2026-02-05 00:28:33 -05:00
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
Barrett Ruth
a6d4dcff1f
Merge pull request #69 from barrettruth/fix/filetype-from-existing-buffer
fix(parser): detect filetype from existing buffer
2026-02-05 00:16:11 -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
Barrett Ruth
b4e40e4093
Merge pull request #68 from barrettruth/fix/highlight-unknown-filetypes
fix(parser): emit hunks for files with unknown filetypes
2026-02-04 23:52:13 -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
Barrett Ruth
83f6069d49
Merge pull request #67 from barrettruth/docs/fugitive-keymaps
docs: add fugitive status buffer keymaps documentation
2026-02-04 23:39:47 -05:00
d8332895f3 docs: add fugitive status buffer keymaps documentation
Document the du/dU keymaps for unified diffs in vim-fugitive status
buffers, including behavior by file status and configuration options.
2026-02-04 23:37:39 -05:00
Barrett Ruth
b5ec99fd06
Merge pull request #64 from barrettruth/feat/fugitive-keymaps
feat(fugitive): add unified diff keymaps to status buffer
2026-02-04 23:32:36 -05:00
08e22af113 fix(tests): suppress unused variable warnings for selene 2026-02-04 23:25:39 -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
ce8fe3b89b test(fugitive): add unit tests for line parsing
Tests for get_section_at_line() and get_file_at_line() covering:
- Section detection (staged, unstaged, untracked)
- File parsing (modified, added, deleted, renamed, untracked)
- Hunk line walk-back to parent file
- Files appearing in multiple sections
2026-02-04 22:23:25 -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
Barrett Ruth
44995aeb19
Merge pull request #57 from barrettruth/feat/gdiff
Some checks are pending
luarocks / quality (push) Waiting to run
luarocks / publish (push) Blocked by required conditions
feat: add :Gdiff command
2026-02-04 19:57:23 -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
Barrett Ruth
2ce76e7683
Merge pull request #54 from barrettruth/feat/diff-header-highlight
feat: treesitter highlighting for diff headers
2026-02-04 15:41:56 -05:00
f83fb8b4a7 fix: remove useless ci script 2026-02-04 15:39:27 -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
Barrett Ruth
4008df3558
Merge pull request #53 from barrettruth/fix/known-limitation-syntax
docs: add incomplete syntax context as known limitation
2026-02-04 13:17:31 -05:00
da7b76555a docs: add incomplete syntax context as known limitation
Treesitter parses diff hunks in isolation without surrounding code
context, which can cause incorrect highlighting when hunks show partial
blocks (e.g., adding lines inside `return { ... }` without seeing the
`return`). Document this as a known limitation in README and vimdoc.
2026-02-04 13:16:22 -05:00
Barrett Ruth
2c943c5b94
Merge pull request #51 from barrettruth/fix/docs-warning
Some checks are pending
luarocks / quality (push) Waiting to run
luarocks / publish (push) Blocked by required conditions
remove vim-fugitive as explicit requirement
2026-02-03 16:33:07 -05:00
1723d68cb3 fix(doc): remove vim-fugitive as explicit requirement 2026-02-03 16:27:46 -05:00
Barrett Ruth
26450d20a4
Merge pull request #50 from barrettruth/fix/docs-warning
warn about conflicting plugins
2026-02-03 16:27:13 -05:00
de81fa26cf fix(doc): warn about conflicting diff plugins 2026-02-03 16:25:15 -05:00
bed98791e5 fix(doc): warn about conflicting diff plugins 2026-02-03 16:24:22 -05:00
ddbcec9a1c fix(doc): warn about conflicting diff plugins 2026-02-03 16:24:11 -05:00
Barrett Ruth
c7dcfc4099
Merge pull request #49 from barrettruth/fix/config
Some checks are pending
luarocks / quality (push) Waiting to run
luarocks / publish (push) Blocked by required conditions
user `vim.g` over `.setup()`
2026-02-03 16:20:07 -05:00
2b38874699 feat(config): use vim.g over .setup() 2026-02-03 16:18:55 -05:00
Barrett Ruth
75a6bf184c
Merge pull request #47 from barrettruth/fix/remove-enabled-flag
specify
2026-02-03 02:56:24 -05:00
83ffbc3c05 specify 2026-02-03 02:56:07 -05:00
Barrett Ruth
1cd3e9b750
Merge pull request #46 from barrettruth/fix/remove-enabled-flag
fix: remove useless `enabled` flag
2026-02-03 02:55:12 -05:00
fd270b8215 fix(test): remove other uesless test 2026-02-03 02:53:25 -05:00
92cddd75c3 fix(test): remove old test 2026-02-03 02:51:48 -05:00
f71b0f54c5 fix: remove useless enabled flag 2026-02-03 02:50:25 -05:00
Barrett Ruth
a72296384c
Merge pull request #44 from barrettruth/fix/doc
Some checks are pending
luarocks / quality (push) Waiting to run
luarocks / publish (push) Blocked by required conditions
fix(doc): move hl documentation to the vimdoc
2026-02-03 01:42:27 -05:00
259763ade4 prefer luarocks install 2026-02-03 01:40:27 -05:00
580fb5e5be fix: ci 2026-02-03 01:36:54 -05:00
2e5400f9c0 fix(doc): move hl documentation to the vimdoc 2026-02-03 01:33:31 -05:00
Barrett Ruth
4a1d4ffb85
Merge pull request #43 from barrettruth/feat/test
Some checks are pending
luarocks / quality (push) Waiting to run
luarocks / publish (push) Blocked by required conditions
more robust testing
2026-02-03 01:29:30 -05:00
ee6f5e1c3e improve screenshot 2026-02-03 01:27:53 -05:00
dc45dd66ec fix highlights 2026-02-03 01:21:57 -05:00