Giter Club home page Giter Club logo

genie.nvim's Introduction

1. INTRODUCTION

Genie is a Neovim plugin that allows users to generate Lua code based on natural language instructions, using the power of GPT-based AI models. With Genie, you can perform actions within Neovim by simply providing natural language descriptions of what you wish to accomplish.

2. INSTALLATION

To install Genie, you can use either the vim-plug or lazy.nvim package manager.

Using vim-plug, add the following to your init.vim or init.lua:

Plug 'mikeslattery/genie'

And then run :PlugInstall in Neovim.

For lazy.nvim, include Genie in your configuration like this:

{
  "mikeslattery/genie",
}

Refer to the lazy.nvim documentation for more details on using this package manager.

3. USAGE

To use Genie, you should have an OpenAI API key set in your environment variables. Once installed and configured, you can use the :Wish command followed by a natural language instruction to execute Lua code in Neovim.

Example: :Wish Open a new tab.

This command will generate Lua code aimed at opening a new tab and execute it immediately.

4. CONFIGURATION

Genie can be configured by passing a table with desired configurations to the setup function. Configuration options include the AI model to use and the temperature setting for responses.

Example in Lua:

local genie = require('genie')
genie.setup({
    model = 'gpt-4',
    temperature = 0.7,
    access_key = 'your_openai_api_key'
})

The access_key is optional if you already have it as an environment variable.

5. COMMANDS

Commands included in Genie are listed below:

  • :Wish: Executes code generated by AI based on natural language input.

Examples:

:Wish Close all windows except current one
:Wish Close all buffers except current one
:Wish Close all *.lua buffers
:Wish Get length of longest line in current buffer. Set current window width to that length plus 9.
:Wish Create vertical split and make it current window. Edit README.md in prior buffer.
:Wish What is our our current location?  You can use `curl` to determine.
:Wish How tall is Mount Everest?
:Wish Send keys 'echo hello' to the tmux pane to the right of current one. Do not use plenary.

6. FUNCTIONS

The notable functions in the Genie plugin:

  • ai(prompt_string): Contacts OpenAI with the given prompt and returns the result.

  • generate_code(action): Generates Lua code based on the given action described in natural language.

  • wish(instruction): Takes a natural language instruction, generates Lua code, and executes it.

  • setup(config): Configures Genie with the given settings.

7. TESTING

Testing is facilitated by Plenary test runner. Refer to test/genie_spec.lua for example tests and how to execute them.

8. LICENSE

Genie is distributed under the Apache License, Version 2.0. See the LICENSE file in the GitHub repository for more details: https://github.com/mikeslattery/genie.nvim

Copyright (c) 2023 Mike Slattery

This is free software; you can redistribute it and/or modify it under the terms of the Apache 2.0 License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

genie.nvim's People

Contributors

mikeslattery avatar

Stargazers

 avatar Yuta Katayama avatar

Watchers

 avatar  avatar

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.