Conversation
- Updated `g:chat_gpt_lang` initialization to differentiate between Vim and Neovim, using `v:null` for Neovim compatibility. - Added a new menu interface for Neovim using `inputlist` to enhance user interaction with ChatGPT commands. - Tested on Neovim v0.10.1.
There was a problem hiding this comment.
Pull Request Overview
This PR adds Neovim compatibility to the ChatGPT plugin by adjusting the language variable initialization and introducing an interactive menu interface using inputlist.
- Differentiate
g:chat_gpt_langdefault between Vim (v:none) and Neovim (v:null) - Add a new menu interface (
ChatGPTMenuands:ChatGPTMenuSink) for Neovim users - Tested on Neovim v0.10.1
Reviewed Changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| plugin/chatgpt.vim | Update g:chat_gpt_lang initialization for Neovim |
| plugin/chatgpt.vim | Add Neovim-only ChatGPTMenu and helper sink function |
Comments suppressed due to low confidence (1)
plugin/chatgpt.vim:426
- [nitpick] The menu header is labeled 'ChatGPT-Vim' although this interface is only for Neovim. Consider renaming it to something neutral like 'ChatGPT Menu' or 'ChatGPT' to avoid confusion.
let menu_choices = ['ChatGPT-Vim', '-----------']
| let choices = {} | ||
|
|
||
| for index in range(len(g:promptKeys)) | ||
| let choices[index+1] = g:promptKeys[index] |
There was a problem hiding this comment.
Using range(len(g:promptKeys)) includes an extra index equal to the length, which can lead to an out-of-bounds lookup on g:promptKeys. Consider using range(0, len(g:promptKeys) - 1) or adjust the loop boundary accordingly.
| let choices[index+1] = g:promptKeys[index] | |
| if index < len(g:promptKeys) | |
| let choices[index+1] = g:promptKeys[index] | |
| endif |
| let choices = {} | ||
|
|
||
| for index in range(len(g:promptKeys)) | ||
| let choices[index+1] = g:promptKeys[index] | ||
| endfor | ||
|
|
||
| if a:choice > 0 && a:choice <= len(g:promptKeys) | ||
| call SendHighlightedCodeToChatGPT(choices[a:choice], input('Prompt > ')) |
There was a problem hiding this comment.
[nitpick] Building a sequential menu mapping via a Dictionary can be less clear than using a List. You might consider using a List for ordered choices and indexing directly, which simplifies both construction and lookup.
| let choices = {} | |
| for index in range(len(g:promptKeys)) | |
| let choices[index+1] = g:promptKeys[index] | |
| endfor | |
| if a:choice > 0 && a:choice <= len(g:promptKeys) | |
| call SendHighlightedCodeToChatGPT(choices[a:choice], input('Prompt > ')) | |
| let choices = [] | |
| for index in range(len(g:promptKeys)) | |
| call add(choices, g:promptKeys[index]) | |
| endfor | |
| if a:choice > 0 && a:choice <= len(g:promptKeys) | |
| call SendHighlightedCodeToChatGPT(choices[a:choice - 1], input('Prompt > ')) |
g:chat_gpt_langinitialization to differentiate between Vim and Neovim, usingv:nullfor Neovim compatibility.inputlistto enhance user interaction with ChatGPT commands.