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

Fallback temp files to OS temp directory #177

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion lua/null-ls/loop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,20 @@ M.temp_file = function(content, bufname, dirname)

local filename = string.format(".null-ls_%d_%s", math.random(100000, 999999), base_name)
---@type string?
local temp_path = u.path.join(dirname, filename)
local temp_path

if u.path.exists(dirname) then
temp_path = u.path.join(dirname, filename)
else
local temp_dir =
-- windows
os.getenv("TEMP")
or os.getenv("TMP")
-- linux / mac
or os.getenv("TMPDIR")
or "/tmp"
temp_path = u.path.join(temp_dir, filename)
end

local fd, err = uv.fs_open(temp_path --[[@as string]], "w", 384)
if not fd then
Expand Down
Loading