Giter VIP home page Giter VIP logo

gemini.nvim's Introduction

gemini.nvim

This plugin try to interface Google's Gemini API into neovim.

It does take some practice to prompt this thing, default press <S-Tab> to select the result

demo1.mp4

popup menu

demo2.mp4
demo3.mp4

function hints

demo4.mp4

It sort of works for flutter widget too?

demo5.mp4

and rust?

demo6.mp4

Installation

export GEMINI_API_KEY="<your API key here>"

if working with code with proprietary license, might want to turn function hints off

export DISABLE_GEMINI_INLINE=1
{
  'kiddos/gemini.nvim',
  build = { 'pip install -r requirements.txt', ':UpdateRemotePlugins' },
  config = function()
    require('gemini').setup()
  end
}
use {
  'kiddos/gemini.nvim',
  run = { 'pip install -r requirements.txt', ':UpdateRemotePlugins' },
  config = function()
    require('gemini').setup()
  end,
}

To install manually

pip install pynvim google-generativeai

and run :UpdateRemotePlugins

Settings

  • default setting
require('gemini').setup({
  menu_key = '<C-o>',
  insert_result_key = '<S-Tab>',
  hints_delay = 3000,
  instruction_delay = 2000,
  menu_prompts = {
    {
      name = 'Unit Test Generation',
      command_name = 'GeminiUnitTest',
      menu = 'Unit Test ๐Ÿš€',
      prompt = 'Write unit tests for the following code\n',
    },
    {
      name = 'Code Review',
      command_name = 'GeminiCodeReview',
      menu = 'Code Review ๐Ÿ“œ',
      prompt = 'Do a thorough code review for the following code.\nProvide detail explaination and sincere comments.\n',
    },
    {
      name = 'Code Explain',
      command_name = 'GeminiCodeExplain',
      menu = 'Code Explain ๐Ÿ‘ป',
      prompt = 'Explain the following code\nprovide the answer in Markdown\n',
    },
  },
  hints_prompt = [[
Instruction: Use 1 or 2 sentences to describe what the following {filetype} function does:

\`\`\`{filetype}
{code_block}
\`\`\`
  ]],
  instruction_prompt = [[
Context: filename: \`{filename}\`

Instruction: ***{instruction}***

  ]],
})

TODO

  • [ ]

gemini.nvim's People

Contributors

kiddos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gemini.nvim's Issues

There may be some bug, in the archlinux

when i use :UpdateRemotePlugin ,i get this error.
it seems like doesn't run 'pip install -r requirements.txt'

Encountered ModuleNotFoundError loading plugin at /home/xx/.local/share/nvim/lazy/gemini.nvim/rplugin/python3/gemini: No module named 'google'
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/pynvim/plugin/host.py", line 187, in _load
module = _handle_import(directory, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pynvim/plugin/host.py", line 40, in _handle_import
return importlib.import_module(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
ModuleNotFoundError: No module named 'google'
remote/host: python3 host registered plugins []
remote/host: generated rplugin manifest: /home/xx/.local/share/nvim/rplugin.vim
I install python through this .

sudo pacman -S python python-neovim python-pip python-google-api-python-client
os: Arch
python:3.11.8
pip: 24.0
python-neovim : 0.5.0

menu_key rebinding ignored

I set up this config:

  { 'kiddos/gemini.nvim',
    build = { 'pip install -r requirements.txt', ':UpdateRemotePlugins' },
    config = function()
      require('gemini').setup {
        menu_key = '<C-g>'
      }
    end
  },

Yet C-o is still triggering the menu

Unknown function: _gemini_api_stream_async

i pressed ctrl+o, selected code explain, and got following error:

Error executing vim.schedule lua callback: ....local/share/nvim/lazy/gemini.nvim/lua/gemini/prompt.lua:69: Vim:E117: Unknown function: _gemini_api_stream_async
stack traceback:
        [C]: in function 'nvim_call_function'
        ....local/share/nvim/lazy/gemini.nvim/lua/gemini/prompt.lua:69: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
Press ENTER or type command to continue

Can not call plugin

Error: Error executing vim.schedule lua callback: ...lu5her/.local/share/nvim/lazy/gemini.nvim/lua/gemini.lua:112: Vim:E117: Unknown function: _gemini_api_stream_async
stack traceback:
   [C]: in function 'nvim_call_function'
   ...lu5her/.local/share/nvim/lazy/gemini.nvim/lua/gemini.lua:112: in function ''
   vim/_editor.lua: in function ''
   vim/_editor.lua: in function <vim/_editor.lua:0>

when use <Ctrl+o> to call plugin

pynvim = 0.5.0
python = 3.11
os = manjaro_x64

Completion mode

How to insert completion,
and after update pop-up is not show

Unknown function: _gemini_api_sync

After installing, I regularly get this error message in neovim:

Error executing vim.schedule lua callback: ...al/share/nvim/lazy/gemini.nvim/lua/gemini/completion.lua:67: Vim:E117: Unknown function: _gemini_api_async                                           
stack traceback:                                                                                                                                                                                             
        [C]: in function 'nvim_call_function'                                                                                                                                                                
        ...al/share/nvim/lazy/gemini.nvim/lua/gemini/completion.lua:67: in function ''                                                                                                                       
        vim/_editor.lua: in function ''                                                                                                                                                                      
        vim/_editor.lua: in function <vim/_editor.lua:0>                                                                                                                                                     
Press ENTER or type command to continue     

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.