addet correct edit function

This commit is contained in:
pika 2024-08-17 21:38:48 +02:00
parent 0000f5203c
commit 4fac477dc6

View file

@ -13,6 +13,21 @@ local function setup_open_file_indicators()
end end
end end
-- Update open_buffers initially
update_open_buffers()
-- Set up autocmds to update open_buffers and refresh Neo-tree
local group = vim.api.nvim_create_augroup("NeoTreeOpenFileIndicator", { clear = true })
vim.api.nvim_create_autocmd({"BufAdd", "BufDelete", "BufWipeout"}, {
group = group,
callback = function()
update_open_buffers()
if package.loaded["neo-tree.sources.manager"] then
require("neo-tree.sources.manager").refresh("filesystem")
end
end,
})
-- Custom component to display open file indicator -- Custom component to display open file indicator
local function open_file_indicator(config, node, state) local function open_file_indicator(config, node, state)
local result = require("neo-tree.sources.common.components").icon(config, node, state) local result = require("neo-tree.sources.common.components").icon(config, node, state)
@ -22,16 +37,14 @@ local function setup_open_file_indicators()
return result return result
end end
return { return open_file_indicator
update_open_buffers = update_open_buffers,
open_file_indicator = open_file_indicator
}
end end
return { return {
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
opts = { opts = function()
return {
sources = { "filesystem", "buffers", "git_status" }, sources = { "filesystem", "buffers", "git_status" },
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
close_if_last_window = false, close_if_last_window = false,
@ -43,7 +56,7 @@ return {
follow_current_file = { enabled = true }, follow_current_file = { enabled = true },
use_libuv_file_watcher = true, use_libuv_file_watcher = true,
components = { components = {
icon = setup_open_file_indicators().open_file_indicator, icon = setup_open_file_indicators(),
}, },
}, },
window = { window = {
@ -82,29 +95,13 @@ return {
}, },
}, },
} }
}, }
end,
branch = "v3.x", branch = "v3.x",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
"3rd/image.nvim", "3rd/image.nvim",
}, },
config = function(_, opts)
local indicators = setup_open_file_indicators()
-- Set up autocmds to update open_buffers and refresh Neo-tree
local group = vim.api.nvim_create_augroup("NeoTreeOpenFileIndicator", { clear = true })
vim.api.nvim_create_autocmd({"BufAdd", "BufDelete", "BufWipeout"}, {
group = group,
callback = function()
indicators.update_open_buffers()
if package.loaded["neo-tree.sources.manager"] then
require("neo-tree.sources.manager").refresh("filesystem")
end
end,
})
require("neo-tree").setup(opts)
end,
} }
} }