Git Product home page Git Product logo

nvim-magic's Introduction

โš ๏ธ This repository is no longer maintained. The plugin was last tested to work with Neovim v0.8.3 and OpenAI's API as it was on 14 February, 2023.

nvim-magic

ci

A pluggable framework for integrating AI code assistance into Neovim. The goals are to make using AI code assistance unobtrusive, and to make it easy to create and share new flows that use AI code assistance. Go to quickstart for how to install. It currently works with OpenAI Codex.

Features

Completion (<Leader>mcs)

Example of Python script being generated from a docstring

Generating a docstring (<Leader>mds)

Example of Python function having a docstring generated

Asking for an alteration (<Leader>mss)

Example of Python function being altered

Quickstart

Prerequisites

  • latest stable version of Neovim (nightly may work as well)
  • curl
  • OpenAI API key

Installation

-- using packer.nvim
use({
	'jameshiew/nvim-magic',
	config = function()
		require('nvim-magic').setup()
	end,
	requires = {
		'nvim-lua/plenary.nvim',
		'MunifTanjim/nui.nvim'
	}
})

See docs/config.md if you want to override the default configuration e.g. to turn off the default keymaps, or use a different OpenAI engine than the default one (davinci-codex). Your OpenAI account might not have access to davinci-codex if it is not in the OpenAI Codex private beta (as of 2022-02-02).

Your API key should be made available to your Neovim session in an environment variable OPENAI_API_KEY. See docs/openai.md for more details. Note that API calls may be charged for by OpenAI depending on the engine used.

 export OPENAI_API_KEY='your-api-key-here'

Keymaps

These flows have keymaps set by default for visual mode selections (though you can disable this by passing use_default_keymap = false in the setup config).

You can map your own key sequences to the predefined <Plug>s if you don't want to use the default keymaps.

<Plug> default keymap mode action
<Plug>nvim-magic-append-completion <Leader>mcs visual Fetch and append completion
<Plug>nvim-magic-suggest-alteration <Leader>mss visual Ask for an alteration to the selected text
<Plug>nvim-magic-suggest-docstring <Leader>mds visual Generate a docstring

Development

There is a development container specified under the .devcontainer directory, that builds and installs the latest stable version of Neovim, and sets it up to use the local nvim-magic repo as a plugin.

nvim-magic's People

Contributors

jameshiew avatar abatilo avatar muniftanjim 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.