1
0

util.lua 819 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. function M.read_helix_config()
  23. local tinytoml = require('tinytoml')
  24. local data = vim.secure.read('.helix/languages.toml')
  25. if data ~= nil then
  26. local status, data = pcall(tinytoml.parse, data, { load_from_string = true })
  27. if status then
  28. return data
  29. end
  30. end
  31. return {}
  32. end
  33. return M