Reputation: 376
I'm using Vim 8.0 and am getting confused about language specific settings. I want to define language specific rules for indentation, folding, additional plugins to be loaded, etc.
My directory structure is as follows:
~
└── .vim/
├── colors/
├── .git/
├── .gitignore
├── pack/
│ └── my_plugins/
│ └── start/
│ ├── fugitive/
│ └── syntastic/
└── vimrc
I've noticed that vim already has a bunch of preinstalled specific settings in
/usr/share/vim/vim80/ftplugin/
with .vim files for css, html, python, etc. (in total 216 .vim files). I don't fully understand the contents of these files but I don't want to completely override them with my own settings. Rather, I'd like to "append" my own settings to the already existing ones. (And in case that my settings are conflicting with the existing ones, I want to use my setting.) Where do I put my language specific settings?
The reason I'm asking is that I've seen different methods:
~/.vim/indent
and ~/.vim/folding
directories which both hold eg html.vim files but one with settings for indentation and the other for folding.~/.vim/ftplugin
directory and putting e.g. a html.vim file in there which holds rules for code folding, indentation, etc.Which of these methods is correct/better?
For language specific plugins I want to make use of the Vim 8 package feature. So I guess I put all language specific plugins into ~/.vim/pack/my_plugins/opt/
, that way they are not loaded on startup. But then how do I load the specific plugin whenever a file of that type is opened? For example, for editing .html files, I want to make use of the sparkup plugin but only when I am editing .html files. How do I load this when opening a .html file?
Upvotes: 1
Views: 2688
Reputation: 32926
Side note: ftplugins are already lazily loaded. We don't need packadd
for this.
packadd
will really make sense for actual plugin files (in plugin/
directory), and when testing/using conflicting filetype specific "plugins" like for instance vim-latex VS any another latex suite for vim, or even different versions of a same "plugin".
Upvotes: 0
Reputation: 228
In your .vimrc add:
filetype plugin on
and any config for specific language put in ~/.vim/ftplugin/{language}.vim or ~/.vim/ftplugin/{language}/otfer_files.vim
Read more by:
:help filetype
Upvotes: 2