From 0000f5203c82ef14fdf62fc32dbcaa5080646275 Mon Sep 17 00:00:00 2001 From: pika Date: Sat, 17 Aug 2024 21:36:00 +0200 Subject: [PATCH] some changes --- init.lua | 2 +- lua/pika/plugins/colorschemes.lua | 2 - lua/pika/plugins/neo-tree.lua | 84 ++++++++++++++++++++----------- lua/pika/plugins/telekasten.lua | 6 +++ 4 files changed, 62 insertions(+), 32 deletions(-) create mode 100644 lua/pika/plugins/telekasten.lua diff --git a/init.lua b/init.lua index af191c2..0e5180b 100644 --- a/init.lua +++ b/init.lua @@ -11,4 +11,4 @@ local function apply_colorscheme(name) vim.cmd.colorscheme(name) end -apply_colorscheme("eldritch") -- Change "witch" to your desired colorscheme name +apply_colorscheme("bamboo") diff --git a/lua/pika/plugins/colorschemes.lua b/lua/pika/plugins/colorschemes.lua index 5a25580..96bf53b 100644 --- a/lua/pika/plugins/colorschemes.lua +++ b/lua/pika/plugins/colorschemes.lua @@ -1,5 +1,4 @@ return { - { "sontungexpt/witch", -- priority = 1000, @@ -7,7 +6,6 @@ return { opts = {}, }, - { "savq/melange-nvim" }, { "rose-pine/neovim" }, { diff --git a/lua/pika/plugins/neo-tree.lua b/lua/pika/plugins/neo-tree.lua index e623bbe..22e6232 100644 --- a/lua/pika/plugins/neo-tree.lua +++ b/lua/pika/plugins/neo-tree.lua @@ -1,10 +1,40 @@ +local function setup_open_file_indicators() + -- Table to store open buffers + local open_buffers = {} + + -- Function to update open_buffers table + local function update_open_buffers() + open_buffers = {} + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted then + local file_path = vim.api.nvim_buf_get_name(buf) + open_buffers[file_path] = true + end + end + end + + -- Custom component to display open file indicator + local function open_file_indicator(config, node, state) + local result = require("neo-tree.sources.common.components").icon(config, node, state) + if node.type == "file" and open_buffers[node:get_id()] then + result.text = result.text .. " 󱞇" + end + return result + end + + return { + update_open_buffers = update_open_buffers, + open_file_indicator = open_file_indicator + } +end + return { { "nvim-neo-tree/neo-tree.nvim", opts = { sources = { "filesystem", "buffers", "git_status" }, open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, - close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab + close_if_last_window = false, popup_border_style = "rounded", enable_git_status = true, enable_diagnostics = true, @@ -13,25 +43,7 @@ return { follow_current_file = { enabled = true }, use_libuv_file_watcher = true, components = { - name = function(config, node, state) - local result = require("neo-tree.sources.filesystem.components").name(config, node, state) - - -- Check if the file is open in a buffer - local is_open = false - for _, buf in ipairs(vim.api.nvim_list_bufs()) do - if vim.api.nvim_buf_get_name(buf) == node.path then - is_open = true - break - end - end - - -- Add an indicator if the file is open - if is_open then - result.text = result.text .. " 󱞇" - end - - return result - end, + icon = setup_open_file_indicators().open_file_indicator, }, }, window = { @@ -56,12 +68,11 @@ return { ["P"] = { "toggle_preview", config = { use_float = false } }, }, }, - default_component_configs = { indent = { - with_expanders = true, -- if nil and file nesting is enabled, will enable expanders - expander_collapsed = "", - expander_expanded = "", + with_expanders = true, + expander_collapsed = "", + expander_expanded = "", expander_highlight = "NeoTreeExpander", }, git_status = { @@ -75,10 +86,25 @@ return { branch = "v3.x", dependencies = { "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - -- "MunifTanjim/nui.nvim", - "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information - } + "nvim-tree/nvim-web-devicons", + "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, } } - diff --git a/lua/pika/plugins/telekasten.lua b/lua/pika/plugins/telekasten.lua new file mode 100644 index 0000000..f56aea1 --- /dev/null +++ b/lua/pika/plugins/telekasten.lua @@ -0,0 +1,6 @@ +return{ + { + 'renerocksai/telekasten.nvim', + dependencies = {'nvim-telescope/telescope.nvim'} + }, +}