Add autocommands and _is_jj_repo function
This commit is contained in:
parent
86241f2193
commit
5b1ea2ba9a
@ -107,13 +107,36 @@ local function _place_signs_in_buffer()
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if current buffer's file is in a jj repo
|
||||
local function _is_jj_repo()
|
||||
local file_path = vim.api.nvim_buf_get_name(0)
|
||||
if file_path == "" then
|
||||
return false
|
||||
end
|
||||
local dir = vim.fn.fnamemodify(file_path, ":h")
|
||||
while dir ~= "" and dir ~= "/" do
|
||||
if vim.fn.isdirectory(dir .. "/.jj") == 1 then
|
||||
return true
|
||||
end
|
||||
dir = vim.fn.fnamemodify(dir, ":h")
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
_define_signs() -- Call to define signs
|
||||
-- TODO: Implement configuration options
|
||||
|
||||
-- Autocommands to update signs
|
||||
vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "CursorHold" }, {
|
||||
group = vim.api.nvim_create_augroup("JjMiniDiff", { clear = true }),
|
||||
callback = function()
|
||||
if _is_jj_repo() then
|
||||
_place_signs_in_buffer()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- TODO: Implement core logic for Git signs
|
||||
|
||||
return M
|
||||
|
||||
Loading…
Reference in New Issue
Block a user