Skip to content

Commit 2177e42

Browse files
committed
Remove folke/snacks.nvim dependency and refactor UI logic to native nvim_open_win.
1 parent de4ccaf commit 2177e42

File tree

5 files changed

+21
-32
lines changed

5 files changed

+21
-32
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Works great for: “show me the last N commits, let me pick one (or two) and ope
2222
- Git available on your `$PATH`
2323
- Dependencies:
2424
- [sindrets/diffview.nvim]
25-
- [folke/snacks.nvim]
2625

2726
## Installation
2827

@@ -36,7 +35,6 @@ Works great for: “show me the last N commits, let me pick one (or two) and ope
3635
main = "gitlogdiff",
3736
dependencies = {
3837
"sindrets/diffview.nvim",
39-
"folke/snacks.nvim",
4038
},
4139
cmd = "GitLogDiff",
4240
opts = { max_count = 300 },
@@ -52,7 +50,6 @@ use({
5250
"Salanoid/gitlogdiff.nvim",
5351
requires = {
5452
"sindrets/diffview.nvim",
55-
"folke/snacks.nvim",
5653
},
5754
config = function()
5855
require("gitlogdiff").setup({
@@ -87,12 +84,10 @@ require("gitlogdiff").setup({
8784

8885
## Roadmap / Notes
8986

90-
- Remove snacks as a dependency.
9187
- Should work with other diff viwers plugins for example with: [esmuellert/codediff.nvim]: https://github.com/esmuellert/codediff.nvim
9288

9389
## License
9490

9591
MIT — see [LICENSE](./LICENSE).
9692

9793
[sindrets/diffview.nvim]: https://github.com/sindrets/diffview.nvim
98-
[folke/snacks.nvim]: https://github.com/folke/snacks.nvim

doc/gitlogdiff.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ A tiny Neovim plugin that shows a simple, keyboard‑driven list of recent Git c
99

1010
Works great for: “show me the last N commits, let me pick one (or two) and open the diff”.
1111

12+
!Preview
13+
1214

1315
==============================================================================
1416
FEATURES *gitlogdiff-features*
@@ -29,7 +31,6 @@ REQUIREMENTS *gitlogdiff-requirements*
2931
- Git available on your $PATH
3032
- Dependencies:
3133
- sindrets/diffview.nvim
32-
- folke/snacks.nvim
3334

3435

3536
==============================================================================
@@ -47,7 +48,6 @@ lazy.nvim *gitlogdiff-lazy.nvim*
4748
main = "gitlogdiff",
4849
dependencies = {
4950
"sindrets/diffview.nvim",
50-
"folke/snacks.nvim",
5151
},
5252
cmd = "GitLogDiff",
5353
opts = { max_count = 300 },
@@ -64,7 +64,6 @@ use({
6464
"Salanoid/gitlogdiff.nvim",
6565
requires = {
6666
"sindrets/diffview.nvim",
67-
"folke/snacks.nvim",
6867
},
6968
config = function()
7069
require("gitlogdiff").setup({
@@ -111,7 +110,7 @@ TROUBLESHOOTING *gitlogdiff-troubleshooting*
111110
ROADMAP / NOTES *gitlogdiff-roadmap-notes*
112111

113112

114-
- Currently, selecting two commits diffs A..B. Selecting more than two is not supported and may yield unexpected results.
113+
- Should work with other diff viwers plugins for example with: esmuellert/codediff.nvim: https://github.com/esmuellert/codediff.nvim
115114

116115

117116
==============================================================================
@@ -121,6 +120,5 @@ LICENSE *gitlogdiff-license*
121120
MIT — see LICENSE.
122121

123122
sindrets/diffview.nvim: https://github.com/sindrets/diffview.nvim
124-
folke/snacks.nvim: https://github.com/folke/snacks.nvim
125123

126124
vim:tw=78:ts=8:ft=help:norl:

lua/gitlogdiff/docs.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ function M.suggested()
88
main = "gitlogdiff",
99
dependencies = {
1010
"sindrets/diffview.nvim",
11-
"folke/snacks.nvim",
1211
},
1312
cmd = "GitLogDiff",
1413
opts = { max_count = 300 },
@@ -26,7 +25,6 @@ function M.update()
2625
main = "gitlogdiff",
2726
dependencies = {
2827
"sindrets/diffview.nvim",
29-
"folke/snacks.nvim",
3028
},
3129
cmd = "GitLogDiff",
3230
opts = { max_count = 300 },

lua/gitlogdiff/ui.lua

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
local api = vim.api
2-
local snacks = require("snacks")
3-
42
local M = {}
53

64
M.state = {
@@ -22,14 +20,23 @@ function M.open(commits)
2220
vim.bo[M.state.buf].swapfile = false
2321
vim.bo[M.state.buf].filetype = "gitlogdiff"
2422

25-
M.state.win_obj = snacks.win({
26-
buf = M.state.buf,
27-
width = 90,
28-
height = math.min(#commits + 2, 30),
29-
title = "Git Commits",
23+
local width = 90
24+
local height = math.min(#commits + 2, 30)
25+
local row = math.floor((vim.o.lines - height) / 2)
26+
local col = math.floor((vim.o.columns - width) / 2)
27+
28+
M.state.win = api.nvim_open_win(M.state.buf, true, {
29+
relative = "editor",
30+
width = width,
31+
height = height,
32+
row = row,
33+
col = col,
34+
style = "minimal",
3035
border = "rounded",
36+
title = "Git Commits",
37+
title_pos = "center",
3138
})
32-
M.state.win = M.state.win_obj.win
39+
3340
vim.wo[M.state.win].cursorline = true
3441

3542
M.render()
@@ -87,7 +94,9 @@ function M.keymaps()
8794
end, opts)
8895

8996
vim.keymap.set("n", "q", function()
90-
M.state.win_obj:close()
97+
if M.state.win and api.nvim_win_is_valid(M.state.win) then
98+
api.nvim_win_close(M.state.win, true)
99+
end
91100
end, opts)
92101
end
93102

tests/test_ui.lua

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
local T = MiniTest.new_set()
22

3-
package.loaded["snacks"] = {
4-
win = function(opts)
5-
local win = vim.api.nvim_get_current_win()
6-
vim.api.nvim_win_set_buf(win, opts.buf)
7-
return {
8-
win = win,
9-
close = function() end,
10-
}
11-
end,
12-
}
13-
143
T.before_each = function()
154
package.loaded["gitlogdiff.ui"] = nil
165
end

0 commit comments

Comments
 (0)