diff --git a/.vimrc b/.vimrc index 74b0283..fbd9e2b 100644 --- a/.vimrc +++ b/.vimrc @@ -1069,6 +1069,24 @@ fu! CountChar(str, char) abort return strlen(l:filtered) endfu +fu! WindowsToUnixPath(str) abort + let l:result = substitute(a:str, '\\', '/', 'g') + return l:result +endfu + +fu! ConvertQuickfixPathsToUnixSlashes() + let l:qflist = getqflist() + for i in range(len(l:qflist)) + let l:bufnr = l:qflist[i]['bufnr'] + if l:bufnr != -1 && bufexists(l:bufnr) + let l:filename = bufname(l:bufnr) + let l:filename = substitute(l:filename, '\\', '/', 'g') + let l:qflist[i]['module'] = l:filename + endif + endfor + call setqflist(l:qflist) +endfu + "################################################################################## " COMPILING CODE "################################################################################## @@ -1290,19 +1308,24 @@ fu! RunProgram() abort return endif - let l:file_exe_name = expand('%:t:r').'.exe' " Just the filename without the path + " Sometimes vim mixes unix and windows slashes so we need to normalize and + " use this in future fnamemodify calls (can't use expand with a string + " that doesn't contain wildcards). + let l:full_path = WindowsToUnixPath(expand('%')) + + let l:file_exe_name = fnamemodify(l:full_path, ':t:r').'.exe' " Just the filename without the path " Easy case is the current file has an exe with the same name in the " same directory. We run that if found. - if filereadable(expand('%:p:h') . '/' . l:file_exe_name) - exec 'AsyncRun! ' . expand('%:p:h') . '/' . l:file_exe_name + if filereadable(fnamemodify(l:full_path, ':p:h') . '/' . l:file_exe_name) + exec 'AsyncRun! ' . fnamemodify(l:full_path, ':p:h') . '/' . l:file_exe_name return endif " We start by looking for something to run relative to the current file's " path. If nothing is found then we start over looking in the current " working directory (the directory vim was opened in). - let l:current_path = expand('%:p:h') + let l:current_path = fnamemodify(l:full_path, ':p:h') if !RunProgramInDirectory(l:current_path, l:file_exe_name) let l:cwd = getcwd() @@ -1314,7 +1337,6 @@ endfu fu! RunProgramInDirectory(starting_path, file_exe_name) abort - let l:search_path = a:starting_path let l:ext = tolower(expand('%:e')) let l:also_search_for_cpp_run_script = 0 " Covers the case of having a run-cpp file in a jai project.