Skip to content

Commit

Permalink
feat(dirman): in_workspace function (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas authored Dec 10, 2024
1 parent 0460ccd commit 62671a7
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 62671a7

Please sign in to comment.