Home

Awesome

๐Ÿค SimpleGPT

Mega-Linter panvimdoc

๐ŸคSimpleGPT is a Vim plugin designed to provide a simple yet flexible way to:

Motivation of this plugin

Though we have a lot of ChatGPT plugins to leverage the power of ChatGPT in Vim, I still find it hard to locate a handy one that completely fits my workflow.

After thinking about it, I found that the main reason is that the most important part of my workflow is missing in existing plugins: Fast editing of questions based on my current status!!

So, quickly editing the question template and building the question is the most important part of my workflow. Existing plugins are not convenient enough for this and focus more on the Chat UI.

This repository is designed to offer a highly customizable and extensible QA interaction with ChatGPT in the simplest way possible.

Installation

โš ๏ธPlease follow the installation guide of ChatGPT.nvim to make sure your ChatGPT works.

-- Lazy.nvim
{
  "you-n-g/simplegpt.nvim",
  dependencies = {
    {
      "jackMort/ChatGPT.nvim", -- You should configure your ChatGPT make sure it works.
      event = "VeryLazy",
      config = true,
      dependencies = {
        "MunifTanjim/nui.nvim",
        "nvim-lua/plenary.nvim",
        "folke/trouble.nvim",
        "nvim-telescope/telescope.nvim",
      },
    },
  },
  config = true,
},

-- or packer.nvim
use({
  "you-n-g/simplegpt.nvim",
  config = function()
    require("simplegpt").setup()
  end,
  requires = {
    {
      "jackMort/ChatGPT.nvim", -- You should configure your ChatGPT make sure it works.
      event = "VimEnter",
      config = function()
        require("chatgpt").setup()
      end,
      requires = {
        "MunifTanjim/nui.nvim",
        "nvim-lua/plenary.nvim",
        "folke/trouble.nvim",
        "nvim-telescope/telescope.nvim",
      },
    },
  },
})

If you want to customize you <LocalLeader>, please use following code:

vim.g.maplocalleader = "\\"  -- change the localleader key to \

More detailed configuration are listed here. You can find my latest and preferred configuration here as an example.

Demo

Console demo

asciicast

Typical workflow & Shortcuts

I have attempted to summarize the key concepts and manual in one image.

Workflow

The question is constructed by rendering a template. The 't' register serves as the template, encompassing:

Features

Core workflow

The primary concepts that govern the functionality of this plugin are:

Registers

An Example of Template Rendering

To illustrate the core template rendering mechanism of SimpleGPT, consider the following example. We have a template in the 't' register:

"I am currently working on a {{filetype}} file. The content of the file is: {{content}}. I have selected the following lines: {{visual}}. My question is: {{q}}."

The register values are:

The constructed question becomes:

"I am currently working on a markdown file. The content of the file is: This is a sample markdown file. I have selected the following lines: This is a selected line. My question is: How can I improve this line?"

Registers are of two types:

vim-native registers

Registermeaning
tThe register for the template.
othersthe variables to render the template

Supported special registers

keymeaning
contentthe whole file content
filetypethe filetype of the file
visualthe selected lines
contextthe nearby context of the selected line(10 lines up & down)

Shutcuts

TODOs

Flag explanation:

Development

Welcome to contribute to this project.

You can test the plugin with minimal config with

Limitations

Related Projects