Skip to content

Commit

Permalink
feat: allow upward paths in tangle
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 authored and vhyrro committed Dec 27, 2023
1 parent c4fc7e6 commit 265e6af
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/neorg/modules/core/tangle/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,17 @@ module.on_event = function(event)
local tangled_count = 0

for file, content in pairs(tangles) do
local upward_count = 0
for _ in string.gmatch(file, "%.%.[\\/]") do
upward_count = upward_count + 1
end
if upward_count > 0 then
-- adding one because the filename also has to be removed
local base = vim.fn.fnamemodify(vim.fn.expand("%"), ":p" .. string.rep(":h", upward_count + 1))
local path, _count = string.gsub(file, "%.%.[\\/]", "")
file = vim.fs.joinpath(base, path)
end

vim.loop.fs_open(
vim.fn.expand(file), ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
"w",
Expand Down

0 comments on commit 265e6af

Please sign in to comment.