Skip to content
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

Feature inquiry/request: Setting max linewidth for AI output #27

Closed
aJns opened this issue Apr 28, 2023 · 10 comments
Closed

Feature inquiry/request: Setting max linewidth for AI output #27

aJns opened this issue Apr 28, 2023 · 10 comments

Comments

@aJns
Copy link

aJns commented Apr 28, 2023

Hello,

I usually use vim on a side monitor or split, so that I can comfortably read maybe 130 characters. AI output usually exceeds this.

Is there a way to set a maximum linewidth? How difficult would it be to add an option? I could look into implementing that option with some guidance.

Best regards,
aJns

@madox2
Copy link
Owner

madox2 commented Apr 28, 2023

Hi, I assume your vim/nvim is configured to not wrap lines. If that's the case, a good solution could be wrapping lines just in the chat, e.g. run this within a chat window: :setlocal wrap.

Does it help?

@aJns
Copy link
Author

aJns commented May 2, 2023

:setlocal wrap does not seem to have any effect with AIChat or AI. I ran both in an empty buffer.

@madox2
Copy link
Owner

madox2 commented May 2, 2023

I am not sure what are you trying to accomplish. Could you attach a screenshot of what is the actual behavior and what would you like it to be?

@madox2
Copy link
Owner

madox2 commented May 2, 2023

I have added a new ui.paste_mode option that allows indentation when disabled. This would also allow you to set textwidth for the chat buffer which breaks lines automatically. For example you can use it like this:

let g:vim_ai_chat = {
\  "ui": {
\    "paste_mode": 0,
\  },
\}
autocmd FileType aichat setlocal textwidth=130

Note that it is experimental as it could mess up indentation completely if used in incorrect context, but should be safe for use in the chat buffer.

@aJns
Copy link
Author

aJns commented May 3, 2023

Here's a screenshot:
image

@madox2
Copy link
Owner

madox2 commented May 3, 2023

I see, does my previous comment resolve the issue? (you need to update the plugin before trying out)

@jeromedalbert
Copy link

setlocal textwidth works for me with paste_mode set to 0.

I think AIChat should be configured with a textwidth by default.

@madox2
Copy link
Owner

madox2 commented May 8, 2023

I think that it depends. If you use to copy data from the chat, it could be quite uncomfortable to join lines every time. Also it does not fit well when used in combination with right sider ("open_chat_command": "preset_right"). For now I will keep defaults as they are, add this tip on the wiki page.

@madox2 madox2 closed this as completed May 8, 2023
@marcelarie
Copy link

I add it to the initial prompt:

		vim.cmd [[
			let g:vim_ai_chat = {
			\  "options": {
			\    "model": "gpt-4-1106-preview",
			\    "max_tokens": 1000,
			\    "temperature": 1,
			\    "request_timeout": 20,
			\    "selection_boundary": "",
			\    "initial_prompt": ">>> system\n - You are a code assistant\n - Always add line breaks at collumn 78\n - Always use 80 characters for each line of the respone\n - If you attach a code block add syntax type after ``` to enable syntax highlighting.\n",
			\  },
			\  "ui": {
			\    "code_syntax_enabled": 1,
			\    "populate_options": 0,
			\    "open_chat_command": "preset_right",
			\    "scratch_buffer_keep_open": 0,
			\  },
			\}
		]]

@brunobispo
Copy link

Does anybody know if it is possible to set set wrap for all chats without having to manually run it every time I start a new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants