1
0
Fork 0
mirror of synced 2024-11-23 09:15:35 -05:00
ultimate-vim/sources_non_forked/vim-go/autoload/go/issue.vim

53 lines
1.4 KiB
VimL
Raw Normal View History

2018-12-17 06:28:27 -05:00
" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
2018-06-14 06:31:12 -04:00
let s:templatepath = go#util#Join(expand('<sfile>:p:h:h:h'), '.github', 'ISSUE_TEMPLATE.md')
function! go#issue#New() abort
2019-05-17 10:09:13 -04:00
let body = go#uri#Encode(s:issuebody())
2018-06-14 06:31:12 -04:00
let url = "https://github.com/fatih/vim-go/issues/new?body=" . l:body
2019-03-08 06:04:56 -05:00
call go#util#OpenBrowser(l:url)
2018-06-14 06:31:12 -04:00
endfunction
function! s:issuebody() abort
let lines = readfile(s:templatepath)
let rtrimpat = '[[:space:]]\+$'
let body = []
for l in lines
let body = add(body, l)
2019-08-22 11:36:17 -04:00
if l =~ '^<!-- :version'
2018-06-14 06:31:12 -04:00
redir => out
silent version
redir END
let body = extend(body, split(out, "\n")[0:2])
2019-08-22 11:36:17 -04:00
elseif l =~ '^<!-- go version -->'
2018-06-14 06:31:12 -04:00
let [out, err] = go#util#Exec(['go', 'version'])
let body = add(body, substitute(l:out, rtrimpat, '', ''))
2019-08-22 11:36:17 -04:00
elseif l =~ '^<!-- go env -->'
2018-06-14 06:31:12 -04:00
let [out, err] = go#util#Exec(['go', 'env'])
let body = add(body, substitute(l:out, rtrimpat, '', ''))
endif
endfor
2019-08-22 11:36:17 -04:00
let body = add(body, "#### vim-go configuration:\n<details><summary>vim-go configuration</summary><br><pre>")
for k in keys(g:)
if k =~ '^go_'
let body = add(body, 'g:' . k . ' = ' . string(get(g:, k)))
endif
endfor
let body = add(body, '</pre></details>')
2018-06-14 06:31:12 -04:00
return join(body, "\n")
endfunction
2018-12-17 06:28:27 -05:00
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
2018-06-14 06:31:12 -04:00
" vim: sw=2 ts=2 et