embear / vim-localvimrc

Search local vimrc files (".lvimrc") in the tree (root dir up to current dir) and load them.
http://www.vim.org/scripts/script.php?script_id=441
GNU General Public License v3.0
484 stars 28 forks source link

Environment variable for specifying path to localvimrc file #78

Closed davidtwco closed 4 years ago

davidtwco commented 4 years ago

It would be great if localvimrc could read $LOCALVIMRC_FILE (or some other environment variable) for a path to the .lvimrc file, falling back to the current search directories/filenames if the variable is unset.

This would be beneficial for users of Nix development shells to be able to define their .lvimrc file as part of their development shell and have localvimrc use it without any further manual intervention (e.g. symlinking the path from $LOCALVIMRC_FILE to .lvimrc whenever you change the development shell).

For example, when working on rustc, I have a .lvimrc file - I define this file in my development shell alongside all the other stuff, and I update the symlink to that file in the working directory whenever the file changes - if I didn't have to do that, and could just enter the development shell and always have localvimrc use the most recent version of the .lvimrc file, then that'd be great.

Thanks!

embear commented 4 years ago

To be honest I don't really understand the use case here. Possibly I just did not understand it. The basic idea of localvimrc is to distribute the configuration with the source code of the source code and not to load it from somewhere in the filesystem. I think for the above use case it would be sufficient to add the following lines to your 'normal' VIMRC:

if exists("$YOUR_ADDITIONAL_VIMRC") && filereadable($YOUR_ADDITIONAL_VIMRC)
  source $YOUR_ADDITIONAL_VIMRC
endif

If I understand wrong then please explain a little bit more.

davidtwco commented 4 years ago

My primary use case was where the project wasn't my own (e.g. some open source project that I regularly contribute to) and where it wouldn't be appropriate to include the .lvimrc file (it contains configuration specific to my workflow or plugins, etc) - I could define the .lvimrc file in my development shell configuration (which I store for each project that I contribute to in my own repository) and then localvimrc would detect that via the environment variable.

However, I wasn't aware that it was as easy to implement something like that myself in my own Vim configuration, which is definitely a better approach - my bad, thanks for your time.