feat(struct_tags): add config option for default tag
This commit is contained in:
parent
c2f64db4a8
commit
85384d1c88
2 changed files with 5 additions and 7 deletions
|
|
@ -62,6 +62,9 @@ local default_config = {
|
||||||
gotag = {
|
gotag = {
|
||||||
---@type gopher.ConfigGoTagTransform
|
---@type gopher.ConfigGoTagTransform
|
||||||
transform = "snakecase",
|
transform = "snakecase",
|
||||||
|
|
||||||
|
-- default tags to add to struct fields
|
||||||
|
default_tag = "json",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,6 @@ local function modify(...)
|
||||||
table.insert(cmd_args, v)
|
table.insert(cmd_args, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set default tag for "clear tags"
|
|
||||||
if #arg == 1 and arg[1] ~= "-clear-tags" then
|
|
||||||
table.insert(cmd_args, "json")
|
|
||||||
end
|
|
||||||
|
|
||||||
local rs = r.sync {
|
local rs = r.sync {
|
||||||
c.commands.gomodifytags,
|
c.commands.gomodifytags,
|
||||||
"-transform",
|
"-transform",
|
||||||
|
|
@ -101,7 +96,7 @@ end
|
||||||
function struct_tags.add(...)
|
function struct_tags.add(...)
|
||||||
local arg = { ... }
|
local arg = { ... }
|
||||||
if #arg == nil or arg == "" then
|
if #arg == nil or arg == "" then
|
||||||
arg = { "json" }
|
arg = { c.gotag.default_tag }
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd_args = { "-add-tags" }
|
local cmd_args = { "-add-tags" }
|
||||||
|
|
@ -116,7 +111,7 @@ end
|
||||||
function struct_tags.remove(...)
|
function struct_tags.remove(...)
|
||||||
local arg = { ... }
|
local arg = { ... }
|
||||||
if #arg == nil or arg == "" then
|
if #arg == nil or arg == "" then
|
||||||
arg = { "json" }
|
arg = { c.gotag.default_tag }
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd_args = { "-remove-tags" }
|
local cmd_args = { "-remove-tags" }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue