diff options
| author | William Boman <william@redwill.se> | 2021-05-17 14:37:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-17 14:37:13 +0200 |
| commit | ae93866358777fcf6766152dd55980c4778f4c59 (patch) | |
| tree | a1b36ba2e2aa09688c4cb96b645b03c34b728042 /lua/nvim-lsp-installer/path.lua | |
| parent | remove :LspInstallAll (diff) | |
| download | mason-ae93866358777fcf6766152dd55980c4778f4c59.tar mason-ae93866358777fcf6766152dd55980c4778f4c59.tar.gz mason-ae93866358777fcf6766152dd55980c4778f4c59.tar.bz2 mason-ae93866358777fcf6766152dd55980c4778f4c59.tar.lz mason-ae93866358777fcf6766152dd55980c4778f4c59.tar.xz mason-ae93866358777fcf6766152dd55980c4778f4c59.tar.zst mason-ae93866358777fcf6766152dd55980c4778f4c59.zip | |
add support for zx install scripts (#13)
Diffstat (limited to 'lua/nvim-lsp-installer/path.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/path.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/path.lua b/lua/nvim-lsp-installer/path.lua new file mode 100644 index 00000000..294d45e5 --- /dev/null +++ b/lua/nvim-lsp-installer/path.lua @@ -0,0 +1,38 @@ +local uv = vim.loop + +local sep = (function() +---@diagnostic disable-next-line: undefined-global + if jit then +---@diagnostic disable-next-line: undefined-global + local os = string.lower(jit.os) + if os == "linux" or os == "osx" or os == "bsd" then + return "/" + else + return "\\" + end + else + return package.config:sub(1, 1) + end +end)() + +local M = {} + +function M.cwd() + return uv.fs_realpath(".") +end + +function M.concat(path_components) + return table.concat(path_components, sep) +end + +-- @param relpath string The relative path to get the realpath(1) to. +-- @param depth number The depth in the call stack to introspect. This effectively controls which stack frame should be used when producing the realpath. +-- The file of the elected stack frame will be used as the "starting point" for the provided relpath. +-- +-- @return The realpath (absolute path). Note that this will currently produce results such as /Users/zuck/./script.js which may not be compatible with some tools. +function M.realpath(relpath, depth) + local callsite_abs_path = debug.getinfo(depth or 2, "S").source:sub(2) + return M.concat { vim.fn.fnamemodify(callsite_abs_path, ":h"), relpath } +end + +return M |
