mirror of
https://github.com/amix/vimrc
synced 2025-07-31 17:55:00 +08:00
Added not added new plugin files
This commit is contained in:
1
sources_non_forked/vim-go/.dockerignore
Normal file
1
sources_non_forked/vim-go/.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
.git/
|
17
sources_non_forked/vim-go/.editorconfig
Normal file
17
sources_non_forked/vim-go/.editorconfig
Normal file
@ -0,0 +1,17 @@
|
||||
# http://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.go]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
7
sources_non_forked/vim-go/.vintrc.yaml
Normal file
7
sources_non_forked/vim-go/.vintrc.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
policies:
|
||||
ProhibitUnnecessaryDoubleQuote:
|
||||
enabled: false
|
||||
ProhibitEqualTildeOperator:
|
||||
enabled: false
|
||||
ProhibitNoAbortFunction:
|
||||
enabled: false
|
19
sources_non_forked/vim-go/Dockerfile
Normal file
19
sources_non_forked/vim-go/Dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM golang:1.9.1
|
||||
|
||||
RUN apt-get update -y && \
|
||||
apt-get install -y build-essential curl git libncurses5-dev python3-pip && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
RUN useradd -ms /bin/bash -d /vim-go vim-go
|
||||
USER vim-go
|
||||
|
||||
COPY . /vim-go/
|
||||
WORKDIR /vim-go
|
||||
|
||||
RUN scripts/install-vim vim-7.4
|
||||
RUN scripts/install-vim vim-8.0
|
||||
RUN scripts/install-vim nvim
|
||||
RUN pip3 install vim-vint
|
||||
|
||||
ENTRYPOINT ["make"]
|
150
sources_non_forked/vim-go/autoload/fzf/decls.vim
Normal file
150
sources_non_forked/vim-go/autoload/fzf/decls.vim
Normal file
@ -0,0 +1,150 @@
|
||||
function! s:code(group, attr) abort
|
||||
let code = synIDattr(synIDtrans(hlID(a:group)), a:attr, "cterm")
|
||||
if code =~ '^[0-9]\+$'
|
||||
return code
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:color(str, group) abort
|
||||
let fg = s:code(a:group, "fg")
|
||||
let bg = s:code(a:group, "bg")
|
||||
let bold = s:code(a:group, "bold")
|
||||
let italic = s:code(a:group, "italic")
|
||||
let reverse = s:code(a:group, "reverse")
|
||||
let underline = s:code(a:group, "underline")
|
||||
let color = (empty(fg) ? "" : ("38;5;".fg)) .
|
||||
\ (empty(bg) ? "" : (";48;5;".bg)) .
|
||||
\ (empty(bold) ? "" : ";1") .
|
||||
\ (empty(italic) ? "" : ";3") .
|
||||
\ (empty(reverse) ? "" : ";7") .
|
||||
\ (empty(underline) ? "" : ";4")
|
||||
return printf("\x1b[%sm%s\x1b[m", color, a:str)
|
||||
endfunction
|
||||
|
||||
function! s:sink(str) abort
|
||||
if len(a:str) < 2
|
||||
return
|
||||
endif
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
let dir = getcwd()
|
||||
try
|
||||
" we jump to the file directory so we can get the fullpath via fnamemodify
|
||||
" below
|
||||
execute cd . fnameescape(s:current_dir)
|
||||
|
||||
let vals = matchlist(a:str[1], '|\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)|')
|
||||
|
||||
" i.e: main.go
|
||||
let filename = vals[1]
|
||||
let line = vals[2]
|
||||
let col = vals[3]
|
||||
|
||||
" i.e: /Users/fatih/vim-go/main.go
|
||||
let filepath = fnamemodify(filename, ":p")
|
||||
|
||||
let cmd = get({'ctrl-x': 'split',
|
||||
\ 'ctrl-v': 'vertical split',
|
||||
\ 'ctrl-t': 'tabe'}, a:str[0], 'e')
|
||||
execute cmd fnameescape(filepath)
|
||||
call cursor(line, col)
|
||||
silent! norm! zvzz
|
||||
finally
|
||||
"jump back to old dir
|
||||
execute cd . fnameescape(dir)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:source(mode,...) abort
|
||||
let s:current_dir = expand('%:p:h')
|
||||
let ret_decls = []
|
||||
|
||||
let bin_path = go#path#CheckBinPath('motion')
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
let command = printf("%s -format vim -mode decls", bin_path)
|
||||
let command .= " -include ". get(g:, "go_decls_includes", "func,type")
|
||||
|
||||
call go#cmd#autowrite()
|
||||
|
||||
if a:mode == 0
|
||||
" current file mode
|
||||
let fname = expand("%:p")
|
||||
if a:0 && !empty(a:1)
|
||||
let fname = a:1
|
||||
endif
|
||||
|
||||
let command .= printf(" -file %s", shellescape(fname))
|
||||
else
|
||||
" all functions mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:current_dir = a:1
|
||||
endif
|
||||
|
||||
let command .= printf(" -dir %s", shellescape(s:current_dir))
|
||||
endif
|
||||
|
||||
let out = go#util#System(command)
|
||||
if go#util#ShellError() != 0
|
||||
call go#util#EchoError(out)
|
||||
return
|
||||
endif
|
||||
|
||||
let result = eval(out)
|
||||
if type(result) != 4 || !has_key(result, 'decls')
|
||||
return ret_decls
|
||||
endif
|
||||
|
||||
let decls = result.decls
|
||||
|
||||
" find the maximum function name
|
||||
let max_len = 0
|
||||
for decl in decls
|
||||
if len(decl.ident)> max_len
|
||||
let max_len = len(decl.ident)
|
||||
endif
|
||||
endfor
|
||||
|
||||
for decl in decls
|
||||
" paddings
|
||||
let space = " "
|
||||
for i in range(max_len - len(decl.ident))
|
||||
let space .= " "
|
||||
endfor
|
||||
|
||||
let pos = printf("|%s:%s:%s|",
|
||||
\ fnamemodify(decl.filename, ":t"),
|
||||
\ decl.line,
|
||||
\ decl.col
|
||||
\)
|
||||
call add(ret_decls, printf("%s\t%s %s\t%s",
|
||||
\ s:color(decl.ident . space, "Function"),
|
||||
\ s:color(decl.keyword, "Keyword"),
|
||||
\ s:color(pos, "SpecialComment"),
|
||||
\ s:color(decl.full, "Comment"),
|
||||
\))
|
||||
endfor
|
||||
|
||||
return ret_decls
|
||||
endfunc
|
||||
|
||||
function! fzf#decls#cmd(...) abort
|
||||
let normal_fg = s:code("Normal", "fg")
|
||||
let normal_bg = s:code("Normal", "bg")
|
||||
let cursor_fg = s:code("CursorLine", "fg")
|
||||
let cursor_bg = s:code("CursorLine", "bg")
|
||||
let colors = printf(" --color %s%s%s%s%s",
|
||||
\ &background,
|
||||
\ empty(normal_fg) ? "" : (",fg:".normal_fg),
|
||||
\ empty(normal_bg) ? "" : (",bg:".normal_bg),
|
||||
\ empty(cursor_fg) ? "" : (",fg+:".cursor_fg),
|
||||
\ empty(cursor_bg) ? "" : (",bg+:".cursor_bg),
|
||||
\)
|
||||
call fzf#run(fzf#wrap('GoDecls', {
|
||||
\ 'source': call('<sid>source', a:000),
|
||||
\ 'options': '-n 1 --ansi --prompt "GoDecls> " --expect=ctrl-t,ctrl-v,ctrl-x'.colors,
|
||||
\ 'sink*': function('s:sink')
|
||||
\ }))
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
21
sources_non_forked/vim-go/autoload/go/decls.vim
Normal file
21
sources_non_forked/vim-go/autoload/go/decls.vim
Normal file
@ -0,0 +1,21 @@
|
||||
if !exists('g:go_decls_mode')
|
||||
let g:go_decls_mode = ''
|
||||
endif
|
||||
|
||||
function! go#decls#Decls(mode, ...) abort
|
||||
if g:go_decls_mode == 'ctrlp'
|
||||
call ctrlp#init(call("ctrlp#decls#cmd", [a:mode] + a:000))
|
||||
elseif g:go_decls_mode == 'fzf'
|
||||
call call("fzf#decls#cmd", [a:mode] + a:000)
|
||||
else
|
||||
if globpath(&rtp, 'plugin/ctrlp.vim') != ""
|
||||
call ctrlp#init(call("ctrlp#decls#cmd", [a:mode] + a:000))
|
||||
elseif globpath(&rtp, 'plugin/fzf.vim') != ""
|
||||
call call("fzf#decls#cmd", [a:mode] + a:000)
|
||||
else
|
||||
call go#util#EchoError("neither ctrlp.vim nor fzf.vim are installed. Please install either one")
|
||||
end
|
||||
end
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
52
sources_non_forked/vim-go/autoload/go/fillstruct.vim
Normal file
52
sources_non_forked/vim-go/autoload/go/fillstruct.vim
Normal file
@ -0,0 +1,52 @@
|
||||
function! go#fillstruct#FillStruct() abort
|
||||
let l:cmd = ['fillstruct',
|
||||
\ '-file', bufname(''),
|
||||
\ '-offset', go#util#OffsetCursor()]
|
||||
|
||||
" Read from stdin if modified.
|
||||
if &modified
|
||||
call add(l:cmd, '-modified')
|
||||
let [l:out, l:err] = go#util#Exec(l:cmd, go#util#archive())
|
||||
else
|
||||
let [l:out, l:err] = go#util#Exec(l:cmd)
|
||||
endif
|
||||
|
||||
if l:err
|
||||
call go#util#EchoError(l:out)
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let l:json = json_decode(l:out)
|
||||
catch
|
||||
call go#util#EchoError(l:out)
|
||||
return
|
||||
endtry
|
||||
|
||||
let l:code = split(l:json['code'], "\n")
|
||||
let l:pos = getpos('.')
|
||||
|
||||
try
|
||||
" Add any code before/after the struct.
|
||||
exe l:json['start'] . 'go'
|
||||
let l:code[0] = getline('.')[:col('.')-1] . l:code[0]
|
||||
exe l:json['end'] . 'go'
|
||||
let l:code[len(l:code)-1] .= getline('.')[col('.'):]
|
||||
|
||||
" Indent every line except the first one; makes it look nice.
|
||||
let l:indent = repeat("\t", indent('.') / &ts)
|
||||
for i in range(1, len(l:code)-1)
|
||||
let l:code[l:i] = l:indent . l:code[i]
|
||||
endfor
|
||||
|
||||
" Out with the old ...
|
||||
exe 'normal! ' . l:json['start'] . 'gov' . l:json['end'] . 'gox'
|
||||
" ... in with the new.
|
||||
call setline('.', l:code[0])
|
||||
call append('.', l:code[1:])
|
||||
finally
|
||||
call setpos('.', l:pos)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
19
sources_non_forked/vim-go/autoload/go/fillstruct_test.vim
Normal file
19
sources_non_forked/vim-go/autoload/go/fillstruct_test.vim
Normal file
@ -0,0 +1,19 @@
|
||||
func! Test_fillstruct() abort
|
||||
try
|
||||
let l:tmp = gotest#write_file('a/a.go', [
|
||||
\ 'package a',
|
||||
\ 'import "net/mail"',
|
||||
\ 'var addr = mail.Address{}'])
|
||||
|
||||
call go#fillstruct#FillStruct()
|
||||
call gotest#assert_buffer(1, [
|
||||
\ 'var addr = mail.Address{',
|
||||
\ '\tName: "",',
|
||||
\ '\tAddress: "",',
|
||||
\ '}'])
|
||||
finally
|
||||
call delete(l:tmp, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" vim: sw=2 ts=2 et
|
23
sources_non_forked/vim-go/autoload/go/tool_test.vim
Normal file
23
sources_non_forked/vim-go/autoload/go/tool_test.vim
Normal file
@ -0,0 +1,23 @@
|
||||
func! Test_ExecuteInDir() abort
|
||||
let l:tmp = gotest#write_file('a/a.go', ['package a'])
|
||||
try
|
||||
let l:out = go#tool#ExecuteInDir("pwd")
|
||||
call assert_equal(l:tmp . "/src/a\n", l:out)
|
||||
finally
|
||||
call delete(l:tmp, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func! Test_ExecuteInDir_nodir() abort
|
||||
let l:tmp = go#util#tempdir("executeindir")
|
||||
exe ':e ' . l:tmp . '/new-dir/a'
|
||||
|
||||
try
|
||||
let l:out = go#tool#ExecuteInDir("pwd")
|
||||
call assert_equal('', l:out)
|
||||
finally
|
||||
call delete(l:tmp, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" vim: sw=2 ts=2 et
|
106
sources_non_forked/vim-go/autoload/gotest.vim
Normal file
106
sources_non_forked/vim-go/autoload/gotest.vim
Normal file
@ -0,0 +1,106 @@
|
||||
" Write a Go file to a temporary directory and append this directory to $GOPATH.
|
||||
"
|
||||
" The file will written to a:path, which is relative to the temporary directory,
|
||||
" and this file will be loaded as the current buffer.
|
||||
"
|
||||
" The cursor will be placed on the character before any 0x1f byte.
|
||||
"
|
||||
" The full path to the created directory is returned, it is the caller's
|
||||
" responsibility to clean that up!
|
||||
fun! gotest#write_file(path, contents) abort
|
||||
let l:dir = go#util#tempdir("vim-go-test/testrun/")
|
||||
let $GOPATH .= ':' . l:dir
|
||||
let l:full_path = l:dir . '/src/' . a:path
|
||||
|
||||
call mkdir(fnamemodify(l:full_path, ':h'), 'p')
|
||||
call writefile(a:contents, l:full_path)
|
||||
exe 'cd ' . l:dir . '/src'
|
||||
silent exe 'e ' . a:path
|
||||
|
||||
" Set cursor.
|
||||
let l:lnum = 1
|
||||
for l:line in a:contents
|
||||
let l:m = match(l:line, '')
|
||||
if l:m > -1
|
||||
call setpos('.', [0, l:lnum, l:m, 0])
|
||||
call setline('.', substitute(getline('.'), '', '', ''))
|
||||
break
|
||||
endif
|
||||
|
||||
let l:lnum += 1
|
||||
endfor
|
||||
|
||||
return l:dir
|
||||
endfun
|
||||
|
||||
" Load a fixture file from test-fixtures.
|
||||
"
|
||||
" The file will be copied to a new GOPATH-compliant temporary directory and
|
||||
" loaded as the current buffer.
|
||||
fun! gotest#load_fixture(path) abort
|
||||
let l:dir = go#util#tempdir("vim-go-test/testrun/")
|
||||
let $GOPATH .= ':' . l:dir
|
||||
let l:full_path = l:dir . '/src/' . a:path
|
||||
|
||||
call mkdir(fnamemodify(l:full_path, ':h'), 'p')
|
||||
exe 'cd ' . l:dir . '/src'
|
||||
silent exe 'noautocmd e ' . a:path
|
||||
silent exe printf('read %s/test-fixtures/%s', g:vim_go_root, a:path)
|
||||
silent noautocmd w!
|
||||
|
||||
return l:dir
|
||||
endfun
|
||||
|
||||
" Diff the contents of the current buffer to a:want, which should be a list.
|
||||
" If a:skipHeader is true we won't bother with the package and import
|
||||
" declarations; so e.g.:
|
||||
"
|
||||
" let l:diff = s:diff_buffer(1, ['_ = mail.Address{}'])
|
||||
"
|
||||
" will pass, whereas otherwise you'd have to:
|
||||
"
|
||||
" let l:diff = s:diff_buffer(0, ['package main', 'import "net/mail", '_ = mail.Address{}'])
|
||||
fun! gotest#assert_buffer(skipHeader, want) abort
|
||||
let l:buffer = go#util#GetLines()
|
||||
|
||||
if a:skipHeader
|
||||
for l:lnum in range(0, len(l:buffer) - 1)
|
||||
" Bit rudimentary, but works reasonably well.
|
||||
if match(l:buffer[l:lnum], '^\v(func|var|const|import \(|\))') > -1
|
||||
" vint bug: https://github.com/Kuniwak/vint/issues/179
|
||||
" vint: -ProhibitUsingUndeclaredVariable
|
||||
let l:buffer = l:buffer[l:lnum:len(l:buffer)]
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Using ' is often easier so we don't have to escape ".
|
||||
let l:want = map(a:want, 'substitute(v:val, "\\\\t", "\t", "")')
|
||||
|
||||
let l:tmp = go#util#tempdir('assert_buffer')
|
||||
try
|
||||
call writefile(l:buffer, l:tmp . '/have')
|
||||
call writefile(l:want, l:tmp . '/want')
|
||||
call go#fmt#run('gofmt', l:tmp . '/have', l:tmp . '/have')
|
||||
call go#fmt#run('gofmt', l:tmp . '/want', l:tmp . '/want')
|
||||
let [l:out, l:err] = go#util#Exec(["diff", "-u", l:tmp . '/have', l:tmp . '/want'])
|
||||
finally
|
||||
call delete(l:tmp . '/have')
|
||||
call delete(l:tmp . '/want')
|
||||
call delete(l:tmp, 'd')
|
||||
endtry
|
||||
|
||||
if l:err || l:out != ''
|
||||
let v:errors = extend(v:errors, split(l:out, "\n"))
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Diff the contents of the current buffer to the fixture file in a:path.
|
||||
fun! gotest#assert_fixture(path) abort
|
||||
let l:want = readfile(printf('%s/test-fixtures/%s', g:vim_go_root, a:path))
|
||||
call gotest#assert_buffer(0, l:want)
|
||||
endfun
|
||||
|
||||
|
||||
" vim: sw=2 ts=2 et
|
70
sources_non_forked/vim-go/autoload/unite/sources/decls.vim
Normal file
70
sources_non_forked/vim-go/autoload/unite/sources/decls.vim
Normal file
@ -0,0 +1,70 @@
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
let s:source = {
|
||||
\ 'name': 'decls',
|
||||
\ 'description': 'GoDecls implementation for unite',
|
||||
\ 'syntax': 'uniteSource__Decls',
|
||||
\ 'action_table': {},
|
||||
\ 'hooks': {},
|
||||
\ }
|
||||
|
||||
function! unite#sources#decls#define()
|
||||
return s:source
|
||||
endfunction
|
||||
|
||||
function! s:source.gather_candidates(args, context) abort
|
||||
let l:bin_path = go#path#CheckBinPath('motion')
|
||||
if empty(l:bin_path)
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:path = expand(get(a:args, 0, '%:p:h'))
|
||||
if isdirectory(l:path)
|
||||
let l:mode = 'dir'
|
||||
elseif filereadable(l:path)
|
||||
let l:mode = 'file'
|
||||
else
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:include = get(g:, 'go_decls_includes', 'func,type')
|
||||
let l:command = printf('%s -format vim -mode decls -include %s -%s %s', l:bin_path, l:include, l:mode, shellescape(l:path))
|
||||
let l:candidates = []
|
||||
try
|
||||
let l:result = eval(unite#util#system(l:command))
|
||||
let l:candidates = get(l:result, 'decls', [])
|
||||
catch
|
||||
call unite#print_source_error(['command returned invalid response.', v:exception], s:source.name)
|
||||
endtry
|
||||
|
||||
return map(l:candidates, "{
|
||||
\ 'word': printf('%s :%d :%s', fnamemodify(v:val.filename, ':~:.'), v:val.line, v:val.full),
|
||||
\ 'kind': 'jump_list',
|
||||
\ 'action__path': v:val.filename,
|
||||
\ 'action__line': v:val.line,
|
||||
\ 'action__col': v:val.col,
|
||||
\ }")
|
||||
endfunction
|
||||
|
||||
function! s:source.hooks.on_syntax(args, context) abort
|
||||
syntax match uniteSource__Decls_Filepath /[^:]*\ze:/ contained containedin=uniteSource__Decls
|
||||
syntax match uniteSource__Decls_Line /\d\+\ze :/ contained containedin=uniteSource__Decls
|
||||
syntax match uniteSource__Decls_WholeFunction /\vfunc %(\([^)]+\) )?[^(]+/ contained containedin=uniteSource__Decls
|
||||
syntax match uniteSource__Decls_Function /\S\+\ze(/ contained containedin=uniteSource__Decls_WholeFunction
|
||||
syntax match uniteSource__Decls_WholeType /type \S\+/ contained containedin=uniteSource__Decls
|
||||
syntax match uniteSource__Decls_Type /\v( )@<=\S+/ contained containedin=uniteSource__Decls_WholeType
|
||||
highlight default link uniteSource__Decls_Filepath Comment
|
||||
highlight default link uniteSource__Decls_Line LineNr
|
||||
highlight default link uniteSource__Decls_Function Function
|
||||
highlight default link uniteSource__Decls_Type Type
|
||||
|
||||
syntax match uniteSource__Decls_Separator /:/ contained containedin=uniteSource__Decls conceal
|
||||
syntax match uniteSource__Decls_SeparatorFunction /func / contained containedin=uniteSource__Decls_WholeFunction conceal
|
||||
syntax match uniteSource__Decls_SeparatorType /type / contained containedin=uniteSource__Decls_WholeType conceal
|
||||
endfunction
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: sw=2 ts=2 et
|
13
sources_non_forked/vim-go/scripts/docker-test
Normal file
13
sources_non_forked/vim-go/scripts/docker-test
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run all tests inside a Docker container
|
||||
#
|
||||
|
||||
set -euC
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
docker build --tag vim-go-test .
|
||||
docker run --rm vim-go-test
|
||||
|
||||
# vim:ts=2:sts=2:sw=2:et
|
112
sources_non_forked/vim-go/scripts/install-vim
Normal file
112
sources_non_forked/vim-go/scripts/install-vim
Normal file
@ -0,0 +1,112 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Install and setup a Vim or Neovim for running tests.
|
||||
# This should work on both Travis and people's desktop computers, and be 100%
|
||||
# independent from any system installed Vim.
|
||||
#
|
||||
# It will echo the full path to a Vim binary, e.g.:
|
||||
# /some/path/src/vim
|
||||
|
||||
set -euC
|
||||
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
vim=${1:-}
|
||||
|
||||
case "$vim" in
|
||||
"vim-7.4")
|
||||
# This is what the most recent Ubuntu LTS (16.04) ships with.
|
||||
tag="v7.4.1689"
|
||||
giturl="https://github.com/vim/vim"
|
||||
;;
|
||||
|
||||
"vim-8.0")
|
||||
# This follows the version in Arch Linux. Vim's master branch isn't always
|
||||
# stable, and we don't want to have the build fail because Vim introduced a
|
||||
# bug.
|
||||
tag="v8.0.1176"
|
||||
giturl="https://github.com/vim/vim"
|
||||
;;
|
||||
|
||||
"nvim")
|
||||
# Use latest stable version.
|
||||
tag="v0.2.0"
|
||||
giturl="https://github.com/neovim/neovim"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "unknown version: '${1:-}'"
|
||||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
srcdir="/tmp/vim-go-test/$1-src"
|
||||
installdir="/tmp/vim-go-test/$1-install"
|
||||
|
||||
# Use cached installdir.
|
||||
if [ -d "$installdir" ]; then
|
||||
echo "$installdir exists; skipping build."
|
||||
|
||||
# The ./scripts/test script relies on this.
|
||||
echo "installed to: $installdir"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "$srcdir"
|
||||
cd "$srcdir"
|
||||
|
||||
# Neovim build requires more deps than Vim and is annoying, so we use the
|
||||
# binary.
|
||||
# 0.2.0 doesn't have a binary build for Linux, so we use 0.2.1-dev for now.
|
||||
if [ "$1" = "nvim" ]; then
|
||||
|
||||
# TODO: Use macOS binaries on macOS
|
||||
curl -Ls https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz |
|
||||
tar xzf - -C /tmp/vim-go-test/
|
||||
mv /tmp/vim-go-test/nvim-linux64 /tmp/vim-go-test/nvim-install
|
||||
mkdir -p "$installdir/share/nvim/runtime/pack/vim-go/start"
|
||||
ln -s "$vimgodir" "$installdir/share/nvim/runtime/pack/vim-go/start/vim-go"
|
||||
|
||||
# Consistent paths makes calling things easier.
|
||||
mv "$installdir/bin/nvim" "$installdir/bin/vim"
|
||||
mkdir -p "$installdir/share/vim/vimgo/pack"
|
||||
ln -s "$installdir/share/nvim/runtime/pack/vim-go" "$installdir/share/vim/vimgo/pack/vim-go"
|
||||
|
||||
# Build Vim from source.
|
||||
else
|
||||
if [ -d "$srcdir/.git" ]; then
|
||||
echo "Skipping clone as $srcdir/.git exists"
|
||||
else
|
||||
echo "Cloning $tag from $giturl"
|
||||
git clone --branch "$tag" --depth 1 "$giturl" "$srcdir"
|
||||
fi
|
||||
|
||||
./configure --prefix="$installdir" --with-features=huge --disable-gui
|
||||
make install
|
||||
mkdir -p "$installdir/share/vim/vimgo/pack/vim-go/start"
|
||||
ln -s "$vimgodir" "$installdir/share/vim/vimgo/pack/vim-go/start/vim-go"
|
||||
fi
|
||||
|
||||
# Make sure all Go tools and other dependencies are installed.
|
||||
echo "Installing Go binaries"
|
||||
export GOPATH=$installdir
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
"$vimgodir/scripts/run-vim" $vim +':silent :GoUpdateBinaries' +':qa'
|
||||
|
||||
echo "Installing lint tools"
|
||||
(
|
||||
mkdir -p "$installdir/share/vim/vimgo/pack/vim-go/start/"
|
||||
cd "$installdir/share/vim/vimgo/pack/vim-go/start/"
|
||||
[ -d "vim-vimhelplint" ] || git clone --depth 1 --quiet https://github.com/machakann/vim-vimhelplint
|
||||
[ -d "vim-vimlparser" ] || git clone --depth 1 --quiet https://github.com/ynkdir/vim-vimlparser
|
||||
[ -d "vim-vimlint" ] || git clone --depth 1 --quiet https://github.com/syngan/vim-vimlint
|
||||
)
|
||||
|
||||
# Don't really need source after successful install.
|
||||
rm -rf "$srcdir"
|
||||
|
||||
echo "installed to: $installdir"
|
||||
|
||||
# vim:ts=2:sts=2:sw=2:et
|
88
sources_non_forked/vim-go/scripts/lint
Normal file
88
sources_non_forked/vim-go/scripts/lint
Normal file
@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run all linting tools.
|
||||
#
|
||||
|
||||
set -euC
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
### Setup Vim and other dependencies.
|
||||
#####################################
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "unknown version: '${1:-}'"
|
||||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vim=$1
|
||||
vimdir="/tmp/vim-go-test/$vim-install"
|
||||
export GOPATH=$vimdir
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
|
||||
if [ ! -f "$vimdir/bin/vim" ]; then
|
||||
echo "$vimdir/bin/vim doesn't exist; did you install it with the install-vim script?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Run vint
|
||||
############
|
||||
failed=0
|
||||
printf "Running vint ... "
|
||||
if [ -x "$(command -v vint)" ]; then
|
||||
lint=$(vint "$vimgodir" 2>&1 ||:)
|
||||
if [ -n "$lint" ]; then
|
||||
echo "FAILED"
|
||||
echo "$lint"
|
||||
echo
|
||||
failed=6
|
||||
else
|
||||
echo "PASSED"
|
||||
fi
|
||||
else
|
||||
echo "SKIPPED"
|
||||
echo "'vint' binary not found; use 'pip install vim-vint' to install it."
|
||||
fi
|
||||
|
||||
### Run vim-vimlint
|
||||
###################
|
||||
printf "Running vim-vimlint ... "
|
||||
lint=$(sh "$vimdir/share/vim/vimgo/pack/vim-go/start/vim-vimlint/bin/vimlint.sh" \
|
||||
-p "$vimdir/share/vim/vimgo/pack/vim-go/start/vim-vimlparser" \
|
||||
-l "$vimdir/share/vim/vimgo/pack/vim-go/start/vim-vimlint" \
|
||||
-u \
|
||||
-c func_abort=1 \
|
||||
-e EVL110=1 -e EVL103=1 -e EVL104=1 -e EVL102=1 \
|
||||
"$vimgodir" \
|
||||
2>&1 ||:)
|
||||
if [ -n "$lint" ]; then
|
||||
echo "FAILED"
|
||||
echo "$lint"
|
||||
echo
|
||||
failed=6
|
||||
else
|
||||
echo "PASSED"
|
||||
fi
|
||||
|
||||
### Run vimhelplint.
|
||||
####################
|
||||
printf "Running vimhelplint ... "
|
||||
|
||||
# set modeline explicitly so that the modeline will be respected when run as root.
|
||||
lint=$($vimdir/bin/vim -esNR \
|
||||
--cmd "set rtp+=$vimdir/share/vim/vimgo/pack/vim-go/start/vim-vimhelplint/" \
|
||||
--cmd 'set modeline' \
|
||||
+'filetype plugin on' \
|
||||
+"e $vimgodir/doc/vim-go.txt" \
|
||||
+'verbose VimhelpLintEcho' \
|
||||
+q \
|
||||
2>&1 ||:)
|
||||
if [ "$lint" ]; then
|
||||
echo "FAILED"
|
||||
echo "$lint"
|
||||
failed=6
|
||||
else
|
||||
echo "PASSED"
|
||||
fi
|
||||
|
||||
exit "$failed"
|
33
sources_non_forked/vim-go/scripts/run-vim
Normal file
33
sources_non_forked/vim-go/scripts/run-vim
Normal file
@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a "bare" Vim with just vim-go and ignoring ~/.vim
|
||||
#
|
||||
|
||||
set -euC
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "unknown version: '${1:-}'"
|
||||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dir="/tmp/vim-go-test/$1-install"
|
||||
export GOPATH=$dir
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
shift
|
||||
|
||||
if [ ! -f "$dir/bin/vim" ]; then
|
||||
echo "$dir/bin/vim doesn't exist; did you install it with the install-vim script?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$dir/bin/vim --noplugin -u NONE -N \
|
||||
+"set shm+=WAFI rtp=$dir/share/vim/vimgo packpath=$dir/share/vim/vimgo,$vimgodir" \
|
||||
+'filetype plugin indent on' \
|
||||
+'packloadall!' \
|
||||
"$@"
|
||||
|
||||
|
||||
# vim:ts=2:sts=2:sw=2:et
|
51
sources_non_forked/vim-go/scripts/test
Normal file
51
sources_non_forked/vim-go/scripts/test
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run all tests.
|
||||
#
|
||||
|
||||
set -euC
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
### Setup Vim and other dependencies.
|
||||
#####################################
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "unknown version: '${1:-}'"
|
||||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vim=$1
|
||||
vimdir="/tmp/vim-go-test/$vim-install"
|
||||
export GOPATH=$vimdir
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
|
||||
if [ ! -f "$vimdir/bin/vim" ]; then
|
||||
echo "$vimdir/bin/vim doesn't exist; did you install it with the install-vim script?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Run tests.
|
||||
##############
|
||||
# Clean stale log file.
|
||||
[ -f '/tmp/vim-go-test/test.log' ] && rm '/tmp/vim-go-test/test.log'
|
||||
[ -f '/tmp/vim-go-test/FAILED' ] && rm '/tmp/vim-go-test/FAILED'
|
||||
|
||||
# Run the actual tests.
|
||||
fail=0
|
||||
for test_file in "$vimgodir"/autoload/go/*_test.vim; do
|
||||
"$vimgodir/scripts/run-vim" $vim -e +"silent e $test_file" -S ./scripts/runtest.vim
|
||||
|
||||
# Append logs
|
||||
cat '/tmp/vim-go-test/test.tmp' | tee '/tmp/vim-go-test/test.log'
|
||||
rm '/tmp/vim-go-test/test.tmp'
|
||||
done
|
||||
|
||||
echo
|
||||
if [ -f "/tmp/vim-go-test/FAILED" ]; then
|
||||
echo 2>&1 "Some tests FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo 2>&1 "All tests PASSED"
|
||||
|
||||
# vim:ts=2:sts=2:sw=2:et
|
Reference in New Issue
Block a user