1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 08:00:04 +08:00

fix(layer): fix all unknown functions

This commit is contained in:
Eric Wong 2024-06-25 10:26:31 +08:00
parent 864ac61848
commit 282e3d5902
37 changed files with 381 additions and 33 deletions

View File

@ -1744,7 +1744,7 @@ function! s:parser_argv() abort
" if use embed nvim
" for exmaple: neovim-qt
" or only run vim/neovim without argvs
if len(v:argv) == 1
if len(v:argv) == 1 || (len(v:argv) == 2 && index(v:argv, '--embed') == 1)
return [0]
elseif index(v:argv, '--embed') !=# -1
if v:argv[-1] =~# '/$'

View File

@ -146,7 +146,7 @@ endfunction
"}}}
function! SpaceVim#default#layers() abort
call SpaceVim#logger#debug('init default layer list.')
call SpaceVim#logger#info('init default layer list.')
call SpaceVim#layers#load('autocomplete')
call SpaceVim#layers#load('checkers')
call SpaceVim#layers#load('format')
@ -156,10 +156,11 @@ function! SpaceVim#default#layers() abort
call SpaceVim#layers#load('core#banner')
call SpaceVim#layers#load('core#statusline')
call SpaceVim#layers#load('core#tabline')
call SpaceVim#logger#info('layer list init done')
endfunction
function! SpaceVim#default#keyBindings() abort
call SpaceVim#logger#debug('init default key bindings.')
call SpaceVim#logger#info('init default key bindings.')
xnoremap <silent> <Leader>y :<C-u>call clipboard#yank()<cr>
nnoremap <expr> <Leader>p clipboard#paste('p')
nnoremap <expr> <Leader>P clipboard#paste('P')
@ -271,7 +272,7 @@ function! SpaceVim#default#keyBindings() abort
nnoremap <silent><M-5> :<C-u>call <SID>tobur(5)<CR>
nnoremap <silent><M-Right> :<C-U>call <SID>tobur("next")<CR>
nnoremap <silent><M-Left> :<C-U>call <SID>tobur("prev")<CR>
call SpaceVim#logger#info('default key binding init done')
endfunction
fu! s:tobur(num) abort

View File

@ -74,10 +74,12 @@ function! SpaceVim#layers#load(layer, ...) abort
elseif empty(a:layer) || type(a:layer) !=# type('')
return
endif
call SpaceVim#logger#info('load layer:' . a:layer)
let loadable = 1
try
let loadable = SpaceVim#layers#{a:layer}#loadable()
catch /^Vim\%((\a\+)\)\=:E117/
call SpaceVim#logger#info(a:layer . ' layer do not implement loadable function')
endtry
if index(s:enabled_layers, a:layer) == -1
if loadable
@ -94,6 +96,7 @@ function! SpaceVim#layers#load(layer, ...) abort
call SpaceVim#layers#{a:layer}#set_variable(a:1)
let s:layers_vars[a:layer] = a:1
catch /^Vim\%((\a\+)\)\=:E117/
call SpaceVim#logger#info(a:layer . ' layer do not implement set_variable function')
endtry
endif
if a:0 > 0 && type(a:1) == 1
@ -101,6 +104,7 @@ function! SpaceVim#layers#load(layer, ...) abort
call SpaceVim#layers#load(l)
endfor
endif
call SpaceVim#logger#info('layer loaded.')
endfunction
function! SpaceVim#layers#disable(layer) abort

View File

@ -21,6 +21,10 @@ scriptencoding utf-8
" SPC g . version control transient state
" <
if exists('s:CMP')
finish
endif
let s:CMP = SpaceVim#api#import('vim#compatible')
let s:enable_gtm_status = 0
@ -512,6 +516,12 @@ function! s:git_transient_state() abort
call state.open()
endfunction
function! SpaceVim#layers#VersionControl#loadable() abort
return 1
endfunction
" function() wrapper {{{
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:_function(fstr) abort

View File

@ -313,5 +313,9 @@ endfunction
function! s:restore_sequence_delay() abort
let &timeoutlen = s:timeoutlen
endfunction
function! SpaceVim#layers#autocomplete#loadable() abort
return 1
endfunction
" vim:set et sw=2 cc=80:

View File

@ -67,3 +67,9 @@ function! SpaceVim#layers#chat#health() abort
return 1
endfunction
function! SpaceVim#layers#chat#loadable() abort
return 1
endfunction

View File

@ -64,6 +64,12 @@ function! SpaceVim#layers#checkers#plugins() abort
return plugins
endfunction
function! SpaceVim#layers#checkers#loadable() abort
return 1
endfunction
function! SpaceVim#layers#checkers#set_variable(var) abort
let s:show_cursor_error = get(a:var, 'show_cursor_error', 1)

View File

@ -41,6 +41,10 @@
"
" SpaceVim is not gonna fix them since these should be in charge of each author.
if exists('s:JSON')
finish
endif
let s:JSON = SpaceVim#api#import('data#json')
function! SpaceVim#layers#colorscheme#plugins() abort
@ -170,6 +174,12 @@ function! SpaceVim#layers#colorscheme#health() abort
return 1
endfunction
function! SpaceVim#layers#colorscheme#loadable() abort
return 1
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:_function(fstr) abort

View File

@ -1223,4 +1223,10 @@ function! s:close_current_tab() abort
endif
endfunction
function! SpaceVim#layers#core#loadable() abort
return 1
endfunction
" vim:set et sw=2 cc=80:

View File

@ -242,4 +242,16 @@ function! SpaceVim#layers#core#banner#health() abort
return 1
endfunction
function! SpaceVim#layers#core#banner#loadable() abort
return 1
endfunction
function! SpaceVim#layers#core#banner#plugins() abort
return []
endfunction
" vim:set et sw=2:

View File

@ -131,6 +131,18 @@ if has('nvim-0.10.0')
return v:lua.require('spacevim.plugin.statusline').health()
endfunction
function! SpaceVim#layers#core#statusline#loadable() abort
return 1
endfunction
function! SpaceVim#layers#core#statusline#plugins() abort
return []
endfunction
finish
endif

View File

@ -89,6 +89,91 @@ endif
let g:_spacevim_tabline_loaded = 1
let s:enable_default_mappings = 1
if has('nvim-0.9.0')
function! SpaceVim#layers#core#tabline#get() abort
return v:lua.require('spacevim.plugin.tabline').get()
endfunction
function! SpaceVim#layers#core#tabline#config() abort
lua require('spacevim.plugin.tabline').enable()
set tabline=%!v:lua.require('spacevim.plugin.tabline').get()
augroup SpaceVim_tabline
autocmd!
autocmd ColorScheme * lua require('spacevim.plugin.tabline').def_colors()
augroup END
if s:enable_default_mappings
nnoremap <silent> <C-S-Left> <cmd>lua require('spacevim.plugin.tabline').move_to_previous()<CR>
nnoremap <silent> <C-S-Right> <cmd>lua require('spacevim.plugin.tabline').move_to_next()<CR>
endif
let shift_keys = {
\ '1': '!',
\ '2': '@',
\ '3': '#',
\ '4': '$',
\ '5': '%',
\ '6': '^',
\ '7': '&',
\ '8': '*',
\ '9': '(',
\ '0': ')'
\}
for i in range(1, 20)
let key = i % 10
if i > 10
let key = shift_keys[string(key)]
endif
exe "call SpaceVim#mapping#def('nmap <silent>', '<leader>" . key
\ . "', ':call SpaceVim#layers#core#tabline#jump("
\ . i . ")<cr>', 'Switch to airline tab " . i
\ . "', '', 'tabline index " . i . "')"
endfor
endfunction
function! SpaceVim#layers#core#tabline#jump(id, ...) abort
call SpaceVim#logger#info(a:id)
call SpaceVim#logger#info(string(a:000))
lua require('spacevim.plugin.tabline').jump(vim.api.nvim_eval('a:id'))
endfunction
function! SpaceVim#layers#core#tabline#def_colors() abort
call v:lua.require('spacevim.plugin.tabline').def_colors()
endfunction
function! SpaceVim#layers#core#tabline#health() abort
call SpaceVim#layers#core#tabline#config()
return 1
endfunction
function! SpaceVim#layers#core#tabline#loadable() abort
return 1
endfunction
function! SpaceVim#layers#core#tabline#plugins() abort
return []
endfunction
function! SpaceVim#layers#core#tabline#set_variable(var) abort
let s:enable_default_mappings = get(a:var, 'enable_default_mappings', s:enable_default_mappings)
endfunction
function! SpaceVim#layers#core#tabline#get_options() abort
return ['enable_default_mappings']
endfunction
finish
endif
" loadding APIs {{{
let s:MESSLETTERS = SpaceVim#api#import('messletters')
let s:FILE = SpaceVim#api#import('file')
@ -122,7 +207,6 @@ let [s:lsep , s:rsep] = ['', '']
let [s:ilsep , s:irsep] = ['', '']
let s:enable_default_mappings = 1
function! s:get_no_empty(a, b) abort
if empty(a:a)
@ -566,18 +650,6 @@ function! SpaceVim#layers#core#tabline#get() abort
endfunction
function! SpaceVim#layers#core#tabline#config() abort
if has('nvim-0.9.5')
lua require('spacevim.plugin.tabline').enable()
set tabline=%!v:lua.require('spacevim.plugin.tabline').get()
augroup SpaceVim_tabline
autocmd!
autocmd ColorScheme * lua require('spacevim.plugin.tabline').def_colors()
augroup END
if s:enable_default_mappings
nnoremap <silent> <C-S-Left> <cmd>lua require('spacevim.plugin.tabline').move_to_previous()<CR>
nnoremap <silent> <C-S-Right> <cmd>lua require('spacevim.plugin.tabline').move_to_next()<CR>
endif
else
let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow'])
let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_iseparator, s:separators['arrow'])
set tabline=%!SpaceVim#layers#core#tabline#get()
@ -591,7 +663,6 @@ function! SpaceVim#layers#core#tabline#config() abort
nnoremap <silent> <C-S-Right> :call <SID>move_tabpage(1)<CR>
endif
endif
let shift_keys = {
\ '1': '!',
\ '2': '@',
@ -622,10 +693,6 @@ endfunction
function! SpaceVim#layers#core#tabline#jump(id, ...) abort
call SpaceVim#logger#info(a:id)
call SpaceVim#logger#info(string(a:000))
if has('nvim-0.9.5')
lua require('spacevim.plugin.tabline').jump(vim.api.nvim_eval('a:id'))
return
endif
if len(s:shown_items) >= a:id
let item = s:shown_items[a:id - 1]
let mouse = get(a:000, 1, '')
@ -683,6 +750,18 @@ function! SpaceVim#layers#core#tabline#health() abort
return 1
endfunction
function! SpaceVim#layers#core#tabline#loadable() abort
return 1
endfunction
function! SpaceVim#layers#core#tabline#plugins() abort
return []
endfunction
function! SpaceVim#layers#core#tabline#set_variable(var) abort
let s:enable_default_mappings = get(a:var, 'enable_default_mappings', s:enable_default_mappings)
endfunction

View File

@ -1069,3 +1069,9 @@ endfunction
function! SpaceVim#layers#edit#add_ft_head_tamplate(ft, tamp) abort
call extend(s:ft_head_tp, {a:ft : a:tamp})
endfunction
function! SpaceVim#layers#edit#loadable() abort
return 1
endfunction

View File

@ -40,6 +40,30 @@ function! SpaceVim#layers#foldsearch#health() abort
return 1
endfunction
function! SpaceVim#layers#foldsearch#plugins() abort
return []
endfunction
function! SpaceVim#layers#foldsearch#set_variable(var) abort
endfunction
function! SpaceVim#layers#foldsearch#get_options() abort
return []
endfunction
function! SpaceVim#layers#foldsearch#loadable() abort
return 1
endfunction
let s:filename = expand('<sfile>:~')
let s:lnum = expand('<slnum>') + 2
function! SpaceVim#layers#foldsearch#config()

View File

@ -134,3 +134,9 @@ function! s:format() abort
endif
endif
endfunction
function! SpaceVim#layers#format#loadable() abort
return 1
endfunction

View File

@ -194,4 +194,10 @@ function! SpaceVim#layers#git#health() abort
endfunction
function! SpaceVim#layers#git#loadable() abort
return 1
endfunction
" vim:set et sw=2 cc=80:

View File

@ -37,16 +37,16 @@ function! SpaceVim#layers#github#plugins() abort
return [
\ [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}],
\ ]
\ '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}],
\ ]
endfunction
function! SpaceVim#layers#github#config() abort
@ -127,4 +127,15 @@ function! s:update_stared_repo_list() abort
call add(g:unite_source_menu_menus.MyStarredrepos.command_candidates, [description,cmd])
endfor
return 1
endf
endfunction
function! SpaceVim#layers#github#set_variable(var) abort
endfunction
function! SpaceVim#layers#github#loadable() abort
return 1
endfunction

View File

@ -114,6 +114,12 @@ function! SpaceVim#layers#gtags#health() abort
return 1
endfunction
function! SpaceVim#layers#gtags#loadable() abort
return 1
endfunction
function! SpaceVim#layers#gtags#get_options() abort
return ['gtagslabel', 'ctags_bin']

View File

@ -524,3 +524,9 @@ function! SpaceVim#layers#lang#c#health() abort
call SpaceVim#layers#lang#c#config()
return 1
endfunction
function! SpaceVim#layers#lang#c#loadable() abort
return 1
endfunction

View File

@ -167,3 +167,9 @@ function! SpaceVim#layers#lang#clojure#health() abort
call SpaceVim#layers#lang#clojure#config()
return 1
endfunction
function! SpaceVim#layers#lang#clojure#loadable() abort
return 1
endfunction

View File

@ -393,3 +393,9 @@ function! SpaceVim#layers#lang#java#health() abort
call SpaceVim#layers#lang#java#config()
return 1
endfunction
function! SpaceVim#layers#lang#java#loadable() abort
return 1
endfunction

View File

@ -174,3 +174,9 @@ function! SpaceVim#layers#lang#lua#health() abort
call SpaceVim#layers#lang#lua#config()
return 1
endfunction
function! SpaceVim#layers#lang#lua#loadable() abort
return 1
endfunction

View File

@ -225,3 +225,9 @@ function! SpaceVim#layers#lang#markdown#health() abort
call SpaceVim#layers#lang#markdown#config()
return 1
endfunction
function! SpaceVim#layers#lang#markdown#loadable() abort
return 1
endfunction

View File

@ -344,3 +344,8 @@ function! SpaceVim#layers#lang#python#health() abort
call SpaceVim#layers#lang#python#config()
return 1
endfunction
function! SpaceVim#layers#lang#python#loadable() abort
return 1
endfunction

View File

@ -48,6 +48,13 @@ endif
" <
"
function! SpaceVim#layers#lang#scheme#plugins() abort
return []
endfunction
function! SpaceVim#layers#lang#scheme#config() abort
if s:scheme_dialect ==# 'mit-scheme'
if has('win32')
@ -106,3 +113,9 @@ function! SpaceVim#layers#lang#scheme#health() abort
call SpaceVim#layers#lang#scheme#config()
return 1
endfunction
function! SpaceVim#layers#lang#scheme#loadable() abort
return 1
endfunction

View File

@ -92,3 +92,9 @@ function! SpaceVim#layers#lang#sh#health() abort
call SpaceVim#layers#lang#sh#config()
return 1
endfunction
function! SpaceVim#layers#lang#sh#loadable() abort
return 1
endfunction

View File

@ -83,3 +83,8 @@ function! SpaceVim#layers#lang#sql#health() abort
call SpaceVim#layers#lang#sql#plugins()
return 1
endfunction
function! SpaceVim#layers#lang#sql#loadable() abort
return 1
endfunction

View File

@ -33,3 +33,15 @@ function! SpaceVim#layers#lang#toml#health() abort
call SpaceVim#layers#lang#toml#plugins()
return 1
endfunction
function! SpaceVim#layers#lang#toml#loadable() abort
return 1
endfunction
function! SpaceVim#layers#lang#toml#set_variable(var) abort
endfunction

View File

@ -218,3 +218,9 @@ function! SpaceVim#layers#lang#vim#health() abort
call SpaceVim#layers#lang#vim#config()
return 1
endfunction
function! SpaceVim#layers#lang#vim#loadable() abort
return 1
endfunction

View File

@ -52,6 +52,12 @@ function! SpaceVim#layers#lsp#health() abort
return 1
endfunction
function! SpaceVim#layers#lsp#loadable() abort
return 1
endfunction
function! SpaceVim#layers#lsp#setup() abort
lua require("spacevim.lsp").setup(

View File

@ -304,3 +304,9 @@ function! SpaceVim#layers#shell#health() abort
call SpaceVim#layers#shell#config()
return 1
endfunction
function! SpaceVim#layers#shell#loadable() abort
return 1
endfunction

View File

@ -387,3 +387,15 @@ function! SpaceVim#layers#telescope#health() abort
return 1
endfunction
function! SpaceVim#layers#telescope#set_variable(var) abort
endfunction
function! SpaceVim#layers#telescope#get_options() abort
return []
endfunction

View File

@ -73,4 +73,10 @@ function! SpaceVim#layers#tools#health() abort
return 1
endfunction
function! SpaceVim#layers#tools#loadable() abort
return 1
endfunction
" vim:set et sw=2 cc=80:

View File

@ -106,6 +106,24 @@ function! SpaceVim#layers#tools#mpv#health() abort
return 1
endfunction
function! SpaceVim#layers#tools#mpv#loadable() abort
return 1
endfunction
function! SpaceVim#layers#tools#mpv#plugins() abort
return []
endfunction
function! SpaceVim#layers#tools#mpv#get_options() abort
return ['musics_directory', 'mpv_interpreter']
endfunction
let s:playId = 0
fu! s:handler(id, data, event) abort
if a:event ==# 'exit'

View File

@ -721,3 +721,9 @@ function! s:reduce_font() abort
let &guifont = substitute(&guifont, ':h\d\+', ':h' . font_size, '')
sleep 100m
endfunction
function! SpaceVim#layers#ui#loadable() abort
return 1
endfunction

View File

@ -26,3 +26,9 @@ function! SpaceVim#layers#vim#health() abort
call SpaceVim#layers#vim#config()
return 1
endfunction
function! SpaceVim#layers#vim#loadable() abort
return 1
endfunction

View File

@ -58,6 +58,7 @@ function! s:getLayerPlugins(layer) abort
try
let p = SpaceVim#layers#{a:layer}#plugins()
catch /^Vim\%((\a\+)\)\=:E117/
call SpaceVim#logger#info(a:layer . ' layer do not implement plugins function')
endtry
return p
endfunction
@ -67,6 +68,7 @@ function! s:loadLayerConfig(layer) abort
try
call SpaceVim#layers#{a:layer}#config()
catch /^Vim\%((\a\+)\)\=:E117/
call SpaceVim#logger#info(a:layer . ' layer do not implement config function')
endtry
endfunction