Skip to content

Commit 1be17b8

Browse files
author
Cedric Halbronn
committed
Merge branch 'nvim-talon' into lua-tests
2 parents 5c99334 + be78d0e commit 1be17b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+612
-744
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
* @pokey @AndreasArvidsson
1+
* @pokey @AndreasArvidsson @phillco
22

3-
*keyboard* @pokey @AndreasArvidsson @josharian
4-
*Keyboard* @pokey @AndreasArvidsson @josharian
3+
*keyboard* @pokey @AndreasArvidsson @phillco @josharian
4+
*Keyboard* @pokey @AndreasArvidsson @phillco @josharian
5+
6+
*neovim* @pokey @AndreasArvidsson @saidelike @fidgetingbits
7+
*Neovim* @pokey @AndreasArvidsson @saidelike @fidgetingbits

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525
env:
2626
APP_VERSION: ${{ matrix.app_version }}
27+
NEOVIM_VERSION: ${{ matrix.app_version == 'stable' && 'stable' || 'v0.10.0' }}
2728
VSCODE_CRASH_DIR: ${{ github.workspace }}/artifacts/dumps
2829
VSCODE_LOGS_DIR: ${{ github.workspace }}/artifacts/logs
2930
CURSORLESS_REPO_ROOT: ${{ github.workspace }}
@@ -46,14 +47,13 @@ jobs:
4647
if: runner.os != 'Linux'
4748
- run: bash -x scripts/install-neovim-dependencies.sh
4849
- uses: rhysd/action-setup-vim@v1
49-
if: matrix.app_version != 'legacy'
5050
id: vim
5151
with:
52-
version: ${{ matrix.app_version }}
52+
version: ${{ env.NEOVIM_VERSION }}
5353
neovim: true
5454
- name: Run neovim tests
55-
run: xvfb-run -a pnpm -F @cursorless/test-harness testNeovim
56-
if: runner.os == 'Linux' && matrix.app_version == 'stable'
55+
run: xvfb-run -a pnpm -F @cursorless/test-harness test:neovim
56+
if: runner.os == 'Linux'
5757
env:
5858
NEOVIM_PATH: ${{ steps.vim.outputs.executable }}
5959
- uses: ./.github/actions/test-neovim-lua/

.vscode/tasks.json

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,21 @@
204204
{
205205
"label": "Neovim: Launch neovim",
206206
"type": "process",
207-
"windows": {
208-
"command": "powershell",
209-
"args": [
210-
"(New-Object -ComObject WScript.Shell).Run(\"\"\"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.bat\"\"\", 1, $false)"
211-
]
212-
},
207+
"command": "packages/cursorless-neovim/scripts/linux-terminal.sh",
208+
"args": [
209+
"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development"
210+
],
213211
"osx": {
214212
"command": "osascript",
215213
"args": [
216214
"-e",
217215
"tell app \"Terminal\" to do script \"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development\" activate"
218216
]
219217
},
220-
"linux": {
221-
"command": "packages/cursorless-neovim/scripts/linux-terminal.sh",
218+
"windows": {
219+
"command": "powershell",
222220
"args": [
223-
"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} development"
221+
"(New-Object -ComObject WScript.Shell).Run(\"\"\"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.bat\"\"\", 1, $false)"
224222
]
225223
},
226224
"group": "build",
@@ -237,23 +235,21 @@
237235
{
238236
"label": "Neovim: Launch neovim (test)",
239237
"type": "process",
240-
"windows": {
241-
"command": "powershell",
242-
"args": [
243-
"(New-Object -ComObject WScript.Shell).Run(\"\"\"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.bat\"\"\", 1, $false)"
244-
]
245-
},
238+
"command": "packages/cursorless-neovim/scripts/linux-terminal.sh",
239+
"args": [
240+
"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test"
241+
],
246242
"osx": {
247243
"command": "osascript",
248244
"args": [
249245
"-e",
250246
"tell app \"Terminal\" to do script \"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test\" activate"
251247
]
252248
},
253-
"linux": {
254-
"command": "packages/cursorless-neovim/scripts/linux-terminal.sh",
249+
"windows": {
250+
"command": "powershell",
255251
"args": [
256-
"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.sh ${workspaceFolder} test"
252+
"(New-Object -ComObject WScript.Shell).Run(\"\"\"${workspaceFolder}/packages/cursorless-neovim/scripts/debug-neovim.bat\"\"\", 1, $false)"
257253
]
258254
},
259255
"group": "build",
@@ -270,20 +266,13 @@
270266
{
271267
"label": "Neovim: Show logs",
272268
"type": "process",
273-
"osx": {
274-
"command": "tail",
275-
"args": [
276-
"-f",
277-
"${workspaceFolder}/packages/cursorless-neovim/out/nvim_node.log"
278-
]
279-
},
280-
"linux": {
281-
"command": "tail",
282-
"args": [
283-
"-f",
284-
"${workspaceFolder}/packages/cursorless-neovim/out/nvim_node.log"
285-
]
286-
}
269+
"command": "tail",
270+
"args": [
271+
"-f",
272+
"${workspaceFolder}/packages/cursorless-neovim/out/nvim_node.log"
273+
],
274+
"problemMatcher": [],
275+
"isBackground": true
287276
// NOTE: We don't have a way on Windows atm due to command with argument inside Run() not working
288277
// so we need to show logs outside of vscode (see #2454)
289278
},

cursorless.nvim/CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Contributing
2+
3+
Welcome! So glad you've decided to help make Cursorless in Neovim better.
4+
5+
Note that Cursorless is maintained as a monorepo, hosted at [`cursorless`](https://github.com/cursorless-dev/cursorless), and the source of truth for all of the files here lives there, so that's where you'll want to file a PR. We automatically deploy from our monorepo to the [cursorless.nvim repo](https://github.com/hands-free-vim/cursorless.nvim) in CI.
6+
7+
See [the Cursorless neovim contributor docs](https://www.cursorless.org/docs/contributing/cursorless-in-neovim/) to get started.

cursorless.nvim/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Cedric Halbronn, Brandon Virgil Rule, et al.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

cursorless.nvim/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# cursorless.nvim
2222

23-
Neovim plugin to support Cursorless
23+
Very experimental Neovim plugin providing partial Cursorless support. We support much of the core functionality, but many features are not yet implemented, in particular hats and language-specific scopes. Expect some rough edges, but please give it a try, and if you like it, consider [contributing](https://www.cursorless.org/docs/contributing/cursorless-in-neovim/)!
2424

2525
## Prerequisites
2626

@@ -109,6 +109,10 @@ Some Linux package managers ship with a version of `nvim` too old for Lazy. If t
109109

110110
If you are on Linux, avoid using the snap package for `npm` as it may not be able to globally expose the neovim npm package due to sandboxing. If this is the case, install node via another method (nvm, brew, etc).
111111

112-
## Contributors
112+
## Contributing
113113

114-
Welcome! So glad you've decided to help make Cursorless in Neovim better. You'll want to start by getting [set up](https://github.com/saidelike/cursorless/blob/nvim-talon/docs/contributing/cursorless-in-neovim.md). You may also find the [Neovim API docs](https://neovim.io/doc/user/api.html) helpful to learn about Neovim extension development.
114+
Welcome! So glad you've decided to help make Cursorless in Neovim better.
115+
116+
Note that Cursorless is maintained as a monorepo, hosted at [`cursorless`](https://github.com/cursorless-dev/cursorless), and the source of truth for all of the files here lives there, so that's where you'll want to file a PR. We automatically deploy from our monorepo to the [cursorless.nvim repo](https://github.com/hands-free-vim/cursorless.nvim) in CI.
117+
118+
See [the Cursorless neovim contributor docs](https://www.cursorless.org/docs/contributing/cursorless-in-neovim/) to get started.

docs/contributing/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension](#running--testing-extension-locally). You may also find the [VSCode A
1414

1515
### Steps
1616

17-
1. Clone [`cursorless`](https://github.com/cursorless-dev/cursorless)
17+
1. Clone [`cursorless`](https://github.com/cursorless-dev/cursorless) locally. Note that it doesn't matter where you clone it, as long as you _**do not**_ clone it into your Talon user directory.
1818
2. Open the newly created `cursorless` directory in VSCode. If you're on Windows, don't use WSL (see [#919](https://github.com/cursorless-dev/cursorless/issues/919) for discussion / workaround).
1919
3. Run the following in the terminal:
2020

docs/contributing/architecture/tests.md renamed to docs/contributing/architecture/neovim-test-infrastructure.md

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
# Tests
1+
# Neovim test infrastructure
22

3-
Tests in Cursorless are done in various ways depending on what is tested.
3+
We'll start with a high-level overview of the architecture of the Cursorless tests for neovim, and then we'll dive into the details.
44

5-
1. **Cursorless tests for VSCode**: tests the actions (`take`, `chuck`, etc.) inside VSCode.
5+
## Neovim tests
66

7-
2. **Cursorless unit tests**: tests specific TypeScript functions (`toggle decorations`, `visible multiple regions`, etc.). These tests don't rely on VSCode or neovim.
8-
9-
3. **Cursorless tests for neovim**: tests the actions (`take`, `chuck`, etc.) inside neovim. 99% of them are the same as the "Cursorless tests for VSCode" except some new ones are needed in order to test all actions, due to no hats being supported yet in neovim (and the fact that lots of "Cursorless tests for VSCode" rely on hats).
7+
Here is the call path when running Neovim tests locally. Note that `->` indicates one file calling another file:
108

119
```
12-
// 3.1 Cursorless tests for neovim locally
1310
launch.json -> .vscode/tasks.json -> nvim -u init.lua
1411
1512
init.lua
1613
-> CursorlessLoadExtension()
17-
-> TestHarnessRun() -> run() -> runAllTests() -> Mocha + packages/cursorless-neovim-e2e/src/suite/recorded.neovim.test.ts
14+
-> TestHarnessRun() -> run() -> runAllTests() -> Mocha -> packages/cursorless-neovim-e2e/src/suite/recorded.neovim.test.ts
1815
```
1916

17+
And here is the call path when running Neovim tests on CI:
18+
2019
```
21-
// 3.2 Cursorless tests for neovim on CI
2220
.github/workflows/test.yml -> packages/test-harness/package.json -> my-ts-node src/scripts/runNeovimTestsCI.ts -> packages/test-harness/src/launchNeovimAndRunTests.ts
2321
2422
launchNeovimAndRunTests.ts
@@ -31,40 +29,7 @@ packages/test-harness/src/config/init.lua
3129
-> TestHarnessRun() -> run() -> runAllTests() -> Mocha + packages/cursorless-neovim-e2e/src/suite/recorded.neovim.test.ts
3230
```
3331

34-
4. **Lua unit tests for neovim**: tests lua functions implemented in cursorless.nvim. These tests are
35-
executed inside neovim.
36-
37-
```
38-
// 4.1 Lua unit tests for neovim locally
39-
launch.json -> .vscode/tasks.json -> cd cursorless.nvim && busted --run unit
40-
41-
cursorless.nvim/.busted
42-
-> lua interpreter: cursorless.nvim/test/nvim-shim.sh -> nvim -l <spec_script>
43-
-> test specification files: cursorless.nvim/test/unit/*_spec.lua
44-
```
45-
46-
```
47-
// 4.2 Lua unit tests for neovim on CI
48-
.github/workflows/test.yml -> .github/actions/test-neovim-lua/action.yml -> cd cursorless.nvim && busted --run unit
49-
50-
cursorless.nvim/.busted
51-
-> lua interpreter: cursorless.nvim/test/nvim-shim.sh -> nvim -l <spec_script>
52-
-> test specification files: cursorless.nvim/test/unit/*_spec.lua
53-
```
54-
55-
5. **Cursorless tests for Talon**: XXX
56-
57-
## 1. Cursorless tests for VSCode
58-
59-
XXX
60-
61-
## 2. Cursorless unit tests
62-
63-
XXX
64-
65-
## 3. Cursorless tests for neovim
66-
67-
### 3.1 Cursorless tests for neovim locally
32+
### Running Neovim tests locally
6833

6934
This is supported on Windows, Linux and OSX.
7035

@@ -236,21 +201,21 @@ async function runTestsInDir(
236201
237202
Consequently, the recorded tests from `data/fixtures/recorded/` are executed when `packages/cursorless-neovim-e2e/src/suite/recorded.neovim.test.ts` is invoked.
238203
239-
### 3.2 Cursorless tests for neovim on CI
204+
### Running Neovim tests on CI
240205
241206
This is supported on Linux only.
242207
243208
It starts from `.github/workflows/test.yml` which currently only tests the latest stable neovim version on Linux:
244209
245210
```yml
246-
run: xvfb-run -a pnpm -F @cursorless/test-harness testNeovim
211+
run: xvfb-run -a pnpm -F @cursorless/test-harness test:neovim
247212
if: runner.os == 'Linux' && matrix.app_version == 'stable'
248213
```
249214
250215
This triggers the script in `packages/test-harness/package.json`:
251216
252217
```json
253-
"testNeovim": "env CURSORLESS_MODE=test my-ts-node src/scripts/runNeovimTestsCI.ts",
218+
"test:neovim": "env CURSORLESS_MODE=test my-ts-node src/scripts/runNeovimTestsCI.ts",
254219
```
255220
256221
This ends up calling the default function from `package/test-harness/src/scripts/runNeovimTestsCI.ts` which calls `launchNeovimAndRunTests()` from `packages/test-harness/src/launchNeovimAndRunTests.ts`:
@@ -310,14 +275,33 @@ NOTE: Because `NVIM_NODE_HOST_DEBUG` is not set on CI, `nvim` loads entirely rig
310275
311276
NOTE: CI uses `dist/cursorless.nvim/` (and not `cursorless.nvim/`), since the symlinks in `cursorless.nvim/` are only created locally in order to get symbols loaded, which we don't need on CI.
312277
313-
## 4. Lua unit tests for neovim
278+
## Lua unit tests
314279
315280
This is supported on Linux only, both locally and on CI.
316281
282+
Here is the call path when running lua unit tests locally. Note that `->` indicates one file calling another file:
283+
284+
```
285+
launch.json -> .vscode/tasks.json -> cd cursorless.nvim && busted --run unit
286+
cursorless.nvim/.busted
287+
-> lua interpreter: cursorless.nvim/test/nvim-shim.sh -> nvim -l <spec_script>
288+
-> test specification files: cursorless.nvim/test/unit/*_spec.lua
289+
```
290+
291+
And here is the call path when running lua unit tests on CI:
292+
293+
```
294+
.github/workflows/test.yml -> .github/actions/test-neovim-lua/action.yml -> cd cursorless.nvim && busted --run unit
295+
cursorless.nvim/.busted
296+
-> lua interpreter: cursorless.nvim/test/nvim-shim.sh -> nvim -l <spec_script>
297+
-> test specification files: cursorless.nvim/test/unit/*_spec.lua
298+
```
299+
300+
### Running lua unit tests
301+
317302
Many of the cursorless.nvim lua functions are run in order to complete Cursorless actions and so are already
318303
indirectly tested by the tests described in the [previous section](#3-cursorless-tests-for-neovim). Nevertheless, we run
319304
more specific unit tests in order to give better visibility into exactly which functions are failing.
320-
321305
The [busted](https://github.com/lunarmodules/busted) framework is used to test lua functions defined in cursorless.nvim.
322306
This relies on a `cursorless.nvim/.busted` file which directs busted to use a lua interpreter and test specifications files:
323307
@@ -336,17 +320,10 @@ The `.busted` file declares the `cursorless.nvim/test/nvim-shim.sh` shell wrappe
336320
Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) environment variables (Linux
337321
only) pointing to a temp directory. This allows loading cursorless.nvim, any helpers and (optional) plugins needed to run
338322
the tests. Consequently, the cursorless.nvim lua functions are exposed to the tests. Afterwards, the shim will use `nvim -l <spec_script>` for each of the [lua test specifications scripts](https://neovim.io/doc/user/starting.html#-l).
339-
340323
The `.busted` file declares that test specifications files are in
341324
`cursorless.nvim/test/unit/`. Any file in that folder ending with `_spec.lua` contains tests and will be executed
342325
by neovim's lua interpreter.
343-
344326
NOTE: Different tests rely on
345327
the same custom test helper functions. These functions are exposed as globals in a file called `helpers.lua` placed in `nvim/plugin/` inside the isolated XDG environment. These helpers themselves also have their own unit tests that will be run by busted.
346-
347328
This busted setup was inspired by this [blog
348329
post](https://hiphish.github.io/blog/2024/01/29/testing-neovim-plugins-with-busted/), which goes into greater detail.
349-
350-
## 5. Cursorless tests for Talon
351-
352-
XXX

docs/contributing/cursorless-in-neovim.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Cursorless in Neovim
22

3-
This document describes how to get set up to work on the Cursorless neovim plugin.
3+
This document describes how to get set up to work on the Cursorless neovim plugin. You may also find the [Neovim API docs](https://neovim.io/doc/user/api.html) helpful to learn about Neovim extension development.
4+
5+
Note that Cursorless is maintained as a monorepo, hosted at [`cursorless`](https://github.com/cursorless-dev/cursorless), and the source of truth for all of the files in cursorless.nvim lives there. We automatically deploy from our monorepo to the [cursorless.nvim repo](https://github.com/hands-free-vim/cursorless.nvim) in CI.
46

57
## Initial setup
68

@@ -50,7 +52,7 @@ running: `busted --run unit`. These tests currently only work on Linux.
5052

5153
## Sending pull requests
5254

53-
The [cursorless.nvim](https://github.com/hands-free-vim/cursorless.nvim) repo is part of the larger cursorless monorepo, and is currently part of a pending PR to that monorepo only. If you'd like to send a PR to `cursorless.nvim`, please send a PR against the `nvim-talon` branch of this [repo](https://github.com/saidelike/cursorless).
55+
The source of truth for `cursorless.nvim` lives in the [Cursorless monorepo](https://github.com/cursorless-dev/cursorless/). We automatically push to the [cursorless.nvim](https://github.com/hands-free-vim/cursorless.nvim) repo in CI. If you'd like to contribute to `cursorless.nvim`, please open a PR in the [Cursorless monorepo](https://github.com/cursorless-dev/cursorless/).
5456

5557
## Frequently asked questions
5658

0 commit comments

Comments
 (0)