refactor: minor param organization
This commit is contained in:
@@ -1,9 +1,13 @@
|
|||||||
local ns = vim.api.nvim_create_namespace('line_blame');
|
local ns = vim.api.nvim_create_namespace('line_blame');
|
||||||
|
|
||||||
|
local lineBlame = function(input_file_path, input_comma_separated_mail_list, blame_text, blame_highlight, blame_position)
|
||||||
|
end
|
||||||
|
|
||||||
-- lineBlame
|
-- lineBlame
|
||||||
-- - does everything the plugin needs xd
|
-- does everything the plugin needs xd
|
||||||
-- @param blame_highlight: 'Normal'
|
-- @param blame_highlight: 'Normal'
|
||||||
-- @param blame_position: 'eol' | 'overlay' | 'right_align'
|
-- @param blame_position: 'eol' | 'overlay' | 'right_align'
|
||||||
local lineBlame = 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}'")
|
||||||
|
|
||||||
if handler == nil then
|
if handler == nil then
|
||||||
@@ -15,7 +19,7 @@ local lineBlame = function(input_file_path, input_comma_separated_mail_list, bla
|
|||||||
for current_line_mail, line_number in string.gmatch(result, "%(<(.+)>(%d+)%)") do
|
for current_line_mail, line_number in string.gmatch(result, "%(<(.+)>(%d+)%)") do
|
||||||
for target_mail in string.gmatch(input_comma_separated_mail_list, "[^,]+") do
|
for target_mail in string.gmatch(input_comma_separated_mail_list, "[^,]+") do
|
||||||
if target_mail == current_line_mail then
|
if target_mail == current_line_mail then
|
||||||
local extid = vim.api.nvim_buf_set_extmark(0, ns, tonumber(line_number), 0, {
|
vim.api.nvim_buf_set_extmark(0, ns, tonumber(line_number) - 1, 0, {
|
||||||
id = tonumber(line_number),
|
id = tonumber(line_number),
|
||||||
virt_text = { { blame_text, blame_highlight } },
|
virt_text = { { blame_text, blame_highlight } },
|
||||||
virt_text_pos = blame_position,
|
virt_text_pos = blame_position,
|
||||||
@@ -24,16 +28,13 @@ local lineBlame = function(input_file_path, input_comma_separated_mail_list, bla
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ,virt_text = {[ "test", "WildMenu"]}
|
|
||||||
end
|
end
|
||||||
result = handler:read("L")
|
result = handler:read("L")
|
||||||
end
|
end
|
||||||
handler:close()
|
handler:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lineBlame("./README.md")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
lineBlame = lineBlame,
|
lineBlame = lineBlame,
|
||||||
|
fileBlame = fileBlame,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
local blame = require("./line-blame")
|
local blame = require("./line-blame")
|
||||||
|
|
||||||
local defaultList = "one;two"
|
local defaultList = "one,two"
|
||||||
-- vim.g.monkeyUserList = defaultList
|
local defaultBlameTextColor = "#bcb8b1"
|
||||||
vim.g.monkeyMailList = defaultList
|
local defaultBlameText = "- Monkey alert 🐒"
|
||||||
|
local defaultBlamePosition = "eol"
|
||||||
|
|
||||||
local function setup(opts)
|
local function setup(opts)
|
||||||
vim.g.monkeyMailList = opts.monkeyMailList
|
vim.api.nvim_set_hl(0, 'Monkey', { fg = opts.blameTextColorHex or defaultBlameTextColor, bold = false })
|
||||||
-- vim.g.monkeyUserList = opts.monkeyUserList
|
vim.g.monkeyMailList = opts.monkeyMailList or defaultList
|
||||||
|
vim.g.monkeyBlameText = opts.blameText or defaultBlameText
|
||||||
|
vim.g.monkeyBlamePosition = opts.blamePosition or defaultBlamePosition
|
||||||
end
|
end
|
||||||
|
|
||||||
local function blameCurrentFile()
|
local function blameCurrentFile()
|
||||||
blame.lineBlame(vim.api.nvim_buf_get_name(0), "test,another,dani.heras@hotmail.com,final", "| Found a fkin monkey 🐒",
|
blame.fileBlame(vim.api.nvim_buf_get_name(0), vim.g.monkeyMailList, vim.g.monkeyBlameText,
|
||||||
"Normal", "eol")
|
"Monkey", vim.g.monkeyBlamePosition)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function blameCurrentLine()
|
||||||
|
blame.lineBlame(vim.api.nvim_buf_get_name(0), vim.g.monkeyMailList, vim.g.monkeyBlameText,
|
||||||
|
"Monkey", vim.g.monkeyBlamePosition)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setup = setup,
|
setup = setup,
|
||||||
blame = blameCurrentFile
|
blameLine = blameCurrentLine,
|
||||||
|
blameFile = blameCurrentFile
|
||||||
}
|
}
|
||||||
|
|
||||||
-- NOTE:
|
|
||||||
-- vim.log.levels.DEBUG vim.log.levels.ERROR vim.log.levels.INFO vim.log.levels.TRACE vim.log.levels.WARN vim.log.levels.OFF
|
|
||||||
--
|
|
||||||
|
|||||||
Reference in New Issue
Block a user