Eu modifiquei meu dicionário de sinônimos para concluir a sentença.
Algumas melhorias seriam
Completo usando PWD / , Gutenberg / books / ,
Melhor regex usando o contexto em torno do cursor.
" What: Complete sentence
" Usage: :so % <CR> Get sentence[press C-x C-o]
" How: Get sentence completions using perl from current file
set completeopt+=menuone
set omnifunc=MoshCompleteSentence
function! MoshCompleteSentence(findstart, base)
" == First call: find-sentence-backwards, see :help omnifunc
if a:findstart
let s:line = getline('.')
let s:wordStart = col('.') - 1
" Check backward for a sentence_prefix
while s:wordStart > 0 && s:line[s:wordStart - 1] =~ '[A-Za-z0-9 _,]'
let s:wordStart -= 1
endwhile
return s:wordStart
else
" == Second call: grep for sentence_regex, output: list of sentences
let a:sentence_regex = a:base
" in regex trim spaces
let a:sentence_regex = substitute( a:sentence_regex,'\v^\s*(.{-})\s*$','','')
" in regex change punctuation as dot.
let a:sentence_regex = substitute(a:sentence_regex,'\W','.','g')
" grep using perl
let s:cmd='perl -ne '' '
\.'chomp;'
\.'next if m/^[;#]/;'
\.'if( /('.a:sentence_regex.'.{1,30})/io ){'
\.' print qq/$1;;/ '
\.'}'
\. ' '' '
\.expand("%:p")
" == To debug: redir echom to file
" redir >> c:/tmp/vim.log
echom s:cmd
let s:rawOutput = system(s:cmd)
let s:listing = split(s:rawOutput, ';;')
" echom join(s:listing,',')
" redir END
return s:listing
endif
endfunction