Closed gogoprog closed 6 years ago
Okay I found it, %s has to be present so here is my workaround:
let project_root = getcwd()
let g:ctrlp_user_command = 'echo %s && cd ' . project_root . ' && find .'
I'll edit title
find
with path return relative path from current directory. So if the project_root is not same as root-marker, the result is not expected.
Yes I slightly changed to
let g:ctrlp_user_command = 'echo %s && find -L ' . project_root
to have absolute paths and it works.
It doesn't change the fact I still have to put '%s' in the variable.
Yes, because printf("here", getcwd())
become error. How about this change?
diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim
index 2a8ae88..f9f4676 100644
--- a/autoload/ctrlp.vim
+++ b/autoload/ctrlp.vim
@@ -439,6 +439,14 @@ fu! ctrlp#addfile(ch, file)
cal s:BuildPrompt(1)
endf
+fu! s:safe_printf(format, ...)
+ try
+ retu call('printf', [a:format] + a:000)
+ cat
+ retu a:format
+ endt
+endf
+
fu! s:UserCmd(lscmd)
let [path, lscmd] = [s:dyncwd, a:lscmd]
let do_ign =
@@ -461,9 +469,9 @@ fu! s:UserCmd(lscmd)
let g:ctrlp_allfiles = []
let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'})
elsei has('patch-7.4-597') && !(has('win32') || has('win64'))
- let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
+ let g:ctrlp_allfiles = systemlist(s:safe_printf(lscmd, path))
el
- let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
+ let g:ctrlp_allfiles = split(system(s:safe_printf(lscmd, path)), "\n")
en
if exists('+ssl') && exists('ssl')
let &ssl = ssl
Yes this seems fine to fix the issue
@mattn I believe this is still broken. Here's an example of a broken g:ctrlp_user_command
:
\ 3: ['P4CONFIG', 'cd $STEM; cat ' .
\ '<(p4 have ... | \grep -v "$STEM/\(emu\|_env\|env_squash\|fp\|tools\|powerPro\|sdpx\|ch/verif/dft\|' .
\ 'ch/verif/txn/old_yml_DO_NOT_USE\|ch/syn\)") ' .
\ '<(p4 opened ... 2> /dev/null | \grep add | \sed "s/#.*//" | \xargs -I{} -n1 p4 where {}) ' .
\ '<(cd $STEM/import/avf; p4 have ... | \grep -v "$STEM/import/avf/\(_env\)") ' .
\ '| \awk "{print \$3}" | sed "s:$STEM/::"'
\ ]
However, if I add a echo %s
like @gogoprog did above, it works:
\ 3: ['P4CONFIG', 'echo %s; cd $STEM; cat ' .
\ '<(p4 have ... | \grep -v "$STEM/\(emu\|_env\|env_squash\|fp\|tools\|powerPro\|sdpx\|ch/verif/dft\|' .
\ 'ch/verif/txn/old_yml_DO_NOT_USE\|ch/syn\)") ' .
\ '<(p4 opened ... 2> /dev/null | \grep add | \sed "s/#.*//" | \xargs -I{} -n1 p4 where {}) ' .
\ '<(cd $STEM/import/avf; p4 have ... | \grep -v "$STEM/import/avf/\(_env\)") ' .
\ '| \awk "{print \$3}" | sed "s:$STEM/::"'
\ ]
Could you please show me more simple example to reproduce?
Hello,
I have this in my vimrc:
And I always have no result in CtrlP. I inspected the command using `:echo g:ctrlp_user_command' and it looks fine.
What is wrong in my setup?