https://github.com/nchern/go-snip
https://github.com/nchern/go-snip
command-line golang snippets vim
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/nchern/go-snip
- Owner: nchern
- License: mit
- Created: 2019-02-15T21:09:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-03T21:29:27.000Z (about 5 years ago)
- Last Synced: 2023-04-02T13:28:45.292Z (about 3 years ago)
- Topics: command-line, golang, snippets, vim
- Language: Go
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/nchern/go-snip)
# go-snip
Lightweight [Neosnippet](https://github.com/Shougo/neosnippet-snippets/tree/master/neosnippets) parser and processor. Just an experiment how to get snippets in vim w/o dealing with many various plugins.
The current implementation reads all the `*.snip` files in `~/.vim` dir recursively each time the command is invoked.
## Install
```bash
go get github.com/nchern/go-snip/...
```
## Usage
### Command line
```bash
$ go-snip -g=go -cmd=show fori 'foo()' index MAX
for index := 0; index < MAX; index++ {
foo()
}
```
### Plug it into vim
Let's say we want to have snippets for golang in vim. Install the command and then just add the following lines into your `.vimrc`:
```vim
"" Map GoSnip command to call the util
command! -range -nargs=* -complete=custom,ListSnippets GoSnip :,!go-snip -g=go -cmd=show
"" Enable autocomplete for GoSnip command
:fun ListSnippets(A,L,P)
: return system("go-snip -g=go -cmd=ls")
:endfun
```
Then in the command mode you can run a command like this: `:GoSnip fori 'foo()' index MAX`. It will insert the `for i ..` snippet at the cursor position.
.
## TODO
- [ ] read snippets from cache file at least for name listing
- [ ] configurable snippets search root
- [ ] multi search roots