feat(struct_tags): add :GoTagClear

This commit is contained in:
Oliver 2025-03-19 15:54:00 +02:00 committed by Oleksandr Smirnov
parent 10abcb661e
commit 07f86d669b
No known key found for this signature in database
6 changed files with 50 additions and 5 deletions

View file

@ -43,6 +43,7 @@ gopher.comment = require("gopher.comment").comment
gopher.tags = {
add = tags.add,
rm = tags.remove,
clear = tags.clear,
}
gopher.test = {

View file

@ -89,7 +89,8 @@ local function handler_user_args(args)
return res
end
-- add tags to struct under cursor
---Adds tags to a struct under the cursor
---@param ... string Tags to add to the struct fields. If not provided, it will use [config.tag.default_tag]
function struct_tags.add(...)
local args = { ... }
local fpath = vim.fn.expand "%"
@ -101,7 +102,8 @@ function struct_tags.add(...)
handle_tags(fpath, bufnr, user_args)
end
-- remove tags to struct under cursor
---Removes tags from a struct under the cursor
---@param ... string Tags to add to the struct fields. If not provided, it will use [config.tag.default_tag]
function struct_tags.remove(...)
local args = { ... }
local fpath = vim.fn.expand "%"
@ -113,4 +115,11 @@ function struct_tags.remove(...)
handle_tags(fpath, bufnr, user_args)
end
---Removes all tags from a struct under the cursor
function struct_tags.clear()
local fpath = vim.fn.expand "%"
local bufnr = vim.api.nvim_get_current_buf()
handle_tags(fpath, bufnr, { "-clear-tags" })
end
return struct_tags