From ce65aaadc89075765f931ad7faf67dd95257fd82 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 15 Apr 2023 18:10:01 +0800 Subject: [PATCH] fix(github): load github-issue only when `has('python')` --- autoload/SpaceVim/layers/github.vim | 70 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/autoload/SpaceVim/layers/github.vim b/autoload/SpaceVim/layers/github.vim index 86d884eda..823d94315 100644 --- a/autoload/SpaceVim/layers/github.vim +++ b/autoload/SpaceVim/layers/github.vim @@ -35,18 +35,18 @@ function! SpaceVim#layers#github#plugins() abort return [ - \ [g:_spacevim_root_dir . 'bundle/github-issues.vim', {'merged' : 0}], + \ [g:_spacevim_root_dir . 'bundle/github-issues.vim', {'merged' : 0, 'if' : has('python')}], \ [g:_spacevim_root_dir . 'bundle/vim-github-dashboard', { \ 'merged' : 0, \ 'if' : has('ruby'), \ }], - \ ['tyru/open-browser-github.vim', { - \ 'depends': 'open-browser.vim', - \ 'on_cmd': ['OpenGithubFile', 'OpenGithubIssue', 'OpenGithubPullReq'], - \ }], - \ [g:_spacevim_root_dir . 'bundle/github.vim', {'merged' : 0}], - \ ['lambdalisue/vim-gista', {'merged' : 0}], - \ ] + \ ['tyru/open-browser-github.vim', { + \ 'depends': 'open-browser.vim', + \ 'on_cmd': ['OpenGithubFile', 'OpenGithubIssue', 'OpenGithubPullReq'], + \ }], + \ [g:_spacevim_root_dir . 'bundle/github.vim', {'merged' : 0}], + \ ['lambdalisue/vim-gista', {'merged' : 0}], + \ ] endfunction function! SpaceVim#layers#github#config() abort @@ -55,13 +55,13 @@ function! SpaceVim#layers#github#config() abort \ 'name' : '+VCS/git', \ }) - if !exists('g:_spacevim_mappings_space.g.h') - let g:_spacevim_mappings_space.g.h = {'name' : ''} - endif - let l:h_submenu_name = SpaceVim#layers#isLoaded('git') ? '+GitHub/Hunks' : '+GitHub' - let g:_spacevim_mappings_space.g.h['name'] = l:h_submenu_name + if !exists('g:_spacevim_mappings_space.g.h') + let g:_spacevim_mappings_space.g.h = {'name' : ''} + endif + let l:h_submenu_name = SpaceVim#layers#isLoaded('git') ? '+GitHub/Hunks' : '+GitHub' + let g:_spacevim_mappings_space.g.h['name'] = l:h_submenu_name - let g:_spacevim_mappings_space.g.g = { 'name': '+Gist' } + let g:_spacevim_mappings_space.g.g = { 'name': '+Gist' } " @todo remove the username " autoload to set default username @@ -75,8 +75,10 @@ function! SpaceVim#layers#github#config() abort " provides more powerful completion. let g:github_issues_no_omni = 1 - call SpaceVim#mapping#space#def('nnoremap', ['g', 'h', 'i'], 'Gissues', - \ 'show issues', 1) + if has('python') + call SpaceVim#mapping#space#def('nnoremap', ['g', 'h', 'i'], 'Gissues', + \ 'show issues', 1) + endif "" }}} if has('ruby') @@ -107,22 +109,22 @@ function! SpaceVim#layers#github#health() abort endfunction function! s:update_stared_repo_list() abort - if empty(g:spacevim_github_username) - call SpaceVim#logger#warn('You need to set g:spacevim_github_username') - return 0 - endif - let cache_file = expand('~/.data/github' . g:spacevim_github_username) - if filereadable(cache_file) - let repos = json_encode(readfile(cache_file, '')[0]) - else - let repos = github#api#users#GetStarred(g:spacevim_github_username) - echom writefile([json_decode(repos)], cache_file, '') - endif + if empty(g:spacevim_github_username) + call SpaceVim#logger#warn('You need to set g:spacevim_github_username') + return 0 + endif + let cache_file = expand('~/.data/github' . g:spacevim_github_username) + if filereadable(cache_file) + let repos = json_encode(readfile(cache_file, '')[0]) + else + let repos = github#api#users#GetStarred(g:spacevim_github_username) + echom writefile([json_decode(repos)], cache_file, '') + endif - for repo in repos - let description = repo.full_name . repeat(' ', 40 - len(repo.full_name)) . repo.description - let cmd = 'OpenBrowser ' . repo.html_url - call add(g:unite_source_menu_menus.MyStarredrepos.command_candidates, [description,cmd]) - endfor - return 1 -endf + for repo in repos + let description = repo.full_name . repeat(' ', 40 - len(repo.full_name)) . repo.description + let cmd = 'OpenBrowser ' . repo.html_url + call add(g:unite_source_menu_menus.MyStarredrepos.command_candidates, [description,cmd]) + endfor + return 1 + endf