diff --git a/autoload/SpaceVim/issue.vim b/autoload/SpaceVim/issue.vim index 215ff752a..4ba569065 100644 --- a/autoload/SpaceVim/issue.vim +++ b/autoload/SpaceVim/issue.vim @@ -1,35 +1,55 @@ function! SpaceVim#issue#report() abort - call s:open() + call s:open() endfunction function! s:open() abort - exe 'tabnew ' . tempname() . '/issue_report.md' - call setline(1, s:template()) - w + exe 'tabnew ' . tempname() . '/issue_report.md' + let b:spacevim_issue_template = 1 + call setline(1, s:template()) + w endfunction function! s:template() abort - let info = [ - \ '', - \ '## Expected behavior, english is recommend', - \ '', - \ '## Environment Information', - \ '', - \ '- OS:' . SpaceVim#api#import('system').name(), - \ '- vim version:' . (has('nvim') ? '' : v:version), - \ '- neovim version:' . (has('nvim') ? v:version : ''), - \ '', - \ '## The reproduce ways from Vim starting (Required!)', - \ '', - \ '## Output of the `:SPDebugInfo!`', - \ ''] - \ + split(SpaceVim#api#import('vim#compatible').execute(':SPDebugInfo'), "\n") + - \ [ - \ '## Screenshots', - \ '', - \ 'If you have any screenshots for this issue please upload here. BTW you can use https://asciinema.org/ for recording video in terminal.' - \ ] - return info + let info = [ + \ '', + \ '## Expected behavior, english is recommend', + \ '', + \ '## Environment Information', + \ '', + \ '- OS:' . SpaceVim#api#import('system').name(), + \ '- vim version:' . (has('nvim') ? '' : v:version), + \ '- neovim version:' . (has('nvim') ? v:version : ''), + \ '', + \ '## The reproduce ways from Vim starting (Required!)', + \ '', + \ '## Output of the `:SPDebugInfo!`', + \ ''] + \ + split(SpaceVim#api#import('vim#compatible').execute(':SPDebugInfo'), "\n") + + \ [ + \ '## Screenshots', + \ '', + \ 'If you have any screenshots for this issue please upload here. BTW you can use https://asciinema.org/ for recording video in terminal.' + \ ] + return info endfunction + + +function! SpaceVim#issue#new() + if get(b:, 'spacevim_issue_template', 0) == 1 + let title = input('Issue title:') + let username = input('github username:') + let password = input('github password:') + let issue = {'title' : title, + \ 'body' : join(getline(1, '$'), "\n"), + \ } + let response = github#api#issues#Create('SpaceVim', 'SpaceVim', username, password, issue) + let g:wsd = response + if has_key(response, 'html_url') + echo 'Issue created done: ' . response.html_url + else + echo 'Failed to create issue, please check the username and password' + endif + endif +endfunction