Buffer with name '.gitignore' already exists, didn't name buffer!
It does appends the new gitignore lines, but not in the existing .gitignore. It creates an untitled buffer.
return {
"wintermute-cell/gitignore.nvim",
cmd = "Gitignore",
config = function() require "gitignore" end,
}
I face exactly the same issue :(
My config looks like this:
return {
'wintermute-cell/gitignore.nvim',
config = function()
local gitignore = require 'gitignore'
-- project root + '.gitignore' file
local file_path = vim.fn.expand '%:p:h' .. '/.gitignore'
vim.keymap.set('n', '<leader>gI', function()
gitignore.generate(file_path)
end, { desc = 'Generate .gitignore' })
end,
}
It works well if the .gitignore file doesn't exist.
Same issue but i can propose a solution (i am new to nvim so idk if possible):
generate() checks if the current buffer is label as .gitignore (or any buffer open with that label). If so than write the template on the cursor position in that buffer Otherwise create the file and if is already created than ask the user if want to override it (if the opts gitignore_nvim_overwrite is false )
P.S Should be label as bug for those who like to resolve it.