8000 mini.diff/lua/mini/diff.lua at main · dmun/mini.diff · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1958 lines (1702 loc) · 78.8 KB

diff.lua

File metadata and controls

1958 lines (1702 loc) · 78.8 KB
sign = { hl_group_prefix = 'MiniDiffSign', field = 'sign_hl_group' },
number = { hl_group_prefix = 'MiniDiffSign', field = 'number_hl_group' },
}
-- Suffix for overlay virtual lines to be highlighted as full line
H.overlay_suffix = vim.fn.has('nvim-0.13') == 1 and '' or string.rep(' ', vim.o.columns)
-- Flag for whether to handle virtual lines overflow
H.extmark_virt_lines_overflow = vim.fn.has('nvim-0.13') == 1 and 'auto'
or (vim.fn.has('nvim-0.11') == 1 and 'scroll' or nil)
-- Permanent `vim.diff()` options
H.vimdiff_opts = { result_type = 'indices', ctxlen = 0, interhunkctxlen = 0 }
-- Options for `vim.diff()` during word diff. Use `interhunkctxlen = 4` to
-- reduce noisiness (chosen as slightly less than average English word length)
--stylua: ignore
H.worddiff_opts = {
algorithm = 'minimal', result_type = 'indices',
ctxlen = 0, interhunkctxlen = 4,
indent_heuristic = false, linematch = 0
}
-- BOM bytes prepended to buffer text if 'bomb' is enabled. See `:h bom-bytes`.
--stylua: ignore
H.bom_bytes = {
['utf-8'] = string.char(0xef, 0xbb, 0xbf),
['utf-16be'] = string.char(0xfe, 0xff),
['utf-16'] = string.char(0xfe, 0xff),
['utf-16le'] = string.char(0xff, 0xfe),
-- In 'fileencoding', 'utf-32' is transformed into 'ucs-4'
['utf-32be'] = string.char(0x00, 0x00, 0xfe, 0xff),
['ucs-4be'] = string.char(0x00, 0x00, 0xfe, 0xff),
['utf-32'] = string.char(0x00, 0x00, 0xfe, 0xff),
['ucs-4'] = string.char(0x00, 0x00, 0xfe, 0xff),
['utf-32le'] = string.char(0xff, 0xfe, 0x00, 0x00),
['ucs-4le'] = string.char(0xff, 0xfe, 0x00, 0x00),
}
-- Helper functionality =======================================================
-- Settings -------------------------------------------------------------------
H.setup_config = function(config)
H.check_type('config', config, 'table', true)
config = vim.tbl_deep_extend('force', vim.deepcopy(H.default_config), config or {})
H.check_type('view', config.view, 'table')
H.check_type('view.style', config.view.style, 'string')
H.check_type('view.signs', config.view.signs, 'table')
H.check_type('view.signs.add', config.view.signs.add, 'string')
H.check_type('view.signs.change', config.view.signs.change, 'string')
H.check_type('view.signs.delete', config.view.signs.delete, 'string')
H.check_type('view.priority', config.view.priority, 'number')
0