diff --git a/plugin/capture.zsh b/autoload/capture.zsh similarity index 88% rename from plugin/capture.zsh rename to autoload/capture.zsh index 1202688..30877f5 100755 --- a/plugin/capture.zsh +++ b/autoload/capture.zsh @@ -3,11 +3,24 @@ zmodload zsh/zpty || { echo 'error: missing module zsh/zpty' >&2; exit 1 } # spawn shell -zpty z zsh -f -i +zpty z zsh -i # line buffer for pty output local line +# swallow input of zshrc, disable hooks and disable PROMPT +# the prompt should be disabled here (before init) in case a prompt theme has +# a verbose prompt +zpty -w z "autoload add-zsh-hook" +zpty -w z "add-zsh-hook -D precmd '*'" +zpty -w z "add-zsh-hook -D preexec '*'" +zpty -w z "PROMPT=" +zpty -w z "echo thisisalonganduniquestringtomarktheendoftheinit >/dev/null" +zpty -r z line +while [[ $line != *'thisisalonganduniquestringtomarktheendoftheinit'* ]]; do + zpty -r z line +done + setopt rcquotes () { zpty -w z source $1 @@ -18,9 +31,6 @@ setopt rcquotes echo 'error initializing.' >&2 exit 2 } =( <<< ' -# no prompt! -PROMPT= - # load completion system autoload compinit compinit -d ~/.zcompdump_capture diff --git a/plugin/zsh_completion.vim b/autoload/zsh_completion.vim similarity index 78% rename from plugin/zsh_completion.vim rename to autoload/zsh_completion.vim index 1adcb81..918de0c 100644 --- a/plugin/zsh_completion.vim +++ b/autoload/zsh_completion.vim @@ -2,13 +2,16 @@ " Maintainer: Valodim Skywalker " Last Updated: 03 Oct 2013 -fun! zsh_completion#Complete(findstart, base) +let s:srcfile = globpath(&runtimepath, 'autoload/capture.zsh') +let s:hasSrcfile = len(s:srcfile) + +fun! zsh_completion#Complete(findstart, base) abort if a:findstart " locate the start of the word let l:line = getline('.') let l:pos = col('.') - 1 - while l:pos > 0 && l:line[l:pos - 1] =~ '\S' + while l:pos > 0 && l:line[l:pos - 1] =~? '\S' let l:pos -= 1 endwhile @@ -23,12 +26,11 @@ fun! zsh_completion#Complete(findstart, base) return l:pos else - let l:srcfile = globpath(&rtp, 'plugin/capture.zsh') - if len(l:srcfile) == 0 + if s:hasSrcfile == 0 return -1 endif - let s:out = system(l:srcfile . ' ' . shellescape(getline(".") . s:base) . ' ' . (col('.')+strlen(s:base)-1)) + let s:out = system(s:srcfile . ' ' . shellescape(getline('.') . s:base) . ' ' . (col('.')+strlen(s:base)-1)) let l:result = [] for item in split(s:out, '\r\n') let l:pieces = split(item, ' -- ')