A lightweight Neovim plugin to manage struct field tags in Go source files.
https://github.com/user-attachments/assets/a0295f98-7d15-4ab1-852c-8be877cb0fd7
✅ Features:
json
, xml
, etc.) interactivelysnake_case
{
"romus204/go-tagger.nvim",
config = function()
require("go_tagger").setup({
skip_private = true, -- Skip unexported fields (starting with lowercase)
})
end,
}
use {
"romus204/go-tagger.nvim",
config = function()
require("go_tagger").setup()
end,
}
require("go_tagger").setup({
skip_private = true -- default: true
})
You can use the plugin in visual mode to tag or untag multiple lines at once. Just select the fields and run one of the available commands.
:AddGoTags
Adds tags to selected struct fields.
json,xml
).skip_private = true
.:AddGoTags
You’ll be prompted:
tag(s): json,xml
Resulting output:
ID int `json:"id" xml:"id"`
Name string `json:"name" xml:"name"`
:RemoveGoTags
Removes tags from selected struct fields.
json
).:RemoveGoTags
Prompt:
tag: json
Result:
ID int `xml:"id"`
Name string `xml:"name"`
vim.keymap.set("v", "<leader>at", ":AddGoTags<CR>", { desc = "Add Go struct tags", silent = true })
vim.keymap.set("v", "<leader>rt", ":RemoveGoTags<CR>", { desc = "Remove Go struct tags", silent = true })