cursorless
cursorless copied to clipboard
neovim: support visualizing debug logs inside vscode
At the moment, to visualize the neovim log when debugging, we need to show the content of a file outside of vscode, for instance in the terminal.
There is a way to actually open a terminal automatically and visualize the logs directly in the terminal using the following:
.vscode\tasks.json:
{
"label": "neovim logs",
"type": "shell",
"windows": {
"command": "powershell",
"args": [
"(New-Object -ComObject WScript.Shell).Run(\"\"\"powershell Get-Content '${workspaceFolder}/packages/cursorless-neovim/out/nvim_node.log' -wait -tail 30\"\"\", 1, $false)"
]
},
"group": "build"
},
I'm not using it atm because I don't find it very nice, but this is a possibility in case we want to improve the workflow.
Note that the above is Windows only so this will need to be ported for macos or Linux.
also note that before neovim 5.1.0, the logs were actually inside vscode due to a bug that were not redirecting them into the custom logging system. see https://github.com/neovim/node-client/issues/329#issuecomment-2009676355 so it may actually be possible to use vscode debug console alternatively writing them to a file.
Since it works for Linux and OSX, I tried again for Windows but encoutering a few problems.
- I need to use
shelltype instead ofprocessas otherwisetailcommand is not found when trying to execute it. As long as it also works for OSX/Linux, we should be fine (cc @pokey / @fidgetingbits) - vscode does not automatically attach anymore when debugging (I am actually wondering if it attaches for you @pokey and @fidgetingbits with that task, since @fidgetingbits mentioned having problems attaching in https://github.com/cursorless-dev/cursorless/issues/2446)
- I need to use a path of the format
C/path/to/instead ofC:\path\to\due to using git bash shell as otherwise the log file is not found. This could be solved by using a script that convert the path then execute the command
NOTE: isBackground: true does show that the task is a background task afaict (it shows neither a "tick" indicating a finished task nor a "loop" indicating a non-finished task)
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 7bdda96f..645e1d4e 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -247,7 +247,8 @@
},
{
"label": "Neovim: Show logs",
- "type": "process",
+ "type": "shell",
+ "isBackground": true,
"osx": {
"command": "tail",
"args": [
@@ -263,9 +264,11 @@
]
},
"windows": {
- // NOTE: We don't have a way on Windows atm due to command with argument inside Run() not working
- // so we need to show logs outside of vscode (see #2454)
- "command": "echo"
+ "command": "tail",
+ "args": [
+ "-f",
+ "/C/path/to/cursorless/packages/cursorless-neovim/out/nvim_node.log"
+ ]
}
},
@pokey With your changes from https://github.com/cursorless-dev/cursorless/pull/2256/commits/56aec571a4930e6423cf17ebcb57e822690b7c18
I get this error on Windows:
* Executing task in folder cursorless_fork: C:\path\to\cursorless\tail -f C:\path\to\cursorless/packages/cursorless-neovim/out/nvim_node.log
* The terminal process failed to launch: Path to shell executable "C:\path\to\cursorless\tail" does not exist.
Should be fixed in https://github.com/cursorless-dev/cursorless/pull/2256/commits/f1908a12800d96c08f6f74786c1a9eed1c785875; worth checking if that works on windows
It works with this change:
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index e706c6f9..cf5e2230 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -269,7 +269,7 @@
},
{
"label": "Neovim: Show logs",
- "type": "process",
+ "type": "shell",
"command": "packages/cursorless-neovim/scripts/show-logs.sh",
"problemMatcher": [],
"isBackground": true,
I haven't pushed as didn't want to break it for you but can you check and update if it works for you too?
ok works for Pokey on OSX and for me on Windows after changing with shell so only remaining to test is Linux if you want to give it a go @fidgetingbits and close this issue.
note that this is not an ideal solution, as it still requires running the task separately, so we might want to keep this issue open to track that, but I don't feel strongly
Ya, we only need to open it once, and then it is revealed each time we debug so it is pretty good like that imho so I would personally mark it as done. But happy too if you think it is worth improving later
Do we have a separate issue to track the long-term solution of using proper console.log once neovim improves their node support? If so I'd def be happy to close this one
Do we have a separate issue to track the long-term solution of using proper console.log once neovim improves their node support? If so I'd def be happy to close this one
created it in https://github.com/cursorless-dev/cursorless/issues/2579 so only remaining is to confirm current nvim-talon branch works for @fidgetingbits on Linux and we can at least close current issue.
This logging works on Linux if I run the task separately yes, I see the logs in the vscode output window; it no longer runs automatically when running the neovim tests. Also the node debugger no longer automatically attaches for me again.
If this isn't what you're asking for, tell me exactly what to test :D
@fidgetingbits sorry so you're saying debugger is still not working for you with the latest changes?
I guess define not working? I have to manually attach to the node process with the latest changes in order for the tests to start running, but otherwise it works.
I guess define not working? I have to manually attach to the node process with the latest changes in order for the tests to start running, but otherwise it works.
Weird. Auto-attach works when debugging for Pokey (OSX) and me (Windows) with the latest changes. I am wondering if your debugging does not work because of something else on Linux.
@fidgetingbits I don't see why debugging should not work as normal for you. The logging task is separate from the build process now. Maybe try to see if it auto attaches if you previously don't run the task to start the logs. My guess is it won't auto attach either?
Not sure. When it worked for me it didn't work for you both :D I can do some more tests, since the devshell recently messed up so maybe has something to do with it still