There is no vim convention for this per se, but there are various operating system conventions.
On neovim, your best bet is probably stdpath('cache')
. On linux, this usually resolves to ~/.cache/nvim
. If needed, you can create a subdir for your plugin like
let l:dir = stdpath('cache') . '/myplugin'
if !isdirectory(l:dir)
call mkdir(l:dir, 'p')
endif
In vim, you can emulate stdpath (for linux at least) using
let l:stdpath_cache = (empty($XDG_CACHE_HOME)
\ ? $HOME . '/.cache'
\ : $XDG_CACHE_HOME) . '/vim'
Some plugins write to their install directory but this is not a good practice, as plugins can be installed to system directories to which the user does not have access.
tempname()
? Or (*nix) use a hidden directory like~/.myplugin
or/path/to/script/.mycache
or something;~/.cache/myplugin
also…:help stdpath()