Skip to content

Commit b1c9efd

Browse files
authored
Merge pull request #253 from vim-volt/devel
Release v0.3.6
2 parents 51871c8 + 14d577a commit b1c9efd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2365
-162
lines changed

CMDREF.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Command
3333
This is shortcut of:
3434
volt profile rm -current {repository} [{repository2} ...]
3535
36+
edit [-e|--editor {editor}] {repository} [{repository2} ...]
37+
Open the plugconf file(s) of one or more {repository} for editing.
38+
3639
profile set {name}
3740
Set profile name
3841
@@ -112,6 +115,23 @@ Description
112115
volt profile rm {current profile} {repository} [{repository2} ...]
113116
```
114117

118+
# volt edit
119+
120+
```
121+
Usage
122+
volt edit [-help] [-e|--editor {editor}] {repository} [{repository2} ...]
123+
124+
Quick example
125+
$ volt edit tyru/caw.vim # will open the plugconf file for tyru/caw.vim for editing
126+
127+
Description
128+
Open the plugconf file(s) of one or more {repository} for editing.
129+
130+
If the -e option was given, use the given editor for editing those files (unless it cannot be found)
131+
132+
It also calls "volt build" afterwards if modifications were made to the plugconf file(s).
133+
```
134+
115135
# volt enable
116136

117137
```

Gopkg.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ precompile:
1818
go build -a -i -o $(BIN_DIR)/$(NAME)
1919
rm $(BIN_DIR)/$(NAME)
2020

21-
install-dep:
22-
[ -x bin/dep ] || go build -o bin/dep github.com/golang/dep/cmd/dep
23-
24-
dep-ensure: install-dep
25-
bin/dep ensure -v
26-
2721
test:
2822
make
2923
go test -v -race -parallel 3 ./...
@@ -38,11 +32,11 @@ release: $(BIN_DIR)/$(NAME)
3832
exe=$$exe.exe; \
3933
fi; \
4034
echo "Creating $$exe ... (os=$$os, arch=$$arch)"; \
41-
GOOS=$$os GOARCH=$$arch GO111MODULE=off go build -tags netgo -installsuffix netgo -ldflags "$(RELEASE_LDFLAGS)" -o $$exe; \
35+
GOOS=$$os GOARCH=$$arch go build -tags netgo -installsuffix netgo -ldflags "$(RELEASE_LDFLAGS)" -o $$exe; \
4236
done; \
4337
done
4438

4539
update-doc: all
4640
go run _scripts/update-cmdref.go >CMDREF.md
4741

48-
.PHONY: all precompile install-dep dep-ensure test release update-doc
42+
.PHONY: all precompile test release update-doc

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ create_skeleton_plugconf = true
181181
# installed, it tries to execute "git clone" or "git pull" as a fallback
182182
# * false: "volt get" or "volt get -u" won't try to execute fallback commands
183183
fallback_git_cmd = true
184+
185+
[edit]
186+
# If you ever wanted to use emacs to edit your vim plugin config, you can
187+
# do so with the following. If not specified, volt will try to use
188+
# vim/nvim, $VISUAL, sensible-editor, or $EDITOR in this order until a usable
189+
# one is found.
190+
editor = "emacs"
184191
```
185192

186193
## Features
@@ -228,8 +235,10 @@ For example, [tyru/open-browser-github.vim](https://github.com/tyru/open-browser
228235

229236
Some special functions can be defined in plugconf file:
230237

231-
* `s:config()`
232-
* Plugin configuration
238+
* `s:on_load_pre()`
239+
* Plugin configuration to be executed before a plugin is loaded
240+
* `s:on_load_post()`
241+
* Plugin configuration to be executed after a plugin is loaded
233242
* `s:loaded_on()` (optional)
234243
* Return value: String (when to load a plugin by `:packadd`)
235244
* This function specifies when to load a plugin by `:packadd`
@@ -247,7 +256,8 @@ An example config of [tyru/open-browser-github.vim](https://github.com/tyru/open
247256

248257
```vim
249258
" Plugin configuration like the code written in vimrc.
250-
function! s:config()
259+
" This configuration is executed *before* a plugin is loaded.
260+
function! s:on_load_pre()
251261
let g:openbrowser_github_always_use_commit_hash = 1
252262
endfunction
253263
@@ -361,12 +371,7 @@ NOTE: If the path(s) exists, `$MYVIMRC` and `$MYGVIMRC` are set. So `:edit $MYVI
361371

362372
This file is copied to `~/.vim/vimrc` and `~/.vim/gvimrc` with magic comment (shows error if existing vimrc/gvimrc files exist with no magic comment).
363373

364-
And you can enable/disable vimrc by `volt profile use` (or you can simply remove `$VOLTPATH/rc/<profile name>/vimrc.vim` file if you don't want vimrc for the profile).
365-
366-
```
367-
$ volt profile use -current vimrc false # Disable installing vimrc on current profile
368-
$ volt profile use default gvimrc true # Enable installing gvimrc on profile default
369-
```
374+
And you can enable/disable vimrc by removing (or renaming) `$VOLTPATH/rc/<profile name>/vimrc.vim` file if you don't want vimrc for the profile.
370375

371376
See `volt help profile` for more detailed information.
372377

_contrib/completion/bash

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ this_plug() {
2626
volt list -f "{{ range .Profiles }}{{ if eq \"$1\" .Name }}{{ range .ReposPath }}{{ println . }}{{ end }}{{ end }}{{ end }}" | sed -E 's@^(www\.)?github\.com/@@' | sort -u
2727
}
2828

29-
CMDS="get rm list enable disable profile build migrate self-upgrade version"
29+
CMDS="get rm list enable disable edit profile build migrate self-upgrade version"
3030
PROFILE_CMDS="set show list new destroy rename add rm"
3131
MIGRATE_CMDS="lockjson plugconf/config-func"
3232

@@ -53,7 +53,7 @@ _volt() {
5353
elif [[ "${first}" == "profile" && "${last}" == "profile" ]] ; then
5454
COMPREPLY=( $(compgen -W "${PROFILE_CMDS}" -- ${cur}) )
5555

56-
elif [[ "${first}" =~ ^(rm|disable)$ ]] ; then
56+
elif [[ "${first}" =~ ^(rm|disable|edit)$ ]] ; then
5757
local profile=$(get_profile)
5858
plugs=$(get_plugs "$profile" "this")
5959
COMPREPLY=( $(compgen -W "${plugs}" -- ${cur}) )
@@ -87,4 +87,10 @@ _volt() {
8787
fi
8888
return 0
8989
}
90+
91+
if [ -n "$ZSH_VERSION" ]; then
92+
autoload bashcompinit
93+
bashcompinit
94+
fi
95+
9096
complete -F _volt volt

_contrib/completion/zsh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#compdef volt
2+
3+
# zsh completion wrapper for volt
4+
#
5+
# Based on git and tig's zsh completion scripts.
6+
# git: https://git-scm.com
7+
# tig: https://jonas.github.io/tig
8+
#
9+
# Copy or symlink this script and bash completion script as '_volt' and
10+
# 'volt-completion.bash' to any directory in '$fpath'.
11+
12+
13+
_volt () {
14+
local e
15+
e=$(dirname ${funcsourcetrace[1]%:*})/volt-completion.bash
16+
if [ -f $e ]; then
17+
. $e
18+
fi
19+
}

config/config.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package config
22

33
import (
4-
"fmt"
5-
64
"github.com/BurntSushi/toml"
5+
"github.com/pkg/errors"
6+
77
"github.com/vim-volt/volt/pathutil"
88
)
99

@@ -12,6 +12,7 @@ type Config struct {
1212
Alias map[string][]string `toml:"alias"`
1313
Build configBuild `toml:"build"`
1414
Get configGet `toml:"get"`
15+
Edit configEdit `toml:"edit"`
1516
}
1617

1718
// configBuild is a config for 'volt build'.
@@ -25,6 +26,11 @@ type configGet struct {
2526
FallbackGitCmd *bool `toml:"fallback_git_cmd"`
2627
}
2728

29+
// configEdit is a config for 'volt edit'.
30+
type configEdit struct {
31+
Editor string `toml:"editor"`
32+
}
33+
2834
const (
2935
// SymlinkBuilder creates symlinks when 'volt build'.
3036
SymlinkBuilder = "symlink"
@@ -43,6 +49,9 @@ func initialConfigTOML() *Config {
4349
CreateSkeletonPlugconf: &trueValue,
4450
FallbackGitCmd: &falseValue,
4551
},
52+
Edit: configEdit{
53+
Editor: "",
54+
},
4655
}
4756
}
4857

@@ -76,11 +85,14 @@ func merge(cfg, initCfg *Config) {
7685
if cfg.Get.FallbackGitCmd == nil {
7786
cfg.Get.FallbackGitCmd = initCfg.Get.FallbackGitCmd
7887
}
88+
if cfg.Edit.Editor == "" {
89+
cfg.Edit.Editor = initCfg.Edit.Editor
90+
}
7991
}
8092

8193
func validate(cfg *Config) error {
8294
if cfg.Build.Strategy != "symlink" && cfg.Build.Strategy != "copy" {
83-
return fmt.Errorf("build.strategy is %q: valid values are %q or %q", cfg.Build.Strategy, "symlink", "copy")
95+
return errors.Errorf("build.strategy is %q: valid values are %q or %q", cfg.Build.Strategy, "symlink", "copy")
8496
}
8597
return nil
8698
}

fileutil/copyfile_linux.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
package fileutil
3232

3333
import (
34-
"fmt"
3534
"os"
3635
"syscall"
36+
37+
"github.com/pkg/errors"
3738
)
3839

3940
// CopyFile copies the contents of the file named src to the file named
@@ -63,7 +64,7 @@ func CopyFile(src, dst string, buf []byte, perm os.FileMode) error {
6364
for {
6465
n, err := syscall.Sendfile(wfd, rfd, nil, readsize)
6566
if err != nil {
66-
return fmt.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
67+
return errors.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
6768
}
6869
written += int64(n)
6970
if written >= fi.Size() {
@@ -72,7 +73,7 @@ func CopyFile(src, dst string, buf []byte, perm os.FileMode) error {
7273
}
7374
} else {
7475
if _, err := syscall.Sendfile(wfd, rfd, nil, int(fi.Size())); err != nil {
75-
return fmt.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
76+
return errors.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
7677
}
7778
}
7879
return nil

gitutil/gitutil.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package gitutil
22

33
import (
4-
"errors"
5-
"fmt"
64
"regexp"
75

6+
"github.com/pkg/errors"
7+
88
"github.com/vim-volt/volt/pathutil"
99
git "gopkg.in/src-d/go-git.v4"
1010
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -109,7 +109,7 @@ func GetUpstreamRemote(r *git.Repository) (string, error) {
109109
subsec := cfg.Raw.Section("branch").Subsection(branch[1])
110110
remote := subsec.Option("remote")
111111
if remote == "" {
112-
return "", fmt.Errorf("gitconfig 'branch.%s.remote' is not found", subsec.Name)
112+
return "", errors.Errorf("gitconfig 'branch.%s.remote' is not found", subsec.Name)
113113
}
114114
return remote, nil
115115
}

httputil/httputil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package httputil
22

33
import (
4-
"errors"
4+
"github.com/pkg/errors"
55
"io"
66
"io/ioutil"
77
"net/http"

internal/testutil/testutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package testutil
22

33
import (
4-
"errors"
54
"fmt"
5+
"github.com/pkg/errors"
66
"io/ioutil"
77
"os"
88
"os/exec"

lockjson/lockjson.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package lockjson
22

33
import (
44
"encoding/json"
5-
"errors"
6-
"fmt"
75
"io/ioutil"
86
"os"
97
"path/filepath"
108
"strconv"
119

10+
"github.com/pkg/errors"
11+
1212
"github.com/vim-volt/volt/logger"
1313
"github.com/vim-volt/volt/pathutil"
1414
)
@@ -112,19 +112,19 @@ func read(doLog bool) (*LockJSON, error) {
112112
// Validate lock.json
113113
err = validate(&lockJSON)
114114
if err != nil {
115-
return nil, errors.New("validation failed: lock.json: " + err.Error())
115+
return nil, errors.Wrap(err, "validation failed: lock.json")
116116
}
117117

118118
return &lockJSON, nil
119119
}
120120

121121
func validate(lockJSON *LockJSON) error {
122122
if lockJSON.Version < 1 {
123-
return fmt.Errorf("lock.json version is '%d' (must be 1 or greater)", lockJSON.Version)
123+
return errors.Errorf("lock.json version is '%d' (must be 1 or greater)", lockJSON.Version)
124124
}
125125
// Validate if volt can manipulate lock.json of this version
126126
if lockJSON.Version > lockJSONVersion {
127-
return fmt.Errorf("this lock.json version is '%d' which volt cannot recognize. please upgrade volt to process this file", lockJSON.Version)
127+
return errors.Errorf("this lock.json version is '%d' which volt cannot recognize. please upgrade volt to process this file", lockJSON.Version)
128128
}
129129

130130
// Validate if missing required keys exist

pathutil/pathutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package pathutil
22

33
import (
4-
"errors"
4+
"github.com/pkg/errors"
55
"os"
66
"os/exec"
77
"path/filepath"

0 commit comments

Comments
 (0)