aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin/hunk.lua
diff options
context:
space:
mode:
Diffstat (limited to 'ftplugin/hunk.lua')
-rw-r--r--ftplugin/hunk.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/ftplugin/hunk.lua b/ftplugin/hunk.lua
new file mode 100644
index 0000000..c01e0a9
--- /dev/null
+++ b/ftplugin/hunk.lua
@@ -0,0 +1,34 @@
+-- TODO: show current hunk in status line
+-- TODO: incorporate more patchutils functionality
+
+-- FIXME https://www.reddit.com/r/neovim/comments/unwvkw/github_hkuptyrunesnvim_lua_test_framework_for/
+-- FIXME https://github.com/hkupty/runes.nvim
+
+pretty = require("pl.pretty")
+
+local M = {}
+
+-- Header object
+M.Header = {}
+
+function M.Header:parse(inline, lineNo)
+ local pat = "@@%s+%-(%d+),(%d+)%s+%+(%d+),(%d+)%s+@@%s*(.*)"
+ local of, oc, nf, nc, rem = inline:match(pat)
+
+ return {
+ line = lineNo,
+ oldFirst = tonumber(of),
+ oldCount = tonumber(oc),
+ newFirst = tonumber(nf),
+ newCount = tonumber(nc),
+ remainderLine = rem
+ }
+end
+
+-- Generate hunk header line
+function M.createHunkHeader(oldStart, oldLen, newStart, newLen, remaind)
+ return "@@ -" .. oldStart .. "," .. oldLen ..
+ " +" .. newStart .. "," .. newLen .. " @@ " .. remaind
+end
+
+return M