From 9a58ea573bf6bec87725953f80c4419e595c6a9e Mon Sep 17 00:00:00 2001 From: themodrnhakr Date: Thu, 2 Oct 2025 16:11:02 -0500 Subject: [PATCH] Add function to get jj diff for current buffer --- lua/jj_mini_diff/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/jj_mini_diff/init.lua b/lua/jj_mini_diff/init.lua index 4b0336a..0a261e8 100644 --- a/lua/jj_mini_diff/init.lua +++ b/lua/jj_mini_diff/init.lua @@ -24,6 +24,21 @@ local function _define_signs() vim.fn.sign_define("JjDiffDelete", { text = "─", texthl = "JjDiffDelete", numhl = "JjDiffDelete" }) end +-- Get jj diff output for the current buffer +local function _get_jj_diff_for_buffer() + local file_path = vim.api.nvim_buf_get_name(0) + if file_path == "" then + return nil, "Current buffer is not associated with a file." + end + + -- Run 'jj diff' for the specific file + local diff_output, err = _run_jj_command({ "diff", "--color=never", file_path }) + if err then + return nil, err + end + return diff_output +end + function M.setup(opts) opts = opts or {} _define_signs() -- Call to define signs