Skip to content
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

More Neogit* Events #981

Merged
merged 6 commits into from
Nov 30, 2023
Merged

More Neogit* Events #981

merged 6 commits into from
Nov 30, 2023

Conversation

gollth
Copy link
Contributor

@gollth gollth commented Nov 29, 2023

This provides a working solution for my problem in #938. Let me explain:

With the current four events the user (me^^) can set up a vim autocmd which closes and reopens the Graph View. Not pretty, but does the job for me. However it's a bit cumbersome to being only limited to update the view on commit, push, pull & fetch. With these additional events the log view also does update on other commands:

more-events

This is my user config for auto-updating:

local group = vim.api.nvim_create_augroup("MyCustomNeogitEvents", { clear = true })
vim.api.nvim_create_autocmd("User", {
  pattern = {
    "NeogitCherryPick",
    "NeogitBranchCheckout",
    "NeogitBranchCreated",
    "NeogitBranchDelete",
    "NeogitBranchReset",
    "NeogitBranchRename",
    "NeogitRebase",
    "NeogitReset",
    "NeogitTagCreate",
    "NeogitTagDelete",
    "NeogitCommitComplete",
    "NeogitPushComplete",
    "NeogitPullComplete",
    "NeogitFetchComplete",
  },
  group = group,
  callback = function(event)
    print("Event: " .. vim.inspect(event.file))
    local buffername = vim.api.nvim_buf_get_name(event.buf)
    if buffername:match("NeogitLogView$") then
      vim.fn.feedkeys("q", "x") -- Close Log Graph
      require("neogit").open({ "log" })
      vim.fn.feedkeys("b", "x") -- Open log graph (branches) again    end
    end
  end,
})

If you want this example config could become part of some "Recipes" documentation or so...


FWIW, maybe other people might benefit from these events, that's why this PR =)

@CKolkey
Copy link
Member

CKolkey commented Nov 30, 2023

Cool! I'm planning to handle the buffer update thing with the watcher module, but these could be handy for people regardless, so I don't see the harm. Thanks!

@CKolkey CKolkey merged commit 3791805 into NeogitOrg:master Nov 30, 2023
3 checks passed
@CKolkey
Copy link
Member

CKolkey commented Nov 30, 2023

(I really like the gif's, btw. Great way to show whats up)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants