diff --git a/doc/gopher.nvim.txt b/doc/gopher.nvim.txt index 868d466..3497b5f 100644 --- a/doc/gopher.nvim.txt +++ b/doc/gopher.nvim.txt @@ -11,6 +11,7 @@ Table of Contents Setup....................................................|gopher.nvim-setup| Install dependencies..............................|gopher.nvim-install-deps| Configuration...........................................|gopher.nvim-config| + Modifty struct tags................................|gopher.nvim-struct-tags| Auto implementation of interface methods..................|gopher.nvim-impl| Setup `nvim-dap` for Go......................................|gopher.nvim-dap| @@ -84,6 +85,35 @@ Parameters ~ {user_config} `(optional)` gopher.Config +============================================================================== +------------------------------------------------------------------------------ + *gopher.nvim-struct-tags* +struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields. +Usage ~ +- put your coursor on the struct +- run `:GoTagAdd json` to add json tags to struct fields +- run `:GoTagRm json` to remove json tags to struct fields + +note: if you dont spesify the tag it will use `json` as default + +simple example: +>go + // before + type User struct { + // ^ put your cursor here + // run `:GoTagAdd yaml` + ID int + Name string + } + + // after + type User struct { + ID int `yaml:id` + Name string `yaml:name` + } +< + + ============================================================================== ------------------------------------------------------------------------------ *gopher.nvim-impl* @@ -120,7 +150,7 @@ simple example: *gopher.nvim-dap* This module sets up `nvim-dap` for Go. Usage ~ -just call `require("gopher.dap").setup()`, adn you're good to go. +just call `require("gopher.dap").setup()`, and you're good to go. vim:tw=78:ts=8:noet:ft=help:norl: \ No newline at end of file diff --git a/lua/gopher/struct_tags.lua b/lua/gopher/struct_tags.lua index 645fa6b..4389b62 100644 --- a/lua/gopher/struct_tags.lua +++ b/lua/gopher/struct_tags.lua @@ -1,3 +1,29 @@ +---@toc_entry Modifty struct tags +---@tag gopher.nvim-struct-tags +---@text struct-tags is utilizing the `gomodifytags` tool to add or remove tags to struct fields. +---@usage - put your coursor on the struct +--- - run `:GoTagAdd json` to add json tags to struct fields +--- - run `:GoTagRm json` to remove json tags to struct fields +--- +--- note: if you dont spesify the tag it will use `json` as default +--- +--- simple example: +--- >go +--- // before +--- type User struct { +--- // ^ put your cursor here +--- // run `:GoTagAdd yaml` +--- ID int +--- Name string +--- } +--- +--- // after +--- type User struct { +--- ID int `yaml:id` +--- Name string `yaml:name` +--- } +--- < + local ts_utils = require "gopher._utils.ts" local r = require "gopher._utils.runner" local c = require "gopher.config" @@ -69,8 +95,7 @@ local function modify(...) vim.cmd "write" end ----add tags to struct under cursor ----@param ... unknown +-- add tags to struct under cursor function struct_tags.add(...) local arg = { ... } if #arg == nil or arg == "" then @@ -85,8 +110,7 @@ function struct_tags.add(...) modify(unpack(cmd_args)) end ----remove tags to struct under cursor ----@param ... unknown +-- remove tags to struct under cursor function struct_tags.remove(...) local arg = { ... } if #arg == nil or arg == "" then diff --git a/scripts/docgen.lua b/scripts/docgen.lua index 981a6fe..2d3c8d9 100644 --- a/scripts/docgen.lua +++ b/scripts/docgen.lua @@ -10,6 +10,7 @@ end local files = { "lua/gopher/init.lua", "lua/gopher/config.lua", + "lua/gopher/struct_tags.lua", "lua/gopher/impl.lua", "lua/gopher/dap.lua", }