Skip to content

Commit 4a23258

Browse files
committed
feat: use vim.env and vim.uv for env and cwd access
1 parent f77e382 commit 4a23258

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

lua/core/global.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function global:load_variables()
1010
self.cache_dir = vim.fn.stdpath("cache")
1111
self.data_dir = string.format("%s/site/", vim.fn.stdpath("data"))
1212
self.modules_dir = self.vim_path .. "/modules"
13-
self.home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME")
13+
self.home = self.is_windows and vim.env.USERPROFILE or vim.env.HOME
1414
end
1515

1616
global:load_variables()

lua/core/options.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ local function load_options()
118118
end
119119

120120
-- Custom python provider
121-
local conda_prefix = os.getenv("CONDA_PREFIX")
121+
local conda_prefix = vim.env.CONDA_PREFIX
122122
if not isempty(conda_prefix) then
123123
vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, conda_prefix .. "/bin/python")
124124
vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, conda_prefix .. "/bin/python")

lua/modules/configs/lang/render-markdown.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ return function()
1414
-- This enables hiding any added text on the line the cursor is on
1515
-- This does have a performance penalty as we must listen to the 'CursorMoved' event
1616
anti_conceal = { enabled = true },
17-
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
17+
-- The level of logs to write to file: vim.fn.stdpath("state") .. "/render-markdown.log"
1818
-- Only intended to be used for plugin development / debugging
1919
log_level = "error",
2020
})

lua/modules/configs/tool/dap/clients/python.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ return function()
5454
program = utils.input_file_path(),
5555
pythonPath = function()
5656
-- Prefer the venv that is defined by the designated environment variable.
57-
local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV")
57+
local cwd, venv = vim.uv.cwd(), vim.env.VIRTUAL_ENV
5858
local python = venv and (is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python") or ""
5959
if vim.fn.executable(python) == 1 then
6060
return python

lua/modules/configs/tool/trouble.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ return function()
2727
any = {
2828
{
2929
function(item)
30-
return item.filename:find(vim.fn.getcwd(), 1, true)
30+
return item.filename:find(vim.uv.cwd(), 1, true)
3131
end,
3232
},
3333
},

lua/modules/configs/ui/lualine.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ return function()
274274
end
275275

276276
if vim.bo.filetype == "python" then
277-
local venv = os.getenv("CONDA_DEFAULT_ENV")
277+
local venv = vim.env.CONDA_DEFAULT_ENV
278278
if venv then
279279
return icons.misc.PyEnv .. env_cleanup(venv)
280280
end
281-
venv = os.getenv("VIRTUAL_ENV")
281+
venv = vim.env.VIRTUAL_ENV
282282
if venv then
283283
return icons.misc.PyEnv .. env_cleanup(venv)
284284
end
@@ -298,7 +298,7 @@ return function()
298298

299299
cwd = {
300300
function()
301-
return icons.ui.FolderWithHeart .. utils.abbreviate_path(vim.fs.normalize(vim.fn.getcwd()))
301+
return icons.ui.FolderWithHeart .. utils.abbreviate_path(vim.fs.normalize(vim.uv.cwd()))
302302
end,
303303
color = utils.gen_hl("subtext0", true, true, nil, "bold"),
304304
},

lua/modules/utils/dap.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515

1616
function M.get_env()
1717
local variables = {}
18-
for k, v in pairs(vim.fn.environ()) do
18+
for k, v in pairs(vim.uv.os_environ()) do
1919
table.insert(variables, string.format("%s=%s", k, v))
2020
end
2121
return variables

lua/modules/utils/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ end
193193
---@return palette
194194
function M.get_palette(overwrite)
195195
if not overwrite then
196-
return vim.deepcopy(init_palette())
196+
return vim.deepcopy(init_palette(), true)
197197
else
198198
return vim.tbl_extend("force", init_palette(), overwrite)
199199
end

0 commit comments

Comments
 (0)