comparison vim/autoload/ludo.vim @ 495:232351531855

Vim config improvements - Support for gui vs non gui plugin exclusions rules - Move HasPlugin to an autoload function that can be used in vimrc-local - Don't load the local bundle if it doesn't exist - Handle VS vs UE for building projects
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 12 Nov 2021 10:51:57 -0800
parents 1a54ffbc3b15
children
comparison
equal deleted inserted replaced
494:76defcf6bf02 495:232351531855
43 echohl ErrorMsg 43 echohl ErrorMsg
44 echom v:errmsg 44 echom v:errmsg
45 echohl None 45 echohl None
46 endfunction 46 endfunction
47 47
48 " Returns whether a plugin file exists in the runtime path.
49 function! ludo#has_plugin(plugname, ...) abort
50 let l:dirname = 'plugin/'
51 if a:0 && a:1
52 let l:dirname = 'autoload/'
53 endif
54 return globpath(&runtimepath, l:dirname.a:plugname.'.vim') !=# ''
55 endfunction
48 56
49 " Loads `pathogenrc` files in each bundle directory and, if found, 57 " Loads `pathogenrc` files in each bundle directory and, if found,
50 " builds an exclude list based on the glob patterns found in them. 58 " builds an exclude list based on the glob patterns found in them.
51 " 59 "
52 function! ludo#setup_pathogen(bundle_dirs) abort 60 function! ludo#setup_pathogen(bundle_dirs) abort
63 let l:rclines = readfile(l:rcfile) 71 let l:rclines = readfile(l:rcfile)
64 for line in l:rclines 72 for line in l:rclines
65 if line[0] == '#' 73 if line[0] == '#'
66 continue 74 continue
67 endif 75 endif
68 76
77 if strcharpart(line, 0, 4) == "gui:"
78 if !has('gui')
79 call ludo#trace("Ignoring gui-only line: ".line)
80 continue
81 else
82 let line = line[4:]
83 endif
84 endif
85 if strcharpart(line, 0, 6) == "nogui:"
86 if has('gui')
87 call ludo#trace("Ignoring terminal-only line: ".line)
88 continue
89 else
90 let line = line[6:]
91 endif
92 endif
93
94 let l:add_to = l:included
95 let l:remove_from = l:excluded
69 if line[0] == '-' 96 if line[0] == '-'
70 let l:excls = glob(bundle_dir.'/'.line[1:], 1, 1) 97 let l:add_to = l:excluded
71 for excl in l:excls 98 let l:remove_from = l:included
72 let l:idx = index(l:included, excl) 99 let line = line[1:]
73 if l:idx >= 0 100 endif
74 call remove(l:included, l:idx) 101
75 endif 102 let l:incls = glob(bundle_dir.'/'.line, 1, 1)
76 call add(l:excluded, excl) 103 for incl in l:incls
77 endfor 104 let l:idx = index(l:remove_from, incl)
78 else 105 if l:idx >= 0
79 let l:incls = glob(bundle_dir.'/'.line, 1, 1) 106 call remove(l:remove_from, l:idx)
80 for incl in l:incls 107 endif
81 let l:idx = index(l:excluded, incl) 108 call add(l:add_to, incl)
82 if l:idx >= 0 109 endfor
83 call remove(l:excluded, l:idx)
84 endif
85 call add(l:included, incl)
86 endfor
87 endif
88 endfor 110 endfor
89 111
90 for excl in l:excluded 112 for excl in l:excluded
91 if isdirectory(excl) 113 if isdirectory(excl)
92 let l:excl_name = fnamemodify(excl, ':t') 114 let l:excl_name = fnamemodify(excl, ':t')
168 endif 190 endif
169 break 191 break
170 endfor 192 endfor
171 execute ':'.string(l:tagidx).'tag '.l:tag 193 execute ':'.string(l:tagidx).'tag '.l:tag
172 endfunction 194 endfunction
195
196 function! ludo#build_vs_or_ue() abort
197 if !empty(get(g:, 'unreal_branch_dir', ''))
198 UnrealBuild
199 elseif !empty(get(g: 'vimcrosoft_current_sln', ''))
200 VimcrosoftBuildActiveProject
201 else
202 call ludo#warn("No VS or UE project active")
203 endif
204 endfunction