From 0c9f5dea0cfe8b7c3d38f26651d82624079774ed Mon Sep 17 00:00:00 2001 From: takuto Date: Wed, 8 Nov 2023 22:52:39 +0900 Subject: [PATCH] fix(dirman): add `raw_path` option to work with arbitrary filetype (#1143) --- lua/neorg/modules/core/dirman/utils/module.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/neorg/modules/core/dirman/utils/module.lua b/lua/neorg/modules/core/dirman/utils/module.lua index e6e1fc982..772f733de 100644 --- a/lua/neorg/modules/core/dirman/utils/module.lua +++ b/lua/neorg/modules/core/dirman/utils/module.lua @@ -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 `$/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("^%$([^/\\]*)[/\\]") @@ -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, }