<commit_before>nmap <silent> <Leader>fi :FactorVocabImpl<CR>
nmap <silent> <Leader>fd :FactorVocabDocs<CR>
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!          FactorVocabImpl  :call GoToFactorVocabImpl()
command!          FactorVocabDocs  :call GoToFactorVocabDocs()
command!          FactorVocabTests :call GoToFactorVocabTests()

function! FactorVocabRoot(root)
    let cwd = getcwd()
    exe "lcd " fnameescape(g:FactorRoot)
    let vocabroot = fnamemodify(a:root, ":p")
    exe "lcd " fnameescape(cwd)
    return vocabroot
endfunction

function! FactorVocabFile(root, vocab)
    let vocabpath = substitute(a:vocab, "\\.", "/", "g")
    let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
    
    if getftype(vocabfile) != ""
        return vocabfile
    else
        return ""
    endif
endfunction

function! GoToFactorVocab(vocab)
    for root in g:FactorVocabRoots
        let vocabfile = FactorVocabFile(root, a:vocab)
        if vocabfile != ""
            exe "edit " fnameescape(vocabfile)
            return
        endif
    endfor
    echo "Vocabulary " vocab " not found"
endfunction

function! FactorFileBase()
    let filename = expand("%:r")
    let filename = substitute(filename, "-docs", "", "")
    let filename = substitute(filename, "-tests", "", "")<commit_msg>completion for :FactorVocab vim function<commit_after>nmap <silent> <Leader>fi :FactorVocabImpl<CR>
nmap <silent> <Leader>fd :FactorVocabDocs<CR>
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 -complete=custom,FactorCompleteVocab FactorVocab :call GoToFactorVocab("<args>")
command! FactorVocabImpl  :call GoToFactorVocabImpl()
command! FactorVocabDocs  :call GoToFactorVocabDocs()
command! FactorVocabTests :call GoToFactorVocabTests()

function! FactorVocabRoot(root)
    let cwd = getcwd()
    exe "lcd " fnameescape(g:FactorRoot)
    let vocabroot = fnamemodify(a:root, ":p")
    exe "lcd " fnameescape(cwd)
    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"
    
    if getftype(vocabfile) != ""
        return vocabfile
    else
        return ""
    endif
endfunction

function! GoToFactorVocab(vocab)
    for root in g:FactorVocabRoots
        let vocabfile = FactorVocabFile(root, a:vocab)
        if vocabfile != ""
            exe "edit " fnameescape(vocabfile)
            return
        endif
    endfor
    echo "Vocabulary " vocab " not found"
endfunction

function! FactorFileBase()
    let filename = expand("%:r")
    let filename = substitute(filename, "-docs", "", "")
    let filename = substitute(filename, "-tests", "", "")
{'fraction_non_alphanumeric': 0.13906581740976645, 'fraction_numerical': 0.0007961783439490446, 'mean_word_length': 3.4709371293001188, 'pattern_counts': {'":': 4, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5418612', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1328, 'n_words': 280}