feat(strct-tags): add support for tag options (#126)

* feat(struct_tags): add options support

* refactor(struct-tags): give input field better name

* feat(struct-tag): add default option

* refactor: make it work on neovim version below 0.12

* chore(struct-tags): update the demo

* refactor: unite struct_tags util with main logic
This commit is contained in:
Oleksandr Smirnov 2025-10-30 12:25:42 +02:00
parent 0de1892ca9
commit 7a18d9f7bd
No known key found for this signature in database
19 changed files with 301 additions and 15 deletions

View file

@ -96,4 +96,52 @@ struct_tags["should remove tag with range"] = function()
t.cleanup(rs)
end
struct_tags["should add tags with option"] = function()
local rs = t.setup_test("tags/with_option", child, { 3, 6 })
child.cmd "GoTagAdd json=omitempty"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
struct_tags["should add tags with default option"] = function()
child.lua [[
require("gopher").setup {
gotag = { option = "xml=theoption" },
}
]]
local rs = t.setup_test("tags/with_default_option", child, { 3, 6 })
child.cmd "GoTagAdd xml"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
struct_tags["should add tags and overwrite default option"] = function()
child.lua [[
require("gopher").setup {
gotag = { option = "xml=theoption" },
}
]]
local rs = t.setup_test("tags/overwrite_default_option", child, { 3, 6 })
child.cmd "GoTagAdd xml=otheroption"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
struct_tags["should remove tag with specified option"] = function()
local rs = t.setup_test("tags/remove_with_option", child, { 3, 6 })
child.cmd "GoTagRm json=omitempty"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
return T