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

Make plugin work with Neovim #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion plugin/chatgpt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ if !exists("g:chat_gpt_model")
endif

if !exists("g:chat_gpt_lang")
let g:chat_gpt_lang = v:none
if has('nvim')
let g:chat_gpt_lang = v:null
else
let g:chat_gpt_lang = v:none
endif
endif

if !exists("g:chat_gpt_split_direction")
Expand Down Expand Up @@ -403,3 +407,29 @@ endfunction


command! -nargs=1 GptBe call SetPersona(<q-args>)

" Menu for ChatGPT using inputlist for Neovim
if has('nvim')
function! s:ChatGPTMenuSink(choice)
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 > '))
endif
endfunction

function! ChatGPTMenu() range
let menu_choices = ['ChatGPT-Vim', '-----------']

for index in range(len(g:promptKeys))
call add(menu_choices, string(index + 1) . ". " . Capitalize(g:promptKeys[index]))
endfor

let choice = inputlist(menu_choices)
call s:ChatGPTMenuSink(choice)
endfunction
endif