Closed gegoune closed 1 year ago
We have a function used internally to get the current open view. I suppose you could use that to determine whether a window is in a diffview:
vim.api.nvim_create_autocmd({ 'InsertEnter', 'WinLeave' }, {
callback = function(event)
if require("diffview.lib").get_current_view() then return end
--- ...
end,
})
Thank you in advance and have a good weekend!
Thank you, you too 😄
(no discussions are enabled for that repository hence abusing issue here)
This is the right place to ask questions. The "Discussions" feature isn't enabled because I just don't want to spread out discussion over multiple places. I think issues work more than fine for questions, when they're labeled as such. Issues can easily be filtered and searched. And this way I keep all discussion in one place.
Thanks for the hint, I still wasn't able to get it to work as is would like to. No need to keep that issue opened. Thanks!
If I correctly understood what you're trying to do, this seems to work for me:
vim.opt.cursorline = false;
vim.api.nvim_create_autocmd({ "WinLeave", "BufLeave" }, {
callback = function(e)
local dv_lib = require("diffview.lib");
if vim.wo.diff or dv_lib.get_current_view() then return end
vim.opt_local.cursorline = nil
end,
})
vim.api.nvim_create_autocmd({ "WinEnter", "BufEnter" }, {
callback = function(e)
vim.opt_local.cursorline = true
end,
})
That is incredibly kind of you! Thank you for taking your time to solve someone else's configuration issue! You are awesome!
Hey Sindre,
I understand that this isn't an issue with Diffview (no discussions are enabled for that repository hence abusing issue here) but I would greatly appreciate your help, feel free to close it without even reading any further though.
I have a functions tied to some auto commands that make
cursorline
appear in window with cursor only. I have noticed that it doesn't work for Diffview buffers though. I have tried to catch Diffview buffers in multiple ways but didn't manage to make it work properly. Here is the entirety of the code:I would like
cursorline
to be always visible in all Diffview buffers, as they are nicely synced between both sides of diff.Thank you in advance and have a good weekend!