From cdaf58ec6e5698017ab67d0e7eb460471b9ec603 Mon Sep 17 00:00:00 2001 From: fidgetingbits Date: Wed, 19 Jun 2024 15:00:12 +0800 Subject: [PATCH] feat: Add tasks for debugging neovim on linux --- .vscode/tasks.json | 14 ++++++++++++-- docs/contributing/cursorless-in-neovim.md | 3 ++- init.lua | 3 +++ scripts/linux-terminal.sh | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 scripts/linux-terminal.sh diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 824601ee4d..d2d70a4f1a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -196,7 +196,12 @@ "tell app \"Terminal\" to do script \"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development\" activate" ] }, - // TODO: Add linux + "linux": { + "command": "scripts/linux-terminal.sh", + "args": [ + "${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development" + ] + }, "group": "build", "options": { "env": { @@ -224,7 +229,12 @@ "tell app \"Terminal\" to do script \"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test\" activate" ] }, - // TODO: Add linux + "linux": { + "command": "scripts/linux-terminal.sh", + "args": [ + "${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test" + ] + }, "group": "build", "options": { "env": { diff --git a/docs/contributing/cursorless-in-neovim.md b/docs/contributing/cursorless-in-neovim.md index 1827917a79..bbde2c41a4 100644 --- a/docs/contributing/cursorless-in-neovim.md +++ b/docs/contributing/cursorless-in-neovim.md @@ -36,7 +36,8 @@ Note that the `C:\path\to\cursorless` path above should match your cloned cursor ## Running / testing extension locally -In order to test out your local version of the extension or to run unit tests locally, you need to run the extension in debug mode. To do so you need to run the `workbench.action.debug.selectandstart` command in VSCode and then select either "Run neovim extension" or "Run neovim extension tests". +In order to test out your local version of the extension or to run unit tests locally, you need to run the extension in +debug mode. To do so you need to run the `workbench.action.debug.selectandstart` (aka `Debug: Select and Start Debugging`) command in VSCode and then select either "Neovim: Run" or "Neovim: Test". The debug logs are written in `C:\path\to\cursorless\packages\cursorless-neovim\out\nvim_node.log`. diff --git a/init.lua b/init.lua index f4440ecf23..d2a18acfb8 100644 --- a/init.lua +++ b/init.lua @@ -17,6 +17,9 @@ require("lazy").setup({ }) local repo_root = os.getenv("CURSORLESS_REPO_ROOT") +if not repo_root then + error("CURSORLESS_REPO_ROOT is not set. Run via debug-neovim.sh script.") +end vim.opt.runtimepath:append(repo_root .. "/cursorless.nvim") require("talon").setup() diff --git a/scripts/linux-terminal.sh b/scripts/linux-terminal.sh new file mode 100755 index 0000000000..912ed927e9 --- /dev/null +++ b/scripts/linux-terminal.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2068 +set -euo pipefail + +if command -v gnome-terminal &>/dev/null; then + # FIXME: Possibly have to use ;exec bash to not auto-close the terminal + gnome-terminal -- $@ +elif command -v gnome-console &>/dev/null; then + gnome-console -- $@ +elif command -v konsole &>/dev/null; then + konsole --hold -e $@ +elif command -v xfce4-terminal &>/dev/null; then + xfce4-terminal --hold -e $@ +elif command -v kitty &>/dev/null; then + kitty -1 --hold $@ +elif command -v alacritty &>/dev/null; then + alacritty --hold -e $@ +elif command -v wezterm &>/dev/null; then + wezterm --config "exit_behavior='Hold'" start --always-new-process $@ +else + echo "No supported terminal emulator found. File an issue to get it added." + exit 1 +fi