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

fix(dirman): add raw_path option to work with arbitrary filetype #1143

Merged
merged 1 commit into from
Nov 8, 2023
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
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
Loading