improve :FactorVocab completion
parent
0e10785508
commit
2a4df54969
|
@ -10,7 +10,7 @@ if !exists("g:FactorVocabRoots")
|
||||||
let g:FactorVocabRoots = ["core", "basis", "extra", "work"]
|
let g:FactorVocabRoots = ["core", "basis", "extra", "work"]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
command! -nargs=1 -complete=custom,FactorCompleteVocab FactorVocab :call GoToFactorVocab("<args>")
|
command! -nargs=1 -complete=customlist,FactorCompleteVocab FactorVocab :call GoToFactorVocab("<args>")
|
||||||
command! FactorVocabImpl :call GoToFactorVocabImpl()
|
command! FactorVocabImpl :call GoToFactorVocabImpl()
|
||||||
command! FactorVocabDocs :call GoToFactorVocabDocs()
|
command! FactorVocabDocs :call GoToFactorVocabDocs()
|
||||||
command! FactorVocabTests :call GoToFactorVocabTests()
|
command! FactorVocabTests :call GoToFactorVocabTests()
|
||||||
|
@ -23,18 +23,29 @@ function! FactorVocabRoot(root)
|
||||||
return vocabroot
|
return vocabroot
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:unique(list)
|
||||||
|
let dict = {}
|
||||||
|
for value in a:list
|
||||||
|
let dict[value] = 1
|
||||||
|
endfor
|
||||||
|
return sort(keys(dict))
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! FactorCompleteVocab(arglead, cmdline, cursorpos)
|
function! FactorCompleteVocab(arglead, cmdline, cursorpos)
|
||||||
let vocabs = ""
|
let vocabs = []
|
||||||
let vocablead = substitute(a:arglead, "\\.", "/", "g")
|
let vocablead = substitute(a:arglead, "\\.", "/", "g")
|
||||||
for root in g:FactorVocabRoots
|
for root in g:FactorVocabRoots
|
||||||
let vocabroot = FactorVocabRoot(root)
|
let vocabroot = FactorVocabRoot(root)
|
||||||
let newvocabs = globpath(vocabroot, vocablead . "*")
|
let newvocabs = globpath(vocabroot, vocablead . "*")
|
||||||
if newvocabs != ""
|
if newvocabs != ""
|
||||||
let newvocabs = substitute(newvocabs, "\\(^\\|\\n\\)\\V" . escape(vocabroot, "\\"), "\\1", "g")
|
let newvocabsl = split(newvocabs, "\n")
|
||||||
let newvocabs = substitute(newvocabs, "/\\|\\\\", ".", "g")
|
let newvocabsl = filter(newvocabsl, 'getftype(v:val) == "dir"')
|
||||||
let vocabs .= newvocabs . "\n"
|
let newvocabsl = map(newvocabsl, 'substitute(v:val, "^\\V" . escape(vocabroot, "\\"), "\\1", "g")')
|
||||||
|
let vocabs += newvocabsl
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
let vocabs = s:unique(vocabs)
|
||||||
|
let vocabs = map(vocabs, 'substitute(v:val, "/\\|\\\\", ".", "g")')
|
||||||
return vocabs
|
return vocabs
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue