From 517f8e6f17b4dc3b1705b8890b9f88cc67cfe382 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Fri, 19 Apr 2024 09:43:26 -0700 Subject: [PATCH] feat(): adds an optional callback when directory changes --- README.md | 3 +++ lua/project_nvim/config.lua | 3 +++ lua/project_nvim/project.lua | 3 +++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index bad08b4..ed3f44c 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,9 @@ use { -- Path where project.nvim will store the project history for use in -- telescope datapath = vim.fn.stdpath("data"), + + -- A function to call then directory is changed + on_chdir = nil, } ``` diff --git a/lua/project_nvim/config.lua b/lua/project_nvim/config.lua index 36e3027..3419633 100644 --- a/lua/project_nvim/config.lua +++ b/lua/project_nvim/config.lua @@ -40,6 +40,9 @@ M.defaults = { -- Path where project.nvim will store the project history for use in -- telescope datapath = vim.fn.stdpath("data"), + + -- A function to call then directory is changed + on_chdir = nil, } ---@type ProjectOptions diff --git a/lua/project_nvim/project.lua b/lua/project_nvim/project.lua index fed310b..0629789 100644 --- a/lua/project_nvim/project.lua +++ b/lua/project_nvim/project.lua @@ -189,6 +189,9 @@ function M.set_pwd(dir, method) if config.options.silent_chdir == false then vim.notify("Set CWD to " .. dir .. " using " .. method) end + if config.options.on_chdir then + config.options.on_chdir() + end end return true end