Closed eshepelyuk closed 5 months ago
Hi, I've been thinking about this a bit since gitsigns dropped yadm support.
I don't really use fugitive as much as I used to, so I have disabled the plugin and just use a terminal whenever I want to commit stuff on my dotfiles.
I was able to figure out how to show modified git hunks with gitsigns, my lazy file here, by adding the _on_attach_pre
function:
-- yadm support. checks if the current file is tracked by yadm.
-- If it is, set the gitdir and toplevel, otherwise just return
-- and call callback with no arguments
_on_attach_pre = function(_, callback)
-- a global I set on nvim launch, so I dont have to check
-- each time this is run
if not has_yadm then
return callback()
end
vim.schedule(function()
-- if buffer is not a file, don't change anything
local file = vim.fn.expand("%:p")
if not vim.fn.filereadable(file) then
return callback()
end
local repo = vim.fn.expand("~/.local/share/yadm/repo.git")
-- use yadm ls-files to check if the file is tracked
require("plenary.job")
:new({
command = "yadm",
args = { "ls-files", "--error-unmatch", file },
on_exit = vim.schedule_wrap(function(_, return_val)
if return_val == 0 then
return callback({
gitdir = repo,
toplevel = os.getenv("HOME"),
})
else
return callback()
end
end),
})
:sync()
end)
end,
Not sure if there are edge cases I haven't encountered yet, but it seems to work so far.
Have been weighing if I should document that somewhere here, or archive this plugin and create a new thing that just works with gitsigns.
In any case, I dont think I would add the lua code here as well, it would likely be a separate repository that just gets require
d when config
for gitsigns is run.
If anyone has suggestions for how to proceed, let me know
Pushed it as a plugin here if you want to test: https://github.com/seanbreckenridge/gitsigns-yadm-callback/
Hello,
Thank you for picking this up and creating a dedicated plugin. I will definitely give it a try a bit later and provide a feedback.
May I suggest to rename it to the anem without suffix -callback
, maybe gitsigns-yadm.nvim` or smth like this ?
May I suggest to rename it to the anem without suffix -callback, maybe gitsigns-yadm.nvim` or smth like this ?
Yeah, probably a good idea. Done
Great, thank you !
WDYT will it be a good idea to leverage more APIs from gitsigns.nvim
, i.e. I've tried to research their codebase and maybe it's possible to revive "old" YADM support using plugins's own API.
i am closign this issue, any other can be tracked in the new plugin.
WDYT will it be a good idea to leverage more APIs from gitsigns.nvim, i.e. I've tried to research their codebase and maybe it's possible to revive "old" YADM support using plugins's own API.
I've gone through the removal commit and matched any of the logic that was used there here:
I think thats all the integration did, if you notice some other feature missing let me know
Hello @seanbreckenridge Tried it, for now - works fine. Thanks for the plugin.
The question.