1
0

util.lua 521 B

12345678910111213141516171819202122232425262728
  1. local M = {}
  2. function M.resolve_git_path(buf_id)
  3. local bufname = vim.api.nvim_buf_get_name(buf_id)
  4. if not vim.startswith(bufname, 'fugitive://') then
  5. return false
  6. end
  7. local parsed = vim.fn.FugitiveParse(bufname)
  8. local resolved_path = parsed[1]
  9. local repo = parsed[2]
  10. if resolved_path == '' then
  11. return false
  12. end
  13. local parts = vim.split(resolved_path, ':')
  14. local commit = parts[1]
  15. local path = parts[2]
  16. return {
  17. repo = repo,
  18. commit = commit,
  19. path = path,
  20. }
  21. end
  22. return M