From 4fe52534e12176ce334df58d3e36d0f595a89616 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 1 Aug 2025 02:23:23 +0200 Subject: [PATCH] feat(health): add temp dir writable check Signed-off-by: Tomas Slusny --- lua/CopilotChat/config/mappings.lua | 1 - lua/CopilotChat/health.lua | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/config/mappings.lua b/lua/CopilotChat/config/mappings.lua index 73cb25a0..3bd339cc 100644 --- a/lua/CopilotChat/config/mappings.lua +++ b/lua/CopilotChat/config/mappings.lua @@ -450,7 +450,6 @@ return { utils.schedule_main() table.insert(lines, '**Logs**: `' .. copilot.config.log_path .. '`') table.insert(lines, '**History**: `' .. copilot.config.history_path .. '`') - table.insert(lines, '**Temp Files**: `' .. vim.fn.fnamemodify(os.tmpname(), ':h') .. '`') table.insert(lines, '') for provider, infolines in pairs(infos) do diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index a75416ee..acfc5bd2 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -55,6 +55,25 @@ function M.check() error('setup: not called, required for plugin to work. See `:h CopilotChat-installation`.') end + start('CopilotChat.nvim [filesystem]') + + local testfile = os.tmpname() + local f = io.open(testfile, 'w') + local writable = false + if f then + f:write('test') + f:close() + writable = true + end + if writable then + ok('temp dir: writable (' .. testfile .. ')') + os.remove(testfile) + else + local stat = vim.loop.fs_stat(vim.fn.fnamemodify(testfile, ':h')) + local perms = stat and string.format('%o', stat.mode % 512) or 'unknown' + error('temp dir: not writable. Permissions: ' .. perms .. ' (dir: ' .. vim.fn.fnamemodify(testfile, ':h') .. ')') + end + start('CopilotChat.nvim [commands]') local curl_version = run_command('curl', '--version')