Find a file
2022-05-09 19:19:27 +02:00
autoload feat: project specific vimrc configuration 2022-05-09 19:19:27 +02:00
plugin feat: project specific vimrc configuration 2022-05-09 19:19:27 +02:00
LICENSE Initial commit 2022-05-09 17:43:49 +02:00
README.md feat: project specific vimrc configuration 2022-05-09 19:19:27 +02:00

Project Config

Drop the plugin into ~/.vim/pack/{foo}/start/projectconfig.

In your ~/.vimrc you need to set up the project directories and the configuration file to map to:

let g:projectconfig_projects = {
    \ '~/dev/my-project' : '~/.config/my-project.vim',
    \ '~/wiki' : '~/wiki/.vimrc',
    \ }

And to load the configuration for the file that you opened:

E.g.

au BufNewFile,BufRead ~/dev/* call projectconfig#load()

Buffer scope for project configuration

Prefer setlocal, localleader and <buffer> for project configuration, so that the changes are scoped to a specific buffer and doesn't override your default, or other project config when you open various files.

E.g. to override my default from 4 spaces to 2 spaces in a project I would use:

~/.vimrc:

# default configuration

set tabstop=4
set shiftwidth=4

and in e.g. ~/.config/my-project.vim

# my-project configuration

setlocal tabstop=2
setlocal shiftwidth=2

Caveats

('._.)

  • Only tested with VIM 8.2.

(;._.)

  • BE MINDFUL OF WHERE THE CONFIG LIVES. If you have vimrc file stored in the project repo, changes to it will happily be sourced the next time you pull. This plugin does not do verification.

(╯._.)╯︵ ┻━┻

  • If a project config sets a setting that the base, or next project config doesn't, then the project config will still be active when changing to a file in another project. Work around this by customising the autocmd and use setlocal, localleader, and <buffer> in project configuration.