fix: change path handling

This commit is contained in:
2024-12-12 22:01:15 +01:00
parent eaa4ee2aa9
commit 6da204767c
2 changed files with 2 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
default_prompt_blocks: default_prompt_blocks:
- "basic prompt" - "basic-prompt"
directories: directories:
- "." - "."

View File

@@ -67,7 +67,7 @@ function M.get_project_files(directories)
local rel_files = {} local rel_files = {}
for _, f in ipairs(all_files) do for _, f in ipairs(all_files) do
local rel = f:gsub("^" .. root .. "/", "") local rel = vim.fn.fnamemodify(f, ":.")
table.insert(rel_files, rel) table.insert(rel_files, rel)
end end
@@ -102,27 +102,4 @@ function M.get_file_contents(files)
return table.concat(sections, "\n") return table.concat(sections, "\n")
end 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 return M