The variable 'runtimepath' contains the paths of all the directories that will be searched for doc and tags files. So, I want to check each of these directories.
If I run the following command I get the default or base set of directories.
$ vim --cmd 'echo &rtp' --cmd 'q' /dev/null
/home/harleypig/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/home/harleypig/.vim/after
But that's incomplete. The '--cmd' is run *before* any configuration files are parsed and handled. However, if I run the same command with the '-c' switch, which is run *after* configuration files are handled, I get all the correct directories--I also get a bunch of ANSI escape sequences. I have to dump it in a file to see it, the codes clear the screen.
$ vim -c 'echo &rtp' -c 'q' /dev/null > t
Vim: Warning: Output is not to a terminal
I've tried filtering it through 'col' and 'col -b' but that just strips the ESC codes, leaving a jumbled mess.
I'm using perl's Regexp::Common::ANSIescape to strip out the escape codes, and it seems to be reliable so far. But it would be better if there weren't any ansi codes in the first place.
So. Is there a way to get the value from vim without the ansi codes?
vim -c "redir! > $RTP" -c 'echo &rtp' -c 'redir END' -c 'q'
given $RTP set to an appropriate target. Starts the output with a blank line, I don't know why.
Regards, John
That did it, though I was hoping to avoid temp files.
> given $RTP set to an appropriate target. Starts the output with a blank line, I don't know why.
I think that has to do with not actually editing a file.
Thanks for the help.
That still leaves ansi escape codes in the output.
> That did it, though I was hoping to avoid temp files.
A challenge left hanging... I foolishly took the bait, though I'm not claiming success, such inelegance as follows cannot be termed such.
One can do this with coprocess trickery, if you have bash version 4:
coproc vim 10>&1- &>/dev/null -c 'exe "!echo \"" . &rtp. "\" >&10"' -c q
read -u${COPROC[0]} rtp
eval "exec ${COPROC[1]}<&-"
Regards, John
:D I didn't mean that as a challenge, but thanks for the hour's worth of yak-shaving exploring coproc. But, I'm using perl and that would make it more complicated. This is what I've done, if anyone's curious.
my @doc_dirs = do {
my $fh = File::Temp->new;
my $tmpfile = $fh->filename;
# Thanks to John Little on vim_use for the pointer to redir.
# https://groups.google.com/d/msg/vim_use/tGQdQX4MB68/kIhYPAMMsTgJ
my @cmd = ( 'vim', '-c', "redir! > $tmpfile", '-c', 'echo &rtp', '-c', 'redir END', '-c', 'q' );
my ( undef, $err, $syserr, $time ) = run3( \@cmd );
warn "Took $time seconds to run @cmd\n";
die "err: ($syserr) $err\n" if $syserr;
die "$err\n" if $err ne '' && $err ne 'Vim: Warning: Output is not to a terminal';
map { "$_/doc" }
grep { ! /^$/ }
split /[,\s]+/, do { local $/ ; <$fh> };
};
That gives me the same result as
vim --cmd 'echo &rtp|q'
Thanks for the hint to use |'s, makes the command so much easier to read.
In both cases above, it appears the command is being run before config files are being sourced. I want to create html files for what the user has available in a normal session though, so any modifications to runtimepath by config files need to be accounted for.
I haven't looked at starting.txt in a while. Time to reread it ...
> Most probably, vim -u ~/.vimrc -Esc 'verbose echo &rtp|q' should work
> however.
That worked. From what I understand from the docs this should be fine in most cases. Thanks for the help.