completion for :FactorVocab vim function
parent
1a5b62238c
commit
5e4751db64
|
@ -5,7 +5,7 @@ nmap <silent> <Leader>ft :FactorVocabTests<CR>
|
|||
let g:FactorRoot = "/Users/joe/Documents/Code/others/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! FactorVocabDocs :call GoToFactorVocabDocs()
|
||||
command! FactorVocabTests :call GoToFactorVocabTests()
|
||||
|
@ -18,6 +18,21 @@ function! FactorVocabRoot(root)
|
|||
return vocabroot
|
||||
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)
|
||||
let vocabpath = substitute(a:vocab, "\\.", "/", "g")
|
||||
let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
|
||||
|
|
Loading…
Reference in New Issue