Skip to content
Discussion options

You must be logged in to vote

Yes, this (marking hunks, not files, to later apply them) is possible with writing custom choose_marked. Something like this:

require('mini.extra').setup()

local stage_hunk_item = function(item)
  local patch = vim.deepcopy(item.header)
  vim.list_extend(patch, item.hunk)
  local cmd = { 'git', 'apply', '--cached', '-' }
  vim.system(cmd, { stdin = patch }):wait()
end
local stage_marked = function(items_marked) vim.tbl_map(stage_hunk_item, items_marked) end

-- NOTE: Make sure `require('mini.pick').setup()` is called prior to this
MiniPick.registry.git_hunks = function(local_opts)
  MiniExtra.pickers.git_hunks(local_opts, { source = { choose_marked = stage_marked } })
end

So with this in…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by echasnovski
Comment options

You must be logged in to vote
1 reply
@echasnovski
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@echasnovski
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested mini.pick mini.extra
3 participants