comparison autoload/unreal.vim @ 1:43d0e448edce

Don't change the vimcrosoft solution if it's not needed. Fix indenting.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 25 Sep 2020 09:44:49 -0700
parents ba03cac1b1c6
children 9235d8341a18
comparison
equal deleted inserted replaced
0:ba03cac1b1c6 1:43d0e448edce
94 94
95 if exists(":VimcrosoftSetSln") 95 if exists(":VimcrosoftSetSln")
96 if l:proj_was_set 96 if l:proj_was_set
97 let l:sln_files = glob(g:unreal_project_dir.s:dirsep."*.sln", 0, 1) 97 let l:sln_files = glob(g:unreal_project_dir.s:dirsep."*.sln", 0, 1)
98 if !empty(l:sln_files) 98 if !empty(l:sln_files)
99 execute "VimcrosoftSetSln ".fnameescape(l:sln_files[0]) 99 " Vimcrosoft might have auto-found the same solution, already,
100 100 " in which case we don't have to set it.
101 call unreal#generate_vimcrosoft_extra_args(l:sln_files[0]) 101 if g:vimcrosoft_current_sln != l:sln_files[0]
102 execute "VimcrosoftSetSln ".fnameescape(l:sln_files[0])
103 endif
104 " Make sure we have our extra compiler args ready.
105 call unreal#generate_vimcrosoft_extra_args(l:sln_files[0])
102 endif 106 endif
103 else 107 else
104 execute "VimcrosoftUnsetSln" 108 execute "VimcrosoftUnsetSln"
105 endif 109 endif
106 endif 110 endif
122 endfunction 126 endfunction
123 127
124 let s:extra_args_version = 1 128 let s:extra_args_version = 1
125 129
126 function! unreal#generate_vimcrosoft_extra_args(solution) abort 130 function! unreal#generate_vimcrosoft_extra_args(solution) abort
127 let l:argfile = 131 let l:argfile =
128 \fnamemodify(a:solution, ':p:h').s:dirsep. 132 \fnamemodify(a:solution, ':p:h').s:dirsep.
129 \'.vimcrosoft'.s:dirsep. 133 \'.vimcrosoft'.s:dirsep.
130 \fnamemodify(a:solution, ':t').'.flags' 134 \fnamemodify(a:solution, ':t').'.flags'
131 135
132 let l:do_regen = 0 136 let l:do_regen = 0
133 let l:version_line = "# version ".string(s:extra_args_version) 137 let l:version_line = "# version ".string(s:extra_args_version)
134 try 138 try
135 call unreal#trace("Checking for extra clang args file: ".l:argfile) 139 call unreal#trace("Checking for extra clang args file: ".l:argfile)
136 let l:lines = readfile(l:argfile) 140 let l:lines = readfile(l:argfile)
137 if len(l:lines) < 1 141 if len(l:lines) < 1
138 call unreal#trace("Extra clang args file is empty... regenerating") 142 call unreal#trace("Extra clang args file is empty... regenerating")
139 let l:do_regen = 1 143 let l:do_regen = 1
140 elseif trim(l:lines[0]) != l:version_line 144 elseif trim(l:lines[0]) != l:version_line
141 call unreal#trace("Extra clang args file is outdated... regenerating") 145 call unreal#trace("Extra clang args file is outdated... regenerating")
142 let l:do_regen = 1 146 let l:do_regen = 1
143 endif 147 endif
144 catch 148 catch
145 call unreal#trace("Extra clang args file doesn't exist... regenerating") 149 call unreal#trace("Extra clang args file doesn't exist... regenerating")
146 let l:do_regen = 1 150 let l:do_regen = 1
147 endtry 151 endtry
148 if l:do_regen 152 if l:do_regen
149 let l:arglines = [ 153 let l:arglines = [
150 \l:version_line, 154 \l:version_line,
151 \"-DUNREAL_CODE_ANALYZER" 155 \"-DUNREAL_CODE_ANALYZER"
152 \] 156 \]
153 call writefile(l:arglines, l:argfile) 157 call writefile(l:arglines, l:argfile)
154 endif 158 endif
155 endfunction 159 endfunction
156 160
157 " }}} 161 " }}}
158 162
159 " Commands {{{ 163 " Commands {{{