Closed RobertBrunhage closed 1 month ago
Hi @RobertBrunhage, can you share the head of your chat file. There are basically 3 things that must hold according to https://github.com/frankroeder/parrot.nvim/blob/670e5d6768690620fe9d7bd0959228c89b4f0dda/lua/parrot/utils.lua#L257 for parrot.nvim to recognize the file as chat. Have you deleted the first lines of the initial chat file?
The config looks fine, I have checked it locally. Dunno what follows, so you might delete the comma after the last bracket.
@frankroeder here is the entire chat file (had to remove the ending quotes of the code snippet because github formatting was off)
# topic: ?
---
🗨:
I have the following content from /Users/robertbrunhage/personal/projects/.dotfiles/nvim/.config/nvim/lua/plugins.lua:
```lua
{
"frankroeder/parrot.nvim",
tag = "v0.3.7",
dependencies = { "ibhagwan/fzf-lua", "nvim-lua/plenary.nvim" },
-- optionally include "rcarriga/nvim-notify" for beautiful notifications
config = function()
require("parrot").setup({
providers = {
anthropic = {
api_key = "api keeeeey :)",
},
},
})
end,
},
How does this look?
I want to add that other functionality works such as PrtImplement
etc but not responding in a chat
@RobertBrunhage, I have tested this with a minimal Neovim setup, with only lazy.nvim and parrot.nvim installed. As expected, there are no issues regarding the chat file detection. Therefore, I am unable to reproduce your case. Feel free to try it yourself (https://lazy.folke.io/installation).
Let me know if you have further hints!
Going to debug a bit more but I would like to say I have quite a lean neovim config setup https://github.com/RobertBrunhage/nvim/tree/main
Update: after debugging I think it's related to using stow for symlinks as chat_dir is looking at the incorrect place, here are some logs
file_name: /Users/robertbrunhage/personal/projects/.dotfiles/bin/.local/share/nvim/parrot/chats/2024-07-27.07-28-03.038.md
chat_dir: /Users/robertbrunhage/.local/share/nvim/parrot/chats
File name does not start with chat_dir
Here is the updated code snippet for adding prints
---@param buf number # buffer number
---@param file_name string # name of the file
---@param chat_dir string # directory path for chat files
---@return boolean # returns true if file is a chat file
M.is_chat = function(buf, file_name, chat_dir)
-- Print for debugging
print("file_name: " .. file_name)
print("chat_dir: " .. chat_dir)
-- Check if file_name starts with chat_dir
if not M.starts_with(file_name, chat_dir) then
print("File name does not start with chat_dir")
return false
end
-- Get the lines from the buffer
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
-- Print lines for debugging
print("Lines:", vim.inspect(lines))
-- Check if the number of lines is less than 4
if #lines < 4 then
print("Less than 4 lines in the file")
return false
end
-- Check if the first line starts with '# '
if not lines[1]:match("^# ") then
print("First line does not start with '# '")
return false
end
return true
end
I was also thinking about something like a symlink. It’s great that you found the error! I apologize for not considering your PR. I had to add the same check for the other config directory too (see https://github.com/frankroeder/parrot.nvim/commit/91bbf78c6bda02cd73bc7ab7c512269e54). Furthermore, I believe it is cleaner to handle this in the main code rather than inside the config.
I was also thinking about something like a symlink. It’s great that you found the error! I apologize for not considering your PR. I had to add the same check for the other config directory too (see 91bbf78). Furthermore, I believe it is cleaner to handle this in the main code rather than inside the config.
No worries at all! Thanks for the quick response and implementing a fix!
@frankroeder I just started using the latest tag instead of my fork and I still get the issue, but only in repos that is not my neovim/.dotfiles repo.
file_name: /Users/robertbrunhage/personal/projects/.dotfiles/bin/.local/share/nvim/parrot/chats/2024-07-30.07-17-08.673.md
chat_dir: /Users/robertbrunhage/.local/share/nvim/parrot/chats
File name does not start with chat_dir
Just to verify I went back to my fork and made sure it was updated with latest changes for this repo, which still didn't work. Then I added in my change again and it worked.
Okay, maybe I'm still misunderstanding your setup — sorry! I just tested it with the "chat" folder being a symlink, and I didn't encounter any issues. What do you mean by "that are not your repo"? Are you testing out other dotfiles?
Hmm, why does it end up in the bin/
folder?
Instead of using your fork, you could simply add this to your Parrot config:
chat_dir = vim.loop.fs_realpath(vim.fn.stdpath("data"):gsub("/$", "") .. "/parrot/chats"
Thanks for reporting!
Okay, maybe I'm still misunderstanding your setup — sorry! I just tested it with the "chat" folder being a symlink, and I didn't encounter any issues. What do you mean by "that are not your repo"? Are you testing out other dotfiles?
It works when I am testing chat in my dotfiles where neovim is setup
When I am opening another location (such as another project), it does not.
If it helps I am using stow
for symlinking and the neovim repo is a submodule of my .dotfiles https://github.com/RobertBrunhage/.dotfiles/tree/main/nvim/.config
Instead of using your fork, you could simply add this to your Parrot config:
chat_dir = vim.loop.fs_realpath(vim.fn.stdpath("data"):gsub("/$", "") .. "/parrot/chats")
Thanks for reporting!
Using this works without the fork!
I've gone through the configuration and is using the following config.
The chat file is named
~/.local/share/nvim/parrot/chats/2024-07-26.14-53-45.300.md
, and opened through:PrtChatNew
and tried to respond with:PrtChatRespond
.Am I missing something in the config?