mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -373,7 +373,7 @@ function! go#cmd#Generate(bang, ...) abort
|
||||
|
||||
let errors = go#list#Get(l:listtype)
|
||||
call go#list#Window(l:listtype, len(errors))
|
||||
if !empty(errors)
|
||||
if !empty(errors)
|
||||
if !a:bang
|
||||
call go#list#JumpToFirst(l:listtype)
|
||||
endif
|
||||
|
@ -27,11 +27,11 @@ function! s:gocodeCommand(cmd, preargs, args) abort
|
||||
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),
|
||||
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)
|
||||
\ )
|
||||
|
||||
@ -55,7 +55,7 @@ endfunction
|
||||
|
||||
let s:optionsEnabled = 0
|
||||
function! s:gocodeEnableOptions() abort
|
||||
if s:optionsEnabled
|
||||
if s:optionsEnabled
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -34,7 +34,7 @@ function! go#coverage#Buffer(bang, ...) abort
|
||||
try
|
||||
execute cd . fnameescape(expand("%:p:h"))
|
||||
if empty(glob("*_test.go"))
|
||||
call go#util#EchoError("no tests files available")
|
||||
call go#util#EchoError("no test files available")
|
||||
return
|
||||
endif
|
||||
finally
|
||||
@ -89,8 +89,8 @@ function! go#coverage#Clear() abort
|
||||
|
||||
if exists("s:toggle") | let s:toggle = 0 | endif
|
||||
|
||||
" remove the autocmd we defined
|
||||
if exists("#BufWinLeave#<buffer>")
|
||||
" remove the autocmd we defined
|
||||
if exists("#BufWinLeave#<buffer>")
|
||||
autocmd! BufWinLeave <buffer>
|
||||
endif
|
||||
endfunction
|
||||
@ -160,8 +160,8 @@ function! go#coverage#genmatch(cov) abort
|
||||
" example: foo.go:92.2,92.65 1 0
|
||||
if a:cov.startline == a:cov.endline
|
||||
call add(matches, {
|
||||
\ 'group': color,
|
||||
\ 'pos': [[a:cov.startline, a:cov.startcol, a:cov.endcol - a:cov.startcol]],
|
||||
\ 'group': color,
|
||||
\ 'pos': [[a:cov.startline, a:cov.startcol, a:cov.endcol - a:cov.startcol]],
|
||||
\ 'priority': 2,
|
||||
\ })
|
||||
return matches
|
||||
@ -171,8 +171,8 @@ function! go#coverage#genmatch(cov) abort
|
||||
" the line, we assume it is at maximum 200 bytes. I know this is hacky,
|
||||
" but that's only way of fixing the issue
|
||||
call add(matches, {
|
||||
\ 'group': color,
|
||||
\ 'pos': [[a:cov.startline, a:cov.startcol, 200]],
|
||||
\ 'group': color,
|
||||
\ 'pos': [[a:cov.startline, a:cov.startcol, 200]],
|
||||
\ 'priority': 2,
|
||||
\ })
|
||||
|
||||
@ -181,16 +181,16 @@ function! go#coverage#genmatch(cov) abort
|
||||
while start_line < a:cov.endline
|
||||
let start_line += 1
|
||||
call add(matches, {
|
||||
\ 'group': color,
|
||||
\ 'pos': [[start_line]],
|
||||
\ 'group': color,
|
||||
\ 'pos': [[start_line]],
|
||||
\ 'priority': 2,
|
||||
\ })
|
||||
endwhile
|
||||
|
||||
" finally end columns
|
||||
call add(matches, {
|
||||
\ 'group': color,
|
||||
\ 'pos': [[a:cov.endline, a:cov.endcol-1]],
|
||||
\ 'group': color,
|
||||
\ 'pos': [[a:cov.endline, a:cov.endcol-1]],
|
||||
\ 'priority': 2,
|
||||
\ })
|
||||
|
||||
|
@ -209,7 +209,7 @@ function! go#def#StackUI() abort
|
||||
let prefix = " "
|
||||
endif
|
||||
|
||||
call add(stackOut, printf("%s %d %s|%d col %d|%s",
|
||||
call add(stackOut, printf("%s %d %s|%d col %d|%s",
|
||||
\ prefix, i+1, entry["file"], entry["line"], entry["col"], entry["ident"]))
|
||||
let i += 1
|
||||
endwhile
|
||||
|
@ -32,10 +32,10 @@ function! go#doc#OpenBrowser(...) abort
|
||||
let import = out["import"]
|
||||
let name = out["name"]
|
||||
let decl = out["decl"]
|
||||
|
||||
|
||||
let godoc_url = "https://godoc.org/" . import
|
||||
if decl !~ "^package"
|
||||
let godoc_url .= "#" . name
|
||||
let godoc_url .= "#" . name
|
||||
endif
|
||||
|
||||
echo godoc_url
|
||||
@ -92,13 +92,20 @@ function! s:GodocView(newposition, position, content) abort
|
||||
execute bufwinnr(s:buf_nr) . 'wincmd w'
|
||||
endif
|
||||
|
||||
" cap buffer height to 20, but resize it for smaller contents
|
||||
let max_height = 20
|
||||
let content_height = len(split(a:content, "\n"))
|
||||
if content_height > max_height
|
||||
exe 'resize ' . max_height
|
||||
if a:position == "split"
|
||||
" cap buffer height to 20, but resize it for smaller contents
|
||||
let max_height = 20
|
||||
let content_height = len(split(a:content, "\n"))
|
||||
if content_height > max_height
|
||||
exe 'resize ' . max_height
|
||||
else
|
||||
exe 'resize ' . content_height
|
||||
endif
|
||||
else
|
||||
exe 'resize ' . content_height
|
||||
" set a sane maximum width for vertical splits. In this case the minimum
|
||||
" that fits the godoc for package http without extra linebreaks and line
|
||||
" numbers on
|
||||
exe 'vertical resize 84'
|
||||
endif
|
||||
|
||||
setlocal filetype=godoc
|
||||
|
@ -77,7 +77,7 @@ function! go#fmt#Format(withGoimport) abort
|
||||
if go#util#ShellError() == 0
|
||||
call go#fmt#update_file(l:tmpname, expand('%'))
|
||||
elseif g:go_fmt_fail_silently == 0
|
||||
let errors = s:parse_errors(out)
|
||||
let errors = s:parse_errors(expand('%'), out)
|
||||
call s:show_errors(errors)
|
||||
endif
|
||||
|
||||
@ -102,7 +102,7 @@ function! go#fmt#Format(withGoimport) abort
|
||||
endfunction
|
||||
|
||||
" update_file updates the target file with the given formatted source
|
||||
function! go#fmt#update_file(source, target)
|
||||
function! go#fmt#update_file(source, target)
|
||||
" remove undo point caused via BufWritePre
|
||||
try | silent undojoin | catch | endtry
|
||||
|
||||
@ -133,8 +133,8 @@ endfunction
|
||||
|
||||
" run runs the gofmt/goimport command for the given source file and returns
|
||||
" the the output of the executed command. Target is the real file to be
|
||||
" formated.
|
||||
function! go#fmt#run(bin_name, source, target)
|
||||
" formated.
|
||||
function! go#fmt#run(bin_name, source, target)
|
||||
let cmd = s:fmt_cmd(a:bin_name, a:source, a:target)
|
||||
if cmd[0] == "goimports"
|
||||
" change GOPATH too, so goimports can pick up the correct library
|
||||
@ -168,10 +168,9 @@ function! s:fmt_cmd(bin_name, source, target)
|
||||
" start constructing the command
|
||||
let cmd = [bin_path]
|
||||
call add(cmd, "-w")
|
||||
call extend(cmd, split(g:go_fmt_options, " "))
|
||||
|
||||
if a:bin_name != "goimports"
|
||||
call extend(cmd, split(g:go_fmt_options, " "))
|
||||
else
|
||||
if a:bin_name == "goimports"
|
||||
" lazy check if goimports support `-srcdir`. We should eventually remove
|
||||
" this in the future
|
||||
if !exists('b:goimports_vendor_compatible')
|
||||
@ -196,7 +195,7 @@ function! s:fmt_cmd(bin_name, source, target)
|
||||
endfunction
|
||||
|
||||
" parse_errors parses the given errors and returns a list of parsed errors
|
||||
function! s:parse_errors(content) abort
|
||||
function! s:parse_errors(filename, content) abort
|
||||
let splitted = split(a:content, '\n')
|
||||
|
||||
" list of errors to be put into location list
|
||||
@ -205,6 +204,7 @@ function! s:parse_errors(content) abort
|
||||
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
|
||||
if !empty(tokens)
|
||||
call add(errors,{
|
||||
\"filename": a:filename,
|
||||
\"lnum": tokens[2],
|
||||
\"col": tokens[3],
|
||||
\"text": tokens[4],
|
||||
@ -218,13 +218,13 @@ endfunction
|
||||
" show_errors opens a location list and shows the given errors. If the given
|
||||
" errors is empty, it closes the the location list
|
||||
function! s:show_errors(errors) abort
|
||||
let l:listtype = "locationlist"
|
||||
let l:listtype = "locationlist"
|
||||
if !empty(a:errors)
|
||||
call go#list#Populate(l:listtype, a:errors, 'Format')
|
||||
echohl Error | echomsg "Gofmt returned error" | echohl None
|
||||
endif
|
||||
|
||||
" this closes the window if there are no errors or it opens
|
||||
" this closes the window if there are no errors or it opens
|
||||
" it if there is any
|
||||
call go#list#Window(l:listtype, len(a:errors))
|
||||
endfunction
|
||||
|
@ -25,7 +25,7 @@ function! s:guru_cmd(args) range abort
|
||||
endif
|
||||
|
||||
"return with a warning if the binary doesn't exist
|
||||
let bin_path = go#path#CheckBinPath("guru")
|
||||
let bin_path = go#path#CheckBinPath("guru")
|
||||
if empty(bin_path)
|
||||
return {'err': "bin path not found"}
|
||||
endif
|
||||
@ -41,7 +41,7 @@ function! s:guru_cmd(args) range abort
|
||||
endif
|
||||
|
||||
" enable outputting in json format
|
||||
if format == "json"
|
||||
if format == "json"
|
||||
call add(cmd, "-json")
|
||||
endif
|
||||
|
||||
@ -120,8 +120,6 @@ function! s:sync_guru(args) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
" run, forrest run!!!
|
||||
let command = join(result.cmd, " ")
|
||||
@ -131,8 +129,6 @@ function! s:sync_guru(args) abort
|
||||
let out = go#util#System(command)
|
||||
endif
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
|
||||
if has_key(a:args, 'custom_parse')
|
||||
call a:args.custom_parse(go#util#ShellError(), out)
|
||||
else
|
||||
@ -217,11 +213,17 @@ 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()
|
||||
return s:async_guru(a:args)
|
||||
let res = s:async_guru(a:args)
|
||||
else
|
||||
let res = s:sync_guru(a:args)
|
||||
endif
|
||||
|
||||
return s:sync_guru(a:args)
|
||||
let $GOPATH = old_gopath
|
||||
|
||||
return res
|
||||
endfunction
|
||||
|
||||
" Show 'implements' relation for selected package
|
||||
@ -270,7 +272,7 @@ endfunction
|
||||
function! go#guru#DescribeInfo() abort
|
||||
" json_encode() and friends are introduced with this patch (7.4.1304)
|
||||
" vim: https://groups.google.com/d/msg/vim_dev/vLupTNhQhZ8/cDGIk0JEDgAJ
|
||||
" nvim: https://github.com/neovim/neovim/pull/4131
|
||||
" nvim: https://github.com/neovim/neovim/pull/4131
|
||||
if !exists("*json_decode")
|
||||
call go#util#EchoError("requires 'json_decode'. Update your Vim/Neovim version.")
|
||||
return
|
||||
@ -465,7 +467,7 @@ function! go#guru#SameIds() abort
|
||||
|
||||
" json_encode() and friends are introduced with this patch (7.4.1304)
|
||||
" vim: https://groups.google.com/d/msg/vim_dev/vLupTNhQhZ8/cDGIk0JEDgAJ
|
||||
" nvim: https://github.com/neovim/neovim/pull/4131
|
||||
" nvim: https://github.com/neovim/neovim/pull/4131
|
||||
if !exists("*json_decode")
|
||||
call go#util#EchoError("GoSameIds requires 'json_decode'. Update your Vim/Neovim version.")
|
||||
return
|
||||
@ -547,7 +549,7 @@ function! go#guru#ClearSameIds() abort
|
||||
endfunction
|
||||
|
||||
function! go#guru#ToggleSameIds() abort
|
||||
if len(getmatches()) != 0
|
||||
if len(getmatches()) != 0
|
||||
call go#guru#ClearSameIds()
|
||||
else
|
||||
call go#guru#SameIds()
|
||||
|
@ -18,7 +18,7 @@ function! go#impl#Impl(...) abort
|
||||
return
|
||||
endif
|
||||
elseif a:0 == 1
|
||||
" we assume the user only passed the interface type,
|
||||
" we assume the user only passed the interface type,
|
||||
" i.e: ':GoImpl io.Writer'
|
||||
let receiveType = expand("<cword>")
|
||||
let recv = printf("%s *%s", tolower(receiveType)[0], receiveType)
|
||||
@ -44,7 +44,7 @@ function! go#impl#Impl(...) abort
|
||||
end
|
||||
|
||||
let pos = getpos('.')
|
||||
put =''
|
||||
put =''
|
||||
put =result
|
||||
call setpos('.', pos)
|
||||
endfunction
|
||||
|
@ -109,9 +109,9 @@ endfunction
|
||||
" Golint calls 'golint' on the current directory. Any warnings are populated in
|
||||
" the location list
|
||||
function! go#lint#Golint(...) abort
|
||||
let bin_path = go#path#CheckBinPath(g:go_golint_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
let bin_path = go#path#CheckBinPath(g:go_golint_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
if a:0 == 0
|
||||
@ -280,7 +280,7 @@ function s:lint_job(args)
|
||||
call go#statusline#Update(status_dir, status)
|
||||
|
||||
let errors = go#list#Get(l:listtype)
|
||||
if empty(errors)
|
||||
if empty(errors)
|
||||
call go#list#Window(l:listtype, len(errors))
|
||||
elseif has("patch-7.4.2200")
|
||||
if l:listtype == 'quickfix'
|
||||
|
@ -124,7 +124,7 @@ function! go#list#Type(listtype) abort
|
||||
if g:go_list_type == "locationlist"
|
||||
return "locationlist"
|
||||
elseif g:go_list_type == "quickfix"
|
||||
return "quickfix"
|
||||
return "quickfix"
|
||||
else
|
||||
return a:listtype
|
||||
endif
|
||||
|
@ -70,7 +70,7 @@ function! s:get_visual_selection() abort
|
||||
return join(lines, "\n")
|
||||
endfunction
|
||||
|
||||
" following two functions are from: https://github.com/mattn/gist-vim
|
||||
" following two functions are from: https://github.com/mattn/gist-vim
|
||||
" thanks @mattn
|
||||
function! s:get_browser_command() abort
|
||||
let go_play_browser_command = get(g:, 'go_play_browser_command', '')
|
||||
|
@ -4,7 +4,7 @@
|
||||
" s:statuses is a global reference to all statuses. It stores the statuses per
|
||||
" import paths (map[string]status), where each status is unique per its
|
||||
" type. Current status dict is in form:
|
||||
" {
|
||||
" {
|
||||
" 'desc' : 'Job description',
|
||||
" 'state' : 'Job state, such as success, failure, etc..',
|
||||
" 'type' : 'Job type, such as build, test, etc..'
|
||||
|
206
sources_non_forked/vim-go/autoload/go/tags.vim
Normal file
206
sources_non_forked/vim-go/autoload/go/tags.vim
Normal file
@ -0,0 +1,206 @@
|
||||
function! go#tags#Add(start, end, count, ...) abort
|
||||
let fname = fnamemodify(expand("%"), ':p:gs?\\?/?')
|
||||
if &modified
|
||||
" Write current unsaved buffer to a temp file and use the modified content
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
let fname = l:tmpname
|
||||
endif
|
||||
|
||||
let offset = 0
|
||||
if a:count == -1
|
||||
let offset = go#util#OffsetCursor()
|
||||
endif
|
||||
|
||||
let test_mode = 0
|
||||
call call("go#tags#run", [a:start, a:end, offset, "add", fname, test_mode] + a:000)
|
||||
|
||||
" if exists, delete it as we don't need it anymore
|
||||
if exists("l:tmpname")
|
||||
call delete(l:tmpname)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! go#tags#Remove(start, end, count, ...) abort
|
||||
let fname = fnamemodify(expand("%"), ':p:gs?\\?/?')
|
||||
if &modified
|
||||
" Write current unsaved buffer to a temp file and use the modified content
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
let fname = l:tmpname
|
||||
endif
|
||||
|
||||
let offset = 0
|
||||
if a:count == -1
|
||||
let offset = go#util#OffsetCursor()
|
||||
endif
|
||||
|
||||
let test_mode = 0
|
||||
call call("go#tags#run", [a:start, a:end, offset, "remove", fname, test_mode] + a:000)
|
||||
|
||||
" if exists, delete it as we don't need it anymore
|
||||
if exists("l:tmpname")
|
||||
call delete(l:tmpname)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" run runs gomodifytag. This is an internal test so we can test it
|
||||
function! go#tags#run(start, end, offset, mode, fname, test_mode, ...) abort
|
||||
" do not split this into multiple lines, somehow tests fail in that case
|
||||
let args = {'mode': a:mode,'start': a:start,'end': a:end,'offset': a:offset,'fname': a:fname,'cmd_args': a:000}
|
||||
|
||||
let result = s:create_cmd(args)
|
||||
if has_key(result, 'err')
|
||||
call go#util#EchoError(result.err)
|
||||
return -1
|
||||
endif
|
||||
|
||||
let command = join(result.cmd, " ")
|
||||
|
||||
call go#cmd#autowrite()
|
||||
let out = go#util#System(command)
|
||||
if go#util#ShellError() != 0
|
||||
call go#util#EchoError(out)
|
||||
return
|
||||
endif
|
||||
|
||||
if a:test_mode
|
||||
exe 'edit ' . a:fname
|
||||
endif
|
||||
|
||||
call s:write_out(out)
|
||||
|
||||
if a:test_mode
|
||||
exe 'write! ' . a:fname
|
||||
endif
|
||||
endfunc
|
||||
|
||||
|
||||
" write_out writes back the given output to the current buffer
|
||||
func s:write_out(out) abort
|
||||
" not a json output
|
||||
if a:out[0] !=# '{'
|
||||
return
|
||||
endif
|
||||
|
||||
" nothing to do
|
||||
if empty(a:out) || type(a:out) != type("")
|
||||
return
|
||||
endif
|
||||
|
||||
let result = json_decode(a:out)
|
||||
if type(result) != type({})
|
||||
call go#util#EchoError(printf("malformed output from gomodifytags: %s", a:out))
|
||||
return
|
||||
endif
|
||||
|
||||
let lines = result['lines']
|
||||
let start_line = result['start']
|
||||
let end_line = result['end']
|
||||
|
||||
let index = 0
|
||||
for line in range(start_line, end_line)
|
||||
call setline(line, lines[index])
|
||||
let index += 1
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
|
||||
" create_cmd returns a dict that contains the command to execute gomodifytags
|
||||
func s:create_cmd(args) abort
|
||||
if !exists("*json_decode")
|
||||
return {'err': "requires 'json_decode'. Update your Vim/Neovim version."}
|
||||
endif
|
||||
|
||||
let bin_path = go#path#CheckBinPath('gomodifytags')
|
||||
if empty(bin_path)
|
||||
return {'err': "gomodifytags does not exist"}
|
||||
endif
|
||||
|
||||
let l:start = a:args.start
|
||||
let l:end = a:args.end
|
||||
let l:offset = a:args.offset
|
||||
let l:mode = a:args.mode
|
||||
let l:cmd_args = a:args.cmd_args
|
||||
|
||||
" start constructing the command
|
||||
let cmd = [bin_path]
|
||||
call extend(cmd, ["-format", "json"])
|
||||
call extend(cmd, ["-file", a:args.fname])
|
||||
|
||||
if l:offset != 0
|
||||
call extend(cmd, ["-offset", l:offset])
|
||||
else
|
||||
let range = printf("%d,%d", l:start, l:end)
|
||||
call extend(cmd, ["-line", range])
|
||||
endif
|
||||
|
||||
if l:mode == "add"
|
||||
let l:tags = []
|
||||
let l:options = []
|
||||
|
||||
if !empty(l:cmd_args)
|
||||
for item in l:cmd_args
|
||||
let splitted = split(item, ",")
|
||||
|
||||
" tag only
|
||||
if len(splitted) == 1
|
||||
call add(l:tags, splitted[0])
|
||||
endif
|
||||
|
||||
" options only
|
||||
if len(splitted) == 2
|
||||
call add(l:tags, splitted[0])
|
||||
call add(l:options, printf("%s=%s", splitted[0], splitted[1]))
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" construct options
|
||||
if !empty(l:options)
|
||||
call extend(cmd, ["-add-options", join(l:options, ",")])
|
||||
else
|
||||
" default value
|
||||
if empty(l:tags)
|
||||
let l:tags = ["json"]
|
||||
endif
|
||||
|
||||
" construct tags
|
||||
call extend(cmd, ["-add-tags", join(l:tags, ",")])
|
||||
endif
|
||||
elseif l:mode == "remove"
|
||||
if empty(l:cmd_args)
|
||||
call add(cmd, "-clear-tags")
|
||||
else
|
||||
let l:tags = []
|
||||
let l:options = []
|
||||
for item in l:cmd_args
|
||||
let splitted = split(item, ",")
|
||||
|
||||
" tag only
|
||||
if len(splitted) == 1
|
||||
call add(l:tags, splitted[0])
|
||||
endif
|
||||
|
||||
" options only
|
||||
if len(splitted) == 2
|
||||
call add(l:options, printf("%s=%s", splitted[0], splitted[1]))
|
||||
endif
|
||||
endfor
|
||||
|
||||
" construct tags
|
||||
if !empty(l:tags)
|
||||
call extend(cmd, ["-remove-tags", join(l:tags, ",")])
|
||||
endif
|
||||
|
||||
" construct options
|
||||
if !empty(l:options)
|
||||
call extend(cmd, ["-remove-options", join(l:options, ",")])
|
||||
endif
|
||||
endif
|
||||
else
|
||||
return {'err': printf("unknown mode: %s", l:mode)}
|
||||
endif
|
||||
|
||||
return {'cmd': cmd}
|
||||
endfunc
|
28
sources_non_forked/vim-go/autoload/go/tags_test.vim
Normal file
28
sources_non_forked/vim-go/autoload/go/tags_test.vim
Normal file
@ -0,0 +1,28 @@
|
||||
func Test_add_tags()
|
||||
let input_file = tempname()
|
||||
call writefile(readfile("test-fixtures/tags/add_all_input.go"), input_file)
|
||||
|
||||
let expected = join(readfile("test-fixtures/tags/add_all_golden.go"), "\n")
|
||||
|
||||
" run for offset 40, which is inside the struct
|
||||
call go#tags#run(0, 0, 40, "add", input_file, 1)
|
||||
|
||||
let actual = join(readfile(input_file), "\n")
|
||||
|
||||
call assert_equal(expected, actual)
|
||||
endfunc
|
||||
|
||||
|
||||
func Test_remove_tags()
|
||||
let input_file = tempname()
|
||||
call writefile(readfile("test-fixtures/tags/remove_all_input.go"), input_file)
|
||||
|
||||
let expected = join(readfile("test-fixtures/tags/remove_all_golden.go"), "\n")
|
||||
|
||||
" run for offset 40, which is inside the struct
|
||||
call go#tags#run(0, 0, 40, "remove", input_file, 1)
|
||||
|
||||
let actual = join(readfile(input_file), "\n")
|
||||
|
||||
call assert_equal(expected, actual)
|
||||
endfunc
|
@ -67,7 +67,7 @@ function! go#textobj#Function(mode) abort
|
||||
normal! v
|
||||
call cursor(info.rbrace.line, info.rbrace.col)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
" rest is inner mode, a:mode == 'i'
|
||||
|
||||
|
@ -164,7 +164,7 @@ function! go#tool#Exists(importpath) abort
|
||||
endfunction
|
||||
|
||||
|
||||
" following two functions are from: https://github.com/mattn/gist-vim
|
||||
" following two functions are from: https://github.com/mattn/gist-vim
|
||||
" thanks @mattn
|
||||
function! s:get_browser_command() abort
|
||||
let go_play_browser_command = get(g:, 'go_play_browser_command', '')
|
||||
|
@ -53,7 +53,7 @@ let s:env_cache = {}
|
||||
|
||||
" env returns the go environment variable for the given key. Where key can be
|
||||
" GOARCH, GOOS, GOROOT, etc... It caches the result and returns the cached
|
||||
" version.
|
||||
" version.
|
||||
function! go#util#env(key) abort
|
||||
let l:key = tolower(a:key)
|
||||
if has_key(s:env_cache, l:key)
|
||||
|
Reference in New Issue
Block a user