grim/micro-hggutter

initial revision
draft
2020-07-30, Gary Kramlich
d36f70303788
Parents
Children 0b09ac19ece5
initial revision
  • +20 -0
    main.lua
  • --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/main.lua Thu Jul 30 23:54:09 2020 -0500
    @@ -0,0 +1,20 @@
    +VERSION = "0.0.1"
    +
    +local os = import("os")
    +local filepath = import("path/filepath")
    +local shell = import("micro/shell")
    +
    +function onBufferOpen(buf)
    + if buf.Settings["hggutter"] and (not buf.Type.Scratch) and (buf.Path ~= "") then
    + local _, err = os.Stat(buf.AbsPath)
    + if err == nil then
    + local dirName, fileName = filepath.Split(buf.AbsPath)
    + local diffBase, err = shell.ExecCommand("hg", "--cwd", dirName, "cat", "./" .. fileName)
    + if err ~= nil then
    + diffBase = buf:Bytes()
    + end
    + buf:SetDiffBase(diffBase)
    + end
    + end
    +end
    +