UnrealEngine.nvim icon indicating copy to clipboard operation
UnrealEngine.nvim copied to clipboard

Fix LSP generation failing on Windows

Open BarakXYZ opened this issue 1 month ago • 2 comments

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:

  1. Neovim parses the string and interprets quotes
  2. cmd.exe parses it again with different quote rules
  3. Arguments reach the batch file mangled
  4. 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.

BarakXYZ avatar Nov 24 '25 18:11 BarakXYZ

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.

mbwilding avatar Nov 25 '25 10:11 mbwilding

Yeah definitely. Felt awkward about that solution too. I hope it will at least help accelerate the troubleshooting a bit ✌️

BarakXYZ avatar Nov 25 '25 12:11 BarakXYZ