diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 257d94a..554e358 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index b50642e..01ab6a0 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ require("gopher").setup { Add and remove tags for structs via gomodifytags + ![Add tags demo](./vhs/tags.gif) + By default `json` tag will be added/removed, if not set: ```vim @@ -176,6 +178,8 @@ require("gopher").setup { Interface implementation via impl + ![Auto interface implementation demo](./vhs/impl.gif) + Syntax of the command: ```vim :GoImpl [receiver] [interface] @@ -199,6 +203,8 @@ require("gopher").setup { Generate boilerplate for doc comments + ![Generate comments](./vhs/comment.gif) + First set a cursor on **public** package/function/interface/struct and execute: ```vim @@ -212,6 +218,8 @@ require("gopher").setup { Generate if err != nil { via iferr + ![Generate if err != nil {](./vhs/iferr.gif) + Set the cursor on the line with `err` and execute ```vim diff --git a/Taskfile.yml b/Taskfile.yml index 226eed9..62ccd0c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,4 +1,10 @@ version: "3" + +includes: + vhs: + taskfile: ./vhs/Taskfile.yml + dir: ./vhs + tasks: lint: cmds: diff --git a/scripts/minimal_init.lua b/scripts/minimal_init.lua index b0f51e6..d7eed81 100644 --- a/scripts/minimal_init.lua +++ b/scripts/minimal_init.lua @@ -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", { diff --git a/vhs/Taskfile.yml b/vhs/Taskfile.yml new file mode 100644 index 0000000..2dfb107 --- /dev/null +++ b/vhs/Taskfile.yml @@ -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 diff --git a/vhs/comment.gif b/vhs/comment.gif new file mode 100644 index 0000000..4b4a7b4 Binary files /dev/null and b/vhs/comment.gif differ diff --git a/vhs/comment.go b/vhs/comment.go new file mode 100644 index 0000000..3869484 --- /dev/null +++ b/vhs/comment.go @@ -0,0 +1,7 @@ +package demos + +func doSomethingImportant() {} + +type User struct{} + +type DataProvider interface{} diff --git a/vhs/comment.tape b/vhs/comment.tape new file mode 100644 index 0000000..bc9724b --- /dev/null +++ b/vhs/comment.tape @@ -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 diff --git a/vhs/go.mod b/vhs/go.mod new file mode 100644 index 0000000..bd64a9b --- /dev/null +++ b/vhs/go.mod @@ -0,0 +1,3 @@ +module demos + +go 1.25.0 diff --git a/vhs/iferr.gif b/vhs/iferr.gif new file mode 100644 index 0000000..217dd60 Binary files /dev/null and b/vhs/iferr.gif differ diff --git a/vhs/iferr.go b/vhs/iferr.go new file mode 100644 index 0000000..a670571 --- /dev/null +++ b/vhs/iferr.go @@ -0,0 +1,11 @@ +package demos + +func ifErr() { + out, err := doSomething() + + _ = out +} + +func doSomething() (string, error) { + return "", nil +} diff --git a/vhs/iferr.tape b/vhs/iferr.tape new file mode 100644 index 0000000..b54e3e7 --- /dev/null +++ b/vhs/iferr.tape @@ -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 diff --git a/vhs/impl.gif b/vhs/impl.gif new file mode 100644 index 0000000..26b6a6a Binary files /dev/null and b/vhs/impl.gif differ diff --git a/vhs/impl.go b/vhs/impl.go new file mode 100644 index 0000000..6f6c0ba --- /dev/null +++ b/vhs/impl.go @@ -0,0 +1,3 @@ +package demos + +type CloserExample struct{} diff --git a/vhs/impl.tape b/vhs/impl.tape new file mode 100644 index 0000000..b8ef6b5 --- /dev/null +++ b/vhs/impl.tape @@ -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 diff --git a/vhs/nvim.sh b/vhs/nvim.sh new file mode 100755 index 0000000..f907eb0 --- /dev/null +++ b/vhs/nvim.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +nvim --clean -u "../scripts/minimal_init.lua" $@ diff --git a/vhs/tags.gif b/vhs/tags.gif new file mode 100644 index 0000000..0b2b068 Binary files /dev/null and b/vhs/tags.gif differ diff --git a/vhs/tags.go b/vhs/tags.go new file mode 100644 index 0000000..91649d7 --- /dev/null +++ b/vhs/tags.go @@ -0,0 +1,12 @@ +package demos + +type AddTagsToMe struct { + Name string + ID int + Address string + Aliases []string + Nested struct { + Foo string + Bar float32 + } +} diff --git a/vhs/tags.tape b/vhs/tags.tape new file mode 100644 index 0000000..4888ec5 --- /dev/null +++ b/vhs/tags.tape @@ -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