Skip to content

oflisback/describe-command.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧘 Purpose

Instead of trying to remember all the Vim and Neovim commands available, this plugin lets the user describe a command and then have an OpenAI model come up with a command to execute or a few suggestions to choose from.

πŸŽ₯ Demo

DescribeCommandSuggest

demo

In the demo :DescribeCommandSuggest is mapped to a keyboard shortcut using which-key.nvim:

  { "<leader>ao", ":DescribeCommandSuggest<cr>", desc = "Suggest described command" },

DescribeCommandExecute

demo

In the demo :DescribeCommandExecute is mapped to a keyboard shortcut using which-key.nvim:

  { "<leader>ae", ":DescribeCommandExecute<cr>", desc = "Execute described command" },

πŸ§‘β€πŸ”§ Installation

  1. Make sure you have curl installed on your system and available on your PATH.

  2. Install describe-command.nvim, here's how to do it with the Lazy package manager:

{
"oflisback/describe-command.nvim",
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
config = function() require("describe-command").setup() end,
lazy = false,
}
  1. You'll have to provide an OpenAI API key for the plugin to work, by default it looks for the key in an environment variable OPENAI_API_KEY. But you can also provide it via another environment variable:
  config = function() require("describe-command").setup({ openai_api_key_env_var = "MY_ALTERANTIVE_ENV_VARIABLE_NAME" }) end,

A better alternative than to expose your API key in an environment variable is to have an executable that provides it, such as:

  config = function() require("describe-command").setup({ openai_api_key_command = "~/echo-openai-api-key.sh" }) end,

βš™οΈ Configuration

Apart from openai_api_key_env_var and openai_api_key_command a few more options are available. These are the default values:

{
    openai_model = "gpt-4o-mini-2024-07-18",
    openai_system_prompt = -- See lua/describe-command/config.lua,
}

Note that the model must support [structured output](https://openai.com/index/introducing-structured-outputs-in-the-api/).

⌨️ Commands

  • :DescribeCommandExecute This command directly executes the command that best matches the given description. If no description is given the user will be prompted for one.
  • :DescribeCommandSuggest This command shows a list of suggestions that match the given description. If no description is given the user will be prompted for one.

πŸ’‘ Feel free to suggest additional useful commands via issue or PR.

πŸ§‘β€πŸ€β€πŸ§‘ Contributing

Contributions, bug reports and suggestions are very welcome.

If you have a suggestion that would make the project better, please fork the repo and create a pull request.

About

Describe what to do in neovim and have OpenAI figure out a command to accomplish it

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages