From 85384d1c88035a7787adf4a181f92a621e6ea657 Mon Sep 17 00:00:00 2001 From: Oleksandr Smirnov Date: Sun, 2 Mar 2025 16:56:43 +0200 Subject: [PATCH] feat(struct_tags): add config option for default tag --- lua/gopher/config.lua | 3 +++ lua/gopher/struct_tags.lua | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lua/gopher/config.lua b/lua/gopher/config.lua index 94dbab9..f86d49c 100644 --- a/lua/gopher/config.lua +++ b/lua/gopher/config.lua @@ -62,6 +62,9 @@ local default_config = { gotag = { ---@type gopher.ConfigGoTagTransform transform = "snakecase", + + -- default tags to add to struct fields + default_tag = "json", }, } --minidoc_afterlines_end diff --git a/lua/gopher/struct_tags.lua b/lua/gopher/struct_tags.lua index 17e0d78..4207dae 100644 --- a/lua/gopher/struct_tags.lua +++ b/lua/gopher/struct_tags.lua @@ -55,11 +55,6 @@ local function modify(...) table.insert(cmd_args, v) 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 { c.commands.gomodifytags, "-transform", @@ -101,7 +96,7 @@ end function struct_tags.add(...) local arg = { ... } if #arg == nil or arg == "" then - arg = { "json" } + arg = { c.gotag.default_tag } end local cmd_args = { "-add-tags" } @@ -116,7 +111,7 @@ end function struct_tags.remove(...) local arg = { ... } if #arg == nil or arg == "" then - arg = { "json" } + arg = { c.gotag.default_tag } end local cmd_args = { "-remove-tags" }