Skip to content

Commit

Permalink
Merge pull request #43 from kbwo/fix/data-structure
Browse files Browse the repository at this point in the history
Change adapterCommand schema
  • Loading branch information
kbwo authored Oct 30, 2024
2 parents 27bfdd0 + c6d8393 commit 7da5b98
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 222 deletions.
16 changes: 7 additions & 9 deletions .vim/coc-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"testing.enable": true,
"testing.fileTypes": ["rust"],
"testing.adapterCommand": {
"rust": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test", "--workspace"],
"include": ["/**/*.rs"],
"exclude": ["/demo/**/*"],
"workspace_dir": "."
}
]
"rust": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test", "--workspace"],
"include": ["/**/*.rs"],
"exclude": ["/demo/**/*"],
"workspace_dir": "."
}
},
"testing.enableWorkspaceDiagnostics": true,
"testing.server.path": "testing-language-server",
Expand Down
113 changes: 80 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,51 +26,98 @@ cargo install testing-ls-adapter

- [x] Realtime testing diagnostics
- [x] [VSCode extension](https://github.com/kbwo/vscode-testing-ls)
- [x] [Coc.nvim extension](https://github.com/kbwo/coc-testing-ls)
- [x] [coc.nvim extension](https://github.com/kbwo/coc-testing-ls)
- [x] For Neovim builtin LSP, see [demo/README.md](./demo/README.md)
- [ ] More efficient checking of diagnostics
- [ ] Useful commands in each extension

## Configuration

language server config:

```
"languageserver": {
"testing": {
"command": "<server path>/testing-language-server",
"trace.server": "verbose",
"filetypes": [
"rust",
"javascript"
],
"initializationOptions": {
"initializationOptions": {
"adapterCommand": {
"cargo test": [
{
"path": "<adapter path>/testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test"],
"include": ["**/*.rs"],
"exclude": ["**/target/**"]
}
],
"jest": [
{
"path": "<adapter path>/testing-ls-adapter",
"extra_arg": ["--test-kind=jest"],
"include": ["/**/*.js"],
"exclude": ["/node_modules/**/*"]
}
]
### VSCode

Install from [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=kbwo.testing-language-server).
You should set `adapterCommand` in `initializationOptions` for each project.
You can see the example in [settings.json](./demo/.vscode/settings.json).


### coc.nvim
Install from `:CocInstall coc-testing-ls`.
You should set `adapterCommand` in `initializationOptions` for each project.
You can see the example in [See more example](./demo/.vim/coc-settings.json)

### Neovim (nvim-lspconfig)

```lua
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
local util = require "lspconfig/util"

configs.testing_ls = {
default_config = {
cmd = { "testing-language-server" },
filetypes = { "rust" },
root_dir = util.root_pattern(".git", "Cargo.toml"),
init_options = {
enable = true,
fileTypes = {"rust"},
adapterCommand = {
-- See test execution settings for each project
-- This configuration assumes a Rust project
rust = {
path = "testing-ls-adapter",
extra_arg = { "--test-kind=cargo-test", "--workspace" },
include = { "/demo/**/src/**/*.rs"},
exclude = { "/**/target/**"},
}
},
enableWorkspaceDiagnostics = true,
trace = {
server = "verbose"
}
}
},
docs = {
description = [[
https://github.com/kbwo/testing-language-server
Language Server for real-time testing.
]],
},
}

lspconfig.testing_ls.setup{}
```


## ⚠️ Breaking Changes (2024-10-25)

The configuration structure for adapter commands has been changed:

**Before:**
```json
"adapterCommand": {
"rust": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test"]
// ...
}
]
}
```

**After:**
```json
"adapterCommand": {
"rust": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test"]
// ...
}
}
```

[See more example](./demo/.vim/coc-settings.json)
The array wrapper has been removed to simplify the configuration structure. Please update your settings accordingly.

## Adapter
- [x] `cargo test`
Expand All @@ -85,4 +132,4 @@ language server config:
### Writing custom adapter
⚠ The specification of adapter CLI is not stabilized yet.

See [ADAPTER_SPEC.md](./doc/ADAPTER_SPEC.md) and [spec.rs](./src/spec.rs).
See [ADAPTER_SPEC.md](./doc/ADAPTER_SPEC.md) and [spec.rs](./src/spec.rs).
3 changes: 3 additions & 0 deletions demo/.helix/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[editor.soft-wrap]
enable = true
max-wrap = 25 # increase value to reduce forced mid-word wrapping
112 changes: 48 additions & 64 deletions demo/.vim/coc-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,54 @@
"filetypes": ["rust", "javascript", "go", "typescript", "php"],
"initializationOptions": {
"adapterCommand": {
"cargo-test": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test"],
"include": ["/**/src/**/*.rs"],
"exclude": ["/**/target/**"]
}
],
"cargo-nextest": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-nextest"],
"include": ["/**/src/**/*.rs"],
"exclude": ["/**/target/**"]
}
],
"jest": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=jest"],
"include": ["/jest/*.js"],
"exclude": ["/jest/**/node_modules/**/*"]
}
],
"vitest": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=vitest"],
"include": ["/vitest/*.test.ts", "/vitest/config/**/*.test.ts"],
"exclude": ["/vitest/**/node_modules/**/*"]
}
],
"deno": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=deno"],
"include": ["/deno/*.ts"],
"exclude": []
}
],
"go": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=go-test"],
"include": ["/**/*.go"],
"exclude": []
}
],
"node-test": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=node-test"],
"include": ["/node-test/*.test.js"],
"exclude": []
}
],
"phpunit": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=phpunit"],
"include": ["/**/*Test.php"],
"exclude": ["/phpunit/vendor/**/*.php"]
}
]
"cargo-test": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-test"],
"include": ["/**/src/**/*.rs"],
"exclude": ["/**/target/**"]
},
"cargo-nextest": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-nextest"],
"include": ["/**/src/**/*.rs"],
"exclude": ["/**/target/**"]
},
"jest": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=jest"],
"include": ["/jest/*.js"],
"exclude": ["/jest/**/node_modules/**/*"]
},
"vitest": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=vitest"],
"include": ["/vitest/*.test.ts", "/vitest/config/**/*.test.ts"],
"exclude": ["/vitest/**/node_modules/**/*"]
},
"deno": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=deno"],
"include": ["/deno/*.ts"],
"exclude": []
},
"go": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=go-test"],
"include": ["/**/*.go"],
"exclude": []
},
"node-test": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=node-test"],
"include": ["/node-test/*.test.js"],
"exclude": []
},
"phpunit": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=phpunit"],
"include": ["/**/*Test.php"],
"exclude": ["/phpunit/vendor/**/*.php"]
}
}
}
}
Expand Down
98 changes: 42 additions & 56 deletions demo/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,48 @@
"testing.enable": true,
"filetypes": ["rust", "javascript", "go", "typescript", "php"],
"testing.adapterCommand": {
"cargo-nextest": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-nextest"],
"include": ["/**/src/**/*.rs"],
"exclude": ["/**/target/**"]
}
],
"jest": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=jest"],
"include": ["/jest/*.js"],
"exclude": ["/jest/**/node_modules/**/*"]
}
],
"vitest": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=vitest"],
"include": ["/vitest/*.test.ts", "/vitest/config/**/*.test.ts"],
"exclude": ["/vitest/**/node_modules/**/*"]
}
],
"deno": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=deno"],
"include": ["/deno/*.ts"],
"exclude": []
}
],
"go": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=go-test"],
"include": ["/**/*.go"],
"exclude": []
}
],
"node-test": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=node-test"],
"include": ["/node-test/*.test.js"],
"exclude": []
}
],
"phpunit": [
{
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=phpunit"],
"include": ["/**/*Test.php"],
"exclude": ["/phpunit/vendor/**/*.php"]
}
]
"cargo-nextest": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=cargo-nextest"],
"include": ["/**/src/**/*.rs"],
"exclude": ["/**/target/**"]
},
"jest": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=jest"],
"include": ["/jest/*.js"],
"exclude": ["/jest/**/node_modules/**/*"]
},
"vitest": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=vitest"],
"include": ["/vitest/*.test.ts", "/vitest/config/**/*.test.ts"],
"exclude": ["/vitest/**/node_modules/**/*"]
},
"deno": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=deno"],
"include": ["/deno/*.ts"],
"exclude": []
},
"go": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=go-test"],
"include": ["/**/*.go"],
"exclude": []
},
"node-test": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=node-test"],
"include": ["/node-test/*.test.js"],
"exclude": []
},
"phpunit": {
"path": "testing-ls-adapter",
"extra_arg": ["--test-kind=phpunit"],
"include": ["/**/*Test.php"],
"exclude": ["/phpunit/vendor/**/*.php"]
}
},
"testing.enableWorkspaceDiagnostics": true,
"testing.server.path": "testing-language-server",
Expand Down
Loading

0 comments on commit 7da5b98

Please sign in to comment.