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

@ -0,0 +1,8 @@
package main
type Test struct {
ID int
Another struct {
Second string
}
}

View file

@ -0,0 +1,8 @@
package main
type Test struct {
ID int `xml:"id,otheroption"`
Another struct {
Second string `xml:"second,otheroption"`
} `xml:"another,otheroption"`
}

View file

@ -0,0 +1,11 @@
package main
type Test struct {
ID int `json:"id,omitempty" xml:"id,someoption"`
Name string `json:"name,omitempty" xml:"name,someoption"`
Num int64 `json:"num,omitempty" xml:"num,someoption"`
Another struct {
First int `json:"first,omitempty" xml:"first,someoption"`
Second string `json:"second,omitempty" xml:"second,someoption"`
} `json:"another,omitempty" xml:"another,someoption"`
}

View file

@ -0,0 +1,11 @@
package main
type Test struct {
ID int `xml:"id,someoption"`
Name string `xml:"name,someoption"`
Num int64 `xml:"num,someoption"`
Another struct {
First int `xml:"first,someoption"`
Second string `xml:"second,someoption"`
} `xml:"another,someoption"`
}

View file

@ -0,0 +1,8 @@
package main
type Test struct {
ID int
Another struct {
Second string
}
}

View file

@ -0,0 +1,8 @@
package main
type Test struct {
ID int `xml:"id,theoption"`
Another struct {
Second string `xml:"second,theoption"`
} `xml:"another,theoption"`
}

11
spec/fixtures/tags/with_option_input.go vendored Normal file
View file

@ -0,0 +1,11 @@
package main
type Test struct {
ID int
Name string
Num int64
Another struct {
First int
Second string
}
}

View file

@ -0,0 +1,11 @@
package main
type Test struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Num int64 `json:"num,omitempty"`
Another struct {
First int `json:"first,omitempty"`
Second string `json:"second,omitempty"`
} `json:"another,omitempty"`
}