diff --git a/lua/fugitive-ts/init.lua b/lua/fugitive-ts/init.lua index f76085e..f7f46c9 100644 --- a/lua/fugitive-ts/init.lua +++ b/lua/fugitive-ts/init.lua @@ -100,7 +100,7 @@ local diff_windows = {} ---@param bufnr integer ---@return boolean -local function is_fugitive_buffer(bufnr) +function M.is_fugitive_buffer(bufnr) return vim.api.nvim_buf_get_name(bufnr):match('^fugitive://') ~= nil end @@ -270,7 +270,7 @@ function M.attach_diff() if vim.api.nvim_win_is_valid(win) and vim.wo[win].diff then table.insert(diff_wins, win) local bufnr = vim.api.nvim_win_get_buf(win) - if is_fugitive_buffer(bufnr) then + if M.is_fugitive_buffer(bufnr) then has_fugitive = true end end diff --git a/lua/fugitive-ts/parser.lua b/lua/fugitive-ts/parser.lua index 025186b..e5b720e 100644 --- a/lua/fugitive-ts/parser.lua +++ b/lua/fugitive-ts/parser.lua @@ -93,7 +93,7 @@ function M.parse_buffer(bufnr) end for i, line in ipairs(lines) do - local filename = line:match('^[MADRC%?!]%s+(.+)$') + local filename = line:match('^[MADRC%?!]%s+(.+)$') or line:match('^diff %-%-git a/.+ b/(.+)$') if filename then flush_hunk() current_filename = filename diff --git a/plugin/fugitive-ts.lua b/plugin/fugitive-ts.lua index 6b815ce..dae4eee 100644 --- a/plugin/fugitive-ts.lua +++ b/plugin/fugitive-ts.lua @@ -4,9 +4,13 @@ end vim.g.loaded_fugitive_ts = 1 vim.api.nvim_create_autocmd('FileType', { - pattern = 'fugitive', + pattern = { 'fugitive', 'git' }, callback = function(args) - require('fugitive-ts').attach(args.buf) + local ft = require('fugitive-ts') + if args.match == 'git' and not ft.is_fugitive_buffer(args.buf) then + return + end + ft.attach(args.buf) end, })