fix(chezmoi): use vim.env.HOME instead of os.getenv("HOME") for Windows compatibility

vim.env.HOME works correctly on Windows where the HOME environment variable may not be set, while os.getenv("HOME") returns nil in such cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Folke Lemaitre
2025-10-24 06:06:38 +02:00
parent 5098a69870
commit 231e476ec9

View File

@@ -5,10 +5,15 @@ local pick_chezmoi = function()
local fzf_lua = require("fzf-lua") local fzf_lua = require("fzf-lua")
local actions = { local actions = {
["enter"] = function(selected) ["enter"] = function(selected)
fzf_lua.actions.vimcmd_entry("ChezmoiEdit", selected, { cwd = os.getenv("HOME") }) fzf_lua.actions.vimcmd_entry("ChezmoiEdit", selected, { cwd = vim.env.HOME })
end, end,
} }
fzf_lua.files({ cmd = "chezmoi managed --include=files,symlinks", actions = actions, hidden = false }) fzf_lua.files({
cmd = "chezmoi managed --include=files,symlinks",
actions = actions,
cwd = vim.env.HOME,
hidden = false,
})
elseif LazyVim.pick.picker.name == "snacks" then elseif LazyVim.pick.picker.name == "snacks" then
local results = require("chezmoi.commands").list({ local results = require("chezmoi.commands").list({
args = { args = {
@@ -50,7 +55,7 @@ return {
"alker0/chezmoi.vim", "alker0/chezmoi.vim",
init = function() init = function()
vim.g["chezmoi#use_tmp_buffer"] = 1 vim.g["chezmoi#use_tmp_buffer"] = 1
vim.g["chezmoi#source_dir_path"] = os.getenv("HOME") .. "/.local/share/chezmoi" vim.g["chezmoi#source_dir_path"] = vim.env.HOME .. "/.local/share/chezmoi"
end, end,
}, },
{ {
@@ -80,7 +85,7 @@ return {
init = function() init = function()
-- run chezmoi edit on file enter -- run chezmoi edit on file enter
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" }, pattern = { vim.env.HOME .. "/.local/share/chezmoi/*" },
callback = function() callback = function()
vim.schedule(require("chezmoi.commands.__edit").watch) vim.schedule(require("chezmoi.commands.__edit").watch)
end, end,