更好的注释生成器。支持多种语言和注释约定。
项目地址: https://github.com/danymat/neogen
注意事项nvim版本以大于等于NVIM v0.6.1
不然会有报错。
插件的运行需要依赖nvim-treesitter/nvim-treesitter
use {
"danymat/neogen",
config = function()
require('neogen').setup {}
end,
requires = "nvim-treesitter/nvim-treesitter",
-- Uncomment next line if you want to follow only stable versions
-- tag = "*"
}
插件配置
我这我目前的配置:
local status, neogen = pcall(require, "neogen")
if (not status) then
return
end
neogen.setup()
neogen.generate(
{
type = "func" -- the annotation type to generate. Currently supported: func, class, type, file
}
)
local opts = {noremap = true, silent = true}
vim.api.nvim_set_keymap("n", "nf", ":lua require('neogen').generate()", opts)
vim.api.nvim_set_keymap("n", "nc", ":lua require('neogen').generate({ type = 'class' })", opts)
仅供参考。
踩坑我用于Java的代码注释生成