chore: add demos (#118)
* chore: add dataset for demos * chore(demos): add demos * chore: update CONTRIBUTING * this copefully will fix comments gif
This commit is contained in:
parent
c0951c4769
commit
9bf72afc63
19 changed files with 204 additions and 2 deletions
|
|
@ -25,11 +25,15 @@ task lint
|
|||
|
||||
### Documentation
|
||||
Here we're using [mini.doc](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-doc.md)
|
||||
for generating help files based on [LuaCats](https://luals.github.io/wiki/annotations/) annotations in comments.
|
||||
for generating vimhelp files based on [LuaCats](https://luals.github.io/wiki/annotations/) annotations in comments.
|
||||
|
||||
For demo gifs in [readme](./README.md) we're using [vhs](https://github.com/charmbracelet/vhs).
|
||||
All files related to demos live in [/vhs](./vhs) dir.
|
||||
|
||||
You can generate docs with:
|
||||
```bash
|
||||
task docgen
|
||||
task docgen # generates vimhelp
|
||||
task vhs:generate # generates demo gifs
|
||||
```
|
||||
|
||||
### Commit messages
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
By default `json` tag will be added/removed, if not set:
|
||||
|
||||
```vim
|
||||
|
|
@ -176,6 +178,8 @@ require("gopher").setup {
|
|||
<b>Interface implementation via <a href="https://github.com/josharian/impl">impl<a></b>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
Syntax of the command:
|
||||
```vim
|
||||
:GoImpl [receiver] [interface]
|
||||
|
|
@ -199,6 +203,8 @@ require("gopher").setup {
|
|||
<b>Generate boilerplate for doc comments</b>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
First set a cursor on **public** package/function/interface/struct and execute:
|
||||
|
||||
```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>
|
||||
</summary>
|
||||
|
||||

|
||||
|
||||
Set the cursor on the line with `err` and execute
|
||||
|
||||
```vim
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
version: "3"
|
||||
|
||||
includes:
|
||||
vhs:
|
||||
taskfile: ./vhs/Taskfile.yml
|
||||
dir: ./vhs
|
||||
|
||||
tasks:
|
||||
lint:
|
||||
cmds:
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ end
|
|||
install_plug "nvim-lua/plenary.nvim"
|
||||
install_plug "nvim-treesitter/nvim-treesitter"
|
||||
install_plug "echasnovski/mini.doc" -- used for docs generation
|
||||
install_plug "folke/tokyonight.nvim" -- theme for generating demos
|
||||
install_plug "echasnovski/mini.test"
|
||||
|
||||
vim.env.XDG_CONFIG_HOME = root ".tests/config"
|
||||
|
|
@ -32,6 +33,8 @@ vim.env.XDG_CACHE_HOME = root ".tests/cache"
|
|||
|
||||
vim.opt.runtimepath:append(root())
|
||||
vim.opt.packpath:append(root ".tests/site")
|
||||
vim.o.swapfile = false
|
||||
vim.o.writebackup = false
|
||||
vim.notify = vim.print
|
||||
|
||||
-- install go treesitter parse
|
||||
|
|
@ -53,6 +56,13 @@ if #vim.api.nvim_list_uis() == 0 then
|
|||
}
|
||||
end
|
||||
|
||||
-- set colorscheme only when running ui
|
||||
if #vim.api.nvim_list_uis() == 1 then
|
||||
vim.cmd.colorscheme "tokyonight-night"
|
||||
vim.o.cursorline = true
|
||||
vim.o.number = true
|
||||
end
|
||||
|
||||
-- needed for tests, i dont know the reason why, but on start
|
||||
-- vim is not able to use treesitter for go by default
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
|
|
|
|||
20
vhs/Taskfile.yml
Normal file
20
vhs/Taskfile.yml
Normal 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
|
||||
BIN
vhs/comment.gif
Normal file
BIN
vhs/comment.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 220 KiB |
7
vhs/comment.go
Normal file
7
vhs/comment.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package demos
|
||||
|
||||
func doSomethingImportant() {}
|
||||
|
||||
type User struct{}
|
||||
|
||||
type DataProvider interface{}
|
||||
34
vhs/comment.tape
Normal file
34
vhs/comment.tape
Normal 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
3
vhs/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module demos
|
||||
|
||||
go 1.25.0
|
||||
BIN
vhs/iferr.gif
Normal file
BIN
vhs/iferr.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
11
vhs/iferr.go
Normal file
11
vhs/iferr.go
Normal 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
23
vhs/iferr.tape
Normal 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
BIN
vhs/impl.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
3
vhs/impl.go
Normal file
3
vhs/impl.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package demos
|
||||
|
||||
type CloserExample struct{}
|
||||
23
vhs/impl.tape
Normal file
23
vhs/impl.tape
Normal 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
2
vhs/nvim.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
nvim --clean -u "../scripts/minimal_init.lua" $@
|
||||
BIN
vhs/tags.gif
Normal file
BIN
vhs/tags.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 246 KiB |
12
vhs/tags.go
Normal file
12
vhs/tags.go
Normal 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
36
vhs/tags.tape
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue