Feat: Add file module with Jread, Jedit, Jsplit , Jvsplit and Jtabedit similar to fugitive's (#105)

Co-authored-by: NicolasGB <ngou0210@gmail.com>
This commit is contained in:
Björn Steinbrink
2026-04-26 09:50:26 -07:00
committed by GitHub
co-authored by NicolasGB
parent 2dbe2c73c5
commit 53a3196210
8 changed files with 527 additions and 68 deletions
+28
View File
@@ -245,4 +245,32 @@ function M.parse_diff_range(range_str)
return nil
end
--- Parse a `<rev>:<path>` argument as used by file commands.
--- With no colon, the whole input is treated as a revision with no file.
--- A trailing colon (`<rev>:`) is accepted and treated as no file path.
--- @param input string
--- @return {rev: string|nil, path: string|nil}|nil
function M.parse_file_module_input(input)
if not input then
return nil
end
input = vim.trim(input)
if input == "" then
return nil
end
local rev, file = input:match("^([^:]+):(.*)$")
if rev then
if file == "" then
return { rev = rev, path = nil }
end
return { rev = rev, path = file }
end
if input:find(":", 1, true) then
return nil
end
return { rev = input, path = nil }
end
return M