Fix LSP generation failing on Windows
Problem
Running generate_lsp() on Windows fails immediately with exit code 1, never creating compile_commands.json. The build command doesn't actually execute UnrealBuildTool.
Root Cause
Commands were passed to jobstart() as strings with complex quoting:
'cmd /c "C:\\path\\Build.bat" "Development" -flag="value"'
When jobstart receives a string in terminal mode, it parses the quotes. On Windows, this causes double-parsing:
- Neovim parses the string and interprets quotes
cmd.exeparses it again with different quote rules- Arguments reach the batch file mangled
- Batch file exits immediately with error
Solution
Pass commands as arrays instead of strings:
{"cmd.exe", "/c", "C:\\path\\Build.bat", "Development", "-flag=value"}
Arrays bypass quote parsing entirely - each element goes directly to the OS as a separate argument. This works consistently across all platforms:
- Windows:
{"cmd.exe", "/c", script, ...}for .bat files - Linux/Mac:
{script, ...}for shell scripts
Changes
- Added
build_command_array()helper function to construct command arrays - Refactored
execute_build_script()to use arrays instead of string concatenation - Updated
execute_command()to accept both strings and arrays
Testing
Tested on Windows and macOS. LSP generation completes successfully and creates compile_commands.json on both platforms.
Will boot into Windows to check this out, I think this fix smells like an AI round about way to fix this, the solution can be much simpler...about to find out at least.
Yeah definitely. Felt awkward about that solution too. I hope it will at least help accelerate the troubleshooting a bit ✌️