Home

Awesome

backseat.nvim

A neovim plugin that uses GPT to highlight and explain code readability issues. Get unsolicited advice of dubious quality in never-before-seen quantities! <br><br> image

Commands

User CommandPurpose
:BackseatSends the current buffer to OpenAI to highlight readability feedback
:BackseatAsk <question>Ask a question about the code in the current buffer (i.e What does the function on line 20 do?, Summarize this code)
:BackseatClearClear all Backseat highlighting from the current buffer
:BackseatClearLineClear the current line of Backseat highlighting

If a buffer contains more than 100 lines, it will be split into multiple <= 100 line requests.

Requirements

Install

Lazy plugin manager

{
    "james1236/backseat.nvim",
    config = function()
        require("backseat").setup({
            -- Alternatively, set the env var $OPENAI_API_KEY by putting "export OPENAI_API_KEY=sk-xxxxx" in your ~/.bashrc
            openai_api_key = 'sk-xxxxxxxxxxxxxx', -- Get yours from platform.openai.com/account/api-keys
            openai_model_id = 'gpt-3.5-turbo', --gpt-4 (If you do not have access to a model, it says "The model does not exist")
            -- language = 'english', -- Such as 'japanese', 'french', 'pirate', 'LOLCAT'
            -- split_threshold = 100,
            -- additional_instruction = "Respond snarkily", -- (GPT-3 will probably deny this request, but GPT-4 complies)
            -- highlight = {
            --     icon = '', -- ''
            --     group = 'Comment',
            -- }
        })
    end
},

The result of using additional_instruction = "Respond snarkily"

image

Config

Setup Table NameDefaultPurpose
openai_api_keynilYour OpenAI API key, needed to use their language models
openai_model_id'gpt-3.5-turbo'The model's identifier, such as gpt-3.5-turbo and gpt-4
language'english'The language of suggestions, such as 'japanese', 'french' or made up ones like 'pirate', 'LOLCAT'
split_threshold100The max number of lines of code sent per request (lower uses more tokens but increases number of suggestions)
additional_instruction,nilAn additional instruction to give the AI, like "Make your responses more brief"
highlight.icon''The sign column icon to display for each line containing suggestions
highlight.group'String'The :hi highlight color group for the icon and the suggestion text

More Examples

image