Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reduce the use of direct syscalls #1294

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local global = require("core.global")

-- Create cache dir and data dirs
local createdir = function()
local data_dir = {
local data_dirs = {
global.cache_dir .. "backup",
global.cache_dir .. "session",
global.cache_dir .. "swap",
Expand All @@ -12,10 +12,11 @@ local createdir = function()
}
-- Only check whether cache_dir exists, this would be enough.
if vim.fn.isdirectory(global.cache_dir) == 0 then
os.execute("mkdir -p " .. global.cache_dir)
for _, v in pairs(data_dir) do
if vim.fn.isdirectory(v) == 0 then
os.execute("mkdir -p " .. v)
---@diagnostic disable-next-line: param-type-mismatch
vim.fn.mkdir(global.cache_dir, "p")
for _, dir in pairs(data_dirs) do
if vim.fn.isdirectory(dir) == 0 then
vim.fn.mkdir(dir, "p")
end
end
end
Expand Down