mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Replace YanRing with yank-stack and update plugins
This commit is contained in:
3
sources_non_forked/vim-go/.coveragerc
Normal file
3
sources_non_forked/vim-go/.coveragerc
Normal file
@ -0,0 +1,3 @@
|
||||
[run]
|
||||
plugins = covimerage
|
||||
data_file = .coverage.covimerage
|
5
sources_non_forked/vim-go/.gitignore
vendored
5
sources_non_forked/vim-go/.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
doc/tags
|
||||
.DS_Store
|
||||
/doc/tags
|
||||
/.coverage.covimerage
|
||||
/coverage.xml
|
||||
*.pyc
|
||||
|
@ -3,12 +3,12 @@ notifications:
|
||||
email: false
|
||||
matrix:
|
||||
include:
|
||||
- env: SCRIPT=test VIM_VERSION=vim-7.4
|
||||
- env: SCRIPT=test VIM_VERSION=vim-8.0
|
||||
- env: SCRIPT=test VIM_VERSION=nvim
|
||||
- env: SCRIPT="test -c" VIM_VERSION=vim-7.4
|
||||
- env: SCRIPT="test -c" VIM_VERSION=vim-8.0
|
||||
- env: SCRIPT="test -c" VIM_VERSION=nvim
|
||||
- env: SCRIPT=lint VIM_VERSION=vim-8.0
|
||||
install:
|
||||
- ./scripts/install-vim $VIM_VERSION
|
||||
- pip install --user vim-vint
|
||||
- pip install --user vim-vint covimerage codecov
|
||||
script:
|
||||
- ./scripts/$SCRIPT $VIM_VERSION
|
||||
|
@ -1,11 +1,43 @@
|
||||
## unplanned
|
||||
|
||||
BACKWARDS INCOMPATIBILITIES:
|
||||
FEATURES:
|
||||
|
||||
* Display a warning for Vim versions older than 7.4.1689. Older versions may
|
||||
still work, but are not supported. You can use `let g:go_version_warning = 0`
|
||||
to disable the warning.
|
||||
[[GH-1524]](https://github.com/fatih/vim-go/pull/1524).
|
||||
* Add `g:go_doc_url` to change the `godoc` server from `godoc.org` to a custom
|
||||
private instance. Currently only `godoc -http` instances are supported.
|
||||
[[GH-1957]](https://github.com/fatih/vim-go/pull/1957).
|
||||
* New setting `g:go_test_prepend_name` (off by default) to add the failing test
|
||||
name to the output of `:GoTest`
|
||||
[[GH-1578]](https://github.com/fatih/vim-go/pull/1578).
|
||||
* Support [denite.vim](https://github.com/Shougo/denite.nvim) for `:GoDecls[Dir]`
|
||||
[[GH-1604]](https://github.com/fatih/vim-go/pull/1604).
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
* `:GoRename` is a bit smarter when automatically pre-filling values, and what
|
||||
gets pre-filled can be configured with `g:go_gorename_prefill` option.
|
||||
In addition `:GoRename <Tab>` now lists some common options.
|
||||
[[GH-1465]](https://github.com/fatih/vim-go/pull/1465).
|
||||
* Add support for `g:go_build_tags` to the `:GoTest` family of functions.
|
||||
[[GH-1562]](https://github.com/fatih/vim-go/pull/1562).
|
||||
* Pass `--tests` to gometalinter when autosaving and when a custom gometalinter
|
||||
command has not been set.
|
||||
[[GH-1563]](https://github.com/fatih/vim-go/pull/1563).
|
||||
* Do not spam messages when command is run in a directory that does not exist.
|
||||
[[GH-1527]](https://github.com/fatih/vim-go/pull/1527).
|
||||
* Run `syntax sync fromstart` after `:GoFmt`; this should make syntax
|
||||
highlighting break slightly less often after formatting code
|
||||
[[GH-1582]](https://github.com/fatih/vim-go/pull/1582).
|
||||
* `:GoDescribe` doesn't require a scope anymore
|
||||
[[GH-1596]](https://github.com/fatih/vim-go/pull/1596).
|
||||
* Add some standard snippets for
|
||||
[vim-minisnip](https://github.com/joereynolds/vim-minisnip)
|
||||
[[GH-1589]](https://github.com/fatih/vim-go/pull/1589).
|
||||
* `g:go_snippet_engine` now defaults to `automatic` to use the first installed
|
||||
snippet engine it can find.
|
||||
[[GH-1589]](https://github.com/fatih/vim-go/pull/1589).
|
||||
* Make sure temporary files created for `:GoFmt` end with `.go` suffix as this
|
||||
is required by some Go formatting tools
|
||||
[[GH-1601]](https://github.com/fatih/vim-go/pull/1601).
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
@ -23,24 +55,27 @@ BUG FIXES:
|
||||
[[GH-1535]](https://github.com/fatih/vim-go/pull/1535)
|
||||
* Fix test output processing to correctly handle panics and log statements.
|
||||
[[GH-1513]](https://github.com/fatih/vim-go/pull/1513)
|
||||
* `:GoImpl` tab-completion would sometimes stop working
|
||||
[[GH-1581]](https://github.com/fatih/vim-go/pull/1581).
|
||||
* Add `g:go_highlight_function_arguments` to highlight function arguments.
|
||||
[[GH-1587]](https://github.com/fatih/vim-go/pull/1587).
|
||||
* Fix installation of `gocode` on MS-Windows.
|
||||
[[GH-1606]](https://github.com/fatih/vim-go/pull/1606).
|
||||
|
||||
IMPROVEMENTS:
|
||||
BACKWARDS INCOMPATIBILITIES:
|
||||
|
||||
* `:GoRename` is a bit smarter when automatically pre-filling values, and what
|
||||
gets pre-filled can be configured with `g:go_gorename_prefill` option.
|
||||
In addition `:GoRename <Tab>` now lists some common options.
|
||||
[[GH-1465]](https://github.com/fatih/vim-go/pull/1465).
|
||||
* Disable `g:go_autodetect_gopath` by default. [[GH-1461]](https://github.com/fatih/vim-go/pull/1461).
|
||||
* Add support for `g:go_build_tags` to the `:GoTest` family of functions.
|
||||
[[GH-1562]](https://github.com/fatih/vim-go/pull/1562).
|
||||
* Pass `--tests` to gometalinter when autosaving and when a custom gometalinter
|
||||
command has not been set.
|
||||
[[GH-1563]](https://github.com/fatih/vim-go/pull/1563).
|
||||
* Do not spam messages when command is run in a directory that does not exist.
|
||||
[[GH-1527]](https://github.com/fatih/vim-go/pull/1527).
|
||||
* New setting `g:go_test_prepend_name` (off by default) to add the failing test
|
||||
name to the output of `:GoTest`
|
||||
[[GH-1578]](https://github.com/fatih/vim-go/pull/1578).
|
||||
* Display a warning for Vim versions older than 7.4.1689. Older versions may
|
||||
still work, but are not supported. You can use `let g:go_version_warning = 0`
|
||||
to disable the warning.
|
||||
[[GH-1524]](https://github.com/fatih/vim-go/pull/1524).
|
||||
* `g:go_autodetect_gopath` is *disabled* by default, as support for `vendor` has
|
||||
been in Go for a while.<br>
|
||||
Also change the implementation for `g:go_autodetect_gopath`; instead of manually
|
||||
setting it before every command it will now be set with the `BufEnter` event,
|
||||
and reset with the `BufLeave` event. This means that `$GOPATH` will be
|
||||
changed for all commands run from Vim.
|
||||
[[GH-1461]](https://github.com/fatih/vim-go/pull/1461) and
|
||||
[[GH-1525]](https://github.com/fatih/vim-go/pull/1525).
|
||||
|
||||
## 1.15 - (October 3, 2017)
|
||||
|
||||
@ -191,8 +226,6 @@ BACKWARDS INCOMPATIBILITIES:
|
||||
here](https://github.com/fatih/vim-go/issues/1375#issuecomment-317535953)
|
||||
[[GH-1382]](https://github.com/fatih/vim-go/pull/1382)
|
||||
|
||||
|
||||
|
||||
## 1.13 - (June 6, 2017)
|
||||
|
||||
FEATURES:
|
||||
|
@ -1,10 +1,12 @@
|
||||
FROM golang:1.9.1
|
||||
FROM golang:1.9.2
|
||||
|
||||
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 pip3 install vim-vint
|
||||
|
||||
RUN useradd -ms /bin/bash -d /vim-go vim-go
|
||||
USER vim-go
|
||||
|
||||
@ -14,6 +16,5 @@ 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"]
|
||||
|
@ -1,16 +1,18 @@
|
||||
VIMS ?= vim-7.4 vim-8.0 nvim
|
||||
|
||||
all: install test lint
|
||||
|
||||
install:
|
||||
@echo "==> Installing Vims"
|
||||
@./scripts/install-vim vim-7.4
|
||||
@./scripts/install-vim vim-8.0
|
||||
@./scripts/install-vim nvim
|
||||
@echo "==> Installing Vims: $(VIMS)"
|
||||
@for vim in $(VIMS); do \
|
||||
./scripts/install-vim $$vim; \
|
||||
done
|
||||
|
||||
test:
|
||||
@echo "==> Running tests"
|
||||
@./scripts/test vim-7.4
|
||||
@./scripts/test vim-8.0
|
||||
@./scripts/test nvim
|
||||
@echo "==> Running tests for $(VIMS)"
|
||||
@for vim in $(VIMS); do \
|
||||
./scripts/test $$vim; \
|
||||
done
|
||||
|
||||
lint:
|
||||
@echo "==> Running linting tools"
|
||||
@ -24,5 +26,4 @@ clean:
|
||||
@echo "==> Cleaning /tmp/vim-go-test"
|
||||
@rm -rf /tmp/vim-go-test
|
||||
|
||||
|
||||
.PHONY: all test install clean lint docker
|
||||
|
@ -41,8 +41,6 @@ function! go#cmd#Build(bang, ...) abort
|
||||
|
||||
" Vim 7.4 without async
|
||||
else
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
let default_makeprg = &makeprg
|
||||
let &makeprg = "go " . join(go#util#Shelllist(args), ' ')
|
||||
|
||||
@ -72,7 +70,6 @@ function! go#cmd#Build(bang, ...) abort
|
||||
endif
|
||||
|
||||
let &makeprg = default_makeprg
|
||||
let $GOPATH = old_gopath
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -125,9 +122,6 @@ function! go#cmd#Run(bang, ...) abort
|
||||
" anything. Once this is implemented we're going to make :GoRun async
|
||||
endif
|
||||
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
if go#util#IsWin()
|
||||
exec '!go run ' . go#util#Shelljoin(go#tool#Files())
|
||||
if v:shell_error
|
||||
@ -136,7 +130,6 @@ function! go#cmd#Run(bang, ...) abort
|
||||
redraws! | echon "vim-go: [run] " | echohl Function | echon "SUCCESS"| echohl None
|
||||
endif
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
return
|
||||
endif
|
||||
|
||||
@ -165,7 +158,6 @@ function! go#cmd#Run(bang, ...) abort
|
||||
call go#list#JumpToFirst(l:listtype)
|
||||
endif
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
let &makeprg = default_makeprg
|
||||
endfunction
|
||||
|
||||
@ -190,8 +182,6 @@ function! go#cmd#Install(bang, ...) abort
|
||||
return
|
||||
endif
|
||||
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
let default_makeprg = &makeprg
|
||||
|
||||
" :make expands '%' and '#' wildcards, so they must also be escaped
|
||||
@ -220,10 +210,9 @@ function! go#cmd#Install(bang, ...) abort
|
||||
if !empty(errors) && !a:bang
|
||||
call go#list#JumpToFirst(l:listtype)
|
||||
else
|
||||
call go#util#EchoSuccess("installed to ". go#path#Detect())
|
||||
call go#util#EchoSuccess("installed to ". go#path#Default())
|
||||
endif
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
let &makeprg = default_makeprg
|
||||
endfunction
|
||||
|
||||
@ -231,9 +220,6 @@ endfunction
|
||||
function! go#cmd#Generate(bang, ...) abort
|
||||
let default_makeprg = &makeprg
|
||||
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" :make expands '%' and '#' wildcards, so they must also be escaped
|
||||
let goargs = go#util#Shelljoin(map(copy(a:000), "expand(v:val)"), 1)
|
||||
if go#util#ShellError() != 0
|
||||
@ -264,7 +250,6 @@ function! go#cmd#Generate(bang, ...) abort
|
||||
endif
|
||||
|
||||
let &makeprg = default_makeprg
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
" ---------------------
|
||||
@ -311,10 +296,6 @@ function s:cmd_job(args) abort
|
||||
\ 'exit_cb': callbacks.exit_cb,
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" pre start
|
||||
let dir = getcwd()
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
@ -325,7 +306,6 @@ function s:cmd_job(args) abort
|
||||
|
||||
" post start
|
||||
execute cd . fnameescape(dir)
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
@ -19,25 +19,25 @@ function! s:gocodeCommand(cmd, preargs, args) abort
|
||||
return
|
||||
endif
|
||||
|
||||
" we might hit cache problems, as gocode doesn't handle well different
|
||||
" GOPATHS: https://github.com/nsf/gocode/issues/239
|
||||
let old_gopath = $GOPATH
|
||||
" We might hit cache problems, as gocode doesn't handle different GOPATHs
|
||||
" well. See: https://github.com/nsf/gocode/issues/239
|
||||
let old_goroot = $GOROOT
|
||||
let $GOPATH = go#path#Detect()
|
||||
let $GOROOT = go#util#env("goroot")
|
||||
|
||||
let socket_type = get(g:, 'go_gocode_socket_type', s:sock_type)
|
||||
let cmd = printf('%s -sock %s %s %s %s',
|
||||
\ go#util#Shellescape(bin_path),
|
||||
\ socket_type,
|
||||
\ join(a:preargs),
|
||||
\ go#util#Shellescape(a:cmd),
|
||||
\ join(a:args)
|
||||
\ )
|
||||
try
|
||||
let socket_type = get(g:, 'go_gocode_socket_type', s:sock_type)
|
||||
let cmd = printf('%s -sock %s %s %s %s',
|
||||
\ go#util#Shellescape(bin_path),
|
||||
\ socket_type,
|
||||
\ join(a:preargs),
|
||||
\ go#util#Shellescape(a:cmd),
|
||||
\ join(a:args)
|
||||
\ )
|
||||
|
||||
let result = go#util#System(cmd)
|
||||
let $GOPATH = old_gopath
|
||||
let $GOROOT = old_goroot
|
||||
let result = go#util#System(cmd)
|
||||
finally
|
||||
let $GOROOT = old_goroot
|
||||
endtry
|
||||
|
||||
if go#util#ShellError() != 0
|
||||
return "[\"0\", []]"
|
||||
|
@ -300,10 +300,6 @@ function s:coverage_job(args)
|
||||
\ 'exit_cb': callbacks.exit_cb,
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" pre start
|
||||
let dir = getcwd()
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
@ -320,7 +316,6 @@ function s:coverage_job(args)
|
||||
|
||||
" post start
|
||||
execute cd . fnameescape(dir)
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
" coverage_callback is called when the coverage execution is finished
|
||||
|
@ -2,9 +2,6 @@ let s:go_stack = []
|
||||
let s:go_stack_level = 0
|
||||
|
||||
function! go#def#Jump(mode) abort
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
let fname = fnamemodify(expand("%"), ':p:gs?\\?/?')
|
||||
|
||||
" so guru right now is slow for some people. previously we were using
|
||||
@ -22,7 +19,6 @@ function! go#def#Jump(mode) abort
|
||||
|
||||
let bin_path = go#path#CheckBinPath("godef")
|
||||
if empty(bin_path)
|
||||
let $GOPATH = old_gopath
|
||||
return
|
||||
endif
|
||||
let command = printf("%s -f=%s -o=%s -t", go#util#Shellescape(bin_path),
|
||||
@ -34,7 +30,6 @@ function! go#def#Jump(mode) abort
|
||||
elseif bin_name == 'guru'
|
||||
let bin_path = go#path#CheckBinPath("guru")
|
||||
if empty(bin_path)
|
||||
let $GOPATH = old_gopath
|
||||
return
|
||||
endif
|
||||
|
||||
@ -88,7 +83,6 @@ function! go#def#Jump(mode) abort
|
||||
endif
|
||||
|
||||
call go#def#jump_to_declaration(out, a:mode, bin_name)
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
function! s:jump_to_declaration_cb(mode, bin_name, job, exit_status, data) abort
|
||||
|
@ -29,7 +29,19 @@ function! go#doc#OpenBrowser(...) abort
|
||||
let name = out["name"]
|
||||
let decl = out["decl"]
|
||||
|
||||
let godoc_url = "https://godoc.org/" . import
|
||||
let godoc_url = get(g:, 'go_doc_url', 'https://godoc.org')
|
||||
if godoc_url isnot 'https://godoc.org'
|
||||
" strip last '/' character if available
|
||||
let last_char = strlen(godoc_url) - 1
|
||||
if godoc_url[last_char] == '/'
|
||||
let godoc_url = strpart(godoc_url, 0, last_char)
|
||||
endif
|
||||
|
||||
" custom godoc installations expects it
|
||||
let godoc_url .= "/pkg"
|
||||
endif
|
||||
|
||||
let godoc_url .= "/" . import
|
||||
if decl !~ "^package"
|
||||
let godoc_url .= "#" . name
|
||||
endif
|
||||
|
@ -58,7 +58,7 @@ function! go#fmt#Format(withGoimport) abort
|
||||
endif
|
||||
|
||||
" Write current unsaved buffer to a temp file
|
||||
let l:tmpname = tempname()
|
||||
let l:tmpname = tempname() . '.go'
|
||||
call writefile(go#util#GetLines(), l:tmpname)
|
||||
if go#util#IsWin()
|
||||
let l:tmpname = tr(l:tmpname, '\', '/')
|
||||
@ -101,6 +101,9 @@ function! go#fmt#Format(withGoimport) abort
|
||||
|
||||
" be smart and jump to the line the new statement was added/removed
|
||||
call cursor(line('.') + diff_offset, current_col)
|
||||
|
||||
" Syntax highlighting breaks less often.
|
||||
syntax sync fromstart
|
||||
endfunction
|
||||
|
||||
" update_file updates the target file with the given formatted source
|
||||
@ -158,21 +161,11 @@ function! go#fmt#run(bin_name, source, target)
|
||||
return
|
||||
endif
|
||||
|
||||
if cmd[0] == "goimports"
|
||||
" change GOPATH too, so goimports can pick up the correct library
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
endif
|
||||
|
||||
let command = join(cmd, " ")
|
||||
|
||||
" execute our command...
|
||||
let out = go#util#System(command)
|
||||
|
||||
if cmd[0] == "goimports"
|
||||
let $GOPATH = old_gopath
|
||||
endif
|
||||
|
||||
return out
|
||||
endfunction
|
||||
|
||||
|
@ -212,16 +212,12 @@ endfunc
|
||||
|
||||
" run_guru runs the given guru argument
|
||||
function! s:run_guru(args) abort
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
if go#util#has_job()
|
||||
let res = s:async_guru(a:args)
|
||||
else
|
||||
let res = s:sync_guru(a:args)
|
||||
endif
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
|
||||
return res
|
||||
endfunction
|
||||
|
||||
@ -366,7 +362,7 @@ function! go#guru#DescribeInfo() abort
|
||||
\ 'mode': 'describe',
|
||||
\ 'format': 'json',
|
||||
\ 'selected': -1,
|
||||
\ 'needs_scope': 1,
|
||||
\ 'needs_scope': 0,
|
||||
\ 'custom_parse': function('s:info'),
|
||||
\ 'disable_progress': 1,
|
||||
\ }
|
||||
|
@ -1,16 +1,11 @@
|
||||
function! go#impl#Impl(...) abort
|
||||
let binpath = go#path#CheckBinPath('impl')
|
||||
if empty(binpath)
|
||||
return
|
||||
endif
|
||||
|
||||
let recv = ""
|
||||
let iface = ""
|
||||
let interactive = 0
|
||||
|
||||
let pos = getpos('.')
|
||||
|
||||
if a:0 == 0
|
||||
if a:0 is 0
|
||||
" Interactive mode if user didn't pass any arguments.
|
||||
let recv = s:getReceiver()
|
||||
let iface = input("vim-go: generating method stubs for interface: ")
|
||||
@ -19,7 +14,7 @@ function! go#impl#Impl(...) abort
|
||||
call go#util#EchoError('usage: interface type is not provided')
|
||||
return
|
||||
endif
|
||||
elseif a:0 == 1
|
||||
elseif a:0 is 1
|
||||
" we assume the user only passed the interface type,
|
||||
" i.e: ':GoImpl io.Writer'
|
||||
let recv = s:getReceiver()
|
||||
@ -41,19 +36,19 @@ function! go#impl#Impl(...) abort
|
||||
|
||||
try
|
||||
let dirname = fnameescape(expand('%:p:h'))
|
||||
let result = go#util#System(join(go#util#Shelllist([binpath, '-dir', dirname, recv, iface], ' ')))
|
||||
let [result, err] = go#util#Exec(['impl', '-dir', dirname, recv, iface])
|
||||
let result = substitute(result, "\n*$", "", "")
|
||||
if go#util#ShellError() != 0
|
||||
if err
|
||||
call go#util#EchoError(result)
|
||||
return
|
||||
endif
|
||||
|
||||
if result ==# ''
|
||||
if result is# ''
|
||||
return
|
||||
end
|
||||
|
||||
put =''
|
||||
put =result
|
||||
silent put =result
|
||||
finally
|
||||
call setpos('.', pos)
|
||||
endtry
|
||||
@ -99,10 +94,6 @@ function! s:root_dirs() abort
|
||||
endif
|
||||
|
||||
let paths = map(split(go#util#env("gopath"), go#util#PathListSep()), "substitute(v:val, '\\\\', '/', 'g')")
|
||||
if go#util#ShellError()
|
||||
return []
|
||||
endif
|
||||
|
||||
if !empty(filter(paths, 'isdirectory(v:val)'))
|
||||
call extend(dirs, paths)
|
||||
endif
|
||||
@ -120,11 +111,12 @@ function! s:go_packages(dirs) abort
|
||||
endfunction
|
||||
|
||||
function! s:interface_list(pkg) abort
|
||||
let contents = split(go#util#System('go doc ' . a:pkg), "\n")
|
||||
if go#util#ShellError()
|
||||
let [contents, err] = go#util#Exec(['go', 'doc', a:pkg])
|
||||
if err
|
||||
return []
|
||||
endif
|
||||
|
||||
let contents = split(contents, "\n")
|
||||
call filter(contents, 'v:val =~# ''^type\s\+\h\w*\s\+interface''')
|
||||
return map(contents, 'a:pkg . "." . matchstr(v:val, ''^type\s\+\zs\h\w*\ze\s\+interface'')')
|
||||
endfunction
|
||||
|
37
sources_non_forked/vim-go/autoload/go/impl_test.vim
Normal file
37
sources_non_forked/vim-go/autoload/go/impl_test.vim
Normal file
@ -0,0 +1,37 @@
|
||||
func! Test_impl() abort
|
||||
try
|
||||
let l:tmp = gotest#write_file('a/a.go', [
|
||||
\ 'package a',
|
||||
\ '',
|
||||
\ ''])
|
||||
|
||||
call go#impl#Impl('r', 'reader', 'io.Reader')
|
||||
call gotest#assert_buffer(1, [
|
||||
\ 'func (r reader) Read(p []byte) (n int, err error) {',
|
||||
\ ' panic("not implemented")',
|
||||
\ '}'])
|
||||
finally
|
||||
call delete(l:tmp, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func! Test_impl_get() abort
|
||||
try
|
||||
let l:tmp = gotest#write_file('a/a.go', [
|
||||
\ 'package a',
|
||||
\ '',
|
||||
\ 'type reader struct {}'])
|
||||
|
||||
call go#impl#Impl('io.Reader')
|
||||
call gotest#assert_buffer(0, [
|
||||
\ 'package a',
|
||||
\ '',
|
||||
\ 'type reader struct {}',
|
||||
\ '',
|
||||
\ 'func (r *reader) Read(p []byte) (n int, err error) {',
|
||||
\ ' panic("not implemented")',
|
||||
\ '}'])
|
||||
finally
|
||||
call delete(l:tmp, 'rf')
|
||||
endtry
|
||||
endfunc
|
@ -33,10 +33,9 @@ function! go#jobcontrol#RemoveHandler(id) abort
|
||||
unlet s:handlers[a:id]
|
||||
endfunction
|
||||
|
||||
" spawn spawns a go subcommand with the name and arguments with jobstart. Once
|
||||
" a job is started a reference will be stored inside s:jobs. spawn changes the
|
||||
" GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the
|
||||
" current files folder.
|
||||
" spawn spawns a go subcommand with the name and arguments with jobstart. Once a
|
||||
" job is started a reference will be stored inside s:jobs. The job is started
|
||||
" inside the current files folder.
|
||||
function! s:spawn(bang, desc, for, args) abort
|
||||
let status_type = a:args[0]
|
||||
let status_dir = expand('%:p:h')
|
||||
@ -65,10 +64,6 @@ function! s:spawn(bang, desc, for, args) abort
|
||||
\ 'for' : a:for,
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" execute go build in the files directory
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
|
||||
@ -94,9 +89,6 @@ function! s:spawn(bang, desc, for, args) abort
|
||||
|
||||
execute cd . fnameescape(dir)
|
||||
|
||||
" restore back GOPATH
|
||||
let $GOPATH = old_gopath
|
||||
|
||||
return job
|
||||
endfunction
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
function! go#keyify#Keyify()
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
let bin_path = go#path#CheckBinPath("keyify")
|
||||
let fname = fnamemodify(expand("%"), ':p:gs?\\?/?')
|
||||
|
||||
if empty(bin_path) || !exists('*json_decode')
|
||||
let $GOPATH = old_gopath
|
||||
return
|
||||
endif
|
||||
|
||||
@ -18,7 +15,6 @@ function! go#keyify#Keyify()
|
||||
" We want to output the error message in case the result isn't a JSON
|
||||
if type(result) != type({})
|
||||
call go#util#EchoError(s:chomp(output))
|
||||
let $GOPATH = old_gopath
|
||||
return
|
||||
endif
|
||||
|
||||
@ -51,7 +47,6 @@ function! go#keyify#Keyify()
|
||||
|
||||
call setpos("'<", vis_start)
|
||||
call setpos("'>", vis_end)
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
function! s:chomp(string)
|
||||
|
@ -46,7 +46,7 @@ function! go#package#Paths() abort
|
||||
let dirs += [s:goroot]
|
||||
endif
|
||||
|
||||
let workspaces = split(go#path#Detect(), go#util#PathListSep())
|
||||
let workspaces = split(go#path#Default(), go#util#PathListSep())
|
||||
if workspaces != []
|
||||
let dirs += workspaces
|
||||
endif
|
||||
|
@ -4,14 +4,14 @@
|
||||
" :GoPath is used
|
||||
let s:initial_go_path = ""
|
||||
|
||||
" GoPath sets or returns the current GOPATH. If no arguments are passed it
|
||||
" GoPath sets or echos the current GOPATH. If no arguments are passed it
|
||||
" echoes the current GOPATH, if an argument is passed it replaces the current
|
||||
" GOPATH with it. If two double quotes are passed (the empty string in go),
|
||||
" it'll clear the GOPATH and will restore to the initial GOPATH.
|
||||
function! go#path#GoPath(...) abort
|
||||
" no argument, show GOPATH
|
||||
if len(a:000) == 0
|
||||
echo go#path#Detect()
|
||||
echo go#path#Default()
|
||||
return
|
||||
endif
|
||||
|
||||
@ -72,11 +72,6 @@ endfunction
|
||||
function! go#path#Detect() abort
|
||||
let gopath = go#path#Default()
|
||||
|
||||
" don't lookup for godeps if autodetect is disabled.
|
||||
if !get(g:, "go_autodetect_gopath", 0)
|
||||
return gopath
|
||||
endif
|
||||
|
||||
let current_dir = fnameescape(expand('%:p:h'))
|
||||
|
||||
" TODO(arslan): this should be changed so folders or files should be
|
||||
@ -124,7 +119,6 @@ function! go#path#Detect() abort
|
||||
return gopath
|
||||
endfunction
|
||||
|
||||
|
||||
" BinPath returns the binary path of installed go tools.
|
||||
function! go#path#BinPath() abort
|
||||
let bin_path = ""
|
||||
|
@ -100,10 +100,6 @@ function s:rename_job(args)
|
||||
\ 'exit_cb': funcref("s:exit_cb"),
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
call go#statusline#Update(status_dir, {
|
||||
\ 'desc': "current status",
|
||||
\ 'type': "gorename",
|
||||
@ -111,8 +107,6 @@ function s:rename_job(args)
|
||||
\})
|
||||
|
||||
call job_start(a:args.cmd, start_options)
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
function s:parse_errors(exit_val, bang, out)
|
||||
|
@ -18,10 +18,6 @@ function! go#term#newmode(bang, cmd, mode) abort
|
||||
let mode = g:go_term_mode
|
||||
endif
|
||||
|
||||
" modify GOPATH if needed
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" execute go build in the files directory
|
||||
let l:winnr = winnr()
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
@ -54,9 +50,6 @@ function! go#term#newmode(bang, cmd, mode) abort
|
||||
|
||||
execute cd . fnameescape(dir)
|
||||
|
||||
" restore back GOPATH
|
||||
let $GOPATH = old_gopath
|
||||
|
||||
let job.id = id
|
||||
let job.cmd = a:cmd
|
||||
startinsert
|
||||
|
@ -207,10 +207,6 @@ function s:test_job(args) abort
|
||||
\ 'exit_cb': funcref("s:exit_cb"),
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" pre start
|
||||
let dir = getcwd()
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
@ -221,7 +217,6 @@ function s:test_job(args) abort
|
||||
|
||||
" post start
|
||||
execute cd . fnameescape(dir)
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
" show_errors parses the given list of lines of a 'go test' output and returns
|
||||
@ -295,20 +290,27 @@ function! s:parse_errors(lines) abort
|
||||
" '\t/usr/local/go/src/time.go:1313 +0x5d'
|
||||
let tokens = matchlist(line, '^\t\+\(.\{-}\.go\):\(\d\+\) \(+0x.*\)')
|
||||
else
|
||||
" matches lines produced by `go test`. All lines produced by `go test`
|
||||
" that we're interested in start with zero or more spaces (increasing
|
||||
" depth of subtests is represented by a similar increase in the number
|
||||
" of spaces at the start of output lines. Top level tests start with
|
||||
" zero leading spaces). Lines that indicate test status (e.g. RUN, FAIL,
|
||||
" PASS) start after the spaces. Lines that indicate test failure
|
||||
" location or test log message location (e.g. "testing.T".Log) begin
|
||||
" with the appropriate number of spaces for the current test level,
|
||||
" followed by a tab, a filename , a colon, the line number, another
|
||||
" colon, a space, and the failure or log message.
|
||||
" Matches lines produced by `go test`. When the test binary cannot be
|
||||
" compiled, the errors will be a filename, followed by a colon, followed
|
||||
" by the line number, followed by another colon, a space, and then the
|
||||
" compiler error.
|
||||
" e.g.:
|
||||
" 'quux.go:123: undefined: foo'
|
||||
"
|
||||
" When the test binary can be successfully compiled, but tests fail, all
|
||||
" lines produced by `go test` that we're interested in start with zero
|
||||
" or more spaces (increasing depth of subtests is represented by a
|
||||
" similar increase in the number of spaces at the start of output lines.
|
||||
" Top level tests start with zero leading spaces). Lines that indicate
|
||||
" test status (e.g. RUN, FAIL, PASS) start after the spaces. Lines that
|
||||
" indicate test failure location or test log message location (e.g.
|
||||
" "testing.T".Log) begin with the appropriate number of spaces for the
|
||||
" current test level, followed by a tab, a filename , a colon, the line
|
||||
" number, another colon, a space, and the failure or log message.
|
||||
"
|
||||
" e.g.:
|
||||
" '\ttime_test.go:30: Likely problem: the time zone files have not been installed.'
|
||||
let tokens = matchlist(line, '^ *\t\+\(.\{-}\.go\):\(\d\+\):\s*\(.*\)')
|
||||
let tokens = matchlist(line, '^\%( *\t\+\)\?\(.\{-}\.go\):\(\d\+\):\s*\(.*\)')
|
||||
endif
|
||||
|
||||
if !empty(tokens) " Check whether the line may refer to a file.
|
||||
|
@ -174,11 +174,6 @@ function! go#tool#ExecuteInDir(cmd) abort
|
||||
return ''
|
||||
endif
|
||||
|
||||
let old_gopath = $GOPATH
|
||||
let old_goroot = $GOROOT
|
||||
let $GOPATH = go#path#Detect()
|
||||
let $GOROOT = go#util#env("goroot")
|
||||
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
let dir = getcwd()
|
||||
try
|
||||
@ -187,9 +182,6 @@ function! go#tool#ExecuteInDir(cmd) abort
|
||||
finally
|
||||
execute cd . fnameescape(dir)
|
||||
endtry
|
||||
|
||||
let $GOROOT = old_goroot
|
||||
let $GOPATH = old_gopath
|
||||
return out
|
||||
endfunction
|
||||
|
||||
|
@ -15,7 +15,7 @@ fun! gotest#write_file(path, contents) abort
|
||||
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
|
||||
silent exe 'e! ' . a:path
|
||||
|
||||
" Set cursor.
|
||||
let l:lnum = 1
|
||||
|
@ -57,7 +57,8 @@ tools developed by the Go community to provide a seamless Vim experience.
|
||||
* Advanced source analysis tools utilizing `guru`, such as |:GoImplements|,
|
||||
|:GoCallees|, and |:GoReferrers|.
|
||||
* Precise type-safe renaming of identifiers with |:GoRename|.
|
||||
* Integrated and improved snippets, supporting `ultisnips` or `neosnippet`.
|
||||
* Integrated and improved snippets, supporting `ultisnips`, `neosnippet`,
|
||||
and `vim-minisnip`.
|
||||
* Share your current code to play.golang.org with |:GoPlay|.
|
||||
* On-the-fly information about the word under the cursor. Plug it into your
|
||||
custom Vim function.
|
||||
@ -136,7 +137,8 @@ The following plugins are supported for use with vim-go:
|
||||
|
||||
* Snippets:
|
||||
https://github.com/Shougo/neosnippet.vim or
|
||||
https://github.com/SirVer/ultisnips
|
||||
https://github.com/SirVer/ultisnips or
|
||||
https://github.com/joereynolds/vim-minisnip
|
||||
|
||||
* For a better documentation viewer check out:
|
||||
https://github.com/garyburd/go-explorer
|
||||
@ -147,7 +149,8 @@ The following plugins are supported for use with vim-go:
|
||||
* Interactive |:GoDecls| and |:GoDeclsDir|:
|
||||
https://github.com/ctrlpvim/ctrlp.vim or
|
||||
https://github.com/junegunn/fzf.vim or
|
||||
https://github.com/Shougo/unite.vim
|
||||
https://github.com/Shougo/unite.vim or
|
||||
https://github.com/Shougo/denite.nvim
|
||||
|
||||
==============================================================================
|
||||
COMMANDS *go-commands*
|
||||
@ -197,7 +200,8 @@ COMMANDS *go-commands*
|
||||
:GoDocBrowser [word]
|
||||
|
||||
Open the relevant GoDoc in browser for either the word[s] passed to the
|
||||
command or by default, the word under the cursor.
|
||||
command or by default, the word under the cursor. By default it opens the
|
||||
documentation in 'https://godoc.org'. To change it see |'g:go_doc_url'|.
|
||||
|
||||
*:GoFmt*
|
||||
:GoFmt
|
||||
@ -684,7 +688,7 @@ CTRL-t
|
||||
Requires `ctrlp.vim` or `fzf`; it will autodetect the plugin if installed,
|
||||
but you can use |'g:go_decls_mode'| to force using one or the other.
|
||||
By default `type` and `func` declarations are shown. This can be changed
|
||||
via |'g:go_decls_includes'|. Also see |unite-decls|.
|
||||
via |'g:go_decls_includes'|. Also see |unite-decls|, |denite-decls|.
|
||||
|
||||
*:GoDeclsDir*
|
||||
:GoDeclsDir [dir]
|
||||
@ -693,20 +697,27 @@ CTRL-t
|
||||
[dir] is given it parses the given directory.
|
||||
|
||||
*unite-decls*
|
||||
:Unite decls[:file or dir]
|
||||
*denite-decls*
|
||||
:Unite decls[:path]
|
||||
:Denite decls[:path]
|
||||
|
||||
Only enabled if `unite.vim` is installed. Show declarations for all
|
||||
functions and types on the current file or directory. If [:file or dir]
|
||||
is non empty, it parses the given one.
|
||||
Only enabled if `unite.vim` or `denite.nvim` is installed. Show
|
||||
declarations for all functions and types on the current file or directory
|
||||
or for [path] if given.
|
||||
|
||||
Note: `denite.nvim` requires NeoVim or Vim 8 with |:python3| enabled.
|
||||
>
|
||||
" show declarations on the parent directory of the current file
|
||||
:Unite decls
|
||||
:Denite decls
|
||||
|
||||
" show declarations on the file
|
||||
" show declarations in the file.
|
||||
:Unite decls:foo/bar.go
|
||||
:Denite decls:foo/bar.go
|
||||
|
||||
" show declarations on the directory
|
||||
" show declarations in the directory "foo".
|
||||
:Unite decls:foo
|
||||
:Denite decls:foo
|
||||
<
|
||||
*:GoImpl*
|
||||
:GoImpl [receiver] [interface]
|
||||
@ -1094,9 +1105,9 @@ SETTINGS *go-settings*
|
||||
*'g:go_test_prepend_name'*
|
||||
|
||||
Prepend the name of the failed test to each test message generated by a failed
|
||||
test. By default it is disabled.
|
||||
test. By default it is disabled.
|
||||
>
|
||||
let g:go_test_prepend_name = 0
|
||||
let g:go_test_prepend_name = 0
|
||||
<
|
||||
|
||||
*'g:go_test_timeout'*
|
||||
@ -1236,6 +1247,14 @@ Maximum height for the GoDoc window created with |:GoDoc|. Default is 20. >
|
||||
let g:go_doc_max_height = 20
|
||||
<
|
||||
|
||||
*'g:go_doc_url'*
|
||||
|
||||
godoc server URL used when |:GoDocBrowser| is used. Change if you want to use
|
||||
a private internal service. Default is 'https://godoc.org'.
|
||||
>
|
||||
let g:go_doc_url = 'https://godoc.org'
|
||||
<
|
||||
|
||||
*'g:go_def_mode'*
|
||||
|
||||
Use this option to define the command to be used for |:GoDef|. By default
|
||||
@ -1278,10 +1297,16 @@ Use this option to change default path for vim-go tools when using
|
||||
<
|
||||
*'g:go_snippet_engine'*
|
||||
|
||||
Use this option to define the default snippet engine. By default "ultisnips"
|
||||
is used. Use "neosnippet" for neosnippet.vim: >
|
||||
Define the snippet engine to use. The default is to auto-detect one. Valid
|
||||
values are:
|
||||
|
||||
let g:go_snippet_engine = "ultisnips"
|
||||
automatic Automatically detect a snippet engine.
|
||||
ultisnips https://github.com/SirVer/ultisnips
|
||||
neosnippet https://github.com/Shougo/neosnippet.vim
|
||||
minisnip https://github.com/joereynolds/vim-minisnip
|
||||
Note: the original at KeyboardFire/vim-minisnip won't work.
|
||||
>
|
||||
let g:go_snippet_engine = "automatic"
|
||||
<
|
||||
*'g:go_get_update'*
|
||||
|
||||
@ -1315,13 +1340,12 @@ remove build tags. By default it's not set.
|
||||
<
|
||||
*'g:go_autodetect_gopath'*
|
||||
|
||||
Automatically modifies GOPATH for certain directory structures, such as for
|
||||
the tool `godep` which has his own dependencies via the `Godeps` folder. What
|
||||
this means is that all tools are now working with the newly modified GOPATH.
|
||||
So |:GoDef| for example jumps to the source inside the `Godeps` (vendored)
|
||||
source. Currently `godep` and `gb` is supported, in the near future more tool
|
||||
supports will be added. By default it's disabled. >
|
||||
|
||||
Automatically modify GOPATH for certain directory structures, such as for
|
||||
the `godep` tool which stores dependencies in the `Godeps` folder. What this
|
||||
means is that all tools are now working with the newly modified GOPATH. So
|
||||
|:GoDef| for example jumps to the source inside the `Godeps` (vendored)
|
||||
source. Currently `godep` and `gb` are supported. By default it's disabled.
|
||||
>
|
||||
let g:go_autodetect_gopath = 0
|
||||
<
|
||||
*'g:go_textobj_enabled'*
|
||||
@ -1565,10 +1589,10 @@ By default the template file specified by |'g:go_template_file'| is used.
|
||||
<
|
||||
*'g:go_decls_includes'*
|
||||
|
||||
Only useful if `ctrlp.vim`, `unite.vim` or `fzf` are installed. This sets
|
||||
which declarations to show for |:GoDecls| (`ctrp.vim`) and |unite-decls|
|
||||
(`unite.vim`). It is a Comma delimited list Possible options are:
|
||||
{func,type}. The default is: >
|
||||
Only useful if `ctrlp.vim`, `unite.vim`, `denite.nvim` or `fzf` are installed.
|
||||
This sets which declarations to show for |:GoDecls| (`ctrp.vim`),
|
||||
|unite-decls| (`unite.vim`) and |denite-decls| (`denite.nvim`). It is a Comma
|
||||
delimited list. Possible options are: {func,type}. The default is: >
|
||||
|
||||
let g:go_decls_includes = 'func,type'
|
||||
<
|
||||
@ -1704,6 +1728,14 @@ Highlight operators such as `:=` , `==`, `-=`, etc.
|
||||
Highlight function names.
|
||||
>
|
||||
let g:go_highlight_functions = 0
|
||||
<
|
||||
*'g:go_highlight_function_arguments'*
|
||||
|
||||
Highlight the variable names in arguments and return values in function
|
||||
declarations. Setting this implies the functionality from
|
||||
|'g:go_highlight_functions'|.
|
||||
>
|
||||
let g:go_highlight_function_arguments = 0
|
||||
<
|
||||
*'g:go_highlight_methods'*
|
||||
|
||||
|
@ -87,7 +87,7 @@ command! -nargs=? -complete=file GoDecls call go#decls#Decls(0, <q-args>)
|
||||
command! -nargs=? -complete=dir GoDeclsDir call go#decls#Decls(1, <q-args>)
|
||||
|
||||
" -- impl
|
||||
command! -nargs=* -buffer -complete=customlist,go#impl#Complete GoImpl call go#impl#Impl(<f-args>)
|
||||
command! -nargs=* -complete=customlist,go#impl#Complete GoImpl call go#impl#Impl(<f-args>)
|
||||
|
||||
" -- template
|
||||
command! -nargs=0 GoTemplateAutoCreateToggle call go#template#ToggleAutoCreate()
|
||||
|
@ -3,13 +3,8 @@ if exists("g:go_loaded_gosnippets")
|
||||
endif
|
||||
let g:go_loaded_gosnippets = 1
|
||||
|
||||
" by default UltiSnips
|
||||
if !exists("g:go_snippet_engine")
|
||||
let g:go_snippet_engine = "ultisnips"
|
||||
endif
|
||||
|
||||
function! s:GoUltiSnips()
|
||||
if globpath(&rtp, 'plugin/UltiSnips.vim') == ""
|
||||
function! s:GoUltiSnips() abort
|
||||
if get(g:, 'did_plugin_ultisnips') isnot 1
|
||||
return
|
||||
endif
|
||||
|
||||
@ -20,29 +15,53 @@ function! s:GoUltiSnips()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GoNeosnippet()
|
||||
if globpath(&rtp, 'plugin/neosnippet.vim') == ""
|
||||
function! s:GoNeosnippet() abort
|
||||
if get(g:, 'loaded_neosnippet') isnot 1
|
||||
return
|
||||
endif
|
||||
|
||||
let g:neosnippet#enable_snipmate_compatibility = 1
|
||||
|
||||
let gosnippets_dir = globpath(&rtp, 'gosnippets/snippets')
|
||||
let l:gosnippets_dir = globpath(&rtp, 'gosnippets/snippets')
|
||||
if type(g:neosnippet#snippets_directory) == type([])
|
||||
let g:neosnippet#snippets_directory += [gosnippets_dir]
|
||||
let g:neosnippet#snippets_directory += [l:gosnippets_dir]
|
||||
elseif type(g:neosnippet#snippets_directory) == type("")
|
||||
if strlen(g:neosnippet#snippets_directory) > 0
|
||||
let g:neosnippet#snippets_directory = g:neosnippet#snippets_directory . "," . gosnippets_dir
|
||||
let g:neosnippet#snippets_directory = g:neosnippet#snippets_directory . "," . l:gosnippets_dir
|
||||
else
|
||||
let g:neosnippet#snippets_directory = gosnippets_dir
|
||||
let g:neosnippet#snippets_directory = l:gosnippets_dir
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if g:go_snippet_engine == "ultisnips"
|
||||
function! s:GoMinisnip() abort
|
||||
if get(g:, 'loaded_minisnip') isnot 1
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('g:minisnip_dir')
|
||||
let g:minisnip_dir .= ':' . globpath(&rtp, 'gosnippets/minisnip')
|
||||
else
|
||||
let g:minisnip_dir = globpath(&rtp, 'gosnippets/minisnip')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
let s:engine = get(g:, 'go_snippet_engine', 'automatic')
|
||||
if s:engine is? "automatic"
|
||||
if get(g:, 'did_plugin_ultisnips') is 1
|
||||
call s:GoUltiSnips()
|
||||
elseif get(g:, 'loaded_neosnippet') is 1
|
||||
call s:GoNeosnippet()
|
||||
elseif get(g:, 'loaded_minisnip') is 1
|
||||
call s:GoMinisnip()
|
||||
endif
|
||||
elseif s:engine is? "ultisnips"
|
||||
call s:GoUltiSnips()
|
||||
elseif g:go_snippet_engine == "neosnippet"
|
||||
elseif s:engine is? "neosnippet"
|
||||
call s:GoNeosnippet()
|
||||
elseif s:engine is? "minisnip"
|
||||
call s:GoMinisnip()
|
||||
endif
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_eq
Normal file
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_eq
Normal file
@ -0,0 +1,3 @@
|
||||
if !reflect.DeepEqual({{+got+}}, {{+want+}}) {
|
||||
t.Errorf("\ngot: %#v\nwant: %#v\n", {{+~\~2+}}, {{+~\~2+}})
|
||||
}
|
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_err
Normal file
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_err
Normal file
@ -0,0 +1,3 @@
|
||||
if err != nil {
|
||||
return {{+err+}}
|
||||
}
|
4
sources_non_forked/vim-go/gosnippets/minisnip/_go_errt
Normal file
4
sources_non_forked/vim-go/gosnippets/minisnip/_go_errt
Normal file
@ -0,0 +1,4 @@
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
{{++}}
|
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_errw
Normal file
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_errw
Normal file
@ -0,0 +1,3 @@
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{++}}")
|
||||
}
|
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_f
Normal file
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_f
Normal file
@ -0,0 +1,3 @@
|
||||
// {{++}}
|
||||
func {{+~\~1+}}() {
|
||||
}
|
1
sources_non_forked/vim-go/gosnippets/minisnip/_go_ff
Normal file
1
sources_non_forked/vim-go/gosnippets/minisnip/_go_ff
Normal file
@ -0,0 +1 @@
|
||||
fmt.Printf("%#v\n", {{++}})
|
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_fori
Normal file
3
sources_non_forked/vim-go/gosnippets/minisnip/_go_fori
Normal file
@ -0,0 +1,3 @@
|
||||
for i := 0; i < {{++}}; i++ {
|
||||
{{++}}
|
||||
}
|
2
sources_non_forked/vim-go/gosnippets/minisnip/_go_pkg
Normal file
2
sources_non_forked/vim-go/gosnippets/minisnip/_go_pkg
Normal file
@ -0,0 +1,2 @@
|
||||
// Package {{+~expand('%:p:h:t')+}} {{++}}
|
||||
package {{+~\~2+}}
|
2
sources_non_forked/vim-go/gosnippets/minisnip/_go_sp
Normal file
2
sources_non_forked/vim-go/gosnippets/minisnip/_go_sp
Normal file
@ -0,0 +1,2 @@
|
||||
fmt.Sprintf("{{++}}", {{++}})
|
||||
|
@ -146,7 +146,7 @@ function! s:GoInstallBinaries(updateBinaries, ...)
|
||||
echo "vim-go: ". binary ." not found. Installing ". importPath . " to folder " . go_bin_path
|
||||
endif
|
||||
|
||||
let out = go#util#System(cmd . l:goGetFlags . shellescape(importPath))
|
||||
let out = go#util#System(printf('%s %s %s', cmd, l:goGetFlags, shellescape(importPath)))
|
||||
if go#util#ShellError() != 0
|
||||
echom "Error installing " . importPath . ": " . out
|
||||
endif
|
||||
@ -260,6 +260,19 @@ augroup vim-go
|
||||
" in the same window doesn't highlight the most recently matched
|
||||
" identifier's positions.
|
||||
autocmd BufWinEnter *.go call go#guru#ClearSameIds()
|
||||
augroup END
|
||||
|
||||
autocmd BufEnter *.go
|
||||
\ if get(g:, 'go_autodetect_gopath', 0) && !exists('b:old_gopath')
|
||||
\| let b:old_gopath = exists('$GOPATH') ? $GOPATH : -1
|
||||
\| let $GOPATH = go#path#Detect()
|
||||
\| endif
|
||||
autocmd BufLeave *.go
|
||||
\ if exists('b:old_gopath')
|
||||
\| if b:old_gopath isnot -1
|
||||
\| let $GOPATH = b:old_gopath
|
||||
\| endif
|
||||
\| unlet b:old_gopath
|
||||
\| endif
|
||||
augroup end
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
@ -0,0 +1,93 @@
|
||||
# ============================================================================
|
||||
# FILE: decls.py
|
||||
# AUTHOR: delphinus <delphinus@remora.cx>
|
||||
# License: MIT license
|
||||
# ============================================================================
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
import denite.util
|
||||
from .base import Base
|
||||
|
||||
DECLS_SYNTAX_HIGHLIGHT = [
|
||||
{'name': 'FilePath', 're': r'[^:]*\ze:', 'link': 'Comment'},
|
||||
{'name': 'Line', 're': r'\d\+\ze :', 'link': 'LineNr'},
|
||||
{'name': 'WholeFunction', 're': r'\vfunc %(\([^)]+\) )?[^(]+'},
|
||||
{'name': 'Function', 'parent': 'WholeFunction',
|
||||
're': r'\S\+\ze(', 'link': 'Function'},
|
||||
{'name': 'WholeType', 're': r'type \S\+'},
|
||||
{'name': 'Type', 'parent': 'WholeType',
|
||||
're': r'\v( )@<=\S+', 'link': 'Type'},
|
||||
{'name': 'Separator', 're': r':', 'conceal': True},
|
||||
{'name': 'SeparatorFunction', 'parent': 'WholeFunction',
|
||||
're': r'func ', 'conceal': True},
|
||||
{'name': 'SeparatorType', 'parent': 'WholeType',
|
||||
're': r'type ', 'conceal': True},
|
||||
]
|
||||
|
||||
class Source(Base):
|
||||
|
||||
def __init__(self, vim):
|
||||
super().__init__(vim)
|
||||
|
||||
self.name = 'decls'
|
||||
self.kind = 'file'
|
||||
|
||||
def gather_candidates(self, context):
|
||||
bin_path = self.vim.call('go#path#CheckBinPath', 'motion')
|
||||
if bin_path == '':
|
||||
return []
|
||||
|
||||
expand = context['args'][0] if context['args'] else '%:p:h'
|
||||
target = self.vim.funcs.expand(expand)
|
||||
|
||||
if os.path.isdir(target):
|
||||
mode = 'dir'
|
||||
elif os.path.isfile(target):
|
||||
mode = 'file'
|
||||
else:
|
||||
return []
|
||||
|
||||
if self.vim.funcs.exists('g:go_decls_includes'):
|
||||
include = self.vim.eval('g:go_decls_includes')
|
||||
else:
|
||||
include = 'func,type'
|
||||
|
||||
command = [bin_path, '-mode', 'decls', '-include', include,
|
||||
'-' + mode, target]
|
||||
|
||||
try:
|
||||
cmd = subprocess.run(command, stdout=subprocess.PIPE, check=True)
|
||||
except subprocess.CalledProcessError as err:
|
||||
denite.util.error(self.vim,
|
||||
'command returned invalid response: ' + str(err))
|
||||
return []
|
||||
|
||||
txt = cmd.stdout.decode('utf-8')
|
||||
output = json.loads(txt, encoding='utf-8')
|
||||
|
||||
def make_candidates(row):
|
||||
name = self.vim.funcs.fnamemodify(row['filename'], ':~:.')
|
||||
return {
|
||||
'word': '{0} :{1} :{2}'.format(name, row['line'], row['full']),
|
||||
'action__path': row['filename'],
|
||||
'action__line': row['line'],
|
||||
'action__col': row['col'],
|
||||
}
|
||||
return list(map(make_candidates, output['decls']))
|
||||
|
||||
def highlight(self):
|
||||
for syn in DECLS_SYNTAX_HIGHLIGHT:
|
||||
containedin = self.syntax_name
|
||||
containedin += '_' + syn['parent'] if 'parent' in syn else ''
|
||||
conceal = ' conceal' if 'conceal' in syn else ''
|
||||
|
||||
self.vim.command(
|
||||
'syntax match {0}_{1} /{2}/ contained containedin={3}{4}'
|
||||
.format(self.syntax_name, syn['name'], syn['re'],
|
||||
containedin, conceal))
|
||||
|
||||
if 'link' in syn:
|
||||
self.vim.command('highlight default link {0}_{1} {2}'.format(
|
||||
self.syntax_name, syn['name'], syn['link']))
|
@ -7,6 +7,14 @@ set -euC
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
coverage=0
|
||||
while getopts "c" option; do
|
||||
case "$option" in
|
||||
c) coverage=1; ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "unknown version: '${1:-}'"
|
||||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'."
|
||||
@ -23,11 +31,20 @@ if [ ! -f "$dir/bin/vim" ]; then
|
||||
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!' \
|
||||
"$@"
|
||||
if [ $coverage -eq 1 ]; then
|
||||
covimerage -q run --report-file /tmp/vim-go-test/cov-profile.txt --append \
|
||||
$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!' \
|
||||
"$@"
|
||||
else
|
||||
$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!' \
|
||||
"$@"
|
||||
fi
|
||||
|
||||
|
||||
# vim:ts=2:sts=2:sw=2:et
|
||||
|
@ -11,6 +11,9 @@ let s:fail = 0
|
||||
let s:done = 0
|
||||
let s:logs = []
|
||||
let s:gopath = $GOPATH
|
||||
if !exists('g:test_verbose')
|
||||
let g:test_verbose = 0
|
||||
endif
|
||||
|
||||
" Source the passed test file.
|
||||
source %
|
||||
@ -38,8 +41,14 @@ for s:test in sort(s:tests)
|
||||
endif
|
||||
|
||||
let s:started = reltime()
|
||||
call add(s:logs, printf("=== RUN %s", s:test[:-3]))
|
||||
exe 'call ' . s:test
|
||||
if g:test_verbose is 1
|
||||
call add(s:logs, printf("=== RUN %s", s:test[:-3]))
|
||||
endif
|
||||
try
|
||||
exe 'call ' . s:test
|
||||
catch
|
||||
let v:errors += [v:exception]
|
||||
endtry
|
||||
|
||||
" Restore GOPATH after each test.
|
||||
let $GOPATH = s:gopath
|
||||
@ -55,7 +64,9 @@ for s:test in sort(s:tests)
|
||||
" Reset so we can capture failures of the next test.
|
||||
let v:errors = []
|
||||
else
|
||||
call add(s:logs, printf("--- PASS %s (%ss)", s:test[:-3], s:elapsed_time))
|
||||
if g:test_verbose is 1
|
||||
call add(s:logs, printf("--- PASS %s (%ss)", s:test[:-3], s:elapsed_time))
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
@ -76,9 +87,14 @@ let s:logs = s:logs + filter(split(s:mess, "\n"), 'v:val !~ "^Messages maintaine
|
||||
" Also store all internal messages from s:logs as well.
|
||||
silent! split /tmp/vim-go-test/test.tmp
|
||||
call append(line('$'), s:logs)
|
||||
call append(line('$'), printf("%s%s %s / %s tests",
|
||||
\ (s:fail > 0 ? 'FAIL ' : 'ok '),
|
||||
\ s:testfile, s:total_elapsed_time, s:done))
|
||||
call append(line('$'), printf("%s %s %s %ss / %s tests",
|
||||
\ (s:fail > 0 ? 'FAIL' : 'ok '),
|
||||
\ s:testfile,
|
||||
\ repeat(' ', 25 - len(s:testfile)),
|
||||
\ s:total_elapsed_time, s:done))
|
||||
if g:test_verbose is 0
|
||||
silent :g/^$/d
|
||||
endif
|
||||
silent! write
|
||||
|
||||
" Our work here is done.
|
||||
|
@ -7,6 +7,35 @@ set -euC
|
||||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd)
|
||||
cd "$vimgodir"
|
||||
|
||||
_usage() {
|
||||
echo "Usage: ${0##*/} [-hvc] [-r file] vim_version"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h Show this help"
|
||||
echo " -v Enable verbose output"
|
||||
echo " -r Run only the tests from this file"
|
||||
echo " -c Generate and submit code coverage reports"
|
||||
echo
|
||||
}
|
||||
|
||||
verbose=0
|
||||
run=""
|
||||
coverage=""
|
||||
while getopts "hvcr:" option; do
|
||||
case "$option" in
|
||||
h) _usage; exit 0 ;;
|
||||
v) verbose=1; ;;
|
||||
r) run=$OPTARG ;;
|
||||
c) coverage="-c" ;;
|
||||
*)
|
||||
echo "error: unknown option '$option'"
|
||||
_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
### Setup Vim and other dependencies.
|
||||
#####################################
|
||||
if [ -z "${1:-}" ]; then
|
||||
@ -21,20 +50,33 @@ 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
|
||||
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'
|
||||
[ -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'
|
||||
[ -f '/tmp/vim-go-test/cov-profile.txt' ] && rm '/tmp/vim-go-test/cov-profile.txt'
|
||||
[ -f '/tmp/vim-go-test/cov-report.txt' ] && rm '/tmp/vim-go-test/cov-report.txt'
|
||||
|
||||
# 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
|
||||
find "$vimgodir" -name '*_test.vim' | while read test_file; do
|
||||
[ -n "$run" -a "$(basename "$test_file")" != "$run" ] && continue
|
||||
|
||||
"$vimgodir/scripts/run-vim" $coverage $vim -e \
|
||||
+"silent e $test_file" \
|
||||
+"let g:test_verbose=$verbose" \
|
||||
-S ./scripts/runtest.vim || (
|
||||
# If Vim exits with non-0 it's almost certainly a bug in the test runner;
|
||||
# should very rarely happen in normal usage.
|
||||
echo 'test runner failure'
|
||||
cat '/tmp/vim-go-test/test.tmp'
|
||||
rm '/tmp/vim-go-test/test.tmp'
|
||||
exit 5
|
||||
)
|
||||
|
||||
# Append logs
|
||||
cat '/tmp/vim-go-test/test.tmp' | tee '/tmp/vim-go-test/test.log'
|
||||
@ -43,9 +85,17 @@ done
|
||||
|
||||
echo
|
||||
if [ -f "/tmp/vim-go-test/FAILED" ]; then
|
||||
echo 2>&1 "Some tests FAILED"
|
||||
echo 2>&1 "Some ($vim) tests FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo 2>&1 "All tests PASSED"
|
||||
echo 2>&1 "All ($vim) tests PASSED"
|
||||
|
||||
# Submit coverage reports
|
||||
if [ -n "$coverage" ]; then
|
||||
coverage xml --omit '*_test.vim'
|
||||
codecov -X search gcov pycov -f coverage.xml --required \
|
||||
--flags "$(echo "$vim" | sed -s 's/[-.]//g')"
|
||||
rm coverage.xml
|
||||
fi
|
||||
|
||||
# vim:ts=2:sts=2:sw=2:et
|
||||
|
@ -38,6 +38,10 @@ if !exists("g:go_highlight_functions")
|
||||
let g:go_highlight_functions = 0
|
||||
endif
|
||||
|
||||
if !exists("g:go_highlight_function_arguments")
|
||||
let g:go_highlight_function_arguments = 0
|
||||
endif
|
||||
|
||||
if !exists("g:go_highlight_methods")
|
||||
let g:go_highlight_methods = 0
|
||||
endif
|
||||
@ -94,7 +98,7 @@ if exists("g:go_fold_enable")
|
||||
if index(g:go_fold_enable, 'package_comment') == -1
|
||||
let s:fold_package_comment = 0
|
||||
endif
|
||||
|
||||
|
||||
" Disabled by default.
|
||||
if index(g:go_fold_enable, 'comment') > -1
|
||||
let s:fold_comment = 1
|
||||
@ -229,14 +233,14 @@ endif
|
||||
" var, const
|
||||
if s:fold_varconst
|
||||
syn region goVar start='var (' end='^\s*)$' transparent fold
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments
|
||||
syn region goConst start='const (' end='^\s*)$' transparent fold
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments
|
||||
else
|
||||
syn region goVar start='var (' end='^\s*)$' transparent
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar
|
||||
syn region goVar start='var (' end='^\s*)$' transparent
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments
|
||||
syn region goConst start='const (' end='^\s*)$' transparent
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar
|
||||
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments
|
||||
endif
|
||||
|
||||
" Single-line var, const, and import.
|
||||
@ -343,14 +347,22 @@ endif
|
||||
hi def link goOperator Operator
|
||||
|
||||
" Functions;
|
||||
if g:go_highlight_functions != 0
|
||||
syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction skipwhite skipnl
|
||||
syn match goReceiver /(\(\w\|[ *]\)\+)/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl
|
||||
syn match goReceiverVar /\w\+/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained
|
||||
if g:go_highlight_functions isnot 0 || g:go_highlight_function_arguments isnot 0
|
||||
syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration
|
||||
syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl
|
||||
syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained
|
||||
syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl
|
||||
syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl
|
||||
syn match goReceiverType /\w\+/ contained
|
||||
syn match goFunction /\w\+/ contained
|
||||
syn match goFunctionCall /\w\+\ze(/ contains=GoBuiltins,goDeclaration
|
||||
if g:go_highlight_function_arguments isnot 0
|
||||
syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl
|
||||
syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl
|
||||
syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl
|
||||
\ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock
|
||||
hi def link goReceiverVar goArgumentName
|
||||
hi def link goArgumentName Identifier
|
||||
endif
|
||||
syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl
|
||||
else
|
||||
syn keyword goDeclaration func
|
||||
endif
|
||||
|
55
sources_non_forked/vim-go/test/gopath_test.vim
Normal file
55
sources_non_forked/vim-go/test/gopath_test.vim
Normal file
@ -0,0 +1,55 @@
|
||||
fun! Test_Detect_Gopath() abort
|
||||
let l:gopath = $GOPATH
|
||||
try
|
||||
let g:go_autodetect_gopath = 1
|
||||
let l:tmp = go#util#tempdir("pathdetect")
|
||||
let l:tmp2 = go#util#tempdir("pathdetect-nogodep")
|
||||
|
||||
call mkdir(l:tmp . '/subdir', 'p')
|
||||
call mkdir(l:tmp . '/Godeps/_workspace', 'p')
|
||||
|
||||
exe ':e ' . l:tmp . '/a.go'
|
||||
call assert_equal(l:tmp . '/Godeps/_workspace:' . l:gopath, $GOPATH)
|
||||
|
||||
exe ':e ' . l:tmp . '/not-a-go-file'
|
||||
call assert_equal(l:gopath, $GOPATH)
|
||||
|
||||
exe ':e ' . l:tmp . '/subdir/a.go'
|
||||
call assert_equal(l:tmp . '/Godeps/_workspace:' . l:gopath, $GOPATH)
|
||||
|
||||
exec ':e ' . l:tmp2 . '/a.go'
|
||||
call assert_equal(l:gopath, $GOPATH)
|
||||
finally
|
||||
let g:go_autodetect_gopath = 0
|
||||
call delete(l:tmp, 'rf')
|
||||
call delete(l:tmp2, 'rf')
|
||||
endtry
|
||||
endfun
|
||||
|
||||
fun! Test_Detect_Gopath_disabled() abort
|
||||
let l:gopath = $GOPATH
|
||||
try
|
||||
let g:go_autodetect_gopath = 0
|
||||
let l:tmp = go#util#tempdir("pathdetect")
|
||||
let l:tmp2 = go#util#tempdir("pathdetect-nogodep")
|
||||
|
||||
call mkdir(l:tmp . '/subdir', 'p')
|
||||
call mkdir(l:tmp . '/Godeps/_workspace', 'p')
|
||||
|
||||
exe ':e ' . l:tmp . '/a.go'
|
||||
call assert_equal(l:gopath, $GOPATH)
|
||||
|
||||
exe ':e ' . l:tmp . '/not-a-go-file'
|
||||
call assert_equal(l:gopath, $GOPATH)
|
||||
|
||||
exe ':e ' . l:tmp . '/subdir/a.go'
|
||||
call assert_equal(l:gopath, $GOPATH)
|
||||
|
||||
exec ':e ' . l:tmp2 . '/a.go'
|
||||
call assert_equal(l:gopath, $GOPATH)
|
||||
finally
|
||||
let g:go_autodetect_gopath = 0
|
||||
call delete(l:tmp, 'rf')
|
||||
call delete(l:tmp2, 'rf')
|
||||
endtry
|
||||
endfun
|
Reference in New Issue
Block a user