-
I use Obsidian on Linux / Windows, and would like to use if vim.loop.os_uname().sysname == "Windows_NT" then
vim.g.obsidianDir = "~/source/docRepo/obDir/"
else
vim.g.obsidianDir = "~/winHome/source/docRepo/obDir/"
end However, when I set: workspaces = {
{
name = "personal",
path = vim.g.obsidianDir,
}, nvim will tell me the plugin cannot find that folder... Is there a way to dynamically set the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
obsidian.nvim/lua/obsidian/path.lua Line 171 in 6661806 |
Beta Was this translation helpful? Give feedback.
-
I even tried this: local workspacePaths = {
linux = "~/source/docRepo/obBase",
windows = "~/winHome/source/docRepo/obBase",
}
local function getWorkspacePath()
local os = vim.loop.os_uname().sysname
if os == "Linux" then
return workspacePaths.linux
elseif os == "Windows_NT" then
return workspacePaths.windows
else
error("Unsupported operating system: " .. os)
end
end
require("obsidian").setup({
workspaces = {
{
name = "personal",
path = getWorkspacePath(),
},
},
}) Still not working. It seems the |
Beta Was this translation helpful? Give feedback.
-
OK, I figured out: local Path = require("plenary.path")
local workspacePaths = {
windows = "~/source/docRepo/obBase",
linux = "~/winHome/source/docRepo/obBase",
}
local function getWorkspacePath()
local os = vim.loop.os_uname().sysname
local path
if os == "Linux" then
path = workspacePaths.linux
elseif os == "Windows_NT" then
path = workspacePaths.windows
else
error("Unsupported operating system: " .. os)
end
return Path:new(path):expand()
end But it is really good to allow direct assignment of vim global variables... |
Beta Was this translation helpful? Give feedback.
OK, I figured out:
But it is really good to allow direct assignment of vim global variables...