Skip to content

Commit 5e984da

Browse files
authored
Merge pull request #226 from Isrothy/mini-diff
feat: Support mini-diff
2 parents 9f7620f + a253653 commit 5e984da

File tree

8 files changed

+348
-183
lines changed

8 files changed

+348
-183
lines changed

README.md

Lines changed: 193 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -170,192 +170,203 @@ local AnnotationMode = {
170170
Line = "line", -- Highlight the background of the line on the minimap
171171
}
172172

173-
vim.g.neominimap ={
174-
-- Enable the plugin by default
175-
auto_enable = true, ---@type boolean
176-
177-
-- Log level
178-
log_level = vim.log.levels.OFF, ---@type Neominimap.Log.Levels
179-
180-
-- Notification level
181-
notification_level = vim.log.levels.INFO, ---@type Neominimap.Log.Levels
182-
183-
-- Path to the log file
184-
log_path = vim.fn.stdpath("data") .. "/neominimap.log", ---@type string
185-
186-
-- Minimap will not be created for buffers of these types
187-
---@type string[]
188-
exclude_filetypes = {
189-
"help",
190-
"bigfile", -- For Snacks.nvim
191-
},
192-
193-
-- Minimap will not be created for buffers of these types
194-
---@type string[]
195-
exclude_buftypes = {
196-
"nofile",
197-
"nowrite",
198-
"quickfix",
199-
"terminal",
200-
"prompt",
201-
},
202-
203-
-- When false is returned, the minimap will not be created for this buffer
204-
---@type fun(bufnr: integer): boolean
205-
buf_filter = function()
206-
return true
207-
end,
208-
209-
-- When false is returned, the minimap will not be created for this window
210-
---@type fun(winid: integer): boolean
211-
win_filter = function()
212-
return true
213-
end,
214-
215-
-- When false is returned, the minimap will not be created for this tab
216-
---@type fun(tabid: integer): boolean
217-
tab_filter = function()
218-
return true
219-
end,
220-
221-
222-
-- How many columns a dot should span
223-
x_multiplier = 4, ---@type integer
224-
225-
-- How many rows a dot should span
226-
y_multiplier = 1, ---@type integer
227-
228-
---@alias Neominimap.Config.LayoutType "split" | "float"
229-
230-
--- Either `split` or `float`
231-
--- When layout is set to `float`,
232-
--- the minimap will be created in floating windows attached to all suitable windows
233-
--- When layout is set to `split`,
234-
--- the minimap will be created in one split window
235-
layout = "float", ---@type Neominimap.Config.LayoutType
236-
237-
--- Used when `layout` is set to `split`
238-
split = {
239-
minimap_width = 20, ---@type integer
240-
241-
-- Always fix the width of the split window
242-
fix_width = false, ---@type boolean
243-
244-
-- split mode:
245-
-- left is an alias for topleft - leftmost vertical split, full height
246-
-- right is an alias for botright - rightmost vertical split, full height
247-
-- aboveleft - left split in current window
248-
-- rightbelow - right split in current window
249-
---@alias Neominimap.Config.SplitDirection "left" | "right" |
250-
--- "topleft" | "botright" | "aboveleft" | "rightbelow"
251-
direction = "right", ---@type Neominimap.Config.SplitDirection
252-
253-
---Automatically close the split window when it is the last window
254-
close_if_last_window = false, ---@type boolean
255-
},
256-
257-
--- Used when `layout` is set to `float`
258-
float = {
259-
minimap_width = 20, ---@type integer
260-
261-
--- If set to nil, there is no maximum height restriction
262-
--- @type integer
263-
max_minimap_height = nil,
264-
265-
margin = {
266-
right = 0, ---@type integer
267-
top = 0, ---@type integer
268-
bottom = 0, ---@type integer
173+
vim.g.neominimap = {
174+
-- Enable the plugin by default
175+
auto_enable = true, ---@type boolean
176+
177+
-- Log level
178+
log_level = vim.log.levels.OFF, ---@type Neominimap.Log.Levels
179+
180+
-- Notification level
181+
notification_level = vim.log.levels.INFO, ---@type Neominimap.Log.Levels
182+
183+
-- Path to the log file
184+
log_path = vim.fn.stdpath("data") .. "/neominimap.log", ---@type string
185+
186+
-- Minimap will not be created for buffers of these types
187+
---@type string[]
188+
exclude_filetypes = {
189+
"help",
190+
"bigfile", -- For Snacks.nvim
191+
},
192+
193+
-- Minimap will not be created for buffers of these types
194+
---@type string[]
195+
exclude_buftypes = {
196+
"nofile",
197+
"nowrite",
198+
"quickfix",
199+
"terminal",
200+
"prompt",
201+
},
202+
203+
-- When false is returned, the minimap will not be created for this buffer
204+
---@type fun(bufnr: integer): boolean
205+
buf_filter = function()
206+
return true
207+
end,
208+
209+
-- When false is returned, the minimap will not be created for this window
210+
---@type fun(winid: integer): boolean
211+
win_filter = function()
212+
return true
213+
end,
214+
215+
-- When false is returned, the minimap will not be created for this tab
216+
---@type fun(tabid: integer): boolean
217+
tab_filter = function()
218+
return true
219+
end,
220+
221+
222+
-- How many columns a dot should span
223+
x_multiplier = 4, ---@type integer
224+
225+
-- How many rows a dot should span
226+
y_multiplier = 1, ---@type integer
227+
228+
---@alias Neominimap.Config.LayoutType "split" | "float"
229+
230+
--- Either `split` or `float`
231+
--- When layout is set to `float`,
232+
--- the minimap will be created in floating windows attached to all suitable windows
233+
--- When layout is set to `split`,
234+
--- the minimap will be created in one split window
235+
layout = "float", ---@type Neominimap.Config.LayoutType
236+
237+
--- Used when `layout` is set to `split`
238+
split = {
239+
minimap_width = 20, ---@type integer
240+
241+
-- Always fix the width of the split window
242+
fix_width = false, ---@type boolean
243+
244+
-- split mode:
245+
-- left is an alias for topleft - leftmost vertical split, full height
246+
-- right is an alias for botright - rightmost vertical split, full height
247+
-- aboveleft - left split in current window
248+
-- rightbelow - right split in current window
249+
---@alias Neominimap.Config.SplitDirection "left" | "right" |
250+
--- "topleft" | "botright" | "aboveleft" | "rightbelow"
251+
direction = "right", ---@type Neominimap.Config.SplitDirection
252+
253+
---Automatically close the split window when it is the last window
254+
close_if_last_window = false, ---@type boolean
255+
},
256+
257+
--- Used when `layout` is set to `float`
258+
float = {
259+
minimap_width = 20, ---@type integer
260+
261+
--- If set to nil, there is no maximum height restriction
262+
--- @type integer
263+
max_minimap_height = nil,
264+
265+
margin = {
266+
right = 0, ---@type integer
267+
top = 0, ---@type integer
268+
bottom = 0, ---@type integer
269+
},
270+
z_index = 1, ---@type integer
271+
272+
--- Border style of the floating window.
273+
--- Accepts all usual border style options (e.g., "single", "double")
274+
--- @type string | string[] | [string, string][]
275+
window_border = "single",
269276
},
270-
z_index = 1, ---@type integer
271-
272-
--- Border style of the floating window.
273-
--- Accepts all usual border style options (e.g., "single", "double")
274-
--- @type string | string[] | [string, string][]
275-
window_border = "single",
276-
},
277-
278-
-- For performance issue, when text changed,
279-
-- minimap is refreshed after a certain delay
280-
-- Set the delay in milliseconds
281-
delay = 200, ---@type integer
282-
283-
-- Sync the cursor position with the minimap
284-
sync_cursor = true, ---@type boolean
285-
286-
click = {
287-
-- Enable mouse click on minimap
288-
enabled = false, ---@type boolean
289-
-- Automatically switch focus to minimap when clicked
290-
auto_switch_focus = true, ---@type boolean
291-
},
292-
293-
diagnostic = {
294-
enabled = true, ---@type boolean
295-
severity = vim.diagnostic.severity.WARN, ---@type vim.diagnostic.SeverityInt
296-
mode = "line", ---@type Neominimap.Handler.Annotation.Mode
297-
priority = {
298-
ERROR = 100, ---@type integer
299-
WARN = 90, ---@type integer
300-
INFO = 80, ---@type integer
301-
HINT = 70, ---@type integer
277+
278+
-- For performance issue, when text changed,
279+
-- minimap is refreshed after a certain delay
280+
-- Set the delay in milliseconds
281+
delay = 200, ---@type integer
282+
283+
-- Sync the cursor position with the minimap
284+
sync_cursor = true, ---@type boolean
285+
286+
click = {
287+
-- Enable mouse click on minimap
288+
enabled = false, ---@type boolean
289+
-- Automatically switch focus to minimap when clicked
290+
auto_switch_focus = true, ---@type boolean
302291
},
303-
icon = {
304-
ERROR = "󰅚 ", ---@type string
305-
WARN = "󰀪 ", ---@type string
306-
INFO = "󰌶 ", ---@type string
307-
HINT = "", ---@type string
292+
293+
diagnostic = {
294+
enabled = true, ---@type boolean
295+
severity = vim.diagnostic.severity.WARN, ---@type vim.diagnostic.SeverityInt
296+
mode = "line", ---@type Neominimap.Handler.Annotation.Mode
297+
priority = {
298+
ERROR = 100, ---@type integer
299+
WARN = 90, ---@type integer
300+
INFO = 80, ---@type integer
301+
HINT = 70, ---@type integer
302+
},
303+
icon = {
304+
ERROR = "󰅚 ", ---@type string
305+
WARN = "󰀪 ", ---@type string
306+
INFO = "󰌶 ", ---@type string
307+
HINT = "", ---@type string
308+
},
308309
},
309-
},
310-
311-
git = {
312-
enabled = true, ---@type boolean
313-
mode = "sign", ---@type Neominimap.Handler.Annotation.Mode
314-
priority = 6, ---@type integer
315-
icon = {
316-
add = "+ ", ---@type string
317-
change = "~ ", ---@type string
318-
delete = "- ", ---@type string
310+
311+
git = {
312+
enabled = true, ---@type boolean
313+
mode = "sign", ---@type Neominimap.Handler.Annotation.Mode
314+
priority = 6, ---@type integer
315+
icon = {
316+
add = "+ ", ---@type string
317+
change = "~ ", ---@type string
318+
delete = "- ", ---@type string
319+
},
319320
},
320-
},
321-
322-
search = {
323-
enabled = false, ---@type boolean
324-
mode = "line", ---@type Neominimap.Handler.Annotation.Mode
325-
priority = 20, ---@type integer
326-
icon = "󰱽 ", ---@type string
327-
},
328-
329-
treesitter = {
330-
enabled = true, ---@type boolean
331-
priority = 200, ---@type integer
332-
},
333-
334-
mark = {
335-
enabled = false, ---@type boolean
336-
mode = "icon", ---@type Neominimap.Handler.Annotation.Mode
337-
priority = 10, ---@type integer
338-
key = "m", ---@type string
339-
show_builtins = false, ---@type boolean -- shows the builtin marks like [ ] < >
340-
},
341-
342-
fold = {
343-
-- Considering fold when rendering minimap
344-
enabled = true, ---@type boolean
345-
},
346-
347-
---Overrite the default winopt
348-
---@param opt vim.wo
349-
---@param winid integer the window id of the source window, NOT minimap window
350-
winopt = function(opt, winid) end,
351-
352-
---Overrite the default bufopt
353-
---@param opt vim.bo
354-
---@param bufnr integer the buffer id of the source buffer, NOT minimap buffer
355-
bufopt = function(opt, bufnr) end,
356-
357-
---@type Neominimap.Map.Handler[]
358-
handlers = {},
321+
322+
mini_diff = {
323+
enabled = false, ---@type boolean
324+
mode = "sign", ---@type Neominimap.Handler.Annotation.Mode
325+
priority = 6, ---@type integer
326+
icon = {
327+
add = "+ ", ---@type string
328+
change = "~ ", ---@type string
329+
delete = "- ", ---@type string
330+
},
331+
},
332+
333+
search = {
334+
enabled = false, ---@type boolean
335+
mode = "line", ---@type Neominimap.Handler.Annotation.Mode
336+
priority = 20, ---@type integer
337+
icon = "󰱽 ", ---@type string
338+
},
339+
340+
treesitter = {
341+
enabled = true, ---@type boolean
342+
priority = 200, ---@type integer
343+
},
344+
345+
mark = {
346+
enabled = false, ---@type boolean
347+
mode = "icon", ---@type Neominimap.Handler.Annotation.Mode
348+
priority = 10, ---@type integer
349+
key = "m", ---@type string
350+
show_builtins = false, ---@type boolean -- shows the builtin marks like [ ] < >
351+
},
352+
353+
fold = {
354+
-- Considering fold when rendering minimap
355+
enabled = true, ---@type boolean
356+
},
357+
358+
---Overrite the default winopt
359+
---@param opt vim.wo
360+
---@param winid integer the window id of the source window, NOT minimap window
361+
winopt = function(opt, winid) end,
362+
363+
---Overrite the default bufopt
364+
---@param opt vim.bo
365+
---@param bufnr integer the buffer id of the source buffer, NOT minimap buffer
366+
bufopt = function(opt, bufnr) end,
367+
368+
---@type Neominimap.Map.Handler[]
369+
handlers = {},
359370
}
360371
```
361372

0 commit comments

Comments
 (0)