mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -3,9 +3,22 @@ if !exists("g:go_jump_to_error")
|
||||
endif
|
||||
|
||||
function! go#cmd#Run(bang, ...)
|
||||
let goFiles = '"' . join(go#tool#Files(), '" "') . '"'
|
||||
|
||||
if IsWin()
|
||||
exec '!go run ' . goFiles
|
||||
if v:shell_error
|
||||
redraws! | echon "vim-go: [run] " | echohl ErrorMsg | echon "FAILED"| echohl None
|
||||
else
|
||||
redraws! | echon "vim-go: [run] " | echohl Function | echon "SUCCESS"| echohl None
|
||||
endif
|
||||
|
||||
return
|
||||
endif
|
||||
|
||||
let default_makeprg = &makeprg
|
||||
if !len(a:000)
|
||||
let &makeprg = "go run " . join(go#tool#Files(), ' ')
|
||||
let &makeprg = 'go run ' . goFiles
|
||||
else
|
||||
let &makeprg = "go run " . expand(a:1)
|
||||
endif
|
||||
@ -25,8 +38,8 @@ function! go#cmd#Run(bang, ...)
|
||||
endfunction
|
||||
|
||||
function! go#cmd#Install(...)
|
||||
let pkgs = join(a:000, ' ')
|
||||
let command = 'go install '.pkgs
|
||||
let pkgs = join(a:000, '" "')
|
||||
let command = 'go install "' . pkgs . '"'
|
||||
let out = go#tool#ExecuteInDir(command)
|
||||
if v:shell_error
|
||||
call go#tool#ShowErrors(out)
|
||||
@ -41,13 +54,13 @@ function! go#cmd#Install(...)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! go#cmd#Build(bang)
|
||||
function! go#cmd#Build(bang, ...)
|
||||
let default_makeprg = &makeprg
|
||||
let gofiles = join(go#tool#Files(), ' ')
|
||||
let gofiles = join(go#tool#Files(), '" "')
|
||||
if v:shell_error
|
||||
let &makeprg = "go build . errors"
|
||||
else
|
||||
let &makeprg = "go build -o /dev/null " . gofiles
|
||||
let &makeprg = "go build -o /dev/null " . join(a:000, ' ') . ' "' . gofiles . '"'
|
||||
endif
|
||||
|
||||
echon "vim-go: " | echohl Identifier | echon "building ..."| echohl None
|
||||
@ -60,7 +73,7 @@ function! go#cmd#Build(bang)
|
||||
if g:go_jump_to_error
|
||||
cc 1 "jump to first error if there is any
|
||||
endif
|
||||
else
|
||||
else
|
||||
redraws! | echon "vim-go: " | echohl Function | echon "[build] SUCCESS"| echohl None
|
||||
endif
|
||||
endif
|
||||
@ -75,21 +88,22 @@ function! go#cmd#Test(...)
|
||||
endif
|
||||
|
||||
echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None
|
||||
redraw
|
||||
let out = go#tool#ExecuteInDir(command)
|
||||
if v:shell_error
|
||||
call go#tool#ShowErrors(out)
|
||||
cwindow
|
||||
let errors = getqflist()
|
||||
if !empty(errors)
|
||||
if g:go_jump_to_error
|
||||
cc 1 "jump to first error if there is any
|
||||
endif
|
||||
endif
|
||||
echon "vim-go: " | echohl ErrorMsg | echon "[test] FAIL" | echohl None
|
||||
else
|
||||
call setqflist([])
|
||||
endif
|
||||
cwindow
|
||||
|
||||
let errors = getqflist()
|
||||
if !empty(errors)
|
||||
if g:go_jump_to_error
|
||||
cc 1 "jump to first error if there is any
|
||||
endif
|
||||
else
|
||||
redraw | echon "vim-go: " | echohl Function | echon "[test] PASS" | echohl None
|
||||
cwindow
|
||||
echon "vim-go: " | echohl Function | echon "[test] PASS" | echohl None
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -43,9 +43,9 @@ fu! s:gocodeCommand(cmd, preargs, args)
|
||||
let a:preargs[i] = s:gocodeShellescape(a:preargs[i])
|
||||
endfor
|
||||
|
||||
let bin_path = go#tool#BinPath(g:go_gocode_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
let bin_path = go#tool#BinPath(g:go_gocode_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
let result = s:system(printf('%s %s %s %s', bin_path, join(a:preargs), a:cmd, join(a:args)))
|
||||
@ -96,7 +96,7 @@ function! go#complete#GetInfo()
|
||||
|
||||
" no candidates are found
|
||||
if len(out) == 1
|
||||
return
|
||||
return ""
|
||||
endif
|
||||
|
||||
" only one candiate is found
|
||||
@ -119,14 +119,16 @@ function! go#complete#GetInfo()
|
||||
if len(filtered) == 1
|
||||
return filtered[0]
|
||||
endif
|
||||
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! go#complete#Info()
|
||||
let result = go#complete#GetInfo()
|
||||
if len(result) > 0
|
||||
if !empty(result)
|
||||
echo "vim-go: " | echohl Function | echon result | echohl None
|
||||
endif
|
||||
endfunction!
|
||||
endfunction
|
||||
|
||||
fu! go#complete#Complete(findstart, base)
|
||||
"findstart = 1 when we need to get the text length
|
||||
|
@ -13,15 +13,15 @@ function! go#def#Jump(...)
|
||||
let arg = a:1
|
||||
endif
|
||||
|
||||
let bin_path = go#tool#BinPath(g:go_godef_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
let bin_path = go#tool#BinPath(g:go_godef_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
let command = bin_path . " -f=" . expand("%:p") . " -i " . shellescape(arg)
|
||||
|
||||
" get output of godef
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), "\n"))
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), LineEnding()))
|
||||
|
||||
" jump to it
|
||||
call s:godefJump(out, "")
|
||||
@ -31,15 +31,15 @@ endfunction
|
||||
function! go#def#JumpMode(mode)
|
||||
let arg = s:getOffset()
|
||||
|
||||
let bin_path = go#tool#BinPath(g:go_godef_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
let bin_path = go#tool#BinPath(g:go_godef_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
let command = bin_path . " -f=" . expand("%:p") . " -i " . shellescape(arg)
|
||||
|
||||
" get output of godef
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), "\n"))
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), LineEnding()))
|
||||
|
||||
call s:godefJump(out, a:mode)
|
||||
endfunction
|
||||
@ -51,7 +51,7 @@ function! s:getOffset()
|
||||
let offs = line2byte(pos[0]) + pos[1] - 2
|
||||
else
|
||||
let c = pos[1]
|
||||
let buf = line('.') == 1 ? "" : (join(getline(1, pos[0] - 1), "\n") . "\n")
|
||||
let buf = line('.') == 1 ? "" : (join(getline(1, pos[0] - 1), LineEnding()) . LineEnding())
|
||||
let buf .= c == 1 ? "" : getline(pos[0])[:c-2]
|
||||
let offs = len(iconv(buf, &encoding, "utf-8"))
|
||||
endif
|
||||
@ -66,7 +66,7 @@ function! s:godefJump(out, mode)
|
||||
let &errorformat = "%f:%l:%c"
|
||||
|
||||
if a:out =~ 'godef: '
|
||||
let out=substitute(a:out, '\n$', '', '')
|
||||
let out=substitute(a:out, LineEnding() . '$', '', '')
|
||||
echom out
|
||||
else
|
||||
let parts = split(a:out, ':')
|
||||
@ -85,7 +85,7 @@ function! s:godefJump(out, mode)
|
||||
let &switchbuf = "usetab"
|
||||
|
||||
if bufloaded(fileName) == 0
|
||||
tab split
|
||||
tab split
|
||||
endif
|
||||
else
|
||||
if a:mode == "split"
|
||||
@ -96,11 +96,10 @@ function! s:godefJump(out, mode)
|
||||
endif
|
||||
|
||||
" jump to file now
|
||||
ll 1
|
||||
sil ll 1
|
||||
normal zz
|
||||
|
||||
let &switchbuf = old_switchbuf
|
||||
end
|
||||
let &errorformat = old_errorformat
|
||||
endfunction
|
||||
|
||||
|
@ -35,7 +35,7 @@ function! s:godocWord(args)
|
||||
if !executable('godoc')
|
||||
echohl WarningMsg
|
||||
echo "godoc command not found."
|
||||
echo " install with: go get code.google.com/p/go.tools/cmd/godoc"
|
||||
echo " install with: go get golang.org/x/tools/cmd/godoc"
|
||||
echohl None
|
||||
return []
|
||||
endif
|
||||
@ -51,7 +51,7 @@ function! s:godocWord(args)
|
||||
let words = a:args
|
||||
endif
|
||||
|
||||
if !len(words)
|
||||
if !len(words)
|
||||
return []
|
||||
endif
|
||||
|
||||
@ -85,7 +85,7 @@ function! go#doc#OpenBrowser(...)
|
||||
call go#tool#OpenBrowser(godoc_url)
|
||||
endfunction
|
||||
|
||||
function! go#doc#Open(mode, ...)
|
||||
function! go#doc#Open(newmode, mode, ...)
|
||||
let pkgs = s:godocWord(a:000)
|
||||
if empty(pkgs)
|
||||
return
|
||||
@ -102,10 +102,14 @@ function! go#doc#Open(mode, ...)
|
||||
return -1
|
||||
endif
|
||||
|
||||
call s:GodocView(a:mode, content)
|
||||
call s:GodocView(a:newmode, a:mode, content)
|
||||
|
||||
if exported_name == ''
|
||||
silent! normal gg
|
||||
return -1
|
||||
endif
|
||||
|
||||
" jump to the specified name
|
||||
|
||||
if search('^func ' . exported_name . '(')
|
||||
silent! normal zt
|
||||
return -1
|
||||
@ -125,11 +129,11 @@ function! go#doc#Open(mode, ...)
|
||||
silent! normal gg
|
||||
endfunction
|
||||
|
||||
function! s:GodocView(position, content)
|
||||
function! s:GodocView(newposition, position, content)
|
||||
" reuse existing buffer window if it exists otherwise create a new one
|
||||
if !bufexists(s:buf_nr)
|
||||
execute a:position
|
||||
file `="[Godoc]"`
|
||||
execute a:newposition
|
||||
sil file `="[Godoc]"`
|
||||
let s:buf_nr = bufnr('%')
|
||||
elseif bufwinnr(s:buf_nr) == -1
|
||||
execute a:position
|
||||
@ -149,9 +153,9 @@ function! s:GodocView(position, content)
|
||||
setlocal iskeyword-=-
|
||||
|
||||
setlocal modifiable
|
||||
%delete _
|
||||
%delete _
|
||||
call append(0, split(a:content, "\n"))
|
||||
$delete _
|
||||
sil $delete _
|
||||
setlocal nomodifiable
|
||||
endfunction
|
||||
|
||||
|
@ -2,13 +2,19 @@ if !exists("g:go_errcheck_bin")
|
||||
let g:go_errcheck_bin = "errcheck"
|
||||
endif
|
||||
|
||||
function! go#errcheck#Run() abort
|
||||
let bin_path = go#tool#BinPath(g:go_errcheck_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
function! go#errcheck#Run(...) abort
|
||||
if a:0 == 0
|
||||
let package = go#package#ImportPath(expand('%:p:h'))
|
||||
else
|
||||
let package = a:1
|
||||
end
|
||||
|
||||
let bin_path = go#tool#BinPath(g:go_errcheck_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
let out = system(bin_path . ' ' . shellescape(expand('%:p:h')))
|
||||
let out = system(bin_path . ' ' . package)
|
||||
if v:shell_error
|
||||
let errors = []
|
||||
let mx = '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)'
|
||||
@ -16,7 +22,7 @@ function! go#errcheck#Run() abort
|
||||
let tokens = matchlist(line, mx)
|
||||
|
||||
if !empty(tokens)
|
||||
call add(errors, {"filename": tokens[1],
|
||||
call add(errors, {"filename": expand(DefaultGoPath() . "/src/" . tokens[1]),
|
||||
\"lnum": tokens[2],
|
||||
\"col": tokens[3],
|
||||
\"text": tokens[4]})
|
||||
|
@ -39,6 +39,10 @@ if !exists('g:go_fmt_options')
|
||||
let g:go_fmt_options = ''
|
||||
endif
|
||||
|
||||
if !exists("g:go_fmt_experimental")
|
||||
let g:go_fmt_experimental = 0
|
||||
endif
|
||||
|
||||
let s:got_fmt_error = 0
|
||||
|
||||
" we have those problems :
|
||||
@ -57,12 +61,15 @@ function! go#fmt#Format(withGoimport)
|
||||
let l:tmpname=tempname()
|
||||
call writefile(getline(1,'$'), l:tmpname)
|
||||
|
||||
" save our undo file to be restored after we are done. This is needed to
|
||||
" prevent an additional undo jump due to BufWritePre auto command and also
|
||||
" restore 'redo' history because it's getting being destroyed every
|
||||
" BufWritePre
|
||||
let tmpundofile=tempname()
|
||||
exe 'wundo! ' . tmpundofile
|
||||
|
||||
if g:go_fmt_experimental == 1
|
||||
" save our undo file to be restored after we are done. This is needed to
|
||||
" prevent an additional undo jump due to BufWritePre auto command and also
|
||||
" restore 'redo' history because it's getting being destroyed every
|
||||
" BufWritePre
|
||||
let tmpundofile=tempname()
|
||||
exe 'wundo! ' . Tmpundofile
|
||||
endif
|
||||
|
||||
" get the command first so we can test it
|
||||
let fmt_command = g:go_fmt_command
|
||||
@ -128,9 +135,11 @@ function! go#fmt#Format(withGoimport)
|
||||
cwindow
|
||||
endif
|
||||
|
||||
" restore our undo history
|
||||
silent! exe 'rundo ' . tmpundofile
|
||||
call delete(tmpundofile)
|
||||
if g:go_fmt_experimental == 1
|
||||
" restore our undo history
|
||||
silent! exe 'rundo ' . tmpundofile
|
||||
call delete(tmpundofile)
|
||||
endif
|
||||
|
||||
" restore our cursor/windows positions
|
||||
call delete(l:tmpname)
|
||||
|
@ -3,8 +3,7 @@
|
||||
"
|
||||
" Part of this plugin was taken directly from the oracle repo, however it's
|
||||
" massively changed for a better integration into vim-go. Thanks Alan Donovan
|
||||
" for the first iteration based on quickfix! - fatih arslan
|
||||
"
|
||||
" for the first iteration based on quickfix! - Fatih Arslan
|
||||
"
|
||||
|
||||
if !exists("g:go_oracle_bin")
|
||||
@ -89,8 +88,6 @@ func! s:RunOracle(mode, selected) range abort
|
||||
" unfortunaly oracle outputs a very long stack trace that is not
|
||||
" parsable to show the real error. But the main issue is usually the
|
||||
" package which doesn't build.
|
||||
" echo out
|
||||
" redraw | echon 'vim-go: could not run static analyser (does it build?)'
|
||||
redraw | echon "vim-go: " | echohl Statement | echon out | echohl None
|
||||
return {}
|
||||
else
|
||||
@ -139,12 +136,12 @@ function! go#oracle#Implements(selected)
|
||||
endfor
|
||||
|
||||
" open a window and put the result
|
||||
call go#ui#OpenWindow(result)
|
||||
call go#ui#OpenWindow("Implements", result)
|
||||
|
||||
" define some buffer related mappings:
|
||||
"
|
||||
" go to definition when hit enter
|
||||
nnoremap <buffer> <CR> :<C-u>call go#ui#OpenDefinition()<CR>
|
||||
nnoremap <buffer> <CR> :<C-u>call go#ui#OpenDefinition("implements")<CR>
|
||||
" close the window when hit ctrl-c
|
||||
nnoremap <buffer> <c-c> :<C-u>call go#ui#CloseWindow()<CR>
|
||||
endfunction
|
||||
@ -182,7 +179,43 @@ endfunction
|
||||
" Show possible targets of selected function call
|
||||
function! go#oracle#Callees(selected)
|
||||
let out = s:RunOracle('callees', a:selected)
|
||||
echo out
|
||||
if empty(out)
|
||||
return
|
||||
endif
|
||||
|
||||
" be sure the callees object exists which contains the position and names
|
||||
" of the callees, before we continue
|
||||
if !has_key(out, "callees")
|
||||
return
|
||||
endif
|
||||
|
||||
" get the callees list
|
||||
if has_key(out.callees, "callees")
|
||||
let callees = out.callees.callees
|
||||
else
|
||||
redraw | echon "vim-go: " | echon "no callees available"| echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
let title = "Call targets:"
|
||||
|
||||
" start to populate our buffer content
|
||||
let result = [title, ""]
|
||||
|
||||
for calls in callees
|
||||
let line = calls.name . "\t" . calls.pos
|
||||
call add(result, line)
|
||||
endfor
|
||||
|
||||
" open a window and put the result
|
||||
call go#ui#OpenWindow("Callees", result)
|
||||
|
||||
" define some buffer related mappings:
|
||||
"
|
||||
" go to definition when hit enter
|
||||
nnoremap <buffer> <CR> :<C-u>call go#ui#OpenDefinition("call targets")<CR>
|
||||
" close the window when hit ctrl-c
|
||||
nnoremap <buffer> <c-c> :<C-u>call go#ui#CloseWindow()<CR>
|
||||
endfunction
|
||||
|
||||
" Show possible callers of selected function
|
||||
|
@ -19,9 +19,9 @@ function! go#rename#Rename(...)
|
||||
return
|
||||
endif
|
||||
|
||||
let fname = expand('%:p:t')
|
||||
let fname = resolve(expand('%:p:t'))
|
||||
let pos = s:getpos(line('.'), col('.'))
|
||||
let cmd = printf('%s -offset %s:#%d -to %s', bin_path, shellescape(fname), pos, to)
|
||||
let cmd = printf('%s -offset %s -to %s', shellescape(bin_path), shellescape(printf('%s:#%d', fname, pos)), shellescape(to))
|
||||
|
||||
let out = go#tool#ExecuteInDir(cmd)
|
||||
|
||||
|
15
sources_non_forked/vim-go/autoload/go/textobj.vim
Normal file
15
sources_non_forked/vim-go/autoload/go/textobj.vim
Normal file
@ -0,0 +1,15 @@
|
||||
if !exists("g:go_textobj_enabled")
|
||||
let g:go_textobj_enabled = 1
|
||||
endif
|
||||
|
||||
function! go#textobj#Function(mode)
|
||||
if search('^\s*func .*{$', 'Wce', line('.')) <= 0
|
||||
\ && search('^\s*func .*{$', 'bWce') <= 0
|
||||
return
|
||||
endif
|
||||
if a:mode == 'a'
|
||||
normal! Va{V
|
||||
else " a:mode == 'i'
|
||||
normal! Vi{V
|
||||
endif
|
||||
endfunction
|
@ -1,18 +1,15 @@
|
||||
function! go#tool#Files()
|
||||
if has ("win32")
|
||||
let command = 'go list -f "{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\n\"}}{{end}}"'
|
||||
if IsWin()
|
||||
let command = 'go list -f "{{range $f := .GoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}"'
|
||||
else
|
||||
" let command = "go list -f $'{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}\n{{end}}'"
|
||||
|
||||
let command = "go list -f '{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}'"
|
||||
|
||||
let command = "go list -f '{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}'"
|
||||
endif
|
||||
let out = go#tool#ExecuteInDir(command)
|
||||
return split(out, '\n')
|
||||
endfunction
|
||||
|
||||
function! go#tool#Deps()
|
||||
if has ("win32")
|
||||
if IsWin()
|
||||
let command = 'go list -f "{{range $f := .Deps}}{{$f}}{{printf \"\n\"}}{{end}}"'
|
||||
else
|
||||
let command = "go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}'"
|
||||
@ -23,7 +20,7 @@ endfunction
|
||||
|
||||
function! go#tool#Imports()
|
||||
let imports = {}
|
||||
if has ("win32")
|
||||
if IsWin()
|
||||
let command = 'go list -f "{{range $f := .Imports}}{{$f}}{{printf \"\n\"}}{{end}}"'
|
||||
else
|
||||
let command = "go list -f $'{{range $f := .Imports}}{{$f}}\n{{end}}'"
|
||||
@ -35,7 +32,7 @@ function! go#tool#Imports()
|
||||
endif
|
||||
|
||||
for package_path in split(out, '\n')
|
||||
let package_name = fnamemodify(package_path, ":t")
|
||||
let package_name = fnamemodify(package_path, ":t:r")
|
||||
let imports[package_name] = package_path
|
||||
endfor
|
||||
|
||||
@ -45,8 +42,12 @@ endfunction
|
||||
function! go#tool#ShowErrors(out)
|
||||
let errors = []
|
||||
for line in split(a:out, '\n')
|
||||
let fatalerrors = matchlist(line, '^\(fatal error:.*\)$')
|
||||
let tokens = matchlist(line, '^\s*\(.\{-}\):\(\d\+\):\s*\(.*\)')
|
||||
if !empty(tokens)
|
||||
|
||||
if !empty(fatalerrors)
|
||||
call add(errors, {"text": fatalerrors[1]})
|
||||
elseif !empty(tokens)
|
||||
call add(errors, {"filename" : expand("%:p:h:") . "/" . tokens[1],
|
||||
\"lnum": tokens[2],
|
||||
\"text": tokens[3]})
|
||||
@ -120,7 +121,7 @@ function! go#tool#BinPath(binpath)
|
||||
" append our GOBIN and GOPATH paths and be sure they can be found there...
|
||||
" let us search in our GOBIN and GOPATH paths
|
||||
let old_path = $PATH
|
||||
let $PATH = $PATH . ":" .go_bin_path
|
||||
let $PATH = $PATH . PathSep() .go_bin_path
|
||||
|
||||
if !executable(binpath)
|
||||
echo "vim-go: could not find '" . basename . "'. Run :GoInstallBinaries to fix it."
|
||||
@ -140,7 +141,7 @@ endfunction
|
||||
function! s:get_browser_command()
|
||||
let go_play_browser_command = get(g:, 'go_play_browser_command', '')
|
||||
if go_play_browser_command == ''
|
||||
if has('win32') || has('win64')
|
||||
if IsWin()
|
||||
let go_play_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%'
|
||||
elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin'
|
||||
let go_play_browser_command = 'open %URL%'
|
||||
|
@ -1,11 +1,11 @@
|
||||
let s:buf_nr = -1
|
||||
|
||||
"OpenWindow opens a new scratch window and put's the content into the window
|
||||
function! go#ui#OpenWindow(content)
|
||||
function! go#ui#OpenWindow(title, content)
|
||||
" reuse existing buffer window if it exists otherwise create a new one
|
||||
if !bufexists(s:buf_nr)
|
||||
execute 'botright new'
|
||||
file `="[Implements]"`
|
||||
file `="[" . a:title . "]"`
|
||||
let s:buf_nr = bufnr('%')
|
||||
elseif bufwinnr(s:buf_nr) == -1
|
||||
execute 'botright new'
|
||||
@ -17,9 +17,9 @@ function! go#ui#OpenWindow(content)
|
||||
|
||||
" Keep minimum height to 10, if there is more just increase it that it
|
||||
" occupies all results
|
||||
let implements_height = 10
|
||||
if len(a:content) < implements_height
|
||||
exe 'resize ' . implements_height
|
||||
let buffer_height = 10
|
||||
if len(a:content) < buffer_height
|
||||
exe 'resize ' . buffer_height
|
||||
else
|
||||
exe 'resize ' . len(a:content)
|
||||
endif
|
||||
@ -58,11 +58,11 @@ endfunction
|
||||
|
||||
" OpenDefinition parses the current line and jumps to it by openening a new
|
||||
" tab
|
||||
function! go#ui#OpenDefinition()
|
||||
function! go#ui#OpenDefinition(filter)
|
||||
let curline = getline('.')
|
||||
|
||||
" don't touch our first line and any blank line
|
||||
if curline =~ "implements" || curline =~ "^$"
|
||||
" don't touch our first line or any blank line
|
||||
if curline =~ a:filter || curline =~ "^$"
|
||||
" supress information about calling this function
|
||||
echo ""
|
||||
return
|
||||
|
Reference in New Issue
Block a user