cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.13k stars 79 forks source link

neovim: debugging should use the workspace `init.lua` instead of the system one #2510

Open saidelike opened 2 months ago

saidelike commented 2 months ago
saidelike commented 2 months ago

I believe @pokey added support for OSX for that already in https://github.com/cursorless-dev/cursorless/pull/2256/commits/94d2f169bc6c72bf72cac08fd4ebc238d2be37c1 by using nvim -u /path/to/init.lua.

I've tried doing the same with my Powershell command on Windows from vscode but without much success atm. It is weird I can't do it from vscode because I am able to load the workspace init.lua manually from a standalone cmd.exe (outside of vscode):

image

I have confirmed it is the right one loaded by adding a print("Cursorless loaded") at the end of the workspace init.lua which we see above was shown.

However when I try the same in tasks.json I get various errors:

  1. this works fine without any argument passed to nvim (but it loads the system one instead of the workspace one)
    {
      "label": "Neovim: Launch neovim",
      "type": "process",
      "windows": {
        "command": "powershell",
        "args": [
          // TODO: Add -u here to use the custom config
          "(New-Object -ComObject WScript.Shell).Run(\"\"\"nvim\"\"\", 1, $false)"
        ]
      },
  1. using a path relative to the workspace does not work
        "args": [
          // TODO: Add -u here to use the custom config
          "(New-Object -ComObject WScript.Shell).Run(\"\"\"nvim -u ${workspaceFolder}\\init.lua \"\"\", 1, $false)"
        ]

result:

 *  Executing task in folder cursorless_fork: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (New-Object -ComObject WScript.Shell).Run("""nvim -u C:\path\to\cursorless_fork\init.lua""", 1, $false) 

The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
At line:1 char:1
+ (New-Object -ComObject WScript.Shell).Run("""nvim -u C:\work\tools\vo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException

Same with single quotes:

        "args": [
          // TODO: Add -u here to use the custom config
          "(New-Object -ComObject WScript.Shell).Run(\"\"\"nvim -u '${workspaceFolder}\\init.lua' \"\"\", 1, $false)"
        ]

result:

 *  Executing task in folder cursorless_fork: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (New-Object -ComObject WScript.Shell).Run("""nvim -u 'C:\path\to\cursorless_fork\init.lua' """, 1, $false) 

The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
At line:1 char:1
+ (New-Object -ComObject WScript.Shell).Run("""nvim -u 'C:\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException

same with double quotes:

        "args": [
          // TODO: Add -u here to use the custom config
          "(New-Object -ComObject WScript.Shell).Run(\"\"\"nvim -u \"${workspaceFolder}\\init.lua\" \"\"\", 1, $false)"
        ]

result:

Executing task in folder cursorless_fork: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (New-Object -ComObject WScript.Shell).Run("""nvim -u "C:\path\to\cursorless_fork\init.lua" """, 1, $false) 

At line:1 char:55
+ (New-Object -ComObject WScript.Shell).Run("""nvim -u "C:\work\tools\v ...
+                                                       ~
Missing ')' in method call.
At line:1 char:55
+ ... """nvim -u "C:\path\to\cursorless_fork\init.lua" """,  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'C:\path\to\cursorless_fork\init.lua" """' in expression or statement.
At line:1 char:110
+ ...  -u "C:\path\to\cursorless_fork\init.lua" """, 1, $fal ...
+                                                                 ~
Missing argument in parameter list.
At line:1 char:121
+ ...  "C:\path\to\cursorless_fork\init.lua" """, 1, $false)
+                                                                         ~
Unexpected token ')' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
  1. hardcoding the path does not work
        "args": [
          // TODO: Add -u here to use the custom config
          "(New-Object -ComObject WScript.Shell).Run(\"\"\"nvim -u C:\\path\\to\\cursorless_fork\\init.lua \"\"\", 1, $false)"
        ]

gives:

 *  Executing task in folder cursorless_fork: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (New-Object -ComObject WScript.Shell).Run("""nvim -u C:\path\to\cursorless_fork\init.lua """, 1, $false) 

The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
At line:1 char:1
+ (New-Object -ComObject WScript.Shell).Run("""nvim -u C:\...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException
saidelike commented 2 months ago

fixed for Windows in c747b51