yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
6.61k stars 241 forks source link

Trim deep indentation #465

Open will-lynas opened 2 months ago

will-lynas commented 2 months ago

When working with deeply nested code, the sidebar view is not easy to read. I think it would be better if the code was left-trimmed so that there are no columns of pure whitespace.

image
aarnphm commented 2 months ago

this is actually intended, otherwise the LLM won't generate correct code.

We need to preserve indentation somehow. Maybe for rendering on sidebar we can skip indentation on view 🤔

Feel free to propose something here.

will-lynas commented 2 months ago

Yeah that's what I mean. Keep the original response but render a trimmed one.

aarnphm commented 2 months ago

feel free to contribute. Check sidebar.lua for this.

will-lynas commented 2 months ago

This is harder than I initially thought because of the token streaming.

And the fact that the code snippets are extracted directly from the content that is rendered in the sidebar: https://github.com/yetone/avante.nvim/blob/713cb403d0e3c3b9b8b9cacb1ca0ff5d6fc35a7d/lua/avante/sidebar.lua#L316

I guess a really hacky way to do this is:

But as a more general solution, what about this:

This way, we are free to change the formatting of the code in the sidebar without it affecting the actual diff.

I'm not sure how to handle partially complete code blocks. I can think of either:

What are your thoughts?