mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(picker): added git_branches
picker. Closes #614
This commit is contained in:
parent
903431903b
commit
8563dfce68
8 changed files with 196 additions and 7 deletions
|
@ -98,8 +98,11 @@ function M.git_log(item, picker)
|
|||
local ret = {} ---@type snacks.picker.Highlight[]
|
||||
ret[#ret + 1] = { picker.opts.icons.git.commit, "SnacksPickerGitCommit" }
|
||||
ret[#ret + 1] = { item.commit, "SnacksPickerGitCommit" }
|
||||
|
||||
ret[#ret + 1] = { " " }
|
||||
ret[#ret + 1] = { a(item.date, 16), "SnacksPickerGitDate" }
|
||||
if item.date then
|
||||
ret[#ret + 1] = { a(item.date, 16), "SnacksPickerGitDate" }
|
||||
end
|
||||
|
||||
local msg = item.msg ---@type string
|
||||
local type, scope, breaking, body = msg:match("^(%S+)(%(.-%))(!?):%s*(.*)$")
|
||||
|
@ -130,6 +133,24 @@ function M.git_log(item, picker)
|
|||
return ret
|
||||
end
|
||||
|
||||
function M.git_branch(item, picker)
|
||||
local a = Snacks.picker.util.align
|
||||
local ret = {} ---@type snacks.picker.Highlight[]
|
||||
if item.current then
|
||||
ret[#ret + 1] = { a("", 2), "SnacksPickerGitBranchCurrent" }
|
||||
ret[#ret + 1] = { a(item.branch, 30, { truncate = true }), "SnacksPickerGitBranch" }
|
||||
else
|
||||
ret[#ret + 1] = { a("", 2) }
|
||||
ret[#ret + 1] = { a(item.branch, 30, { truncate = true }), "SnacksPickerGitBranch" }
|
||||
end
|
||||
ret[#ret + 1] = { " " }
|
||||
local offset = Snacks.picker.highlight.offset(ret)
|
||||
local log = M.git_log(item, picker)
|
||||
Snacks.picker.highlight.fix_offset(log, offset)
|
||||
vim.list_extend(ret, log)
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.lsp_symbol(item, picker)
|
||||
local ret = {} ---@type snacks.picker.Highlight[]
|
||||
if item.hierarchy then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue