Skip to content

Is there a way to set the path using global variables? #536

Answered by xarthurx
xarthurx asked this question in Q&A
Discussion options

You must be logged in to vote

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...

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by xarthurx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant