feat: update autocmds for git filetypes with fugiive:/// bufnames
This commit is contained in:
parent
e2a62a6aa5
commit
686b02b790
3 changed files with 9 additions and 5 deletions
|
|
@ -100,7 +100,7 @@ local diff_windows = {}
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return boolean
|
---@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
|
return vim.api.nvim_buf_get_name(bufnr):match('^fugitive://') ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -270,7 +270,7 @@ function M.attach_diff()
|
||||||
if vim.api.nvim_win_is_valid(win) and vim.wo[win].diff then
|
if vim.api.nvim_win_is_valid(win) and vim.wo[win].diff then
|
||||||
table.insert(diff_wins, win)
|
table.insert(diff_wins, win)
|
||||||
local bufnr = vim.api.nvim_win_get_buf(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
|
has_fugitive = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ function M.parse_buffer(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, line in ipairs(lines) do
|
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
|
if filename then
|
||||||
flush_hunk()
|
flush_hunk()
|
||||||
current_filename = filename
|
current_filename = filename
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,13 @@ end
|
||||||
vim.g.loaded_fugitive_ts = 1
|
vim.g.loaded_fugitive_ts = 1
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
pattern = 'fugitive',
|
pattern = { 'fugitive', 'git' },
|
||||||
callback = function(args)
|
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,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue