mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:40:06 +08:00
Fix compare error (#4001)
This commit is contained in:
parent
e3f1819930
commit
78f47b69d2
@ -1384,8 +1384,6 @@ function! SpaceVim#end() abort
|
|||||||
let g:leaderGuide_max_size = 15
|
let g:leaderGuide_max_size = 15
|
||||||
call SpaceVim#plugins#load()
|
call SpaceVim#plugins#load()
|
||||||
|
|
||||||
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
|
|
||||||
|
|
||||||
call SpaceVim#util#loadConfig('general.vim')
|
call SpaceVim#util#loadConfig('general.vim')
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@ function! SpaceVim#layers#leaderf#config() abort
|
|||||||
|
|
||||||
let g:Lf_Extensions = get(g:, 'Lf_Extensions', {})
|
let g:Lf_Extensions = get(g:, 'Lf_Extensions', {})
|
||||||
let g:Lf_Extensions = {
|
let g:Lf_Extensions = {
|
||||||
\ 'neomru': {
|
\ 'neomru': {
|
||||||
\ 'source': string(s:_function('s:neomru', 1))[10:-3],
|
\ 'source': string(s:_function('s:neomru', 1))[10:-3],
|
||||||
\ 'accept': string(s:_function('s:neomru_acp', 1))[10:-3],
|
\ 'accept': string(s:_function('s:neomru_acp', 1))[10:-3],
|
||||||
\ 'supports_name_only': 1,
|
\ 'supports_name_only': 1,
|
||||||
\ 'supports_multi': 0,
|
\ 'supports_multi': 0,
|
||||||
\ },
|
\ },
|
||||||
\}
|
\}
|
||||||
|
|
||||||
let g:Lf_Extensions.menu =
|
let g:Lf_Extensions.menu =
|
||||||
\ {
|
\ {
|
||||||
@ -318,7 +318,7 @@ function! s:register_acp(line, args) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:neomru(...) abort
|
function! s:neomru(...) abort
|
||||||
return neomru#_gather_file_candidates()
|
return neomru#_gather_file_candidates()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:neomru_acp(line, args) abort
|
function! s:neomru_acp(line, args) abort
|
||||||
@ -378,9 +378,23 @@ function! s:neoyank_acp(line, args) abort
|
|||||||
call append(0, split(line, '\\n'))
|
call append(0, split(line, '\\n'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
let s:menu_high = {}
|
||||||
|
call extend(s:menu_high, {'Projects' :
|
||||||
|
\ {
|
||||||
|
\ 'highlights_def' : {
|
||||||
|
\ 'Lf_menu_projects_time' : '<\d\+-\d\+-\d\+\s\d\+:\d\+:\d\+>'
|
||||||
|
\ },
|
||||||
|
\ 'highlights_cmd' : [
|
||||||
|
\ 'hi def link Lf_menu_projects_time Comment'
|
||||||
|
\ ],
|
||||||
|
\ }
|
||||||
|
\ })
|
||||||
|
|
||||||
function! s:menu(name) abort
|
function! s:menu(name) abort
|
||||||
|
let menu_name = a:name['--name'][0]
|
||||||
let s:menu_action = {}
|
let s:menu_action = {}
|
||||||
let menu = get(g:unite_source_menu_menus, a:name['--name'][0], {})
|
let menu = get(g:unite_source_menu_menus, menu_name, {})
|
||||||
if has_key(menu, 'command_candidates')
|
if has_key(menu, 'command_candidates')
|
||||||
let rt = []
|
let rt = []
|
||||||
for item in menu.command_candidates
|
for item in menu.command_candidates
|
||||||
@ -393,6 +407,16 @@ function! s:menu(name) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#layers#leaderf#run_menu(name) abort
|
||||||
|
call s:run_menu(a:name)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:run_menu(name) abort
|
||||||
|
let g:Lf_Extensions.menu.highlights_def = get(get(s:menu_high, a:name, {}), 'highlights_def', {})
|
||||||
|
let g:Lf_Extensions.menu.highlights_cmd = get(get(s:menu_high, a:name, {}), 'highlights_cmd', {})
|
||||||
|
exe printf('Leaderf menu --name %s', a:name)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:accept(line, args) abort
|
function! s:accept(line, args) abort
|
||||||
let action = get(s:menu_action, a:line, '')
|
let action = get(s:menu_action, a:line, '')
|
||||||
exe action
|
exe action
|
||||||
@ -558,7 +582,7 @@ function! s:defind_fuzzy_finder() abort
|
|||||||
\ 'Definition: ' . s:file . ':' . lnum,
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
nnoremap <silent> <Leader>f<Space> :<C-u>Leaderf menu --name CustomKeyMaps<CR>
|
nnoremap <silent> <Leader>f<Space> :<C-u>call <SID>run_menu('CustomKeyMaps')<CR>
|
||||||
let g:_spacevim_mappings.f['[SPC]'] = ['Leaderf menu --name CustomKeyMaps',
|
let g:_spacevim_mappings.f['[SPC]'] = ['Leaderf menu --name CustomKeyMaps',
|
||||||
\ 'fuzzy find custom key bindings',
|
\ 'fuzzy find custom key bindings',
|
||||||
\ [
|
\ [
|
||||||
@ -567,7 +591,7 @@ function! s:defind_fuzzy_finder() abort
|
|||||||
\ 'Definition: ' . s:file . ':' . lnum,
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
nnoremap <silent> <Leader>fp :<C-u>Leaderf menu --name AddedPlugins<CR>
|
nnoremap <silent> <Leader>fp :<C-u>call <SID>run_menu('AddedPlugins')<CR>
|
||||||
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
let g:_spacevim_mappings.f.p = ['Leaderf menu --name AddedPlugins',
|
let g:_spacevim_mappings.f.p = ['Leaderf menu --name AddedPlugins',
|
||||||
\ 'fuzzy find vim packages',
|
\ 'fuzzy find vim packages',
|
||||||
|
@ -22,6 +22,7 @@ let s:LOGGER =SpaceVim#logger#derive('rooter')
|
|||||||
let s:TIME = SpaceVim#api#import('time')
|
let s:TIME = SpaceVim#api#import('time')
|
||||||
let s:JSON = SpaceVim#api#import('data#json')
|
let s:JSON = SpaceVim#api#import('data#json')
|
||||||
let s:LIST = SpaceVim#api#import('data#list')
|
let s:LIST = SpaceVim#api#import('data#list')
|
||||||
|
let s:VIM = SpaceVim#api#import('vim')
|
||||||
|
|
||||||
function! s:update_rooter_patterns() abort
|
function! s:update_rooter_patterns() abort
|
||||||
let s:project_rooter_patterns = filter(copy(g:spacevim_project_rooter_patterns), 'v:val !~# "^!"')
|
let s:project_rooter_patterns = filter(copy(g:spacevim_project_rooter_patterns), 'v:val !~# "^!"')
|
||||||
@ -49,7 +50,10 @@ function! s:load_cache() abort
|
|||||||
call s:LOGGER.info('Load projects cache from: ' . s:project_cache_path)
|
call s:LOGGER.info('Load projects cache from: ' . s:project_cache_path)
|
||||||
let cache_context = join(readfile(s:project_cache_path, ''), '')
|
let cache_context = join(readfile(s:project_cache_path, ''), '')
|
||||||
if !empty(cache_context)
|
if !empty(cache_context)
|
||||||
let s:project_paths = s:JSON.json_decode(cache_context)
|
let cache_object = s:JSON.json_decode(cache_context)
|
||||||
|
if s:VIM.is_dict(cache_object)
|
||||||
|
let s:project_paths = filter(cache_object, '!empty(v:key)')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call s:LOGGER.info('projects cache file does not exists!')
|
call s:LOGGER.info('projects cache file does not exists!')
|
||||||
@ -95,7 +99,11 @@ function! s:sort_by_opened_time() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:compare_time(d1, d2) abort
|
function! s:compare_time(d1, d2) abort
|
||||||
return s:project_paths[a:d2].opened_time - s:project_paths[a:d1].opened_time
|
let proj1 = get(s:project_paths, a:d1, {})
|
||||||
|
let proj1time = get(proj1, 'opened_time', 0)
|
||||||
|
let proj2 = get(s:project_paths, a:d2, {})
|
||||||
|
let proj2time = get(proj2, 'opened_time', 0)
|
||||||
|
return proj2time - proj1time
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +118,7 @@ function! SpaceVim#plugins#projectmanager#list() abort
|
|||||||
elseif SpaceVim#layers#isLoaded('fzf')
|
elseif SpaceVim#layers#isLoaded('fzf')
|
||||||
FzfMenu Projects
|
FzfMenu Projects
|
||||||
elseif SpaceVim#layers#isLoaded('leaderf')
|
elseif SpaceVim#layers#isLoaded('leaderf')
|
||||||
Leaderf menu --name Projects
|
call SpaceVim#layers#leaderf#run_menu('Projects')
|
||||||
else
|
else
|
||||||
call SpaceVim#logger#warn('fuzzy find layer is needed to find project!')
|
call SpaceVim#logger#warn('fuzzy find layer is needed to find project!')
|
||||||
endif
|
endif
|
||||||
@ -143,6 +151,9 @@ function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort
|
|||||||
\ 'name' : fnamemodify(getcwd(), ':t'),
|
\ 'name' : fnamemodify(getcwd(), ':t'),
|
||||||
\ 'opened_time' : localtime()
|
\ 'opened_time' : localtime()
|
||||||
\ }
|
\ }
|
||||||
|
if empty(project.path)
|
||||||
|
return
|
||||||
|
endif
|
||||||
call s:cache_project(project)
|
call s:cache_project(project)
|
||||||
let g:_spacevim_project_name = project.name
|
let g:_spacevim_project_name = project.name
|
||||||
let b:_spacevim_project_name = g:_spacevim_project_name
|
let b:_spacevim_project_name = g:_spacevim_project_name
|
||||||
|
@ -6,7 +6,7 @@ let g:Lf_StlColorscheme = get(g:, 'spacevim_colorscheme', 'default')
|
|||||||
" disable default mru, and use neomru by default
|
" disable default mru, and use neomru by default
|
||||||
augroup LeaderF_Mru
|
augroup LeaderF_Mru
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType leaderf setlocal nonumber
|
autocmd FileType leaderf setlocal nonumber nowrap
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" change the leaderf Colorscheme automatically
|
" change the leaderf Colorscheme automatically
|
||||||
|
Loading…
Reference in New Issue
Block a user