Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,149 changes: 0 additions & 2,149 deletions generate/bindata.go

This file was deleted.

32 changes: 20 additions & 12 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package generate

import (
"bytes"
"embed"
"fmt"
"log"
"path/filepath"
"text/template"
)
Expand Down Expand Up @@ -39,13 +39,25 @@ type Object struct {
// VimBuffer ...
var VimBuffer bytes.Buffer

func buff(list []string, t string) (mList, mBundle map[string]string) {
//go:embed vim_template/vimrc
var vimrc string

//go:embed vim_template/langs
var langs embed.FS

//go:embed vim_template/frameworks
var frameworks embed.FS

//go:embed vim_template/themes
var themes embed.FS

func buff(list []string, t string, fs embed.FS) (mList, mBundle map[string]string) {
mList = make(map[string]string)
mBundle = make(map[string]string)
for _, name := range list {
for _, ext := range []string{"bundle", "vim"} {
filePath := fmt.Sprintf("vim_template/%s/%s/%s.%s", t, name, name, ext)
read, _ := Asset(filePath)
read, _ := fs.ReadFile(filePath)
if ext == "vim" {
mList[name] = string(read)
} else {
Expand Down Expand Up @@ -77,14 +89,14 @@ func Generate(obj *Object) (buffer string) {

obj.Config = &config

mLang, mBundle := buff(obj.Language, "langs")
mLang, mBundle := buff(obj.Language, "langs", langs)
obj.BufferLang = mLang

mFrameworks, bundles := buff(obj.Frameworks, "frameworks")
mFrameworks, bundles := buff(obj.Frameworks, "frameworks", frameworks)
obj.BufferFramework = mFrameworks

themes := []string{obj.Theme}
mThemes, tBundles := buff(themes, "themes")
choosenThemes := []string{obj.Theme}
mThemes, tBundles := buff(choosenThemes, "themes", themes)
obj.BufferTheme.Bundle = tBundles[obj.Theme]
obj.BufferTheme.Coloscheme = mThemes[obj.Theme]

Expand All @@ -93,11 +105,7 @@ func Generate(obj *Object) (buffer string) {
}
obj.BufferBundle = mBundle

vimrc, err := Asset("vim_template/vimrc")
if err != nil {
log.Fatal(err)
}
t := template.Must(template.New("vimrc").Parse(string(vimrc)))
t := template.Must(template.New("vimrc").Parse(vimrc))
t.Execute(&VimBuffer, obj)

buffer = VimBuffer.String()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
module github.com/editor-bootstrap/vim-bootstrap

go 1.15
go 1.16

require (
github.com/gorilla/mux v1.8.0
github.com/shuLhan/go-bindata v4.0.0+incompatible // indirect
github.com/urfave/negroni v1.0.0
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/shuLhan/go-bindata v4.0.0+incompatible h1:xD8LkuVZLV5OOn/IEuFdt6EEAW7deWiqgwaaSGhjAJc=
github.com/shuLhan/go-bindata v4.0.0+incompatible/go.mod h1:pkcPAATLBDD2+SpAPnX5vEM90F7fcwHCvvLCMXcmw3g=
github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=