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.
In the demo :DescribeCommandSuggest is mapped to a keyboard shortcut using which-key.nvim:
{ "<leader>ao", ":DescribeCommandSuggest<cr>", desc = "Suggest described command" },
In the demo :DescribeCommandExecute is mapped to a keyboard shortcut using which-key.nvim:
{ "<leader>ae", ":DescribeCommandExecute<cr>", desc = "Execute described command" },
-
Make sure you have curl installed on your system and available on your
PATH. -
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,
}- 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,
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/).
:DescribeCommandExecuteThis command directly executes the command that best matches the given description. If no description is given the user will be prompted for one.:DescribeCommandSuggestThis 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.
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.

