Skip to content

meinside/gemini.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

gemini.nvim

A neovim plugin for generating texts using Google Gemini APIs.

Installation

lazy.nvim

  {
    'meinside/gemini.nvim', config = function()
      require'gemini'.setup {
        -- (default values)
        configFilepath = '~/.config/gemini.nvim/config.json',
        timeout = 30 * 1000,
        model = 'gemini-1.0-pro',
        safetyThreshold = 'BLOCK_ONLY_HIGH',
        stripOutermostCodeblock = function()
          return vim.bo.filetype ~= 'markdown'
        end,
        verbose = false,
      }
    end,
    dependencies = { { 'nvim-lua/plenary.nvim' } },
  },

Configuration

Get your API key from here

and create a JSON config file at path configFilepath with following content:

{
  "api_key": "AI0123456789-abcdefg-XYZW"
}

Usage

Insert Generated Text At Current Cursor Position

gemini-nvim insert-with-prompt

Run following command with a prompt:

:GeminiGenerate your prompt text here

It will generate a text from your prompt and insert it at the current cursor position.

Generate Text With Selected Range As A Prompt

gemini-nvim replace

Select a range of text with visual block, and run following command:

:'<,'>GeminiGenerate

then it will generate a text from the selected text as a prompt, and replace the range with the generated one.

Replace Selected Range With Generated Text

gemini-nvim replace-with-prompt

Select a range of text with visual block, and run following command with a prompt:

:'<,'>GeminiGenerate your prompt text here

then it will generate a text from both the selected text and prompt, and replace the range with the generated one.

Todos / Improvements

  • Add screen recordings for each usage.
  • Strip unwanted markdown codeblock around the generated texts.
  • Add an option for setting safety threshold.
  • Handle multiple number of candidates and content parts.
  • Add nice UIs for comparing & applying generated texts.

License

MIT

About

A neovim plugin for using Google Gemini APIs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages