Skip to content

Commit

Permalink
refactor: vim.loop -> compat.uv; os.getenv -> compat.uv.os_getenv
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Nov 27, 2023
1 parent 773110e commit 1dee411
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,22 @@ local function add_dynamic_library_paths(workspace_root)
local sep = ':'
local win_sep = ';'
if shell.is_windows() then
local path = os.getenv('PATH') or ''
---@diagnostic disable-next-line: missing-parameter
local path = compat.uv.os_getenv('PATH') or ''
environments[workspace_root] = environments[workspace_root]
or {
PATH = rustc_target_path .. win_sep .. target_path .. win_sep .. path,
}
elseif shell.is_macos() then
local dkld_library_path = os.getenv('DKLD_LIBRARY_PATH') or ''
---@diagnostic disable-next-line: missing-parameter
local dkld_library_path = compat.uv.os_getenv('DKLD_LIBRARY_PATH') or ''
environments[workspace_root] = environments[workspace_root]
or {
DKLD_LIBRARY_PATH = rustc_target_path .. sep .. target_path .. sep .. dkld_library_path,
}
else
local ld_library_path = os.getenv('LD_LIBRARY_PATH') or ''
---@diagnostic disable-next-line: missing-parameter
local ld_library_path = compat.uv.os_getenv('LD_LIBRARY_PATH') or ''
environments[workspace_root] = environments[workspace_root]
or {
LD_LIBRARY_PATH = rustc_target_path .. sep .. target_path .. sep .. ld_library_path,
Expand Down
6 changes: 4 additions & 2 deletions lua/rustaceanvim/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ local function override_apply_text_edits()
end

local function is_library(fname)
local cargo_home = os.getenv('CARGO_HOME') or joinpath(vim.env.HOME, '.cargo')
---@diagnostic disable-next-line: missing-parameter
local cargo_home = compat.uv.os_getenv('CARGO_HOME') or joinpath(vim.env.HOME, '.cargo')
local registry = joinpath(cargo_home, 'registry', 'src')

local rustup_home = os.getenv('RUSTUP_HOME') or joinpath(vim.env.HOME, '.rustup')
---@diagnostic disable-next-line: missing-parameter
local rustup_home = compat.uv.os_getenv('RUSTUP_HOME') or joinpath(vim.env.HOME, '.rustup')
local toolchains = joinpath(rustup_home, 'toolchains')

for _, item in ipairs { toolchains, registry } do
Expand Down
8 changes: 5 additions & 3 deletions lua/rustaceanvim/shell.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
local M = {}

local compat = require('rustaceanvim.compat')

---@return boolean
function M.is_windows()
local sysname = vim.loop.os_uname().sysname
local sysname = compat.uv.os_uname().sysname
return sysname == 'Windows' or sysname == 'Windows_NT'
end

---@return boolean
function M.is_macos()
return vim.loop.os_uname().sysname == 'Darwin'
return compat.uv.os_uname().sysname == 'Darwin'
end

---@return boolean
local function is_nushell()
---@diagnostic disable-next-line: missing-parameter
local shell = vim.loop.os_getenv('SHELL')
local shell = compat.uv.os_getenv('SHELL')
local nu = 'nu'
-- Check if $SHELL ends in "nu"
return shell ~= nil and shell:sub(-string.len(nu)) == nu
Expand Down

0 comments on commit 1dee411

Please sign in to comment.