Skip to content

Commit

Permalink
feat: Add tasks for debugging neovim on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
fidgetingbits committed Jun 19, 2024
1 parent 0af05b2 commit cdaf58e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
14 changes: 12 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion docs/contributing/cursorless-in-neovim.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
3 changes: 3 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 23 additions & 0 deletions scripts/linux-terminal.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cdaf58e

Please sign in to comment.