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