fix: change path handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
default_prompt_blocks:
|
default_prompt_blocks:
|
||||||
- "basic prompt"
|
- "basic-prompt"
|
||||||
directories:
|
directories:
|
||||||
- "."
|
- "."
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user