Skip to content

Commit 2c2a4a7

Browse files
committed
initial commit
1 parent ebf390f commit 2c2a4a7

18 files changed

Lines changed: 453 additions & 6 deletions

File tree

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: StyLua
14+
uses: JohnnyMorganz/stylua-action@v4
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
args: --check .
18+
19+
tests:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Install Neovim
24+
uses: rhysd/action-setup-vim@v1
25+
with:
26+
neovim: true
27+
version: stable
28+
- name: Run tests
29+
run: ./scripts/test

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.log
2+
/.repro
3+
/.tests
4+
/build
5+
/debug
6+
/doc/tags
7+
foo.*
8+
node_modules
9+
tt.*

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# gitlogdiff.nvim
22

3+
[![CI](https://github.com/Salanoid/gitlogdiff.nvim/actions/workflows/ci.yml/badge.svg)](https://github.com/Salanoid/gitlogdiff.nvim/actions/workflows/ci.yml)
4+
35
A tiny Neovim plugin that shows a simple, keyboard‑driven list of recent Git commits and lets you diff them quickly via Diffview.
46

57
Works great for: “show me the last N commits, let me pick one (or two) and open the diff”.
@@ -24,6 +26,8 @@ Works great for: “show me the last N commits, let me pick one (or two) and ope
2426

2527
### lazy.nvim
2628

29+
<!-- suggested:start -->
30+
2731
```lua
2832
{
2933
"Salanoid/gitlogdiff.nvim",
@@ -35,9 +39,10 @@ Works great for: “show me the last N commits, let me pick one (or two) and ope
3539
cmd = "GitLogDiff",
3640
opts = { max_count = 300 },
3741
}
38-
3942
```
4043

44+
<!-- suggested:end -->
45+
4146
### packer.nvim
4247

4348
```lua

doc/gitlogdiff.txt

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
*gitlogdiff.txt* Recent Git commits and diffs
2+
3+
==============================================================================
4+
INTRODUCTION *gitlogdiff-intro*
5+
6+
7+
8+
A tiny Neovim plugin that shows a simple, keyboard‑driven list of recent Git commits and lets you diff them quickly via Diffview.
9+
10+
Works great for: “show me the last N commits, let me pick one (or two) and open the diff”.
11+
12+
13+
==============================================================================
14+
FEATURES *gitlogdiff-features*
15+
16+
17+
- Lists recent commits using git log (configurable max_count)
18+
- Toggle selection with space, navigate with j/k
19+
- Press Enter to open diffs in diffview.nvim
20+
- 1 selected commit → diff that commit against its parent (<hash>^..<hash>)
21+
- 2 selected commits → diff between the two commits
22+
23+
24+
==============================================================================
25+
REQUIREMENTS *gitlogdiff-requirements*
26+
27+
28+
- Neovim ≥ 0.10 (uses vim.system)
29+
- Git available on your $PATH
30+
- Dependencies:
31+
- sindrets/diffview.nvim
32+
- folke/snacks.nvim
33+
34+
35+
==============================================================================
36+
INSTALLATION *gitlogdiff-installation*
37+
38+
39+
40+
lazy.nvim *gitlogdiff-lazy.nvim*
41+
42+
43+
44+
>
45+
{
46+
"Salanoid/gitlogdiff.nvim",
47+
main = "gitlogdiff",
48+
dependencies = {
49+
"sindrets/diffview.nvim",
50+
"folke/snacks.nvim",
51+
},
52+
cmd = "GitLogDiff",
53+
opts = { max_count = 300 },
54+
}
55+
<
56+
57+
58+
59+
packer.nvim *gitlogdiff-packer.nvim*
60+
61+
62+
>
63+
use({
64+
"Salanoid/gitlogdiff.nvim",
65+
requires = {
66+
"sindrets/diffview.nvim",
67+
"folke/snacks.nvim",
68+
},
69+
config = function()
70+
require("gitlogdiff").setup({
71+
max_count = 300,
72+
})
73+
end,
74+
})
75+
<
76+
77+
Note: This plugin defines the :GitLogDiff command on load. If your plugin manager pre-defines lazy command stubs, gitlogdiff.nvim will safely overwrite them (we create the command with force = true).
78+
79+
80+
==============================================================================
81+
USAGE *gitlogdiff-usage*
82+
83+
84+
- Run :GitLogDiff inside a Git repository
85+
- Navigate with j/k
86+
- Toggle selection with <space>
87+
- Press <CR> to open diffs in Diffview
88+
- Press q to close the list
89+
90+
91+
==============================================================================
92+
CONFIGURATION *gitlogdiff-configuration*
93+
94+
95+
>
96+
require("gitlogdiff").setup({
97+
max_count = 300, -- how many commits to list
98+
})
99+
<
100+
101+
102+
==============================================================================
103+
TROUBLESHOOTING *gitlogdiff-troubleshooting*
104+
105+
106+
- “No git commits found”: you are likely not in a Git repo (or max_count is 0)
107+
- “git log failed …”: check that git is installed and available in $PATH
108+
109+
110+
==============================================================================
111+
ROADMAP / NOTES *gitlogdiff-roadmap-notes*
112+
113+
114+
- Currently, selecting two commits diffs A..B. Selecting more than two is not supported and may yield unexpected results.
115+
116+
117+
==============================================================================
118+
LICENSE *gitlogdiff-license*
119+
120+
121+
MIT — see LICENSE.
122+
123+
sindrets/diffview.nvim: https://github.com/sindrets/diffview.nvim
124+
folke/snacks.nvim: https://github.com/folke/snacks.nvim
125+
126+
vim:tw=78:ts=8:ft=help:norl:
File renamed without changes.

lua/gitlogdiff/docs.lua

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
local Docs = require("lazy.docs")
2+
3+
local M = {}
4+
5+
function M.suggested()
6+
return {
7+
"Salanoid/gitlogdiff.nvim",
8+
main = "gitlogdiff",
9+
dependencies = {
10+
"sindrets/diffview.nvim",
11+
"folke/snacks.nvim",
12+
},
13+
cmd = "GitLogDiff",
14+
opts = { max_count = 300 },
15+
}
16+
end
17+
18+
function M.update()
19+
local name = "gitlogdiff"
20+
21+
-- Update README.md
22+
Docs.save({
23+
suggested = {
24+
content = [[{
25+
"Salanoid/gitlogdiff.nvim",
26+
main = "gitlogdiff",
27+
dependencies = {
28+
"sindrets/diffview.nvim",
29+
"folke/snacks.nvim",
30+
},
31+
cmd = "GitLogDiff",
32+
opts = { max_count = 300 },
33+
}]],
34+
lang = "lua",
35+
},
36+
})
37+
38+
-- Generate Vimdocs
39+
local readme = vim.fn.readfile("README.md")
40+
local lines = {}
41+
42+
table.insert(lines, "*" .. name .. ".txt* Recent Git commits and diffs")
43+
table.insert(lines, "")
44+
table.insert(lines, "==============================================================================")
45+
table.insert(lines, "INTRODUCTION *" .. name .. "-intro*")
46+
table.insert(lines, "")
47+
48+
local in_code_block = false
49+
for _, line in ipairs(readme) do
50+
if line:find("^<!%-%-") then
51+
-- Skip HTML comments
52+
elseif line:find("^```") then
53+
in_code_block = not in_code_block
54+
table.insert(lines, in_code_block and ">" or "<")
55+
elseif line:find("^%s*# ") then
56+
-- Skip
57+
elseif line:find("^%s*%[!%[") then
58+
-- Skip badges
59+
elseif line:find("^## ") then
60+
local title = line:match("^## (.*)")
61+
local tag = "*" .. name .. "-" .. title:lower():gsub("[%s/]+", "-"):gsub("%-+$", "") .. "*"
62+
table.insert(lines, "")
63+
table.insert(lines, "==============================================================================")
64+
table.insert(lines, title:upper() .. string.rep(" ", 78 - #title - #tag) .. tag)
65+
table.insert(lines, "")
66+
elseif line:find("^### ") then
67+
local title = line:match("^### (.*)")
68+
local tag = "*" .. name .. "-" .. title:lower():gsub("[%s/]+", "-"):gsub("%-+$", "") .. "*"
69+
table.insert(lines, "")
70+
table.insert(lines, title .. string.rep(" ", 78 - #title - #tag) .. tag)
71+
table.insert(lines, "")
72+
else
73+
if not in_code_block then
74+
line = line:gsub("%%", "%%%%")
75+
line = line:gsub("%[(.-)%]%(.-%)", "%1")
76+
line = line:gsub("%[(.-)%]", "%1")
77+
line = line:gsub("`(.-)`", "%1")
78+
end
79+
table.insert(lines, line)
80+
end
81+
end
82+
83+
table.insert(lines, "")
84+
table.insert(lines, " vim:tw=78:ts=8:ft=help:norl:")
85+
86+
vim.fn.mkdir("doc", "p")
87+
vim.fn.writefile(lines, "doc/" .. name .. ".txt")
88+
end
89+
90+
M.update()
91+
92+
return M

init.lua renamed to lua/gitlogdiff/init.lua

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,4 @@ function M.open()
1818
end)
1919
end
2020

21-
vim.api.nvim_create_user_command("GitLogDiff", M.open, {
22-
force = true,
23-
desc = "Open a picker to select commits and diff them",
24-
})
25-
2621
return M
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)