From 6da204767c60bf21abf49375470a606d8d5d5636 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Thu, 12 Dec 2024 22:01:15 +0100 Subject: [PATCH] fix: change path handling --- .chatgpt_config.yaml | 2 +- lua/chatgpt_nvim/context.lua | 25 +------------------------ 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/.chatgpt_config.yaml b/.chatgpt_config.yaml index 83a99c9..658ecfb 100644 --- a/.chatgpt_config.yaml +++ b/.chatgpt_config.yaml @@ -1,4 +1,4 @@ default_prompt_blocks: - - "basic prompt" + - "basic-prompt" directories: - "." diff --git a/lua/chatgpt_nvim/context.lua b/lua/chatgpt_nvim/context.lua index f695e68..f26df99 100644 --- a/lua/chatgpt_nvim/context.lua +++ b/lua/chatgpt_nvim/context.lua @@ -67,7 +67,7 @@ function M.get_project_files(directories) local rel_files = {} for _, f in ipairs(all_files) do - local rel = f:gsub("^" .. root .. "/", "") + local rel = vim.fn.fnamemodify(f, ":.") table.insert(rel_files, rel) end @@ -102,27 +102,4 @@ function M.get_file_contents(files) return table.concat(sections, "\n") end -function M.get_current_file() - local current_path = vim.fn.expand("%:p") - if current_path == "" then - return nil, nil - end - local fd = uv.fs_open(current_path, "r", 438) - if not fd then return nil, current_path end - local stat = uv.fs_fstat(fd) - local data = uv.fs_read(fd, stat.size, 0) - uv.fs_close(fd) - return data, current_path -end - -function M.get_readme_content() - local root = vim.fn.getcwd() - local fd = uv.fs_open(root .. "/README.md", "r", 438) - if not fd then return nil end - local stat = uv.fs_fstat(fd) - local data = uv.fs_read(fd, stat.size, 0) - uv.fs_close(fd) - return data -end - return M