1 nmap <silent> <Leader>fi :FactorVocabImpl<CR>
2 nmap <silent> <Leader>fd :FactorVocabDocs<CR>
3 nmap <silent> <Leader>ft :FactorVocabTests<CR>
5 let g:FactorRoot = "/Users/joe/Documents/Code/others/factor"
6 let g:FactorVocabRoots = ["core", "basis", "extra", "work", "/Users/joe/Documents/Code/Factor"]
8 command! -nargs=1 -complete=custom,FactorCompleteVocab FactorVocab :call GoToFactorVocab("<args>")
9 command! FactorVocabImpl :call GoToFactorVocabImpl()
10 command! FactorVocabDocs :call GoToFactorVocabDocs()
11 command! FactorVocabTests :call GoToFactorVocabTests()
13 function! FactorVocabRoot(root)
15 exe "lcd " fnameescape(g:FactorRoot)
16 let vocabroot = fnamemodify(a:root, ":p")
17 exe "lcd " fnameescape(cwd)
21 function! FactorCompleteVocab(arglead, cmdline, cursorpos)
23 let vocablead = substitute(a:arglead, "\\.", "/", "g")
24 for root in g:FactorVocabRoots
25 let vocabroot = FactorVocabRoot(root)
26 let newvocabs = globpath(vocabroot, vocablead . "*")
28 let newvocabs = substitute(newvocabs, "\\(^\\|\\n\\)\\V" . escape(vocabroot, "\\"), "\\1", "g")
29 let newvocabs = substitute(newvocabs, "/\\|\\\\", ".", "g")
30 let vocabs .= newvocabs . "\n"
36 function! FactorVocabFile(root, vocab)
37 let vocabpath = substitute(a:vocab, "\\.", "/", "g")
38 let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
40 if getftype(vocabfile) != ""
47 function! GoToFactorVocab(vocab)
48 for root in g:FactorVocabRoots
49 let vocabfile = FactorVocabFile(root, a:vocab)
51 exe "edit " fnameescape(vocabfile)
55 echo "Vocabulary " vocab " not found"
58 function! FactorFileBase()
59 let filename = expand("%:r")
60 let filename = substitute(filename, "-docs", "", "")
61 let filename = substitute(filename, "-tests", "", "")
65 function! GoToFactorVocabImpl()
66 exe "edit " fnameescape(FactorFileBase() . ".factor")
69 function! GoToFactorVocabDocs()
70 exe "edit " fnameescape(FactorFileBase() . "-docs.factor")
73 function! GoToFactorVocabTests()
74 exe "edit " fnameescape(FactorFileBase() . "-tests.factor")