Skip to content

feat(dirman): in_workspace function #1615

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

Merged
merged 1 commit into from
Dec 10, 2024
Merged
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
16 changes: 15 additions & 1 deletion lua/neorg/modules/core/dirman/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ module.public = {
get_workspace = function(name)
return module.config.public.workspaces[name]
end,
--- Returns a table in the format { "workspace_name", "path" }
--- @return { [1]: string, [2]: PathlibPath }
get_current_workspace = function()
return module.private.current_workspace
end,
Expand Down Expand Up @@ -472,6 +472,20 @@ module.public = {
end)
end
end,

---Is the file a part of the given workspace?
---@param file PathlibPath
---@param workspace_name string? workspace or current ws when nil
---@return boolean
in_workspace = function(file, workspace_name)
local ws_path
if not workspace_name then
ws_path = module.private.current_workspace[2]
else
ws_path = module.public.get_workspace(workspace_name)
end
return not not file:match("^" .. ws_path)
end,
}

module.on_event = function(event)
Expand Down
Loading