mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 20:30:05 +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
|
||||
call SpaceVim#plugins#load()
|
||||
|
||||
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
|
||||
|
||||
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 = {
|
||||
\ 'neomru': {
|
||||
\ 'source': string(s:_function('s:neomru', 1))[10:-3],
|
||||
\ 'accept': string(s:_function('s:neomru_acp', 1))[10:-3],
|
||||
\ 'supports_name_only': 1,
|
||||
\ 'supports_multi': 0,
|
||||
\ },
|
||||
\}
|
||||
\ 'neomru': {
|
||||
\ 'source': string(s:_function('s:neomru', 1))[10:-3],
|
||||
\ 'accept': string(s:_function('s:neomru_acp', 1))[10:-3],
|
||||
\ 'supports_name_only': 1,
|
||||
\ 'supports_multi': 0,
|
||||
\ },
|
||||
\}
|
||||
|
||||
let g:Lf_Extensions.menu =
|
||||
\ {
|
||||
@ -318,7 +318,7 @@ function! s:register_acp(line, args) abort
|
||||
endfunction
|
||||
|
||||
function! s:neomru(...) abort
|
||||
return neomru#_gather_file_candidates()
|
||||
return neomru#_gather_file_candidates()
|
||||
endfunction
|
||||
|
||||
function! s:neomru_acp(line, args) abort
|
||||
@ -378,9 +378,23 @@ function! s:neoyank_acp(line, args) abort
|
||||
call append(0, split(line, '\\n'))
|
||||
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
|
||||
let menu_name = a:name['--name'][0]
|
||||
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')
|
||||
let rt = []
|
||||
for item in menu.command_candidates
|
||||
@ -393,6 +407,16 @@ function! s:menu(name) abort
|
||||
endif
|
||||
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
|
||||
let action = get(s:menu_action, a:line, '')
|
||||
exe action
|
||||
@ -558,7 +582,7 @@ function! s:defind_fuzzy_finder() abort
|
||||
\ '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',
|
||||
\ 'fuzzy find custom key bindings',
|
||||
\ [
|
||||
@ -567,7 +591,7 @@ function! s:defind_fuzzy_finder() abort
|
||||
\ '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 g:_spacevim_mappings.f.p = ['Leaderf menu --name AddedPlugins',
|
||||
\ 'fuzzy find vim packages',
|
||||
|
@ -22,6 +22,7 @@ let s:LOGGER =SpaceVim#logger#derive('rooter')
|
||||
let s:TIME = SpaceVim#api#import('time')
|
||||
let s:JSON = SpaceVim#api#import('data#json')
|
||||
let s:LIST = SpaceVim#api#import('data#list')
|
||||
let s:VIM = SpaceVim#api#import('vim')
|
||||
|
||||
function! s:update_rooter_patterns() abort
|
||||
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)
|
||||
let cache_context = join(readfile(s:project_cache_path, ''), '')
|
||||
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
|
||||
else
|
||||
call s:LOGGER.info('projects cache file does not exists!')
|
||||
@ -95,7 +99,11 @@ function! s:sort_by_opened_time() abort
|
||||
endfunction
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -110,7 +118,7 @@ function! SpaceVim#plugins#projectmanager#list() abort
|
||||
elseif SpaceVim#layers#isLoaded('fzf')
|
||||
FzfMenu Projects
|
||||
elseif SpaceVim#layers#isLoaded('leaderf')
|
||||
Leaderf menu --name Projects
|
||||
call SpaceVim#layers#leaderf#run_menu('Projects')
|
||||
else
|
||||
call SpaceVim#logger#warn('fuzzy find layer is needed to find project!')
|
||||
endif
|
||||
@ -143,6 +151,9 @@ function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort
|
||||
\ 'name' : fnamemodify(getcwd(), ':t'),
|
||||
\ 'opened_time' : localtime()
|
||||
\ }
|
||||
if empty(project.path)
|
||||
return
|
||||
endif
|
||||
call s:cache_project(project)
|
||||
let g:_spacevim_project_name = 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
|
||||
augroup LeaderF_Mru
|
||||
autocmd!
|
||||
autocmd FileType leaderf setlocal nonumber
|
||||
autocmd FileType leaderf setlocal nonumber nowrap
|
||||
augroup END
|
||||
|
||||
" change the leaderf Colorscheme automatically
|
||||
|
Loading…
Reference in New Issue
Block a user