Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nakhan98
Copy link
Contributor

@nakhan98 nakhan98 commented Mar 3, 2025

  • 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.

- 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.
@CoderCookE CoderCookE requested a review from Copilot July 11, 2025 15:48
Copy link

@Copilot Copilot AI left a 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 and s: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]
Copy link
Preview

Copilot AI Jul 11, 2025

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.

Suggested change
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.

Comment on lines +414 to +421
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 > '))
Copy link
Preview

Copilot AI Jul 11, 2025

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.

Suggested change
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.

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

Successfully merging this pull request may close these issues.

1 participant