fix: pre-release cleanup for v0.2.0 (#102)
## Problem Three minor issues remain before the v0.2.0 release: 1. Git quotes filenames containing spaces, unicode, or special characters in the fugitive status buffer. `parse_file_line` passed the quotes through verbatim, causing file-not-found errors on diff operations. 2. Navigation wrap-around in both conflict and merge modules was silent, giving no indication when jumping past the last/first item back to the beginning/end. 3. `resolved_hunks` and `(resolved)` virtual text in the merge module persisted across buffer re-reads, showing stale markers for hunks that were no longer resolved. ## Solution 1. Add an `unquote()` helper to fugitive.lua that strips surrounding quotes and unescapes `\\`, `\"`, `\n`, `\t`, and octal `\NNN` sequences. Applied to both return paths in `parse_file_line`. 2. Add `vim.notify` before the wrap-around jump in all four navigation functions (`goto_next`/`goto_prev` in conflict.lua and merge.lua). 3. Clear `resolved_hunks[bufnr]` and the merge namespace at the top of `setup_keymaps` so each buffer init starts fresh. Closes #66
This commit is contained in:
parent
b5d28e9f2b
commit
35067151e4
11 changed files with 393 additions and 931 deletions
|
|
@ -20,8 +20,6 @@ local attached_buffers = {}
|
|||
---@type table<integer, boolean>
|
||||
local diagnostics_suppressed = {}
|
||||
|
||||
local PRIORITY_LINE_BG = 200
|
||||
|
||||
---@param lines string[]
|
||||
---@return diffs.ConflictRegion[]
|
||||
function M.parse(lines)
|
||||
|
|
@ -114,7 +112,7 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = region.marker_ours + 1,
|
||||
hl_group = 'DiffsConflictMarker',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
|
||||
if config.show_virtual_text then
|
||||
|
|
@ -156,11 +154,11 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = line + 1,
|
||||
hl_group = 'DiffsConflictOurs',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, line, 0, {
|
||||
number_hl_group = 'DiffsConflictOursNr',
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
@ -169,7 +167,7 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = region.marker_base + 1,
|
||||
hl_group = 'DiffsConflictMarker',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
|
||||
for line = region.base_start, region.base_end - 1 do
|
||||
|
|
@ -177,11 +175,11 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = line + 1,
|
||||
hl_group = 'DiffsConflictBase',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, line, 0, {
|
||||
number_hl_group = 'DiffsConflictBaseNr',
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
@ -190,7 +188,7 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = region.marker_sep + 1,
|
||||
hl_group = 'DiffsConflictMarker',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
|
||||
for line = region.theirs_start, region.theirs_end - 1 do
|
||||
|
|
@ -198,11 +196,11 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = line + 1,
|
||||
hl_group = 'DiffsConflictTheirs',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, line, 0, {
|
||||
number_hl_group = 'DiffsConflictTheirsNr',
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
@ -210,7 +208,7 @@ local function apply_highlights(bufnr, regions, config)
|
|||
end_row = region.marker_theirs + 1,
|
||||
hl_group = 'DiffsConflictMarker',
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = config.priority,
|
||||
})
|
||||
|
||||
if config.show_virtual_text then
|
||||
|
|
@ -364,6 +362,7 @@ function M.goto_next(bufnr)
|
|||
return
|
||||
end
|
||||
end
|
||||
vim.notify('[diffs.nvim]: wrapped to first conflict', vim.log.levels.INFO)
|
||||
vim.api.nvim_win_set_cursor(0, { regions[1].marker_ours + 1, 0 })
|
||||
end
|
||||
|
||||
|
|
@ -381,6 +380,7 @@ function M.goto_prev(bufnr)
|
|||
return
|
||||
end
|
||||
end
|
||||
vim.notify('[diffs.nvim]: wrapped to last conflict', vim.log.levels.INFO)
|
||||
vim.api.nvim_win_set_cursor(0, { regions[#regions].marker_ours + 1, 0 })
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -26,17 +26,62 @@ function M.get_section_at_line(bufnr, lnum)
|
|||
return nil
|
||||
end
|
||||
|
||||
---@param s string
|
||||
---@return string
|
||||
local function unquote(s)
|
||||
if s:sub(1, 1) ~= '"' then
|
||||
return s
|
||||
end
|
||||
local inner = s:sub(2, -2)
|
||||
local result = {}
|
||||
local i = 1
|
||||
while i <= #inner do
|
||||
if inner:sub(i, i) == '\\' and i < #inner then
|
||||
local next_char = inner:sub(i + 1, i + 1)
|
||||
if next_char == 'n' then
|
||||
table.insert(result, '\n')
|
||||
i = i + 2
|
||||
elseif next_char == 't' then
|
||||
table.insert(result, '\t')
|
||||
i = i + 2
|
||||
elseif next_char == '"' then
|
||||
table.insert(result, '"')
|
||||
i = i + 2
|
||||
elseif next_char == '\\' then
|
||||
table.insert(result, '\\')
|
||||
i = i + 2
|
||||
elseif next_char:match('%d') then
|
||||
local oct = inner:match('^(%d%d%d)', i + 1)
|
||||
if oct then
|
||||
table.insert(result, string.char(tonumber(oct, 8)))
|
||||
i = i + 4
|
||||
else
|
||||
table.insert(result, next_char)
|
||||
i = i + 2
|
||||
end
|
||||
else
|
||||
table.insert(result, next_char)
|
||||
i = i + 2
|
||||
end
|
||||
else
|
||||
table.insert(result, inner:sub(i, i))
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return table.concat(result)
|
||||
end
|
||||
|
||||
---@param line string
|
||||
---@return string?, string?, string?
|
||||
local function parse_file_line(line)
|
||||
local old, new = line:match('^R%d*%s+(.-)%s+->%s+(.+)$')
|
||||
if old and new then
|
||||
return vim.trim(new), vim.trim(old), 'R'
|
||||
return unquote(vim.trim(new)), unquote(vim.trim(old)), 'R'
|
||||
end
|
||||
|
||||
local status, filename = line:match('^([MADRCU?])[MADRCU%s]*%s+(.+)$')
|
||||
if status and filename then
|
||||
return vim.trim(filename), nil, status
|
||||
return unquote(vim.trim(filename)), nil, status
|
||||
end
|
||||
|
||||
return nil, nil, nil
|
||||
|
|
|
|||
|
|
@ -3,38 +3,6 @@ local M = {}
|
|||
local dbg = require('diffs.log').dbg
|
||||
local diff = require('diffs.diff')
|
||||
|
||||
---@param filepath string
|
||||
---@param from_line integer
|
||||
---@param count integer
|
||||
---@return string[]
|
||||
local function read_line_range(filepath, from_line, count)
|
||||
if count <= 0 then
|
||||
return {}
|
||||
end
|
||||
local f = io.open(filepath, 'r')
|
||||
if not f then
|
||||
return {}
|
||||
end
|
||||
local result = {}
|
||||
local line_num = 0
|
||||
for line in f:lines() do
|
||||
line_num = line_num + 1
|
||||
if line_num >= from_line then
|
||||
table.insert(result, line)
|
||||
if #result >= count then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
return result
|
||||
end
|
||||
|
||||
local PRIORITY_CLEAR = 198
|
||||
local PRIORITY_SYNTAX = 199
|
||||
local PRIORITY_LINE_BG = 200
|
||||
local PRIORITY_CHAR_BG = 201
|
||||
|
||||
---@param bufnr integer
|
||||
---@param ns integer
|
||||
---@param hunk diffs.Hunk
|
||||
|
|
@ -42,8 +10,9 @@ local PRIORITY_CHAR_BG = 201
|
|||
---@param text string
|
||||
---@param lang string
|
||||
---@param context_lines? string[]
|
||||
---@param priorities diffs.PrioritiesConfig
|
||||
---@return integer
|
||||
local function highlight_text(bufnr, ns, hunk, col_offset, text, lang, context_lines)
|
||||
local function highlight_text(bufnr, ns, hunk, col_offset, text, lang, context_lines, priorities)
|
||||
local parse_text = text
|
||||
if context_lines and #context_lines > 0 then
|
||||
parse_text = text .. '\n' .. table.concat(context_lines, '\n')
|
||||
|
|
@ -77,7 +46,7 @@ local function highlight_text(bufnr, ns, hunk, col_offset, text, lang, context_l
|
|||
local buf_sc = col_offset + sc
|
||||
local buf_ec = col_offset + ec
|
||||
|
||||
local priority = lang == 'diff' and (tonumber(metadata.priority) or 100) or PRIORITY_SYNTAX
|
||||
local priority = lang == 'diff' and (tonumber(metadata.priority) or 100) or priorities.syntax
|
||||
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_sr, buf_sc, {
|
||||
end_row = buf_er,
|
||||
|
|
@ -103,6 +72,7 @@ end
|
|||
---@param line_map table<integer, integer>
|
||||
---@param col_offset integer
|
||||
---@param covered_lines? table<integer, true>
|
||||
---@param priorities diffs.PrioritiesConfig
|
||||
---@return integer
|
||||
local function highlight_treesitter(
|
||||
bufnr,
|
||||
|
|
@ -111,7 +81,8 @@ local function highlight_treesitter(
|
|||
lang,
|
||||
line_map,
|
||||
col_offset,
|
||||
covered_lines
|
||||
covered_lines,
|
||||
priorities
|
||||
)
|
||||
local code = table.concat(code_lines, '\n')
|
||||
if code == '' then
|
||||
|
|
@ -152,7 +123,7 @@ local function highlight_treesitter(
|
|||
local buf_ec = ec + col_offset
|
||||
|
||||
local priority = tree_lang == 'diff' and (tonumber(metadata.priority) or 100)
|
||||
or PRIORITY_SYNTAX
|
||||
or priorities.syntax
|
||||
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_sr, buf_sc, {
|
||||
end_row = buf_er,
|
||||
|
|
@ -219,8 +190,17 @@ end
|
|||
---@param code_lines string[]
|
||||
---@param covered_lines? table<integer, true>
|
||||
---@param leading_offset? integer
|
||||
---@param priorities diffs.PrioritiesConfig
|
||||
---@return integer
|
||||
local function highlight_vim_syntax(bufnr, ns, hunk, code_lines, covered_lines, leading_offset)
|
||||
local function highlight_vim_syntax(
|
||||
bufnr,
|
||||
ns,
|
||||
hunk,
|
||||
code_lines,
|
||||
covered_lines,
|
||||
leading_offset,
|
||||
priorities
|
||||
)
|
||||
local ft = hunk.ft
|
||||
if not ft then
|
||||
return 0
|
||||
|
|
@ -267,7 +247,7 @@ local function highlight_vim_syntax(bufnr, ns, hunk, code_lines, covered_lines,
|
|||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, span.col_start, {
|
||||
end_col = span.col_end,
|
||||
hl_group = span.hl_name,
|
||||
priority = PRIORITY_SYNTAX,
|
||||
priority = priorities.syntax,
|
||||
})
|
||||
extmark_count = extmark_count + 1
|
||||
if covered_lines then
|
||||
|
|
@ -284,6 +264,7 @@ end
|
|||
---@param hunk diffs.Hunk
|
||||
---@param opts diffs.HunkOpts
|
||||
function M.highlight_hunk(bufnr, ns, hunk, opts)
|
||||
local p = opts.highlights.priorities
|
||||
local use_ts = hunk.lang and opts.highlights.treesitter.enabled
|
||||
local use_vim = not use_ts and hunk.ft and opts.highlights.vim.enabled
|
||||
|
||||
|
|
@ -303,21 +284,6 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
---@type table<integer, true>
|
||||
local covered_lines = {}
|
||||
|
||||
local ctx_cfg = opts.highlights.context
|
||||
local context = (ctx_cfg and ctx_cfg.enabled) and ctx_cfg.lines or 0
|
||||
local leading = {}
|
||||
local trailing = {}
|
||||
if (use_ts or use_vim) and context > 0 and hunk.file_new_start and hunk.repo_root then
|
||||
local filepath = vim.fs.joinpath(hunk.repo_root, hunk.filename)
|
||||
local lead_from = math.max(1, hunk.file_new_start - context)
|
||||
local lead_count = hunk.file_new_start - lead_from
|
||||
if lead_count > 0 then
|
||||
leading = read_line_range(filepath, lead_from, lead_count)
|
||||
end
|
||||
local trail_from = hunk.file_new_start + (hunk.file_new_count or 0)
|
||||
trailing = read_line_range(filepath, trail_from, context)
|
||||
end
|
||||
|
||||
local extmark_count = 0
|
||||
if use_ts then
|
||||
---@type string[]
|
||||
|
|
@ -329,11 +295,6 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
---@type table<integer, integer>
|
||||
local old_map = {}
|
||||
|
||||
for _, pad_line in ipairs(leading) do
|
||||
table.insert(new_code, pad_line)
|
||||
table.insert(old_code, pad_line)
|
||||
end
|
||||
|
||||
for i, line in ipairs(hunk.lines) do
|
||||
local prefix = line:sub(1, 1)
|
||||
local stripped = line:sub(2)
|
||||
|
|
@ -352,21 +313,17 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
end
|
||||
end
|
||||
|
||||
for _, pad_line in ipairs(trailing) do
|
||||
table.insert(new_code, pad_line)
|
||||
table.insert(old_code, pad_line)
|
||||
end
|
||||
|
||||
extmark_count = highlight_treesitter(bufnr, ns, new_code, hunk.lang, new_map, 1, covered_lines)
|
||||
extmark_count =
|
||||
highlight_treesitter(bufnr, ns, new_code, hunk.lang, new_map, 1, covered_lines, p)
|
||||
extmark_count = extmark_count
|
||||
+ highlight_treesitter(bufnr, ns, old_code, hunk.lang, old_map, 1, covered_lines)
|
||||
+ highlight_treesitter(bufnr, ns, old_code, hunk.lang, old_map, 1, covered_lines, p)
|
||||
|
||||
if hunk.header_context and hunk.header_context_col then
|
||||
local header_line = hunk.start_line - 1
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, header_line, hunk.header_context_col, {
|
||||
end_col = hunk.header_context_col + #hunk.header_context,
|
||||
hl_group = 'DiffsClear',
|
||||
priority = PRIORITY_CLEAR,
|
||||
priority = p.clear,
|
||||
})
|
||||
local header_extmarks = highlight_text(
|
||||
bufnr,
|
||||
|
|
@ -375,7 +332,8 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
hunk.header_context_col,
|
||||
hunk.header_context,
|
||||
hunk.lang,
|
||||
new_code
|
||||
new_code,
|
||||
p
|
||||
)
|
||||
if header_extmarks > 0 then
|
||||
dbg('header %s:%d applied %d extmarks', hunk.filename, hunk.start_line, header_extmarks)
|
||||
|
|
@ -385,16 +343,10 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
elseif use_vim then
|
||||
---@type string[]
|
||||
local code_lines = {}
|
||||
for _, pad_line in ipairs(leading) do
|
||||
table.insert(code_lines, pad_line)
|
||||
end
|
||||
for _, line in ipairs(hunk.lines) do
|
||||
table.insert(code_lines, line:sub(2))
|
||||
end
|
||||
for _, pad_line in ipairs(trailing) do
|
||||
table.insert(code_lines, pad_line)
|
||||
end
|
||||
extmark_count = highlight_vim_syntax(bufnr, ns, hunk, code_lines, covered_lines, #leading)
|
||||
extmark_count = highlight_vim_syntax(bufnr, ns, hunk, code_lines, covered_lines, 0, p)
|
||||
end
|
||||
|
||||
if
|
||||
|
|
@ -409,7 +361,7 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
header_map[i] = hunk.header_start_line - 1 + i
|
||||
end
|
||||
extmark_count = extmark_count
|
||||
+ highlight_treesitter(bufnr, ns, hunk.header_lines, 'diff', header_map, 0)
|
||||
+ highlight_treesitter(bufnr, ns, hunk.header_lines, 'diff', header_map, 0, nil, p)
|
||||
end
|
||||
|
||||
---@type diffs.IntraChanges?
|
||||
|
|
@ -467,7 +419,7 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 1, {
|
||||
end_col = line_len,
|
||||
hl_group = 'DiffsClear',
|
||||
priority = PRIORITY_CLEAR,
|
||||
priority = p.clear,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
@ -476,12 +428,12 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
end_row = buf_line + 1,
|
||||
hl_group = line_hl,
|
||||
hl_eol = true,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = p.line_bg,
|
||||
})
|
||||
if opts.highlights.gutter then
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
|
||||
number_hl_group = number_hl,
|
||||
priority = PRIORITY_LINE_BG,
|
||||
priority = p.line_bg,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
@ -501,7 +453,7 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
local ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, span.col_start, {
|
||||
end_col = span.col_end,
|
||||
hl_group = char_hl,
|
||||
priority = PRIORITY_CHAR_BG,
|
||||
priority = p.char_bg,
|
||||
})
|
||||
if not ok then
|
||||
dbg('char extmark FAILED: %s', err)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@
|
|||
---@field enabled boolean
|
||||
---@field lines integer
|
||||
|
||||
---@class diffs.PrioritiesConfig
|
||||
---@field clear integer
|
||||
---@field syntax integer
|
||||
---@field line_bg integer
|
||||
---@field char_bg integer
|
||||
|
||||
---@class diffs.Highlights
|
||||
---@field background boolean
|
||||
---@field gutter boolean
|
||||
|
|
@ -24,6 +30,7 @@
|
|||
---@field treesitter diffs.TreesitterConfig
|
||||
---@field vim diffs.VimConfig
|
||||
---@field intra diffs.IntraConfig
|
||||
---@field priorities diffs.PrioritiesConfig
|
||||
|
||||
---@class diffs.FugitiveConfig
|
||||
---@field horizontal string|false
|
||||
|
|
@ -43,6 +50,7 @@
|
|||
---@field show_virtual_text boolean
|
||||
---@field format_virtual_text? fun(side: string, keymap: string|false): string?
|
||||
---@field show_actions boolean
|
||||
---@field priority integer
|
||||
---@field keymaps diffs.ConflictKeymaps
|
||||
|
||||
---@class diffs.Config
|
||||
|
|
@ -121,6 +129,12 @@ local default_config = {
|
|||
algorithm = 'default',
|
||||
max_lines = 500,
|
||||
},
|
||||
priorities = {
|
||||
clear = 198,
|
||||
syntax = 199,
|
||||
line_bg = 200,
|
||||
char_bg = 201,
|
||||
},
|
||||
},
|
||||
fugitive = {
|
||||
horizontal = 'du',
|
||||
|
|
@ -131,6 +145,7 @@ local default_config = {
|
|||
disable_diagnostics = true,
|
||||
show_virtual_text = true,
|
||||
show_actions = false,
|
||||
priority = 200,
|
||||
keymaps = {
|
||||
ours = 'doo',
|
||||
theirs = 'dot',
|
||||
|
|
@ -328,6 +343,7 @@ local function init()
|
|||
['highlights.treesitter'] = { opts.highlights.treesitter, 'table', true },
|
||||
['highlights.vim'] = { opts.highlights.vim, 'table', true },
|
||||
['highlights.intra'] = { opts.highlights.intra, 'table', true },
|
||||
['highlights.priorities'] = { opts.highlights.priorities, 'table', true },
|
||||
})
|
||||
|
||||
if opts.highlights.context then
|
||||
|
|
@ -368,6 +384,15 @@ local function init()
|
|||
['highlights.intra.max_lines'] = { opts.highlights.intra.max_lines, 'number', true },
|
||||
})
|
||||
end
|
||||
|
||||
if opts.highlights.priorities then
|
||||
vim.validate({
|
||||
['highlights.priorities.clear'] = { opts.highlights.priorities.clear, 'number', true },
|
||||
['highlights.priorities.syntax'] = { opts.highlights.priorities.syntax, 'number', true },
|
||||
['highlights.priorities.line_bg'] = { opts.highlights.priorities.line_bg, 'number', true },
|
||||
['highlights.priorities.char_bg'] = { opts.highlights.priorities.char_bg, 'number', true },
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if opts.fugitive then
|
||||
|
|
@ -396,6 +421,7 @@ local function init()
|
|||
['conflict.show_virtual_text'] = { opts.conflict.show_virtual_text, 'boolean', true },
|
||||
['conflict.format_virtual_text'] = { opts.conflict.format_virtual_text, 'function', true },
|
||||
['conflict.show_actions'] = { opts.conflict.show_actions, 'boolean', true },
|
||||
['conflict.priority'] = { opts.conflict.priority, 'number', true },
|
||||
['conflict.keymaps'] = { opts.conflict.keymaps, 'table', true },
|
||||
})
|
||||
|
||||
|
|
@ -457,6 +483,17 @@ local function init()
|
|||
then
|
||||
error('diffs: highlights.blend_alpha must be >= 0 and <= 1')
|
||||
end
|
||||
if opts.highlights and opts.highlights.priorities then
|
||||
for _, key in ipairs({ 'clear', 'syntax', 'line_bg', 'char_bg' }) do
|
||||
local v = opts.highlights.priorities[key]
|
||||
if v and v < 0 then
|
||||
error('diffs: highlights.priorities.' .. key .. ' must be >= 0')
|
||||
end
|
||||
end
|
||||
end
|
||||
if opts.conflict and opts.conflict.priority and opts.conflict.priority < 0 then
|
||||
error('diffs: conflict.priority must be >= 0')
|
||||
end
|
||||
|
||||
config = vim.tbl_deep_extend('force', default_config, opts)
|
||||
log.set_enabled(config.debug)
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ function M.goto_next(bufnr)
|
|||
end
|
||||
end
|
||||
|
||||
vim.notify('[diffs.nvim]: wrapped to first hunk', vim.log.levels.INFO)
|
||||
vim.api.nvim_win_set_cursor(0, { candidates[1].start_line + 1, 0 })
|
||||
end
|
||||
|
||||
|
|
@ -335,6 +336,7 @@ function M.goto_prev(bufnr)
|
|||
end
|
||||
end
|
||||
|
||||
vim.notify('[diffs.nvim]: wrapped to last hunk', vim.log.levels.INFO)
|
||||
vim.api.nvim_win_set_cursor(0, { candidates[#candidates].start_line + 1, 0 })
|
||||
end
|
||||
|
||||
|
|
@ -378,6 +380,9 @@ end
|
|||
---@param bufnr integer
|
||||
---@param config diffs.ConflictConfig
|
||||
function M.setup_keymaps(bufnr, config)
|
||||
resolved_hunks[bufnr] = nil
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||
|
||||
local km = config.keymaps
|
||||
|
||||
local maps = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue