docs(struct_tags): add doc

This commit is contained in:
Smirnov Oleksandr 2024-04-02 17:19:26 +03:00
parent a0d4321239
commit de17bcac04
3 changed files with 60 additions and 5 deletions

View file

@ -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:

View file

@ -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

View file

@ -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",
}