nomnivore / ollama.nvim

A plugin for managing and integrating your ollama workflows in neovim.
MIT License
311 stars 22 forks source link

crash for any action with latest version of nvim #29

Open prabhakarjuzgar opened 3 months ago

prabhakarjuzgar commented 3 months ago

Error executing vim.schedule lua callback: ...r/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:173: start_col must be less than end_col stack traceback: [C]: in function 'nvim_buf_get_text' ...r/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:173: in function 'parse_prompt' ...r/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:249: in function 'callback' ...r/.local/share/nvim/lazy/ollama.nvim/lua/ollama/init.lua:205: in function 'cb' ...ocal/share/nvim/lazy/dressing.nvim/lua/dressing/util.lua:203: in function <...ocal/share/nvim/lazy/dressing.nvim/lua/dressing/util.lua:202> Press ENTER or type command to continue

mclarkson commented 2 months ago

I got this as well. Code needs to be selected first.

yamsergey commented 2 months ago

I've faced similar issue (not the same though) and tried to debug, it leads me to this line https://github.com/nomnivore/ollama.nvim/blob/d99e2462be8875602d173c117d5301862669d985/lua/ollama/actions/factory.lua#L145

It was my first experience with lua, but seems that vim.api.nvim_buf_set_text is a bit fragile, and might be not the best choice when number of lines doesn't match for original and suggested text. I ended up by replacing it with:

    vim.api.nvim_buf_set_lines(bufnr, start_line, end_line, false, {})
    vim.api.nvim_buf_set_lines(bufnr, start_line, start_line, false, lines)