chore(demos): add demos

This commit is contained in:
Oleksandr Smirnov 2025-08-30 14:49:54 +03:00
parent 11d61810ce
commit 5a0f978586
No known key found for this signature in database
17 changed files with 188 additions and 0 deletions

View file

@ -99,6 +99,8 @@ require("gopher").setup {
<b>Add and remove tags for structs via <a href="https://github.com/fatih/gomodifytags">gomodifytags</a></b> <b>Add and remove tags for structs via <a href="https://github.com/fatih/gomodifytags">gomodifytags</a></b>
</summary> </summary>
![Add tags demo](./vhs/tags.gif)
By default `json` tag will be added/removed, if not set: By default `json` tag will be added/removed, if not set:
```vim ```vim
@ -176,6 +178,8 @@ require("gopher").setup {
<b>Interface implementation via <a href="https://github.com/josharian/impl">impl<a></b> <b>Interface implementation via <a href="https://github.com/josharian/impl">impl<a></b>
</summary> </summary>
![Auto interface implementation demo](./vhs/impl.gif)
Syntax of the command: Syntax of the command:
```vim ```vim
:GoImpl [receiver] [interface] :GoImpl [receiver] [interface]
@ -199,6 +203,8 @@ require("gopher").setup {
<b>Generate boilerplate for doc comments</b> <b>Generate boilerplate for doc comments</b>
</summary> </summary>
![Generate comments](./vhs/comment.gif)
First set a cursor on **public** package/function/interface/struct and execute: First set a cursor on **public** package/function/interface/struct and execute:
```vim ```vim
@ -212,6 +218,8 @@ require("gopher").setup {
<b>Generate <code>if err != nil {</code> via <a href="https://github.com/koron/iferr">iferr</a></b> <b>Generate <code>if err != nil {</code> via <a href="https://github.com/koron/iferr">iferr</a></b>
</summary> </summary>
![Generate if err != nil {](./vhs/iferr.gif)
Set the cursor on the line with `err` and execute Set the cursor on the line with `err` and execute
```vim ```vim

View file

@ -1,4 +1,10 @@
version: "3" version: "3"
includes:
vhs:
taskfile: ./vhs/Taskfile.yml
dir: ./vhs
tasks: tasks:
lint: lint:
cmds: cmds:

20
vhs/Taskfile.yml Normal file
View file

@ -0,0 +1,20 @@
version: "3"
tasks:
generate:
deps:
- comment
- iferr
- tags
- impl
comment:
cmd: vhs comment.tape
iferr:
cmd: vhs iferr.tape
tags:
cmd: vhs tags.tape
impl:
cmd: vhs impl.tape

0
vhs/comment.gif Normal file
View file

7
vhs/comment.go Normal file
View file

@ -0,0 +1,7 @@
package demos
func doSomethingImportant() {}
type User struct{}
type DataProvider interface{}

34
vhs/comment.tape Normal file
View file

@ -0,0 +1,34 @@
Output comment.gif
Require nvim
Set FontFamily "JetBrains Mono"
Set Height 800
Set Width 1500
Set Padding 20
Set Shell "bash"
Set Theme "tokyonight"
Set TypingSpeed 250ms
Hide
Type@0ms "alias nvim='./nvim.sh'" Enter
Type@0ms "clear" Enter
Show
Type "nvim comment.go" Sleep 150ms Enter
# package
Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms
# func
Type "3j"
Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms
# struct
Type "3j"
Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms
# interface
Type "3j"
Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms
Sleep 5s

3
vhs/go.mod Normal file
View file

@ -0,0 +1,3 @@
module demos
go 1.25.0

BIN
vhs/iferr.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

11
vhs/iferr.go Normal file
View file

@ -0,0 +1,11 @@
package demos
func ifErr() {
out, err := doSomething()
_ = out
}
func doSomething() (string, error) {
return "", nil
}

23
vhs/iferr.tape Normal file
View file

@ -0,0 +1,23 @@
Output iferr.gif
Require nvim
Require iferr
Set FontFamily "JetBrains Mono"
Set Height 800
Set Width 1500
Set Padding 20
Set Shell "bash"
Set Theme "tokyonight"
Set TypingSpeed 250ms
Hide
Type@0ms "alias nvim='./nvim.sh'" Enter
Type@0ms "clear" Enter
Show
Type "nvim iferr.go" Sleep 150ms Enter
Type "3j"
Type ":GoIfErr" Sleep 500ms Enter
Sleep 5s

BIN
vhs/impl.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

3
vhs/impl.go Normal file
View file

@ -0,0 +1,3 @@
package demos
type CloserExample struct{}

23
vhs/impl.tape Normal file
View file

@ -0,0 +1,23 @@
Output impl.gif
Require nvim
Require iferr
Set FontFamily "JetBrains Mono"
Set Height 800
Set Width 1500
Set Padding 20
Set Shell "bash"
Set Theme "tokyonight"
Set TypingSpeed 250ms
Hide
Type@0ms "alias nvim='./nvim.sh'" Enter
Type@0ms "clear" Enter
Show
Type "nvim impl.go" Sleep 150ms Enter
Type "2j"
Type ":GoImpl io.Reader" Sleep 500ms Enter
Sleep 5s

2
vhs/nvim.sh Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
nvim --clean -u "../scripts/minimal_init.lua" $@

BIN
vhs/tags.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

12
vhs/tags.go Normal file
View file

@ -0,0 +1,12 @@
package demos
type AddTagsToMe struct {
Name string
ID int
Address string
Aliases []string
Nested struct {
Foo string
Bar float32
}
}

36
vhs/tags.tape Normal file
View file

@ -0,0 +1,36 @@
Output tags.gif
Require nvim
Require gomodifytags
Set FontFamily "JetBrains Mono"
Set Height 800
Set Width 1500
Set Padding 20
Set Shell "bash"
Set Theme "tokyonight"
Set TypingSpeed 250ms
Hide
Type@0ms "alias nvim='./nvim.sh'" Enter
Type@0ms "clear" Enter
Show
Type "nvim tags.go" Sleep 150ms Enter
Type "3j"
Type ":GoTagAdd json yaml" Sleep 500ms Enter
Type@120ms ":w" Enter
Sleep 1s
Type ":GoTagRm json" Sleep 500ms Enter
Type@120ms ":w" Enter
Sleep 1s
Type ":GoTagClear" Sleep 500ms Enter
Type@120ms ":w" Enter
Sleep 1s
Type "jV2j"
Type ":GoTagAdd xml" Sleep 500ms Enter
Sleep 5s