feat(struct_tags): set default tag (#87)
* feat(struct_tags): add config option for default tag * docs: docgen * fix(struct_tags): as it turns out it didnt work as i supposed to before, but now it does
This commit is contained in:
parent
c2f64db4a8
commit
57b5dbf62e
3 changed files with 19 additions and 13 deletions
|
|
@ -55,6 +55,10 @@ You can look at default options |gopher.nvim-config-defaults|
|
||||||
---@type number
|
---@type number
|
||||||
log_level = vim.log.levels.INFO,
|
log_level = vim.log.levels.INFO,
|
||||||
|
|
||||||
|
-- timeout for running commands
|
||||||
|
---@type number
|
||||||
|
timeout = 2000,
|
||||||
|
|
||||||
-- user specified paths to binaries
|
-- user specified paths to binaries
|
||||||
---@class gopher.ConfigCommand
|
---@class gopher.ConfigCommand
|
||||||
commands = {
|
commands = {
|
||||||
|
|
@ -80,6 +84,9 @@ You can look at default options |gopher.nvim-config-defaults|
|
||||||
gotag = {
|
gotag = {
|
||||||
---@type gopher.ConfigGoTagTransform
|
---@type gopher.ConfigGoTagTransform
|
||||||
transform = "snakecase",
|
transform = "snakecase",
|
||||||
|
|
||||||
|
-- default tags to add to struct fields
|
||||||
|
default_tag = "json",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,9 @@ local default_config = {
|
||||||
gotag = {
|
gotag = {
|
||||||
---@type gopher.ConfigGoTagTransform
|
---@type gopher.ConfigGoTagTransform
|
||||||
transform = "snakecase",
|
transform = "snakecase",
|
||||||
|
|
||||||
|
-- default tags to add to struct fields
|
||||||
|
default_tag = "json",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,6 @@ local function modify(...)
|
||||||
table.insert(cmd_args, v)
|
table.insert(cmd_args, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set default tag for "clear tags"
|
|
||||||
if #arg == 1 and arg[1] ~= "-clear-tags" then
|
|
||||||
table.insert(cmd_args, "json")
|
|
||||||
end
|
|
||||||
|
|
||||||
local rs = r.sync {
|
local rs = r.sync {
|
||||||
c.commands.gomodifytags,
|
c.commands.gomodifytags,
|
||||||
"-transform",
|
"-transform",
|
||||||
|
|
@ -99,13 +94,14 @@ end
|
||||||
|
|
||||||
-- add tags to struct under cursor
|
-- add tags to struct under cursor
|
||||||
function struct_tags.add(...)
|
function struct_tags.add(...)
|
||||||
local arg = { ... }
|
local user_tags = { ... }
|
||||||
if #arg == nil or arg == "" then
|
if #user_tags == 0 then
|
||||||
arg = { "json" }
|
vim.print("c.gotag.default_tag", c.gotag.default_tag)
|
||||||
|
user_tags = { c.gotag.default_tag }
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd_args = { "-add-tags" }
|
local cmd_args = { "-add-tags" }
|
||||||
for _, v in ipairs(arg) do
|
for _, v in ipairs(user_tags) do
|
||||||
table.insert(cmd_args, v)
|
table.insert(cmd_args, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -114,13 +110,13 @@ end
|
||||||
|
|
||||||
-- remove tags to struct under cursor
|
-- remove tags to struct under cursor
|
||||||
function struct_tags.remove(...)
|
function struct_tags.remove(...)
|
||||||
local arg = { ... }
|
local user_tags = { ... }
|
||||||
if #arg == nil or arg == "" then
|
if #user_tags == 0 then
|
||||||
arg = { "json" }
|
user_tags = { c.gotag.default_tag }
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd_args = { "-remove-tags" }
|
local cmd_args = { "-remove-tags" }
|
||||||
for _, v in ipairs(arg) do
|
for _, v in ipairs(user_tags) do
|
||||||
table.insert(cmd_args, v)
|
table.insert(cmd_args, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue