refactor: options renamed
This commit is contained in:
@@ -41,9 +41,6 @@ local lineBlame = function(input_file_path, line_number, input_comma_separated_m
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lineBlame
|
|
||||||
-- does everything the plugin needs xd
|
|
||||||
-- @param blame_highlight: 'Normal'
|
|
||||||
-- @param blame_position: 'eol' | 'overlay' | 'right_align'
|
-- @param blame_position: 'eol' | 'overlay' | 'right_align'
|
||||||
local fileBlame = function(input_file_path, input_comma_separated_mail_list, blame_text, blame_highlight, blame_position)
|
local fileBlame = function(input_file_path, input_comma_separated_mail_list, blame_text, blame_highlight, blame_position)
|
||||||
local handler = io.popen("git blame -e " .. input_file_path .. " | awk '{print $2$6}'")
|
local handler = io.popen("git blame -e " .. input_file_path .. " | awk '{print $2$6}'")
|
||||||
|
|||||||
@@ -5,38 +5,44 @@ local defaultBlameTextColor = "#bcb8b1"
|
|||||||
local defaultBlameText = "- Monkey alert 🐒"
|
local defaultBlameText = "- Monkey alert 🐒"
|
||||||
local defaultBlamePosition = "eol"
|
local defaultBlamePosition = "eol"
|
||||||
|
|
||||||
local function setup(opts)
|
|
||||||
vim.api.nvim_set_hl(0, 'Monkey', { fg = opts.blameTextColorHex or defaultBlameTextColor, bold = false })
|
|
||||||
vim.g.monkeyMailList = opts.monkeyMailList or defaultList
|
|
||||||
vim.g.monkeyBlameText = opts.blameText or defaultBlameText
|
|
||||||
vim.g.monkeyBlamePosition = opts.blamePosition or defaultBlamePosition
|
|
||||||
end
|
|
||||||
|
|
||||||
local function blameCurrentFile()
|
|
||||||
blame.fileBlame(vim.api.nvim_buf_get_name(0), vim.g.monkeyMailList, vim.g.monkeyBlameText,
|
|
||||||
"Monkey", vim.g.monkeyBlamePosition)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function blameCurrentLine()
|
|
||||||
local row = vim.api.nvim_win_get_cursor(0)[1]
|
|
||||||
blame.lineBlame(vim.api.nvim_buf_get_name(0), tonumber(row) - 1, vim.g.monkeyMailList,
|
|
||||||
vim.g.monkeyBlameText,
|
|
||||||
"Monkey", vim.g.monkeyBlamePosition)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function clearBlame()
|
local function clearBlame()
|
||||||
blame.clearBlame()
|
blame.clearBlame()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function blameCurrentFile()
|
||||||
|
clearBlame()
|
||||||
|
blame.fileBlame(vim.api.nvim_buf_get_name(0), vim.g.monkey_mail_list, vim.g.monkey_blame_text,
|
||||||
|
"Monkey", vim.g.monkey_blame_position)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function blameCurrentLine()
|
||||||
|
clearBlame()
|
||||||
|
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
|
blame.lineBlame(vim.api.nvim_buf_get_name(0), tonumber(row) - 1, vim.g.monkey_mail_list,
|
||||||
|
vim.g.monkey_blame_text,
|
||||||
|
"Monkey", vim.g.monkey_blame_position)
|
||||||
|
end
|
||||||
|
|
||||||
local function enableOnLine()
|
local function enableOnLine()
|
||||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
callback = function(opts)
|
callback = function()
|
||||||
clearBlame()
|
clearBlame()
|
||||||
blameCurrentLine()
|
blameCurrentLine()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function setup(opts)
|
||||||
|
vim.api.nvim_set_hl(0, 'Monkey', { fg = opts.blame_text_color_hex or defaultBlameTextColor, bold = false })
|
||||||
|
vim.g.monkey_mail_list = opts.monkey_mail_list or defaultList
|
||||||
|
vim.g.monkey_blame_text = opts.blame_text or defaultBlameText
|
||||||
|
vim.g.monkey_blame_position = opts.blame_position or defaultBlamePosition
|
||||||
|
|
||||||
|
if opts.auto_attach then
|
||||||
|
enableOnLine()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setup = setup,
|
setup = setup,
|
||||||
blameLine = blameCurrentLine,
|
blameLine = blameCurrentLine,
|
||||||
|
|||||||
Reference in New Issue
Block a user