docs(struct_tags): add doc
This commit is contained in:
parent
a0d4321239
commit
de17bcac04
3 changed files with 60 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ Table of Contents
|
||||||
Setup....................................................|gopher.nvim-setup|
|
Setup....................................................|gopher.nvim-setup|
|
||||||
Install dependencies..............................|gopher.nvim-install-deps|
|
Install dependencies..............................|gopher.nvim-install-deps|
|
||||||
Configuration...........................................|gopher.nvim-config|
|
Configuration...........................................|gopher.nvim-config|
|
||||||
|
Modifty struct tags................................|gopher.nvim-struct-tags|
|
||||||
Auto implementation of interface methods..................|gopher.nvim-impl|
|
Auto implementation of interface methods..................|gopher.nvim-impl|
|
||||||
Setup `nvim-dap` for Go......................................|gopher.nvim-dap|
|
Setup `nvim-dap` for Go......................................|gopher.nvim-dap|
|
||||||
|
|
||||||
|
|
@ -84,6 +85,35 @@ Parameters ~
|
||||||
{user_config} `(optional)` gopher.Config
|
{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*
|
*gopher.nvim-impl*
|
||||||
|
|
@ -120,7 +150,7 @@ simple example:
|
||||||
*gopher.nvim-dap*
|
*gopher.nvim-dap*
|
||||||
This module sets up `nvim-dap` for Go.
|
This module sets up `nvim-dap` for Go.
|
||||||
Usage ~
|
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:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
|
@ -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 ts_utils = require "gopher._utils.ts"
|
||||||
local r = require "gopher._utils.runner"
|
local r = require "gopher._utils.runner"
|
||||||
local c = require "gopher.config"
|
local c = require "gopher.config"
|
||||||
|
|
@ -69,8 +95,7 @@ local function modify(...)
|
||||||
vim.cmd "write"
|
vim.cmd "write"
|
||||||
end
|
end
|
||||||
|
|
||||||
---add tags to struct under cursor
|
-- add tags to struct under cursor
|
||||||
---@param ... unknown
|
|
||||||
function struct_tags.add(...)
|
function struct_tags.add(...)
|
||||||
local arg = { ... }
|
local arg = { ... }
|
||||||
if #arg == nil or arg == "" then
|
if #arg == nil or arg == "" then
|
||||||
|
|
@ -85,8 +110,7 @@ function struct_tags.add(...)
|
||||||
modify(unpack(cmd_args))
|
modify(unpack(cmd_args))
|
||||||
end
|
end
|
||||||
|
|
||||||
---remove tags to struct under cursor
|
-- remove tags to struct under cursor
|
||||||
---@param ... unknown
|
|
||||||
function struct_tags.remove(...)
|
function struct_tags.remove(...)
|
||||||
local arg = { ... }
|
local arg = { ... }
|
||||||
if #arg == nil or arg == "" then
|
if #arg == nil or arg == "" then
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ end
|
||||||
local files = {
|
local files = {
|
||||||
"lua/gopher/init.lua",
|
"lua/gopher/init.lua",
|
||||||
"lua/gopher/config.lua",
|
"lua/gopher/config.lua",
|
||||||
|
"lua/gopher/struct_tags.lua",
|
||||||
"lua/gopher/impl.lua",
|
"lua/gopher/impl.lua",
|
||||||
"lua/gopher/dap.lua",
|
"lua/gopher/dap.lua",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue