Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): adds an optional callback when directory changes #151

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
```

Expand Down
3 changes: 3 additions & 0 deletions lua/project_nvim/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lua/project_nvim/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down