go-snip

command module
v0.0.0-...-222bce3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 9 Imported by: 0

README

Go Report Card

go-snip

Lightweight Neosnippet 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

go get github.com/nchern/go-snip/...

Usage

Command line
$ 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:

"" Map GoSnip command to call the util
command! -range -nargs=* -complete=custom,ListSnippets GoSnip :<line1>,<line2>!go-snip -g=go -cmd=show <args>
"" 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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL