completion for :FactorVocab vim function
parent
1a5b62238c
commit
5e4751db64
|
@ -5,10 +5,10 @@ nmap <silent> <Leader>ft :FactorVocabTests<CR>
|
||||||
let g:FactorRoot = "/Users/joe/Documents/Code/others/factor"
|
let g:FactorRoot = "/Users/joe/Documents/Code/others/factor"
|
||||||
let g:FactorVocabRoots = ["core", "basis", "extra", "work", "/Users/joe/Documents/Code/Factor"]
|
let g:FactorVocabRoots = ["core", "basis", "extra", "work", "/Users/joe/Documents/Code/Factor"]
|
||||||
|
|
||||||
command! -nargs=1 FactorVocab :call GoToFactorVocab("<args>")
|
command! -nargs=1 -complete=custom,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()
|
||||||
|
|
||||||
function! FactorVocabRoot(root)
|
function! FactorVocabRoot(root)
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
|
@ -18,6 +18,21 @@ function! FactorVocabRoot(root)
|
||||||
return vocabroot
|
return vocabroot
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! FactorCompleteVocab(arglead, cmdline, cursorpos)
|
||||||
|
let vocabs = ""
|
||||||
|
let vocablead = substitute(a:arglead, "\\.", "/", "g")
|
||||||
|
for root in g:FactorVocabRoots
|
||||||
|
let vocabroot = FactorVocabRoot(root)
|
||||||
|
let newvocabs = globpath(vocabroot, vocablead . "*")
|
||||||
|
if newvocabs != ""
|
||||||
|
let newvocabs = substitute(newvocabs, "\\(^\\|\\n\\)\\V" . escape(vocabroot, "\\"), "\\1", "g")
|
||||||
|
let newvocabs = substitute(newvocabs, "/\\|\\\\", ".", "g")
|
||||||
|
let vocabs .= newvocabs . "\n"
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return vocabs
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! FactorVocabFile(root, vocab)
|
function! FactorVocabFile(root, vocab)
|
||||||
let vocabpath = substitute(a:vocab, "\\.", "/", "g")
|
let vocabpath = substitute(a:vocab, "\\.", "/", "g")
|
||||||
let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
|
let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
|
||||||
|
|
Loading…
Reference in New Issue