diff options
| author | William Boman <william@redwill.se> | 2022-06-06 00:25:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-06 00:25:50 +0200 |
| commit | 2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c (patch) | |
| tree | e10f9c1eb1267b7ff52ac9dc7faa8b1b7b8d73d8 | |
| parent | feat: add apex_ls (#746) (diff) | |
| download | mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.tar mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.tar.gz mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.tar.bz2 mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.tar.lz mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.tar.xz mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.tar.zst mason-2f38d3bb39cdfb7b2e543e4af1b030261b0b1b6c.zip | |
fix(platform): memoize .get_libc() ret val (#753)
| -rw-r--r-- | lua/nvim-lsp-installer/core/platform.lua | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lua/nvim-lsp-installer/core/platform.lua b/lua/nvim-lsp-installer/core/platform.lua index 58847d2c..10427a63 100644 --- a/lua/nvim-lsp-installer/core/platform.lua +++ b/lua/nvim-lsp-installer/core/platform.lua @@ -1,6 +1,5 @@ -local functional = require "nvim-lsp-installer.core.functional" +local _ = require "nvim-lsp-installer.core.functional" local Result = require "nvim-lsp-installer.core.result" -local lazy = functional.lazy local M = {} local uname = vim.loop.os_uname() @@ -28,16 +27,6 @@ M.is_unix = vim.fn.has "unix" == 1 M.is_mac = vim.fn.has "mac" == 1 M.is_linux = not M.is_mac and M.is_unix --- @return string @The libc found on the system, musl or glibc (glibc if ldd is not found) -function M.get_libc() - local _, _, libc_exit_code = os.execute "ldd --version 2>&1 | grep -q musl" - if libc_exit_code == 0 then - return "musl" - else - return "glibc" - end -end - -- PATH separator M.path_sep = M.is_win and ";" or ":" @@ -70,7 +59,7 @@ function M.when(cases) end ---@type async fun(): table -M.os_distribution = lazy(function() +M.os_distribution = _.lazy(function() ---Parses the provided contents of an /etc/\*-release file and identifies the Linux distribution. ---@param contents string @The contents of a /etc/\*-release file. ---@return table<string, any> @@ -130,7 +119,7 @@ M.os_distribution = lazy(function() end) ---@type async fun() Result @of String -M.get_homebrew_prefix = lazy(function() +M.get_homebrew_prefix = _.lazy(function() assert(M.is_mac, "Can only locate Homebrew installation on Mac systems.") local spawn = require "nvim-lsp-installer.core.spawn" return spawn.brew({ "--prefix" }) @@ -142,6 +131,16 @@ M.get_homebrew_prefix = lazy(function() end) end) +-- @return string @The libc found on the system, musl or glibc (glibc if ldd is not found) +M.get_libc = _.lazy(function() + local _, _, libc_exit_code = os.execute "ldd --version 2>&1 | grep -q musl" + if libc_exit_code == 0 then + return "musl" + else + return "glibc" + end +end) + M.is = setmetatable({}, { __index = function(_, key) local platform, arch = unpack(vim.split(key, "_", { plain = true })) |
