mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins, also experimenting with a new font
The font is IBM Plex Mono: https://ibm.github.io/type/
This commit is contained in:
@ -4,36 +4,65 @@ if exists("g:go_loaded_install")
|
||||
endif
|
||||
let g:go_loaded_install = 1
|
||||
|
||||
" Not using the has('patch-7.4.1689') syntax because that wasn't added until
|
||||
" 7.4.237, and we want to be sure this works for everyone (this is also why
|
||||
" we're not using utils#EchoError()).
|
||||
"
|
||||
" Version 7.4.1689 was chosen because that's what the most recent Ubuntu LTS
|
||||
" release (16.04) uses.
|
||||
if
|
||||
\ get(g:, 'go_version_warning', 1) != 0 &&
|
||||
\ (v:version < 704 || (v:version == 704 && !has('patch1689')))
|
||||
\ && !has('nvim')
|
||||
echohl Error
|
||||
echom "vim-go requires Vim 7.4.1689 or Neovim, but you're using an older version."
|
||||
echom "Please update your Vim for the best vim-go experience."
|
||||
echom "If you really want to continue you can set this to make the error go away:"
|
||||
echom " let g:go_version_warning = 0"
|
||||
echom "Note that some features may error out or behave incorrectly."
|
||||
echom "Please do not report bugs unless you're using Vim 7.4.1689 or newer."
|
||||
echohl None
|
||||
|
||||
" Make sure people see this.
|
||||
sleep 2
|
||||
endif
|
||||
|
||||
" these packages are used by vim-go and can be automatically installed if
|
||||
" needed by the user with GoInstallBinaries
|
||||
let s:packages = [
|
||||
\ "github.com/nsf/gocode",
|
||||
\ "github.com/alecthomas/gometalinter",
|
||||
\ "golang.org/x/tools/cmd/goimports",
|
||||
\ "golang.org/x/tools/cmd/guru",
|
||||
\ "golang.org/x/tools/cmd/gorename",
|
||||
\ "github.com/golang/lint/golint",
|
||||
\ "github.com/rogpeppe/godef",
|
||||
\ "github.com/kisielk/errcheck",
|
||||
\ "github.com/jstemmer/gotags",
|
||||
\ "github.com/klauspost/asmfmt/cmd/asmfmt",
|
||||
\ "github.com/fatih/motion",
|
||||
\ "github.com/fatih/gomodifytags",
|
||||
\ "github.com/zmb3/gogetdoc",
|
||||
\ "github.com/josharian/impl",
|
||||
\ "github.com/dominikh/go-tools/cmd/keyify",
|
||||
\ ]
|
||||
let s:packages = {
|
||||
\ 'asmfmt': ['github.com/klauspost/asmfmt/cmd/asmfmt'],
|
||||
\ 'errcheck': ['github.com/kisielk/errcheck'],
|
||||
\ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'],
|
||||
\ 'gocode': ['github.com/nsf/gocode', {'windows': '-ldflags -H=windowsgui'}],
|
||||
\ 'godef': ['github.com/rogpeppe/godef'],
|
||||
\ 'gogetdoc': ['github.com/zmb3/gogetdoc'],
|
||||
\ 'goimports': ['golang.org/x/tools/cmd/goimports'],
|
||||
\ 'golint': ['github.com/golang/lint/golint'],
|
||||
\ 'gometalinter': ['github.com/alecthomas/gometalinter'],
|
||||
\ 'gomodifytags': ['github.com/fatih/gomodifytags'],
|
||||
\ 'gorename': ['golang.org/x/tools/cmd/gorename'],
|
||||
\ 'gotags': ['github.com/jstemmer/gotags'],
|
||||
\ 'guru': ['golang.org/x/tools/cmd/guru'],
|
||||
\ 'impl': ['github.com/josharian/impl'],
|
||||
\ 'keyify': ['github.com/dominikh/go-tools/cmd/keyify'],
|
||||
\ 'motion': ['github.com/fatih/motion'],
|
||||
\ }
|
||||
|
||||
" These commands are available on any filetypes
|
||||
command! GoInstallBinaries call s:GoInstallBinaries(-1)
|
||||
command! GoUpdateBinaries call s:GoInstallBinaries(1)
|
||||
command! -nargs=* -complete=customlist,s:complete GoInstallBinaries call s:GoInstallBinaries(-1, <f-args>)
|
||||
command! -nargs=* -complete=customlist,s:complete GoUpdateBinaries call s:GoInstallBinaries(1, <f-args>)
|
||||
command! -nargs=? -complete=dir GoPath call go#path#GoPath(<f-args>)
|
||||
|
||||
" GoInstallBinaries downloads and install all necessary binaries stated in the
|
||||
" packages variable. It uses by default $GOBIN or $GOPATH/bin as the binary
|
||||
" target install directory. GoInstallBinaries doesn't install binaries if they
|
||||
" exist, to update current binaries pass 1 to the argument.
|
||||
function! s:GoInstallBinaries(updateBinaries)
|
||||
fun! s:complete(lead, cmdline, cursor)
|
||||
return filter(keys(s:packages), 'strpart(v:val, 0, len(a:lead)) == a:lead')
|
||||
endfun
|
||||
|
||||
" GoInstallBinaries downloads and installs binaries defined in s:packages to
|
||||
" $GOBIN or $GOPATH/bin. GoInstallBinaries will update already installed
|
||||
" binaries only if updateBinaries = 1. By default, all packages in s:packages
|
||||
" will be installed, but the set can be limited by passing the desired
|
||||
" packages in the unnamed arguments.
|
||||
function! s:GoInstallBinaries(updateBinaries, ...)
|
||||
let err = s:CheckBinaries()
|
||||
if err != 0
|
||||
return
|
||||
@ -79,26 +108,47 @@ function! s:GoInstallBinaries(updateBinaries)
|
||||
let cmd .= "-f "
|
||||
endif
|
||||
|
||||
for pkg in s:packages
|
||||
let basename = fnamemodify(pkg, ":t")
|
||||
let binname = "go_" . basename . "_bin"
|
||||
" Filter packages from arguments (if any).
|
||||
let l:packages = {}
|
||||
if a:0 > 0
|
||||
for l:bin in a:000
|
||||
let l:pkg = get(s:packages, l:bin, [])
|
||||
if len(l:pkg) == 0
|
||||
call go#util#EchoError('unknown binary: ' . l:bin)
|
||||
return
|
||||
endif
|
||||
let l:packages[l:bin] = l:pkg
|
||||
endfor
|
||||
else
|
||||
let l:packages = s:packages
|
||||
endif
|
||||
|
||||
let bin = basename
|
||||
let l:platform = ''
|
||||
if go#util#IsWin()
|
||||
let l:platform = 'windows'
|
||||
endif
|
||||
|
||||
for [binary, pkg] in items(l:packages)
|
||||
let l:importPath = pkg[0]
|
||||
let l:goGetFlags = len(pkg) > 1 ? get(pkg[1], l:platform, '') : ''
|
||||
|
||||
let binname = "go_" . binary . "_bin"
|
||||
|
||||
let bin = binary
|
||||
if exists("g:{binname}")
|
||||
let bin = g:{binname}
|
||||
endif
|
||||
|
||||
if !executable(bin) || a:updateBinaries == 1
|
||||
if a:updateBinaries == 1
|
||||
echo "vim-go: Updating ". basename .". Reinstalling ". pkg . " to folder " . go_bin_path
|
||||
echo "vim-go: Updating " . binary . ". Reinstalling ". importPath . " to folder " . go_bin_path
|
||||
else
|
||||
echo "vim-go: ". basename ." not found. Installing ". pkg . " to folder " . go_bin_path
|
||||
echo "vim-go: ". binary ." not found. Installing ". importPath . " to folder " . go_bin_path
|
||||
endif
|
||||
|
||||
|
||||
let out = go#util#System(cmd . shellescape(pkg))
|
||||
let out = go#util#System(cmd . l:goGetFlags . shellescape(importPath))
|
||||
if go#util#ShellError() != 0
|
||||
echo "Error installing ". pkg . ": " . out
|
||||
echom "Error installing " . importPath . ": " . out
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
Reference in New Issue
Block a user