Prompts that use $sel fail when the selected text contains the string %2.
Neovim throws an error, and no prompt is submitted.
> Error executing vim.schedule lua callback: ...l/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:183: invalid capture index
stack traceback:
[C]: in function 'gsub'
...l/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:183: in function 'parse_prompt'
...l/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:249: in function 'callback'
...l/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:205: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
This is because gsub treats the % character a bit magically!
Prompts that use
$sel
fail when the selected text contains the string%2
.Neovim throws an error, and no prompt is submitted.
This is because
gsub
treats the%
character a bit magically!https://www.lua.org/pil/20.4.html suggests escaping any
%
characters first, but there might be other solutions too.