epwalsh / obsidian.nvim

Obsidian 🤝 Neovim
Apache License 2.0
3.77k stars 165 forks source link

Link global files #356

Open danilka4 opened 7 months ago

danilka4 commented 7 months ago

🚀 The feature, motivation and pitch

Obsidian has a feature to absolute link files [Text](file:///path/to/any/file.txt) that can then be opened up and edited. It would allow linkage to files outside the vault that are within their own organizational structure (such as tex files for papers and presentations).

Alternatives

No response

Additional context

image

krishna-godoi commented 6 months ago

@dawsers thanks for adding the base support! It doesn't do exactly what I wanted, though, so I added this to the configs:

         {
        ...
        follow_url_func = function(url)
            local abs_file_url = string.match(url, "file:(.+)")
            if abs_file_url ~= nil then
                vim.fn.execute("edit " .. abs_file_url)
            else
                vim.fn.jobstart({ "xdg-open", url })
            end
        end,
        ...
        }

This lets "gf" (along with the gf passthrough) open file links directly in neovim. Thought I'd add this here for anyone who's trying to get this working.