Skip to content

Commit d124747

Browse files
committed
feat: Add tasks for debugging neovim on linux
1 parent 49cb9f2 commit d124747

File tree

8 files changed

+90
-11
lines changed

8 files changed

+90
-11
lines changed

.vscode/tasks.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@
205205
"tell app \"Terminal\" to do script \"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development\" activate"
206206
]
207207
},
208-
// TODO: Add linux
208+
"linux": {
209+
"command": "packages/cursorless-neovim/scripts/linux-terminal.sh",
210+
"args": [
211+
"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development"
212+
]
213+
},
209214
"group": "build",
210215
"options": {
211216
"env": {
@@ -233,7 +238,12 @@
233238
"tell app \"Terminal\" to do script \"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test\" activate"
234239
]
235240
},
236-
// TODO: Add linux
241+
"linux": {
242+
"command": "packages/cursorless-neovim/scripts/linux-terminal.sh",
243+
"args": [
244+
"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test"
245+
]
246+
},
237247
"group": "build",
238248
"options": {
239249
"env": {

docs/contributing/cursorless-in-neovim.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Note that the `C:\path\to\cursorless` path above should match your cloned cursor
3535

3636
## Running / testing extension locally
3737

38-
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".
38+
In order to test out your local version of the extension or to run unit tests locally, you need to run the extension in
39+
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".
3940

4041
The debug logs are written in `C:\path\to\cursorless\packages\cursorless-neovim\out\nvim_node.log`.
4142

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
description = "A Nix-flake-based development environment for Cursorless";
33

4-
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
};
57

68
outputs =
79
{ self, nixpkgs }:
@@ -13,7 +15,43 @@
1315
"aarch64-darwin"
1416
];
1517
forEachSupportedSystem =
16-
f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
18+
f:
19+
nixpkgs.lib.genAttrs supportedSystems (
20+
system:
21+
f {
22+
pkgs = import nixpkgs {
23+
inherit system;
24+
overlays = [
25+
# https://github.com/NixOS/nixpkgs/pull/317333
26+
(final: prev: {
27+
nodePackages = prev.nodePackages // {
28+
neovim = prev.buildNpmPackage rec {
29+
pname = "neovim-node-client";
30+
version = "5.1.1-dev.0";
31+
src = prev.fetchFromGitHub {
32+
owner = "neovim";
33+
repo = "node-client";
34+
rev = "d99ececf115ddc8ade98467417c1bf0120b676b5";
35+
hash = "sha256-eiKyhJNz7kH2iX55lkn7NZYTj6yaSZLMZxqiqPxDIPs=";
36+
};
37+
npmDeps = prev.fetchNpmDeps {
38+
inherit src;
39+
hash = "sha256-UoMq+7evskxtZygycxLBgeUtwrET8jYKeZwMiXdBMAw=";
40+
};
41+
postInstall = ''
42+
mkdir -p $out/bin
43+
ln -s $out/lib/node_modules/neovim/node_modules/.bin/neovim-node-host $out/bin
44+
'';
45+
};
46+
};
47+
neovim = prev.neovim.override { withNodeJs = true; };
48+
49+
})
50+
51+
];
52+
};
53+
}
54+
);
1755
pythonVersion = builtins.replaceStrings [ "py" ] [
1856
"python"
1957
] (nixpkgs.lib.importTOML ./pyproject.toml).tool.ruff.target-version;
@@ -37,17 +75,18 @@
3775
--set PYTHONPATH $PYTHONPATH
3876
'';
3977
}))
40-
4178
python
79+
pkgs.neovim
4280
];
4381
# To prevent weird broken non-interactive bash terminal
4482
buildInputs = [ pkgs.bashInteractive ];
4583
shellHook = ''
4684
if [ ! -f .git/hooks/pre-commit ]; then
4785
echo "You can run 'pre-commit install' to install git commit hooks if you want them."
4886
fi
49-
5087
pnpm install
88+
89+
PATH=${pkgs.lib.getBin pkgs.neovim}/bin:$PATH}
5190
'';
5291
};
5392
}

init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ require("lazy").setup({
1717
})
1818

1919
local repo_root = os.getenv("CURSORLESS_REPO_ROOT")
20+
if not repo_root then
21+
error("CURSORLESS_REPO_ROOT is not set. Run via debug-neovim.sh script.")
22+
end
2023
vim.opt.runtimepath:append(repo_root .. "/cursorless.nvim")
2124

2225
require("talon").setup()

packages/cursorless-neovim/scripts/debug-neovim.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export NVIM_NODE_LOG_FILE="${workspaceFolder}/packages/cursorless-neovim/out/nvi
1010
export NVIM_NODE_LOG_LEVEL="info"
1111
export CURSORLESS_MODE="${cursorless_mode}"
1212

13-
nvim -u "${workspaceFolder}/init.lua"
13+
command nvim -u "${workspaceFolder}/init.lua"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC2068
3+
set -euo pipefail
4+
5+
if command -v gnome-terminal &>/dev/null; then
6+
# FIXME: Possibly have to use ;exec bash to not auto-close the terminal
7+
gnome-terminal -- $@
8+
elif command -v gnome-console &>/dev/null; then
9+
gnome-console -- $@
10+
elif command -v konsole &>/dev/null; then
11+
konsole --hold -e $@
12+
elif command -v xfce4-terminal &>/dev/null; then
13+
xfce4-terminal --hold -e $@
14+
elif command -v kitty &>/dev/null; then
15+
kitty -1 --hold $@
16+
elif command -v alacritty &>/dev/null; then
17+
alacritty --hold -e $@
18+
elif command -v wezterm &>/dev/null; then
19+
wezterm --config "exit_behavior='Hold'" start --always-new-process $@
20+
else
21+
echo "No supported terminal emulator found. File an issue to get it added."
22+
exit 1
23+
fi

packages/cursorless-neovim/scripts/populate-dist.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
set -euo pipefail
33

44
echo "Populating dist directory..."
5+
if [ ! -e "${CURSORLESS_REPO_ROOT-nonexistent}" ]; then
6+
CURSORLESS_REPO_ROOT=$(git rev-parse --show-toplevel)
7+
fi
58
echo "CURSORLESS_REPO_ROOT: $CURSORLESS_REPO_ROOT"
69
cursorless_nvim_dir="$CURSORLESS_REPO_ROOT/cursorless.nvim"
710
cursorless_neovim_node_in_dir="$CURSORLESS_REPO_ROOT/packages/cursorless-neovim"

0 commit comments

Comments
 (0)