This plugin sends selected text to the OpenAI API and retrieves a summary, which is then displayed in a new Neovim window.
This allows you to easily create summaries of code or documentation.
2023-09-13.4.03.03.mov
- Neovim 0.5.0 or later
curl
command-line tool installed
- Add the following line to your
init.vim
orinit.lua
to install the plugin.
-- For packer.nvim
use 'ouchi2501/code-explain'
-
Open Neovim and run or
:PackerInstall
to install the plugin. -
Set your API key and Language.
require("code-explain").setup({token = 'your_api_key',language = 'English'}) -- or Japanese
- Set your keymap.
vim.api.nvim_set_keymap('v', '<leader>a', ':lua require("code-explain").print_summary()<CR>', {noremap = true, silent = true})
To use the code-explain
plugin, follow these steps:
- In Neovim, enter Visual mode by pressing
v
,V
, or<C-v>
. - Select the text you want to send to the API.
- Press
<leader>s
to send the selected text to the API. The result will be displayed in a new window.
Note: If you want to use a different key mapping, replace <leader>s
in the init.vim
configuration with your preferred key combination.
If you have any issues or need further assistance, feel free to ask.
Currently, the following languages are supported:
- English (
en
) - Japanese (
ja
)
This project is licensed under the MIT License. See the LICENSE file for more information.