Problem setting runtimepath in vimrc

3,964 views
Skip to first unread message

Pablo Giménez

unread,
Jun 3, 2010, 11:10:54 AM6/3/10
to vim_use
Hi vimers
I have in my $HOME/.vimrc the next statetement to set the runtime path:
set runtimepath=$MYPATH, $VIMRUNTIME

Let say that I am setting MYPATH with:
let $MYPATH=/opt/myvimstuff

Yes I want to define it as an enviroment variable.
The thing is that the resulting runtime path is:
/opt//opt/myvimstuff,/usr/share/vim/vim71
Even if I leave the  set runbtime as:
set runtimepath=$VIMRUNTIME
I got:
/usr/share/vim/vim71

But if I don't set the runtime path option in my .vimrc then I got:
/u/pgp/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim71,/usr/share/vim/vimfiles/after,/u/pgp/.vim/after
which seems to be the default runtime path in my system.
My question is why when I am including $VIMRUNTIME it is only including /usr/share/vim/vim71
and not this:
/u/pgp/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim71,/usr/share/vim/vimfiles/after,/u/pgp/.vim/after

Any ideas???
thanks

--
Un saludo
Best Regards
Pablo Giménez

Luc Hermitte

unread,
Jun 3, 2010, 11:23:44 AM6/3/10
to vim use
Hello,

"Pablo Giménez" wrote:

> I have in my $HOME/.vimrc the next statetement to set the runtime
> path:
> set runtimepath=$MYPATH, $VIMRUNTIME

It looks like you should be using:
let &rtp=$MYPATH.','.&rtp

rtp default value is not $VIMRUNTIME, see :h 'rtp'

--
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

Pablo Giménez

unread,
Jun 3, 2010, 12:00:13 PM6/3/10
to vim...@googlegroups.com
Thanks worked like a charm!

2010/6/3 Luc Hermitte <herm...@free.fr>

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

John Little

unread,
Jun 4, 2010, 7:51:58 AM6/4/10
to vim_use

On Jun 4, 3:23 am, Luc Hermitte <hermi...@free.fr> wrote:

> It looks like you should be using:
>     let &rtp=$MYPATH.','.&rtp

or more plainly

set rtp^=$MYPATH

This handles corner cases better, like only adding a comma if needed,
and if done twice, avoids doubling up.

Regards, John

Luc Hermitte

unread,
Jun 4, 2010, 7:58:38 AM6/4/10
to vim use
"John Little" wrote :

> On Jun 4, 3:23 am, Luc Hermitte <hermi...@free.fr> wrote:
>
> > It looks like you should be using:
> >     let &rtp=$MYPATH.','.&rtp
>
> or more plainly
>
> set rtp^=$MYPATH

Indeed, that's much better!
I didn't know :set^=

Tony Mechelynck

unread,
Jun 4, 2010, 9:02:55 AM6/4/10
to vim...@googlegroups.com, Pablo Giménez
> Pablo Gim�nez

>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

It is recommended to also have "after" directories (see :help
after-directory) so you can tweak, /a posteriori/, the settings set by
the standard Vim scripts.

The default 'vimruntime' setting, on most systems, includes the
following in order:

$HOME/.vim (on Unix), or
$HOME/vimfiles (on Windows)
for single-user full-fledged scripts

$VIM/vimfiles (on all platforms)
for system-wide scripts not distributed with Vim

$VIMRUNTIME
for scripts distributed with Vim (don't touch them)

$VIM/vimfiles/after
for system-wide tweaks to any of the above

$HOME/.vim/after (on Unix)
$HOME/vimfiles/after (on Windows)
for single-user tweaks to any of the above

This is a "sane" default, and in most cases it is better not to change
it. However if you are still dead set on using another value by means of
the environment, try the following:

:let $MYVIMPATH1 = '/opt/myvimstuff'
:let $MYVIMPATH2 = '/opt/myvimstuff/after'
:set runtimepath=$VIMRUNTIME
:set runtimepath^=$MYVIMPATH1
:set runtimepath+=$MYVIMPATH2

Note that there should be NO SPACES immediately before or after the
commas in this option, or after the equal sign in the :set statement,
and that if you want to include spaces inside the value (as on Windows,
where typical directory names include "Documents and Settings" and
"Program Files") each space must be backslash-escaped in the :set
statement (this applies to any option, and also for backslashes, hard
tabs, vertical bars and double quotes, see ":help option-backlash").


Best regards,
Tony.
--
f y cn rd ths thn y cn hv grt jb n cmptr prgrmmng

Pablo Giménez

unread,
Jun 4, 2010, 12:53:22 PM6/4/10
to vim...@googlegroups.com
I am using this code to make a proper runtimepath:
if exists("$TDVIMROOT")
    let s:paths = split(&rtp, ',')
    let s:userPaths = []
    let s:sysPaths = []
    if has("win32") || has("win64")
    let s:user = $USERNAME
    else
    let s:user =$USER
    endif
    for path in s:paths
    if path =~ s:user
        let s:userPaths += [path]
    else
        let s:sysPaths += [path]
    endif
    endfor
    " Add initial paths for runtimepath:
    let &rtp = s:userPaths[0] . ',' . $TDVIMROOT
    " Add system paths
    for path in s:sysPaths
    let &rtp = &rtp . ',' . path
    endfor
    " Add after paths
    let &rtp = &rtp . ',' . $TDVIMROOT . '/after' . '.' . s:userPaths[1]
    "let &runtimepath=$TDVIMROOT. ',' . &rtp . ',' . $TDVIMROOT . '/after'
else
    echohl ErrorMsg
    echo "TDVIMROOT nor defined.\nPlese set en environment veriable called TDVIMRROT to the TDVim install location"
    echohl Normal
endif

So user paths will be before, then my path, and the nsystem paths.
for the after just the other way around , first system, then my stuff and finally user after location

El 4 de junio de 2010 14:02, Tony Mechelynck <antoine.m...@gmail.com> escribió:
Pablo Giménez

Pablo Giménez

Tony Mechelynck

unread,
Jun 4, 2010, 7:39:36 PM6/4/10
to vim...@googlegroups.com, Pablo Giménez
On 04/06/10 18:53, Pablo Gim�nez wrote:
> I am using this code to make a proper runtimepath:
> if exists("$TDVIMROOT")
> let s:paths = split(&rtp, ',')
> let s:userPaths = []
> let s:sysPaths = []
> if has("win32") || has("win64")
> let s:user = $USERNAME
> else
> let s:user =$USER
> endif
> for path in s:paths
> if path =~ s:user
> let s:userPaths += [path]
> else
> let s:sysPaths += [path]
> endif
> endfor
> " Add initial paths for runtimepath:
> let&rtp = s:userPaths[0] . ',' . $TDVIMROOT

> " Add system paths
> for path in s:sysPaths
> let&rtp =&rtp . ',' . path
> endfor
> " Add after paths
> let&rtp =&rtp . ',' . $TDVIMROOT . '/after' . '.' . s:userPaths[1]
> "let&runtimepath=$TDVIMROOT. ',' .&rtp . ',' . $TDVIMROOT . '/after'

> else
> echohl ErrorMsg
> echo "TDVIMROOT nor defined.\nPlese set en environment veriable called
> TDVIMRROT to the TDVim install location"
> echohl Normal
> endif
>
> So user paths will be before, then my path, and the nsystem paths.
> for the after just the other way around , first system, then my stuff and
> finally user after location

This sounds quite complicated.

Why not just

if exists('$TDVIMROOT') && ($TDVIMROOT != "")
\ && isdirectory($TDVIMROOT)
let s:rtp = split(&rtp, ',')
call insert(s:rtp, $TDVIMROOT, 1)
call insert(s:rtp, $TDVIMROOT . '/after', -1)
let &rtp = join(s:rtp, ',')
else
echoerr 'Please define $TDVIMROOT as the TDVim install directory'
endif

but then, why insist that your plugin be housed in a different directory
tree than the rest? Why not just add one or more additional files at the
appropriate location(s) in some existing 'runtimepath' directory tree
(other than $VIMRUNTIME), like everyone else does? Distributing a bunch
of files for installation into a 'runtimepath' tree, each file into its
proper subdir, can even be automated, see ":help pi_vimball.txt".


Best regards,
Tony.
--
Everything you've learned in school as "obvious" becomes less and less
obvious as you begin to study the universe. For example, there are no
solids in the universe. There's not even a suggestion of a solid.
There are no absolute continuums. There are no surfaces. There are no
straight lines.
-- R. Buckminster Fuller

Pablo Giménez

unread,
Jun 4, 2010, 9:24:02 PM6/4/10
to vim...@googlegroups.com


El 5 de junio de 2010 00:39, Tony Mechelynck <antoine.m...@gmail.com> escribió:
Thanks for the tip, ill try it.

but then, why insist that your plugin be housed in a different directory tree than the rest? Why not just add one or more additional files at the appropriate location(s) in some existing 'runtimepath' directory tree (other than $VIMRUNTIME), like everyone else does? Distributing a bunch of files for installation into a 'runtimepath' tree, each file into its proper subdir, can even be automated, see ":help pi_vimball.txt".

Well the think is that my plugin is basically  a lot of other plugins and scripts integrated to make a de velopment environment.
I understand vim's point of view and  I think is good for one user who is installing plugins separately.
But in my situation is a pluging that affects many aspepect of vim and I prefer to have everything in one location that eveybody can reuse, not to force every user to install it.
So I followed what many other apps do, being able to replicate the hierarchy of the conf folder and then using an evironment variable enable to use it or not.

Best regards,
Tony.
--
Everything you've learned in school as "obvious" becomes less and less
obvious as you begin to study the universe.  For example, there are no
solids in the universe.  There's not even a suggestion of a solid.
There are no absolute continuums.  There are no surfaces.  There are no
straight lines.
               -- R. Buckminster Fuller
Reply all
Reply to author
Forward
0 new messages