From f97eca8e22d4c22f4c154b933571f933de4ea68e Mon Sep 17 00:00:00 2001 From: Oliver <1571880470@qq.com> Date: Sun, 24 Mar 2024 17:57:36 +0800 Subject: [PATCH] feat: add GoTagClear command --- lua/gopher/api.lua | 1 + lua/gopher/struct_tags.lua | 11 +++++++++++ plugin/gopher.vim | 1 + 3 files changed, 13 insertions(+) diff --git a/lua/gopher/api.lua b/lua/gopher/api.lua index 6e854af..544dd2d 100644 --- a/lua/gopher/api.lua +++ b/lua/gopher/api.lua @@ -6,6 +6,7 @@ local cmd = require "gopher._utils.commands" API.install_deps = require "gopher.installer" API.tags_add = tags.add API.tags_rm = tags.remove +API.tags_clear = tags.clear API.impl = require "gopher.impl" API.iferr = require "gopher.iferr" API.comment = require "gopher.comment" diff --git a/lua/gopher/struct_tags.lua b/lua/gopher/struct_tags.lua index a91901a..042641f 100644 --- a/lua/gopher/struct_tags.lua +++ b/lua/gopher/struct_tags.lua @@ -116,4 +116,15 @@ function M.remove(...) modify(unpack(cmd_args)) end +---clear all tags to struct under cursor +function M.clear() + if #arg == nil or arg == "" then + arg = { "json" } + end + + local cmd_args = { "-clear-tags" } + + modify(unpack(cmd_args)) +end + return M diff --git a/plugin/gopher.vim b/plugin/gopher.vim index e797966..9f1ae1e 100644 --- a/plugin/gopher.vim +++ b/plugin/gopher.vim @@ -1,5 +1,6 @@ command! -nargs=* GoTagAdd :lua require"gopher.api".tags_add() command! -nargs=* GoTagRm :lua require"gopher.api".tags_rm() +command! -nargs=0 GoTagClear :lua require"gopher.api".tags_clear() command! -nargs=* GoTestAdd :lua require"gopher.api".test_add() command! -nargs=* GoTestsAll :lua require"gopher.api".tests_all() command! -nargs=* GoTestsExp :lua require"gopher.api".test_exported()