Skip to content

Commit

Permalink
fix(dirman): add raw_path option to work with arbitrary filetype (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pysan3 authored Nov 8, 2023
1 parent 6fac434 commit 0c9f5de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/neorg/modules/core/dirman/utils/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ local log, modules = neorg.log, neorg.modules
local module = neorg.modules.create("core.dirman.utils")

module.public = {
expand_path = function(path)
---Resolve `$<workspace>/path/to/file` and return the real path
---@param path string # path
---@param raw_path boolean? # If true, returns resolved path, else, return with appended ".norg"
---@return string? # Resolved path. If path does not start with `$` or not absolute, adds relative from current file.
expand_path = function(path, raw_path)
-- Expand special chars like `$`
local custom_workspace_path = path:match("^%$([^/\\]*)[/\\]")

Expand Down Expand Up @@ -47,7 +51,7 @@ module.public = {
path = (vim.tbl_contains({ "/", "~" }, path:sub(1, 1)) and "" or (vim.fn.expand("%:p:h") .. "/")) .. path
end

return path .. ".norg"
return path .. (raw_path and "" or ".norg")
end,
}

Expand Down

0 comments on commit 0c9f5de

Please sign in to comment.