David-Kunz / gen.nvim

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

[Feature Request] [QoL] Add an option to split horizontally instead of vertically if the window height is greater than the width #94

Closed gabrilend closed 1 month ago

gabrilend commented 2 months ago

Currently, when creating a new split in Nvim using gen.nvim, the plugin defaults to opening a vertical split such that the conversation with the LLM is on the left, and the previously opened file is on the right.

This behavior is fine when there is more horizontal space than vertical, as is the case on most landscape orientation monitors. However when working from a CLI it is often desirable to have windows arranged tall and thin, rather than short and wide.

The proposed behavior is to dynamically check the height and width of the terminal window when creating a new nvim split and if the height is greater than the width (perhaps by 20% or more) then the split should be made below the previously opened file, thus preserving the horizontal space (which is in limited supply compared to the vertical space)

Current behavior:
*------------------------------------------------------------------------------*
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|             gen.nvim                 |              source code              |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
|                                      |                                       |
*------------------------------------------------------------------------------*
Proposed behavior:
*------------------------------------------------------------------------------*
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                 source code                                  |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
*------------------------------------------------------------------------------*
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                   gen.nvim                                   |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
*------------------------------------------------------------------------------*

I believe this behavior would allow for less disruption to the currently viewed source-code, which is often structured around the width of the document rather than the height. Many style guides restrict code to a length of 80, 100, or 120 characters and altering the width of the code can make it difficult to maintain a sense of cohesion when working in tandem with the LLM agent.

David-Kunz commented 1 month ago

Thanks for this nice feature request, @gabrilend 👍 You can now use display_mode = 'horizontal-split'.