:FactorVocab factor.vocab.name
Opens the source file implementing the "factor.vocab.name"
vocabulary.
+ :NewFactorVocab factor.vocab.name
+ Creates a new factor vocabulary under the working vocabulary root.
:FactorVocabImpl
Opens the main implementation file for the current vocabulary
(name.factor). The keyboard shortcut "\fi" is bound to this
This variable should be set to a list of Factor vocabulary roots.
The paths may be either relative to g:FactorRoot or absolute paths.
The default value is ["core", "basis", "extra", "work"].
+ g:FactorNewVocabRoot
+ This variable should be set to the vocabulary root in which
+ vocabularies created with NewFactorVocab should be created. The
+ default value is "work".
Note: The syntax-highlighting file is automatically generated to include the
names of all the vocabularies Factor knows about. To regenerate it manually,
let g:FactorVocabRoots = ["core", "basis", "extra", "work"]
endif
+if !exists("g:FactorNewVocabRoot")
+ let g:FactorNewVocabRoot = "work"
+endif
+
command! -nargs=1 -complete=customlist,FactorCompleteVocab FactorVocab :call GoToFactorVocab("<args>")
+command! -nargs=1 -complete=customlist,FactorCompleteVocab NewFactorVocab :call MakeFactorVocab("<args>")
command! FactorVocabImpl :call GoToFactorVocabImpl()
command! FactorVocabDocs :call GoToFactorVocabDocs()
command! FactorVocabTests :call GoToFactorVocabTests()
return vocabs
endfunction
-function! FactorVocabFile(root, vocab)
+function! FactorVocabFile(root, vocab, mustexist)
let vocabpath = substitute(a:vocab, "\\.", "/", "g")
let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
- if getftype(vocabfile) != ""
+ if !a:mustexist || getftype(vocabfile) != ""
return vocabfile
else
return ""
function! GoToFactorVocab(vocab)
for root in g:FactorVocabRoots
- let vocabfile = FactorVocabFile(root, a:vocab)
+ let vocabfile = FactorVocabFile(root, a:vocab, 1)
if vocabfile != ""
exe "edit " fnameescape(vocabfile)
return
echo "Vocabulary " vocab " not found"
endfunction
+function! MakeFactorVocab(vocab)
+ let vocabfile = FactorVocabFile(g:FactorNewVocabRoot, a:vocab, 0)
+ echo vocabfile
+ let vocabdir = fnamemodify(vocabfile, ":h")
+ echo vocabdir
+ exe "!mkdir -p " shellescape(vocabdir)
+ exe "edit " fnameescape(vocabfile)
+endfunction
+
function! FactorFileBase()
let filename = expand("%:r")
let filename = substitute(filename, "-docs", "", "")