Since the Vim 8 release, there's thankfully only one way of structuring your plugins (which is also compatible with major plugin managers, such as vim-plug, Vundle, or Pathogen). The plugins are expected to have the following directory structure:
- autoload/ lets you lazy load bits of your plugin (more on that later)
- colors/ color schemes
- compiler/ (language-specific) compiler-related functionality
- doc/ documentation
- ftdetect/ (filetype-specific) filetype detection settings
- ftplugin/ (filetype-specific) filetype-related plugin code
- indent/ (filetype-specific) indentation-related settings
- plugin/ the core functionality of your plugin
- syntax/ (language-specific) defines language syntax group
As we develop our plugin, let's use Vim 8's new plugin functionality and place our plugin directory into .vim/pack/plugins/start. Since we decided to name our plugin commenter, we'll plop it into .vim/pack/plugins/start/vim-commenter.
Remember, the plugins/ directory can have any name. See Chapter 3, Follow the Leader - Plugin Management for more info. The start/ directory means that the plugin will be loaded on Vim startup.
Let's create a directory for it now:
$ mkdir -p ~/.vim/pack/plugins/start/vim-commenter