fix: small improvements
This commit is contained in:
+18
-8
@@ -5,21 +5,31 @@ local function show(buf_id, items, query)
|
||||
MiniPick.default_show(buf_id, items, query)
|
||||
vim.api.nvim_buf_clear_namespace(buf_id, ns, 0, -1)
|
||||
for i, item in ipairs(items) do
|
||||
local hl = hls[item.text:match('%S')]
|
||||
if hl then
|
||||
vim.api.nvim_buf_set_extmark(buf_id, ns, i - 1, 0, { end_col = 2, hl_group = hl, priority = 202, hl_mode = 'combine' })
|
||||
if item.hl then
|
||||
vim.api.nvim_buf_set_extmark(buf_id, ns, i - 1, 1, { end_col = 3, hl_group = item.hl, priority = 202, hl_mode = 'combine' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
status = function()
|
||||
local items = {}
|
||||
for _, l in ipairs(vim.fn.systemlist('git status -s -u')) do
|
||||
local p = l:sub(4):gsub('.* %-> ', '')
|
||||
if vim.uv.fs_stat(p) then items[#items + 1] = { text = l, path = p } end
|
||||
local lines = vim.fn.systemlist('git status -s -u')
|
||||
if vim.v.shell_error ~= 0 then
|
||||
return vim.notify('Not a git repository', vim.log.levels.WARN)
|
||||
end
|
||||
if #items == 0 then return vim.notify('No changes') end
|
||||
|
||||
local items = {}
|
||||
for _, l in ipairs(lines) do
|
||||
local s = l:sub(1, 2):match('%S+')
|
||||
local p = l:sub(4):gsub('.* %-> ', ''):gsub('^"(.*)"$', '%1')
|
||||
local hl = l:sub(1, 1) ~= ' ' and l:sub(1, 1) ~= '?' and 'DiagnosticOk' or hls[s:sub(1, 1)]
|
||||
items[#items + 1] = {
|
||||
text = string.format(' %-2s %s', s == '??' and '?' or s, p),
|
||||
path = p,
|
||||
hl = hl,
|
||||
}
|
||||
end
|
||||
if #items == 0 then return vim.notify('No changes', vim.log.levels.INFO) end
|
||||
|
||||
MiniPick.start({
|
||||
source = { items = items, name = 'Git Status', show = show },
|
||||
|
||||
Reference in New Issue
Block a user