-
-
Notifications
You must be signed in to change notification settings - Fork 33
Make plugin work with Neovim #51
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
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_lang
default between Vim (v:none
) and Neovim (v:null
) - Add a new menu interface (
ChatGPTMenu
ands: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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
Copilot uses AI. Check for mistakes.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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 > ')) |
Copilot uses AI. Check for mistakes.
g:chat_gpt_lang
initialization to differentiate between Vim and Neovim, usingv:null
for Neovim compatibility.inputlist
to enhance user interaction with ChatGPT commands.