robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
adb2258345
master
1if exists ( 'g:loaded_remote_plugins' ) 2finish 3endif 4let g: loaded_remote_plugins = '/path/to/manifest' 5 6" Get the path to the rplugin manifest file. 7function ! s: GetManifestPath () abort 8let manifest_base = '' 9 10if exists ( '$NVIM_RPLUGIN_MANIFEST' ) 11return fnamemodify ( $ NVIM_RPLUGIN_MANIFEST , ':p' ) 12endif 13 14let dest = stdpath ( 'data' ) 15if ! empty ( dest ) 16if ! isdirectory ( dest ) 17if getftype ( dest ) != "link" 18call mkdir ( dest , 'p' , 0700 ) 19endif 20endif 21let manifest_base = dest 22endif 23 24return manifest_base . '/rplugin.vim' 25endfunction 26 27" Old manifest file based on known script locations. 28function ! s: GetOldManifestPaths () abort 29let prefix = exists ( '$MYVIMRC' ) 30 \? $ MYVIMRC 31 \: matchstr ( get ( split ( execute ( 'scriptnames' ), '\n' ), 0 , '' ), '\f\+$' ) 32let origpath = fnamemodify ( expand ( prefix , 1 ), ':h' ) 33 \. '/.' . fnamemodify ( prefix , ':t' ) . '-rplugin~' 34if ! has ( 'win32' ) 35return [ origpath ] 36endif 37" Windows used to use $APPLOCALDATA/nvim but stdpath('data') is 38" $XDG_DATA_DIR/nvim-data 39let pseudostdpath = exists ( '$LOCALAPPDATA' ) ? '$LOCALAPPDATA' : '~/AppData/Local' 40let pseudostdpath = fnamemodify ( expand ( pseudostdpath ), ':p' ) 41return [ substitute ( pseudostdpath , '[/\\]\=$' , '/' , '' ) . 'nvim/rplugin.vim' , origpath ] 42endfunction 43 44function ! s: GetManifest () abort 45let manifest = s: GetManifestPath () 46if ! filereadable ( manifest ) 47" Check if an old manifest file exists and move it to the new location. 48for old_manifest in s: GetOldManifestPaths () 49if filereadable ( old_manifest ) 50call rename ( old_manifest , manifest ) 51break 52endif 53endfor 54endif 55return manifest 56endfunction 57 58function ! s: LoadRemotePlugins () abort 59let g: loaded_remote_plugins = s: GetManifest () 60if filereadable ( g: loaded_remote_plugins ) 61execute 'source' fnameescape ( g: loaded_remote_plugins ) 62endif 63endfunction 64 65command ! -bar UpdateRemotePlugins call remote#host#UpdateRemotePlugins() 66 67if index ( v: argv , "--clean" ) < 0 68call s: LoadRemotePlugins () 69endif