Code Monkey home page Code Monkey logo

navi's Introduction

naVi - Your NeoVim assistant

Natural language first based development

Usage

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

navi.Edit() 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.EditBuffer() 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.Review() 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.Explain() 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.Chat() 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 = {
    { "<leader>na", "<cmd>lua require('navi').Append()<cr>", mode = "n", desc = "NaVI append" },
    { "<leader>ne", "<cmd>lua require('navi').Edit()<cr>", mode = "v", desc = "NaVI edit" },
    { "<leader>nb", "<cmd>lua require('navi').EditBuffer()<cr>", mode = "n", desc = "NaVI edit buffer" },
    { "<leader>nr", "<cmd>lua require('navi').Review()<cr>", mode = "v", desc = "NaVI review" },
    { "<leader>nx", "<cmd>lua require('navi').Explain()<cr>", mode = "v", desc = "NaVI explain" },
    { "<leader>nc", "<cmd>lua require('navi').Chat()<cr>", mode = "n", desc = "NaVI chat" },
  },
}

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', '<leader>ne', '', { callback = navi.Edit })
vim.api.nvim_set_keymap('i', '<leader>na', '', { callback = navi.Append })
vim.api.nvim_set_keymap('v', '<leader>nr', '', { callback = navi.Review })
vim.api.nvim_set_keymap('v', '<leader>ne', '', { callback = navi.Explain })
vim.api.nvim_set_keymap('n', '<leader>nc', '', { callback = navi.Chat })

Roadmap

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

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

deifyed avatar bsek avatar

Stargazers

 avatar Tibor Schmidt avatar Pablo P Varela avatar Dustin Blackman avatar Andrejs Agejevs avatar Adelar da Silva Queiróz avatar  avatar Sergey Mezentsev avatar AlexRain avatar Bailey Bjornstad avatar Lennart Kiil avatar Vincent von Schmidt avatar Samuel Otterman avatar John Doe Antler avatar Sébastien Bourdu avatar Andy Shevchenko avatar  avatar Sandalots avatar Miguel Morais avatar Mickaël Menu avatar J avatar chokerman avatar Carlos avatar Adam Henley avatar Abhijeet avatar Teppei Taguchi avatar  avatar Matt James avatar Marcel Klenk avatar xqtc avatar  avatar Yuta Katayama avatar Aaron Sullivan avatar Anders K. Pettersen avatar

Watchers

Adelar da Silva Queiróz avatar  avatar  avatar

navi's Issues

Can't close Prompt Window

So i was playing around a bit and the prompt window stays open even if you switch to a different window. And then there is no way to close it.

No Results

So i tried the plugin but i don't get any response from ChatGPT. I have my open ai key set in the env. At least an error message of what went wrong would be nice.

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.