Open Fabian-programmer opened 1 year ago
Why don't you just use Telescope's commit picker to do this? Telescope is designed to be incredibly extensible. You can do whatever you want with the selections from any Telescope picker. As an example, I have have this mapping in my own Telescope config to open a diffview for the commit under the cursor in the git_commits
picker.
We already offer quite decent completion for branches, tags, stashes, heads, and ranges. Given that it's so easy to configure picker plugins to do what you're describing, I don't feel like it's necessary to implement picker integration here.
Thanks for the mapping!
I agree it would just be an convenience feature and is not necessary. It would be nice to have that mapping in the Tips & FAQ section. What do you think about that?
I am very sorry to be making noise here but I would like that mapping as well, unfortunately it errors with
Vim(append):E36: Not enough room
Any idea why that could be?
@Fabian-programmer I don't think it belongs in the README. I want that to be a concise overview of the plugin. But I suppose we could put that in the repo's wiki or something.
@gegoune That error happens when something tries to create a window that is too small, or there is not enough space to create a new split. Could be related to an option in your nvim config. Having 'equalalways'
disabled used to cause this error, but we are handling that in the plugin now. However, there might be another option that I'm unaware of that could also cause this. If you can manage to reproduce this with a minimal config, I would be grateful if you would open a bug report. Here's a template.
@sindrets minimal configuration works fine, so after narrowing it down I can report that it is https://github.com/rebelot/heirline.nvim plugin that causes an issue. Maybe it is setting some option that breaks your mapping? I will try to narrow it down further.
Edit: it's something with its winbar setup.
@sindrets minimal configuration works fine, so after narrowing it down I can report that it is https://github.com/rebelot/heirline.nvim plugin that causes an issue. Maybe it is setting some option that breaks your mapping? I will try to narrow it down further.
Edit: it's something with its winbar setup.
I met the same error. Have you solved this issue?
@meijieru Unfortunately not, gave up. :)
Thanks for your information lol.
Problem fixed by replacing the function as following
function (prompt_bufnr)
-- Open in diffview
local selected_entry = action_state.get_selected_entry()
local value = selected_entry.value
actions.close(prompt_bufnr)
vim.schedule(function()
vim.cmd(("DiffviewOpen %s^!"):format(value))
end)
end
Works indeed, thanks!
Share my LazyVim's telescope config:
opts = function(_, opts)
opts.pickers = vim.tbl_deep_extend("force", opts.pickers or {}, {
git_commits = {
mappings = {
i = {
["<C-d>"] = function() -- show diffview for the selected commit
-- Open in diffview
local entry = action_state.get_selected_entry()
-- close Telescope window properly prior to switching windows
actions.close(vim.api.nvim_get_current_buf())
vim.cmd(("DiffviewOpen %s^!"):format(entry.value))
end,
},
},
},
git_bcommits = {
mappings = {
i = {
["<C-d>"] = function() -- show diffview for the selected commit of current buffer
-- Open in diffview
local entry = action_state.get_selected_entry()
-- close Telescope window properly prior to switching windows
actions.close(vim.api.nvim_get_current_buf())
vim.cmd(("DiffviewOpen %s^!"):format(entry.value))
end,
},
},
},
git_branches = {
mappings = {
i = {
["<C-d>"] = function() -- show diffview comparing the selected branch with the current branch
-- Open in diffview
local entry = action_state.get_selected_entry()
-- close Telescope window properly prior to switching windows
actions.close(vim.api.nvim_get_current_buf())
vim.cmd(("DiffviewOpen %s.."):format(entry.value))
end,
},
},
},
})
end
Hey, I really love this plugin. One thing that could be improved in my opinion, is a picker for the commit selection.
f.e. this line is from the example of this plugin.
:DiffviewOpen d4a7b0d
Personally I often copy&paste commit hashes around for different usages. Wouldn't it be more convenient to have a function like:
:DiffviewOpen picker
, which opens sth. like the telescope commit picker:and lets you select the diff commit?