feat: json2go (#130)
* feat(json2go): implement * feat(json2go): support manual input * chore(readme): add json2go * chore(docs): add docs
This commit is contained in:
parent
4a2384ade8
commit
6a3924cee5
16 changed files with 312 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ local default_config = {
|
|||
gotests = "gotests",
|
||||
impl = "impl",
|
||||
iferr = "iferr",
|
||||
json2go = "json2go",
|
||||
},
|
||||
---@class gopher.ConfigGotests
|
||||
gotests = {
|
||||
|
|
@ -68,12 +69,24 @@ local default_config = {
|
|||
---@type string|nil
|
||||
option = nil,
|
||||
},
|
||||
---@class gopher.ConfigIfErr
|
||||
iferr = {
|
||||
-- choose a custom error message, nil to use default
|
||||
-- e.g: `message = 'fmt.Errorf("failed to %w", err)'`
|
||||
---@type string|nil
|
||||
message = nil,
|
||||
},
|
||||
---@class gopher.ConfigJson2Go
|
||||
json2go = {
|
||||
-- command used to open interactive input.
|
||||
-- e.g: `split`, `botright split`, `tabnew`
|
||||
interactive_cmd = "vsplit",
|
||||
|
||||
-- name of autogenerated struct, if nil none, will the default one of json2go.
|
||||
-- e.g: "MySuperCoolName"
|
||||
---@type string|nil
|
||||
type_name = nil,
|
||||
},
|
||||
}
|
||||
--minidoc_afterlines_end
|
||||
|
||||
|
|
@ -104,6 +117,7 @@ function config.setup(user_config)
|
|||
vim.validate("commands.gotests", _config.commands.gotests, "string")
|
||||
vim.validate("commands.impl", _config.commands.impl, "string")
|
||||
vim.validate("commands.iferr", _config.commands.iferr, "string")
|
||||
vim.validate("commands.json2go", _config.commands.json2go, "string")
|
||||
vim.validate("gotests", _config.gotests, "table")
|
||||
vim.validate("gotests.template", _config.gotests.template, "string")
|
||||
vim.validate("gotests.template_dir", _config.gotests.template_dir, { "string", "nil" })
|
||||
|
|
@ -114,6 +128,8 @@ function config.setup(user_config)
|
|||
vim.validate("gotag.option", _config.gotag.option, { "string", "nil" })
|
||||
vim.validate("iferr", _config.iferr, "table")
|
||||
vim.validate("iferr.message", _config.iferr.message, { "string", "nil" })
|
||||
vim.validate("json2go.installer_timeout", _config.json2go.interactive_cmd, "string")
|
||||
vim.validate("json2go.type_name", _config.json2go.type_name, { "string", "nil" })
|
||||
end
|
||||
|
||||
setmetatable(config, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue