mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:50:06 +08:00
fix(projectmanager): fix root sort function
This commit is contained in:
parent
0a7ec1a1c5
commit
91e367637a
@ -146,6 +146,7 @@ function! SpaceVim#layers#lang#java#config() abort
|
|||||||
call SpaceVim#mapping#space#regesit_lang_mappings('java', function('s:language_specified_mappings'))
|
call SpaceVim#mapping#space#regesit_lang_mappings('java', function('s:language_specified_mappings'))
|
||||||
call SpaceVim#plugins#repl#reg('java', 'jshell')
|
call SpaceVim#plugins#repl#reg('java', 'jshell')
|
||||||
call add(g:spacevim_project_rooter_patterns, 'pom.xml')
|
call add(g:spacevim_project_rooter_patterns, 'pom.xml')
|
||||||
|
call add(g:spacevim_project_rooter_patterns, 'build.gradle')
|
||||||
|
|
||||||
" for neomake
|
" for neomake
|
||||||
"
|
"
|
||||||
|
@ -145,9 +145,32 @@ local function change_dir(dir)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function compare(d1, d2)
|
||||||
|
local al = #vim.split(d1, '/')
|
||||||
|
local bl = #vim.split(d2, '/')
|
||||||
|
-- logger.debug('al is ' .. al)
|
||||||
|
-- logger.debug('bl is ' .. bl)
|
||||||
|
-- the project_rooter_outermost is 0/false or 1 true
|
||||||
|
if sp_opt.project_rooter_outermost == 0
|
||||||
|
or sp_opt.project_rooter_outermost == false then
|
||||||
|
if bl > al then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if al > bl then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function sort_dirs(dirs)
|
local function sort_dirs(dirs)
|
||||||
table.sort(dirs, compare)
|
table.sort(dirs, compare)
|
||||||
local dir = dirs[1]
|
local dir = dirs[1]
|
||||||
|
-- logger.debug(vim.inspect(dirs))
|
||||||
local bufdir = fn.getbufvar('%', 'rootDir', '')
|
local bufdir = fn.getbufvar('%', 'rootDir', '')
|
||||||
if bufdir == dir then
|
if bufdir == dir then
|
||||||
return ''
|
return ''
|
||||||
@ -156,16 +179,6 @@ local function sort_dirs(dirs)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function compare(d1, d2)
|
|
||||||
local _, al = string.gsub(d1, '/', '')
|
|
||||||
local _, bl = string.gsub(d2, '/', '')
|
|
||||||
if sp_opt.project_rooter_outermost == 0 then
|
|
||||||
return bl - al
|
|
||||||
else
|
|
||||||
return al - bl
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function find_root_directory()
|
local function find_root_directory()
|
||||||
local fd = fn.bufname('%')
|
local fd = fn.bufname('%')
|
||||||
if fd == '' then
|
if fd == '' then
|
||||||
|
Loading…
Reference in New Issue
Block a user