I am trying to load my optional language packages based on filetype. I am using vim8 native package feature.
In vim I can load them with :packadd vim-javascript
. However, I read in :help packadd
- (emphasis mine)
Search for an optional plugin directory in
'packpath'
and source any plugin files found. The directory must match:pack/*/opt/{name}
The directory is added to
'runtimepath'
if it wasn't there yet. If the directorypack/*/opt/{name}/after
exists it is added at the end of'runtimepath'
.If loading packages from
pack/*/start
was skipped, then this directory is searched first:pack/*/start/{name}
Note that
{name}
is the directory name, not the name of the.vim
file. All the files matching the patternpack/*/opt/{name}/plugin/**/*.vim
will be sourced. This allows for using subdirectories belowplugin
, just like with plugins in'runtimepath'
.If the filetype detection was not enabled yet (this is usually done with a
syntax enable
orfiletype on
command in your.vimrc
file), this will also look for{name}/ftdetect/*.vim
files.When the optional
!
is added no plugin files or ftdetect scripts are loaded, only the matching directories are added to'runtimepath'
. This is useful in your.vimrc
. The plugins will then be loaded during initialization, see |load-plugins|.Also see |pack-add|. {only available when compiled with
+eval
}
So I try to write something in my vimrc but it doesn't work.
autocmd! FileType javascript packadd vim-javascript
" Or
autocmd FileType javascript packadd! vim-javascript
I found this Reddit post but as I mentioned, it doesn't work.