-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace = true not replacing #50
Comments
Hi @Amzd , It seems the visual selection is lost. Can you try with the following? require('gen').prompts['Fix_Err'] = {
replace = true,
extract = "```$filetype\n(.-)```",
}
vim.keymap.set({'v', "n"}, '<leader>sf', function()
local lsp = vim.lsp
local cursor = vim.fn.getcurpos()
local line_number = cursor[2] - 1
local diagnostics = vim.diagnostic.get(0, { lnum = line_number })
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
local filecontents = table.concat(lines, "\n")
local line = tostring(line_number)
local error = diagnostics[1].message
require('gen').prompts['Fix_Err'].prompt = "This is my code: \n\n```$filetype\n" .. filecontents .. "```\n\n"
.. "Tell me the replacement for line " .. line
.. " that fixes the error \"" .. error
.. "\" in format: ```$filetype\n...\n``` without any other text."
- vim.api.nvim_command('Gen Fix_Err')
+ vim.cmd("'<,'>Gen Fix_Err")
end) |
Thanks for the suggestion @David-Kunz When I do that I get an error in the cmd function |
it works when the mode says -- (insert) VISUAL -- but I think I can only get into that with the mouse |
And in normal visual mode? |
In normal visual mode it does not work |
I also had issues with visual selection related commands. I use lazy and here is an example of selection keymap: {
"David-Kunz/gen.nvim",
opts = {
model = "mistral:7b", -- The default model to use.
},
keys = {
{
"<leader>cg",
"<cmd>Gen<cr>",
mode = "n",
noremap = true,
silent = true,
desc = "LLM tools",
},
{
"<leader>cg",
":'<,'>Gen<cr>",
mode = "v",
noremap = true,
silent = true,
desc = "LLM tools",
},
},
}, |
I'm facing something similar. In visual mode, replacement does not happen. I get the the below error: ^I/Users/sm/.local/share/nvim/lazy/gen.nvim/lua/gen/init.lua:325: in function </Users/sm/.local/share/nvim/lazy/gen.nvim/lua/gen/init.lua:317> |
dito. Here's the full error from :messages
|
Hey folks! Try this. If you select a "line" using "V", replace works like a charm. But if you select a "text-line", f.e. using "^v$", replace throws error. |
I created a custom prompt with
replace = true
but it just adds the result at the spot of the cursor without removing the selected part.It usually gets the code that would fix the error but it does not remove the selected part.
Am I doing something obviously wrong? I am new to vim.
The text was updated successfully, but these errors were encountered: