1. ZyX_I
  2. frawor

Commits

ZyX_I  committed 6dd9678

Added support for ignoredeps features into newfeature.unload, fixed double addition of a plugin in getdeps function, some other fixes of unloadplugin so that frawor is able to reload itself now; documented return value of FraworLoad and FraworUnload functions

  • Participants
  • Parent commits 737328f
  • Branches default

Comments (0)

Files changed (2)

File doc/frawor.txt

View file
  • Ignore whitespace
 
 FraworLoad({plugin})                                            *FraworLoad()*
         Load {plugin}. {plugin} argument may be either a plugin ID or plugin 
-        dictionary.
+        dictionary. Return 0 if it failed to load plugin, 1 if plugin was 
+        successfully loaded and 2 if plugin is being loaded now.
 
 FraworUnload({plugin})                                        *FraworUnload()*
         Unload {plugin}. {plugin} argument may be either a plugin ID or plugin 
-        dictionary.
+        dictionary. Return list of files in order they must be sourced to load 
+        unloaded plugins back.
 
 ------------------------------------------------------------------------------
 2.2. Commands                                                *frawor-commands*

File plugin/frawor.vim

View file
  • Ignore whitespace
 "▶1 getdeps
 function s:F.getdeps(plugdict, hasdep)
     let r=[a:plugdict]
+    let a:hasdep[a:plugdict.id]=1
     for dplugdict in map(keys(get(s:g.dependents, a:plugdict.id, {})),
                 \        's:g.pls[v:val]')
         if !has_key(a:hasdep, dplugdict.id)
         if has_key(feature, a:key) && (has_key(a:plugdict.dependencies,
                     \                          feature.plid) ||
                     \                  has_key(feature, 'ignoredeps'))
-            call feature[a:key](a:plugdict)
+            " XXX can't use feature[a:key](a:plugdict) due to the vim bug
+            call call(feature[a:key], [a:plugdict], {})
         endif
     endfor
     " XXX required in order not to copy list
         " XXX runfeature returns v:val
         call map(ordered, 's:F.runfeatures(v:val, "unloadpre")')
         for plugdict in ordered
+            if has_key(plugdict.F, '_unload')
+                call plugdict.F._unload()
+            endif
             call s:F.runfeatures(plugdict, "unload")
+            unlockvar plugdict.status
+            let plugdict.status=0
+            lockvar! plugdict.status
+            unlet s:g.pls[plugdict.id]
             unlockvar plugdict.g
             call map(keys(plugdict.g), 'remove(plugdict.g, v:val)')
             unlockvar plugdict.F
             call map(keys(plugdict.F), 'remove(plugdict.F, v:val)')
-            unlockvar plugdict.status
-            let plugdict.status=0
-            lockvar! plugdict.status
-            unlet s:g.pls[plugdict.id]
         endfor
         return tosource
     else
 endfunction
 let s:F._functions.FraworLoad=function('FraworLoad')
 "▶1 FraworUnload
-function FraworUnload(...)
+function! FraworUnload(...)
     return call(s:F.unloadplugin, a:000, {})
 endfunction
 let s:F._functions.FraworUnload=function('FraworUnload')
     endif
 endfunction
 "▶1 features.newfeature.unload
-function s:g.features.newfeature.unload(plugdict, featdict)
-    for fid in keys(a:featdict)
-        unlet s:g.features[fid]
+function s:g.features.newfeature.unload(plugdict)
+    for feature in values(a:plugdict.features.newfeature)
+        if has_key(feature, 'ignoredeps')
+            for plugdict in values(s:g.pls)
+                if has_key(plugdict.features, feature.id)
+                    unlet plugdict.features[feature.id]
+                endif
+            endfor
+        endif
+        unlet s:g.features[feature.id]
     endfor
 endfunction
 "▶1 Plugin registration