-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add filetype for diff and blame window #609
Conversation
What do you think? @lewis6991. I have another usecase for this as well. I want to be able to move into the popup window of the diff/blame. I do this with something like this: local open_or_attach = function(filetype, callback)
local found = false
local wininfo = vim.fn.getwininfo()
for _, win in ipairs(wininfo) do
if vim.bo[win.bufnr].filetype == filetype then
found = true
vim.cmd.wincmd({ 'w', count = win.winnr })
end
end
if not found then
callback()
end
end
local gs = package.loaded.gitsigns
local map = function(m, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(m, l, r, opts)
end
map('n', '<leader>gd', function()
open_or_attach('gitsigns_diff', gs.preview_hunk)
end, { desc = 'Gitsigns: Preview diff hunk' }) |
It sounds like you want a preview callback instead. |
That would also work. Is that preferable over just doing it in For me it would work just as well with just giving the previews a filetype though. |
Instead of looking at the filetype, you can instead look for the window variable For #609 (comment). We can consider just doing this by default as it seems to be a developing convention that calling a preview function twice causes it to get focus. |
I opened another PR for attaching to the popups if they are already open as I agree that it could definitely be the default behaviour as it is the default behaviour in most lsp stuff with a popup. I am not too sure if I could use the window variable for search and replace in the blame window for setting gitmojis. I could listen for |
Preview windows now have the window variable |
@seblj : Were you able to implement preview navigation? If possible, can you share code? Thanks! |
I am not sure what you mean by preview navigation, but I was able to implement what I wanted to do with this: |
I would like to navigate the preview using j and k, right now the preview is full screen but I cannot scroll it to view the change. |
I want to run some code to substitute a gitmoji code for the actual emoji in the git-blame window (for example
%s/:sparkles:/✨
, and I need the filetype to do this. I figured I could add a filetype to the diff-window as well.Not 100% sure of the naming of filetype though, so open for other suggestions here