[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang

chore: add demos (#118)

* chore: add dataset for demos

* chore(demos): add demos

* chore: update CONTRIBUTING

* this copefully will fix comments gif

authored by olexsmir.xyz and committed by olexsmir.xyz 9bf72afc c0951c47

+6 -2
CONTRIBUTING.md
··· 25 25 26 26 ### Documentation 27 27 Here we're using [mini.doc](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-doc.md) 28 - for generating help files based on [LuaCats](https://luals.github.io/wiki/annotations/) annotations in comments. 28 + for generating vimhelp files based on [LuaCats](https://luals.github.io/wiki/annotations/) annotations in comments. 29 + 30 + For demo gifs in [readme](./README.md) we're using [vhs](https://github.com/charmbracelet/vhs). 31 + All files related to demos live in [/vhs](./vhs) dir. 29 32 30 33 You can generate docs with: 31 34 ```bash 32 - task docgen 35 + task docgen # generates vimhelp 36 + task vhs:generate # generates demo gifs 33 37 ``` 34 38 35 39 ### Commit messages
+8
README.md
··· 99 99 <b>Add and remove tags for structs via <a href="https://github.com/fatih/gomodifytags">gomodifytags</a></b> 100 100 </summary> 101 101 102 + ![Add tags demo](./vhs/tags.gif) 103 + 102 104 By default `json` tag will be added/removed, if not set: 103 105 104 106 ```vim ··· 176 178 <b>Interface implementation via <a href="https://github.com/josharian/impl">impl<a></b> 177 179 </summary> 178 180 181 + ![Auto interface implementation demo](./vhs/impl.gif) 182 + 179 183 Syntax of the command: 180 184 ```vim 181 185 :GoImpl [receiver] [interface] ··· 199 203 <b>Generate boilerplate for doc comments</b> 200 204 </summary> 201 205 206 + ![Generate comments](./vhs/comment.gif) 207 + 202 208 First set a cursor on **public** package/function/interface/struct and execute: 203 209 204 210 ```vim ··· 211 217 <summary> 212 218 <b>Generate <code>if err != nil {</code> via <a href="https://github.com/koron/iferr">iferr</a></b> 213 219 </summary> 220 + 221 + ![Generate if err != nil {](./vhs/iferr.gif) 214 222 215 223 Set the cursor on the line with `err` and execute 216 224
+6
Taskfile.yml
··· 1 1 version: "3" 2 + 3 + includes: 4 + vhs: 5 + taskfile: ./vhs/Taskfile.yml 6 + dir: ./vhs 7 + 2 8 tasks: 3 9 lint: 4 10 cmds:
+10
scripts/minimal_init.lua
··· 23 23 install_plug "nvim-lua/plenary.nvim" 24 24 install_plug "nvim-treesitter/nvim-treesitter" 25 25 install_plug "echasnovski/mini.doc" -- used for docs generation 26 + install_plug "folke/tokyonight.nvim" -- theme for generating demos 26 27 install_plug "echasnovski/mini.test" 27 28 28 29 vim.env.XDG_CONFIG_HOME = root ".tests/config" ··· 32 33 33 34 vim.opt.runtimepath:append(root()) 34 35 vim.opt.packpath:append(root ".tests/site") 36 + vim.o.swapfile = false 37 + vim.o.writebackup = false 35 38 vim.notify = vim.print 36 39 37 40 -- install go treesitter parse ··· 51 54 end, 52 55 }, 53 56 } 57 + end 58 + 59 + -- set colorscheme only when running ui 60 + if #vim.api.nvim_list_uis() == 1 then 61 + vim.cmd.colorscheme "tokyonight-night" 62 + vim.o.cursorline = true 63 + vim.o.number = true 54 64 end 55 65 56 66 -- needed for tests, i dont know the reason why, but on start
+20
vhs/Taskfile.yml
··· 1 + version: "3" 2 + tasks: 3 + generate: 4 + deps: 5 + - comment 6 + - iferr 7 + - tags 8 + - impl 9 + 10 + comment: 11 + cmd: vhs comment.tape 12 + 13 + iferr: 14 + cmd: vhs iferr.tape 15 + 16 + tags: 17 + cmd: vhs tags.tape 18 + 19 + impl: 20 + cmd: vhs impl.tape
vhs/comment.gif

This is a binary file and will not be displayed.

+7
vhs/comment.go
··· 1 + package demos 2 + 3 + func doSomethingImportant() {} 4 + 5 + type User struct{} 6 + 7 + type DataProvider interface{}
+34
vhs/comment.tape
··· 1 + Output comment.gif 2 + Require nvim 3 + 4 + Set FontFamily "JetBrains Mono" 5 + Set Height 800 6 + Set Width 1500 7 + Set Padding 20 8 + Set Shell "bash" 9 + Set Theme "tokyonight" 10 + Set TypingSpeed 250ms 11 + 12 + Hide 13 + Type@0ms "alias nvim='./nvim.sh'" Enter 14 + Type@0ms "clear" Enter 15 + Show 16 + 17 + Type "nvim comment.go" Sleep 150ms Enter 18 + 19 + # package 20 + Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms 21 + 22 + # func 23 + Type "3j" 24 + Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms 25 + 26 + # struct 27 + Type "3j" 28 + Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms 29 + 30 + # interface 31 + Type "3j" 32 + Type ":GoCmt" Enter Sleep 500ms Escape Sleep 700ms 33 + 34 + Sleep 5s
+3
vhs/go.mod
··· 1 + module demos 2 + 3 + go 1.25.0
vhs/iferr.gif

This is a binary file and will not be displayed.

+11
vhs/iferr.go
··· 1 + package demos 2 + 3 + func ifErr() { 4 + out, err := doSomething() 5 + 6 + _ = out 7 + } 8 + 9 + func doSomething() (string, error) { 10 + return "", nil 11 + }
+23
vhs/iferr.tape
··· 1 + Output iferr.gif 2 + Require nvim 3 + Require iferr 4 + 5 + Set FontFamily "JetBrains Mono" 6 + Set Height 800 7 + Set Width 1500 8 + Set Padding 20 9 + Set Shell "bash" 10 + Set Theme "tokyonight" 11 + Set TypingSpeed 250ms 12 + 13 + Hide 14 + Type@0ms "alias nvim='./nvim.sh'" Enter 15 + Type@0ms "clear" Enter 16 + Show 17 + 18 + Type "nvim iferr.go" Sleep 150ms Enter 19 + 20 + Type "3j" 21 + Type ":GoIfErr" Sleep 500ms Enter 22 + 23 + Sleep 5s
vhs/impl.gif

This is a binary file and will not be displayed.

+3
vhs/impl.go
··· 1 + package demos 2 + 3 + type CloserExample struct{}
+23
vhs/impl.tape
··· 1 + Output impl.gif 2 + Require nvim 3 + Require iferr 4 + 5 + Set FontFamily "JetBrains Mono" 6 + Set Height 800 7 + Set Width 1500 8 + Set Padding 20 9 + Set Shell "bash" 10 + Set Theme "tokyonight" 11 + Set TypingSpeed 250ms 12 + 13 + Hide 14 + Type@0ms "alias nvim='./nvim.sh'" Enter 15 + Type@0ms "clear" Enter 16 + Show 17 + 18 + Type "nvim impl.go" Sleep 150ms Enter 19 + 20 + Type "2j" 21 + Type ":GoImpl io.Reader" Sleep 500ms Enter 22 + 23 + Sleep 5s
+2
vhs/nvim.sh
··· 1 + #!/usr/bin/env bash 2 + nvim --clean -u "../scripts/minimal_init.lua" $@
vhs/tags.gif

This is a binary file and will not be displayed.

+12
vhs/tags.go
··· 1 + package demos 2 + 3 + type AddTagsToMe struct { 4 + Name string 5 + ID int 6 + Address string 7 + Aliases []string 8 + Nested struct { 9 + Foo string 10 + Bar float32 11 + } 12 + }
+36
vhs/tags.tape
··· 1 + Output tags.gif 2 + Require nvim 3 + Require gomodifytags 4 + 5 + Set FontFamily "JetBrains Mono" 6 + Set Height 800 7 + Set Width 1500 8 + Set Padding 20 9 + Set Shell "bash" 10 + Set Theme "tokyonight" 11 + Set TypingSpeed 250ms 12 + 13 + Hide 14 + Type@0ms "alias nvim='./nvim.sh'" Enter 15 + Type@0ms "clear" Enter 16 + Show 17 + 18 + Type "nvim tags.go" Sleep 150ms Enter 19 + 20 + Type "3j" 21 + Type ":GoTagAdd json yaml" Sleep 500ms Enter 22 + Type@120ms ":w" Enter 23 + Sleep 1s 24 + 25 + Type ":GoTagRm json" Sleep 500ms Enter 26 + Type@120ms ":w" Enter 27 + Sleep 1s 28 + 29 + Type ":GoTagClear" Sleep 500ms Enter 30 + Type@120ms ":w" Enter 31 + Sleep 1s 32 + 33 + Type "jV2j" 34 + Type ":GoTagAdd xml" Sleep 500ms Enter 35 + 36 + Sleep 5s