David-Kunz / gen.nvim

Neovim plugin to generate text using LLMs with customizable prompts
The Unlicense
977 stars 62 forks source link

`$text` only grab a single character into prompt #84

Closed gzfrozen closed 3 months ago

gzfrozen commented 3 months ago

While Select any amount of text (both in v and V mode), use prompt contains $text to generate, there seems to be only one character is grabbed into the prompt.

In the following example, it seems only , is send to the prompt.

image

The prompt I am using:

prompt = "Explain the meaning of following code:\n```$filetype\n$text\n```",
David-Kunz commented 3 months ago

Hi @gzfrozen ,

Thanks for reporting, do you have an example?

How do you select the text, with v or V?

gzfrozen commented 3 months ago

@David-Kunz I tried both v select and V select, single line and multiple lines. But all seem to only grab the character under the final cursor's place.

David-Kunz commented 3 months ago

Thank you @gzfrozen , it works for me. Are you using the newest version?

gzfrozen commented 3 months ago

@David-Kunz Yes. I started to use this plugin yesterday so I think it"s the newest version.

gzfrozen commented 3 months ago

@David-Kunz https://github.com/gzfrozen/gen.nvim/commit/8e1999ef97a4a41f9d95888fc9b8677cc296094c

I tried to debug this by print out the grabbed content, and it seems to grab only 1 character:

image
David-Kunz commented 3 months ago

Thank you, @gzfrozen , could you update the plugin? Yesterday there have been many changes. Thank you!

gzfrozen commented 3 months ago

@David-Kunz I updated to the latest version (46ab810). And it is still unfixed.

David-Kunz commented 3 months ago

Thank you, @gzfrozen .

Could you try it with the following keymap?

vim.keymap.set({ 'n', 'v' }, '<leader>]', ':Gen<CR>')

then select some text (e.g. with shift-v) and trigger the command.

So far, I could not reproduce your issue.

gzfrozen commented 3 months ago

Thank you, @gzfrozen .

Could you try it with the following keymap?

vim.keymap.set({ 'n', 'v' }, '<leader>]', ':Gen<CR>')

then select some text (e.g. with shift-v) and trigger the command.

So far, I could not reproduce your issue.

@David-Kunz Wow, that fix my problem. Thank you!

My key binding target command was <cmd>Gen<GR>, and it failed. After I change it to :Gen<GR> and the problem is fixed.

I'm new to vim and don't know the difference between <cmd> and :, so there is a difference I guess.

David-Kunz commented 3 months ago

Thanks for confirming, @gzfrozen !