Skip to content

Commit

Permalink
Merge pull request #253 from vim-volt/devel
Browse files Browse the repository at this point in the history
Release v0.3.6
  • Loading branch information
tyru authored Apr 26, 2019
2 parents 51871c8 + 14d577a commit b1c9efd
Show file tree
Hide file tree
Showing 48 changed files with 2,365 additions and 162 deletions.
20 changes: 20 additions & 0 deletions CMDREF.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Command
This is shortcut of:
volt profile rm -current {repository} [{repository2} ...]
edit [-e|--editor {editor}] {repository} [{repository2} ...]
Open the plugconf file(s) of one or more {repository} for editing.
profile set {name}
Set profile name
Expand Down Expand Up @@ -112,6 +115,23 @@ Description
volt profile rm {current profile} {repository} [{repository2} ...]
```

# volt edit

```
Usage
volt edit [-help] [-e|--editor {editor}] {repository} [{repository2} ...]
Quick example
$ volt edit tyru/caw.vim # will open the plugconf file for tyru/caw.vim for editing
Description
Open the plugconf file(s) of one or more {repository} for editing.
If the -e option was given, use the given editor for editing those files (unless it cannot be found)
It also calls "volt build" afterwards if modifications were made to the plugconf file(s).
```

# volt enable

```
Expand Down
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ precompile:
go build -a -i -o $(BIN_DIR)/$(NAME)
rm $(BIN_DIR)/$(NAME)

install-dep:
[ -x bin/dep ] || go build -o bin/dep github.com/golang/dep/cmd/dep

dep-ensure: install-dep
bin/dep ensure -v

test:
make
go test -v -race -parallel 3 ./...
Expand All @@ -38,11 +32,11 @@ release: $(BIN_DIR)/$(NAME)
exe=$$exe.exe; \
fi; \
echo "Creating $$exe ... (os=$$os, arch=$$arch)"; \
GOOS=$$os GOARCH=$$arch GO111MODULE=off go build -tags netgo -installsuffix netgo -ldflags "$(RELEASE_LDFLAGS)" -o $$exe; \
GOOS=$$os GOARCH=$$arch go build -tags netgo -installsuffix netgo -ldflags "$(RELEASE_LDFLAGS)" -o $$exe; \
done; \
done

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

.PHONY: all precompile install-dep dep-ensure test release update-doc
.PHONY: all precompile test release update-doc
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ create_skeleton_plugconf = true
# installed, it tries to execute "git clone" or "git pull" as a fallback
# * false: "volt get" or "volt get -u" won't try to execute fallback commands
fallback_git_cmd = true

[edit]
# If you ever wanted to use emacs to edit your vim plugin config, you can
# do so with the following. If not specified, volt will try to use
# vim/nvim, $VISUAL, sensible-editor, or $EDITOR in this order until a usable
# one is found.
editor = "emacs"
```

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

Some special functions can be defined in plugconf file:

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

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

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).

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).

```
$ volt profile use -current vimrc false # Disable installing vimrc on current profile
$ volt profile use default gvimrc true # Enable installing gvimrc on profile default
```
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.

See `volt help profile` for more detailed information.

Expand Down
10 changes: 8 additions & 2 deletions _contrib/completion/bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ this_plug() {
volt list -f "{{ range .Profiles }}{{ if eq \"$1\" .Name }}{{ range .ReposPath }}{{ println . }}{{ end }}{{ end }}{{ end }}" | sed -E 's@^(www\.)?github\.com/@@' | sort -u
}

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

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

elif [[ "${first}" =~ ^(rm|disable)$ ]] ; then
elif [[ "${first}" =~ ^(rm|disable|edit)$ ]] ; then
local profile=$(get_profile)
plugs=$(get_plugs "$profile" "this")
COMPREPLY=( $(compgen -W "${plugs}" -- ${cur}) )
Expand Down Expand Up @@ -87,4 +87,10 @@ _volt() {
fi
return 0
}

if [ -n "$ZSH_VERSION" ]; then
autoload bashcompinit
bashcompinit
fi

complete -F _volt volt
19 changes: 19 additions & 0 deletions _contrib/completion/zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#compdef volt

# zsh completion wrapper for volt
#
# Based on git and tig's zsh completion scripts.
# git: https://git-scm.com
# tig: https://jonas.github.io/tig
#
# Copy or symlink this script and bash completion script as '_volt' and
# 'volt-completion.bash' to any directory in '$fpath'.


_volt () {
local e
e=$(dirname ${funcsourcetrace[1]%:*})/volt-completion.bash
if [ -f $e ]; then
. $e
fi
}
18 changes: 15 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package config

import (
"fmt"

"github.com/BurntSushi/toml"
"github.com/pkg/errors"

"github.com/vim-volt/volt/pathutil"
)

Expand All @@ -12,6 +12,7 @@ type Config struct {
Alias map[string][]string `toml:"alias"`
Build configBuild `toml:"build"`
Get configGet `toml:"get"`
Edit configEdit `toml:"edit"`
}

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

// configEdit is a config for 'volt edit'.
type configEdit struct {
Editor string `toml:"editor"`
}

const (
// SymlinkBuilder creates symlinks when 'volt build'.
SymlinkBuilder = "symlink"
Expand All @@ -43,6 +49,9 @@ func initialConfigTOML() *Config {
CreateSkeletonPlugconf: &trueValue,
FallbackGitCmd: &falseValue,
},
Edit: configEdit{
Editor: "",
},
}
}

Expand Down Expand Up @@ -76,11 +85,14 @@ func merge(cfg, initCfg *Config) {
if cfg.Get.FallbackGitCmd == nil {
cfg.Get.FallbackGitCmd = initCfg.Get.FallbackGitCmd
}
if cfg.Edit.Editor == "" {
cfg.Edit.Editor = initCfg.Edit.Editor
}
}

func validate(cfg *Config) error {
if cfg.Build.Strategy != "symlink" && cfg.Build.Strategy != "copy" {
return fmt.Errorf("build.strategy is %q: valid values are %q or %q", cfg.Build.Strategy, "symlink", "copy")
return errors.Errorf("build.strategy is %q: valid values are %q or %q", cfg.Build.Strategy, "symlink", "copy")
}
return nil
}
7 changes: 4 additions & 3 deletions fileutil/copyfile_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
package fileutil

import (
"fmt"
"os"
"syscall"

"github.com/pkg/errors"
)

// CopyFile copies the contents of the file named src to the file named
Expand Down Expand Up @@ -63,7 +64,7 @@ func CopyFile(src, dst string, buf []byte, perm os.FileMode) error {
for {
n, err := syscall.Sendfile(wfd, rfd, nil, readsize)
if err != nil {
return fmt.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
return errors.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
}
written += int64(n)
if written >= fi.Size() {
Expand All @@ -72,7 +73,7 @@ func CopyFile(src, dst string, buf []byte, perm os.FileMode) error {
}
} else {
if _, err := syscall.Sendfile(wfd, rfd, nil, int(fi.Size())); err != nil {
return fmt.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
return errors.Errorf("sendfile(%q, %q) failed: %s", src, dst, err.Error())
}
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions gitutil/gitutil.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package gitutil

import (
"errors"
"fmt"
"regexp"

"github.com/pkg/errors"

"github.com/vim-volt/volt/pathutil"
git "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
Expand Down Expand Up @@ -109,7 +109,7 @@ func GetUpstreamRemote(r *git.Repository) (string, error) {
subsec := cfg.Raw.Section("branch").Subsection(branch[1])
remote := subsec.Option("remote")
if remote == "" {
return "", fmt.Errorf("gitconfig 'branch.%s.remote' is not found", subsec.Name)
return "", errors.Errorf("gitconfig 'branch.%s.remote' is not found", subsec.Name)
}
return remote, nil
}
2 changes: 1 addition & 1 deletion httputil/httputil.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package httputil

import (
"errors"
"github.com/pkg/errors"
"io"
"io/ioutil"
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/testutil.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package testutil

import (
"errors"
"fmt"
"github.com/pkg/errors"
"io/ioutil"
"os"
"os/exec"
Expand Down
10 changes: 5 additions & 5 deletions lockjson/lockjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package lockjson

import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"

"github.com/pkg/errors"

"github.com/vim-volt/volt/logger"
"github.com/vim-volt/volt/pathutil"
)
Expand Down Expand Up @@ -112,19 +112,19 @@ func read(doLog bool) (*LockJSON, error) {
// Validate lock.json
err = validate(&lockJSON)
if err != nil {
return nil, errors.New("validation failed: lock.json: " + err.Error())
return nil, errors.Wrap(err, "validation failed: lock.json")
}

return &lockJSON, nil
}

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

// Validate if missing required keys exist
Expand Down
2 changes: 1 addition & 1 deletion pathutil/pathutil.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pathutil

import (
"errors"
"github.com/pkg/errors"
"os"
"os/exec"
"path/filepath"
Expand Down
Loading

0 comments on commit b1c9efd

Please sign in to comment.