diff options
| author | William Boman <william@redwill.se> | 2025-02-15 21:00:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-15 21:00:35 +0100 |
| commit | 3a444cb7b0cee6b1e2ed31b7e76f37509075dc46 (patch) | |
| tree | 4cfc848de225c78f0b9ff63a64902203b9c043b7 /lua | |
| parent | fix(ui): reposition window if border is different than "none" (#1859) (diff) | |
| download | mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.tar mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.tar.gz mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.tar.bz2 mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.tar.lz mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.tar.xz mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.tar.zst mason-3a444cb7b0cee6b1e2ed31b7e76f37509075dc46.zip | |
fix: avoid calling vim.fn in fast event (#1878)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-core/package/init.lua | 3 | ||||
| -rw-r--r-- | lua/mason-core/platform.lua | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lua/mason-core/package/init.lua b/lua/mason-core/package/init.lua index a5b14548..899370fa 100644 --- a/lua/mason-core/package/init.lua +++ b/lua/mason-core/package/init.lua @@ -7,6 +7,7 @@ local a = require "mason-core.async" local fs = require "mason-core.fs" local log = require "mason-core.log" local path = require "mason-core.path" +local platform = require "mason-core.platform" local registry = require "mason-registry" local is_not_nil = _.complement(_.is_nil) @@ -87,7 +88,7 @@ local PackageMt = { __index = Package } ---@param spec PackageSpec | RegistryPackageSpec local function validate_spec(spec) - if vim.fn.has "nvim-0.11" ~= 1 then + if platform.cached_features["nvim-0.11"] ~= 1 then return end if is_registry_spec(spec) then diff --git a/lua/mason-core/platform.lua b/lua/mason-core/platform.lua index cd958abc..1fe20e5e 100644 --- a/lua/mason-core/platform.lua +++ b/lua/mason-core/platform.lua @@ -66,7 +66,7 @@ end) -- Most of the code that calls into these functions executes outside of the main event loop, where API/fn functions are -- disabled. We evaluate these immediately here to avoid issues with main loop synchronization. -local cached_features = { +M.cached_features = { ["win"] = vim.fn.has "win32", ["win32"] = vim.fn.has "win32", ["win64"] = vim.fn.has "win64", @@ -74,6 +74,7 @@ local cached_features = { ["darwin"] = vim.fn.has "mac", ["unix"] = vim.fn.has "unix", ["linux"] = vim.fn.has "linux", + ["nvim-0.11"] = vim.fn.has "nvim-0.11", } ---@type fun(env: string): boolean @@ -104,7 +105,7 @@ local check_env = _.memoize(_.cond { M.is = setmetatable({}, { __index = function(__, key) local os, arch, env = unpack(vim.split(key, "_", { plain = true })) - if not cached_features[os] or cached_features[os] ~= 1 then + if not M.cached_features[os] or M.cached_features[os] ~= 1 then return false end if arch and arch ~= M.arch then |
