diff vim/autoload/ludo.vim @ 424:d8086f81b9c8

Pathogen config files.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 27 Mar 2018 21:34:25 -0700
parents
children 67f14a8c2304
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vim/autoload/ludo.vim	Tue Mar 27 21:34:25 2018 -0700
@@ -0,0 +1,49 @@
+
+" Loads `pathogenrc` files in each bundle directory and, if found,
+" builds an exclude list based on the glob patterns found in them.
+"
+function! ludo#setup_pathogen(bundle_dirs) abort
+    for bundle_dir in a:bundle_dirs
+        let l:rcfile = bundle_dir.'/pathogenrc'
+        if !filereadable(l:rcfile)
+            continue
+        endif
+
+        let l:included = []
+        let l:excluded = []
+        let l:rclines = readfile(l:rcfile)
+        for line in l:rclines
+            if line[0] == '#'
+                continue
+            endif
+            
+            if line[0] == '-'
+                let l:excls = glob(bundle_dir.'/'.line[1:], 1, 1)
+                for excl in l:excls
+                    let l:idx = index(l:included, excl)
+                    if l:idx >= 0
+                        call remove(l:included, l:idx)
+                    endif
+                    call add(l:excluded, excl)
+                endfor
+            else
+                let l:incls = glob(bundle_dir.'/'.line, 1, 1)
+                for incl in l:incls
+                    let l:idx = index(l:excluded, incl)
+                    if l:idx >= 0
+                        call remove(l:excluded, l:idx)
+                    endif
+                    call add(l:included, incl)
+                endfor
+            endif
+        endfor
+
+        for excl in l:excluded
+            if isdirectory(excl)
+                let l:excl_name = fnamemodify(excl, ':t')
+                call add(g:pathogen_disabled, l:excl_name)
+            endif
+        endfor
+    endfor
+endfunction
+