Code Monkey home page Code Monkey logo

navi's Introduction

naVi - Your NeoVim assistant

Natural language first based development

Usage

navi.open() will open a prompt. Use this prompt to tell naVi what to do. For example, insert a React component outline.

navi.openRange() will open a prompt using the current selection as context. Use this prompt to get naVi to make changes to the selected text. For example, remove a bug.

navi.openFile() will open a prompt using the current file as context. Use this prompt to get naVi to make changes to the current file. For example, add a new function.

navi.requestReview() will request a review using the current selection as context. The final report will open in a separate window, and will not alter the selected text.

navi.explainRange() will provide an explanation of code using the current selection as context. The explanation will open in a separate window and will not alter the selected text.

navi.openChat() will open a chat interface where you can discuss your code with GPT.

Installation

Requirements

Packer

Add the following to your Packer config

    use({
        'deifyed/naVi',
        requires = {'jcdickinson/http.nvim', run = 'cargo build --workspace --release'},
    })

Lazy

Add the following to your Lazy.vim config

{
  'deifyed/naVi',
  dependencies = { 
    {
      "jcdickinson/http.nvim", build = "cargo build --workspace --release",
    },
  },
  config = function()
    require("navi").setup({ })
  end,
  keys = {
    { "<C-PageDown>", "<cmd>lua require('navi').open()<cr>", mode = "i", desc = "NaVI prompt" },
    { "<C-PageDown>", "<cmd>lua require('navi').openRange()<cr>", mode = "v", desc = "NaVI prompt with context" },
    { "<C-PageUp>", "<cmd>lua require('navi').requestReview()<cr>", mode = "v", desc = "NaVI request review" },
  },
}

Configuration

in ~/.config/nvim/after/plugin/navi.lua:

local navi = require('navi')

navi.setup({
    -- OpenAI token. Required
    openai_token = "<token>", -- Alternatively, use environment variable OPENAI_TOKEN=<token>
    -- OpenAI model. Optional. Default is gpt-3.5-turbo
    openai_model = "gpt-3.5-turbo",
    -- OpenAI max tokens. Optional. Default is 512
    openai_max_tokens = 512,
    -- OpenAI temperature. Optional. Default is 0.6
    openai_temperature = 0.6,
    -- Debug mode. Optional. Default is false
    debug = false, -- Alternatively, use environment variable NAVI_DEBUG=true
    -- Setup for input window 
    prompt_window = {
        border = "single",
        style = "minimal",
        relative = "editor",
    },
    -- Setup for window showing various reports
    report_window = {
        -- Specifies if the report will be shown in a vertical window or in a floating window.
        window = "floating",
        border = "single",
        style = "minimal",
        relative = "editor",
    },
})

-- Set keybindings
vim.api.nvim_set_keymap('v', '<C-PageDown>', '', { callback = navi.openRange })
vim.api.nvim_set_keymap('i', '<C-PageDown>', '', { callback = navi.open })
vim.api.nvim_set_keymap('v', '<C-PageUp>', '', { callback = navi.requestReview })
vim.api.nvim_set_keymap('v', '<C-End>', '', { callback = navi.explainRange })
vim.api.nvim_set_keymap('n', '<C-End>', '', { callback = navi.openChat })

Roadmap

  • Make the current file context of the chat interface
  • Make the chat toggleable
  • Improve prompts
  • Refactor

FAQ

  • Where can I get an OpenAI token?

    https://platform.openai.com/

  • Can naVi close nVim for me?

    AI has come far, but not that far. We'll have to wait for human alignment before attempting this.

  • Neat! How can I contribute?

    Great! Check out the contributing guide for more information.

navi's People

Contributors

bsek avatar deifyed 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.