From d660d9be8d871027c5135c961e33cebb72745227 Mon Sep 17 00:00:00 2001 From: Marco Mayer Date: Fri, 2 Feb 2024 10:27:51 +0100 Subject: [PATCH] check if state file exists before trying to open it Fixes an issue with an warning popping up on new installations if the state file does not exist. --- lua/gp/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/gp/init.lua b/lua/gp/init.lua index d351311..9eab3d6 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -887,7 +887,10 @@ end M.refresh_state = function() local state_file = M.config.state_dir .. "/state.json" - local state = M.file_to_table(state_file) or {} + local state = {} + if vim.fn.filereadable(state_file) ~= 0 then + state = M.file_to_table(state_file) or {} + end M._state.chat_agent = M._state.chat_agent or state.chat_agent or nil if M._state.chat_agent == nil or not M.agents[M._state.chat_agent] then