@torpor/language-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/dist/bin/index.d.mts +1 -0
- package/dist/bin/index.js +9 -0
- package/dist/bin/index.js.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/src-DXbwpiIY.mjs +1333 -0
- package/dist/src-DXbwpiIY.mjs.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @torpor/language-server
|
|
2
|
+
|
|
3
|
+
A language server for [Torpor](https://torpor.dev) ([GitHub](https://github.com/andrewjk/torpor)),
|
|
4
|
+
for use in any editor that speaks the Language Server Protocol.
|
|
5
|
+
|
|
6
|
+
It provides type checking and diagnostics, auto-completion, hover information,
|
|
7
|
+
go to definition and more for `.torp` files. Syntax highlighting is handled by
|
|
8
|
+
each editor (see below).
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
The `torpor-lsp` binary is installed with the package and defaults to stdio:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
torpor-lsp --stdio
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The transport can also be set explicitly with `--node-ipc` or
|
|
19
|
+
`--socket={number}` (VS Code uses `--node-ipc`).
|
|
20
|
+
|
|
21
|
+
The server reads the project's `tsconfig.json`, and resolves imports against
|
|
22
|
+
the project's `node_modules`, so it works best inside a Torpor project that
|
|
23
|
+
has `@torpor/view` installed.
|
|
24
|
+
|
|
25
|
+
It also uses the project's own TypeScript for the language service when one
|
|
26
|
+
is installed (resolved from the opened file, like Node would), so that
|
|
27
|
+
diagnostics match the user's build. If the project does not have TypeScript,
|
|
28
|
+
or the installed version is not compatible, it falls back to the version
|
|
29
|
+
bundled with this package.
|
|
30
|
+
|
|
31
|
+
## Editors
|
|
32
|
+
|
|
33
|
+
### VS Code
|
|
34
|
+
|
|
35
|
+
Use the [Torpor extension](https://marketplace.visualstudio.com/items?itemName=Torpor.torpor),
|
|
36
|
+
which bundles this server -- see [packages/vscode](../vscode).
|
|
37
|
+
|
|
38
|
+
### Neovim
|
|
39
|
+
|
|
40
|
+
With the built-in LSP API (Neovim 0.11+):
|
|
41
|
+
|
|
42
|
+
```lua
|
|
43
|
+
vim.lsp.config.torpor = {
|
|
44
|
+
cmd = { "torpor-lsp", "--stdio" },
|
|
45
|
+
filetypes = { "torpor" },
|
|
46
|
+
}
|
|
47
|
+
vim.lsp.enable("torpor")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For syntax highlighting, a tree-sitter grammar is needed -- the
|
|
51
|
+
[@torpor/textmate](../textmate) grammar can be used with a TextMate plugin
|
|
52
|
+
(e.g. `nvim-treesitter`'s `tmLanguage` support) in the meantime.
|
|
53
|
+
|
|
54
|
+
### Helix
|
|
55
|
+
|
|
56
|
+
In `languages.toml`:
|
|
57
|
+
|
|
58
|
+
```toml
|
|
59
|
+
[[language]]
|
|
60
|
+
name = "torpor"
|
|
61
|
+
scope = "source.torp"
|
|
62
|
+
file-types = ["torp"]
|
|
63
|
+
language-servers = ["torpor-lsp"]
|
|
64
|
+
|
|
65
|
+
[language-server.torpor-lsp]
|
|
66
|
+
command = "torpor-lsp"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### OpenCode
|
|
70
|
+
|
|
71
|
+
In `opencode.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"lsp": {
|
|
76
|
+
"torpor": {
|
|
77
|
+
"command": ["torpor-lsp", "--stdio"],
|
|
78
|
+
"extensions": [".torp"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Zed
|
|
85
|
+
|
|
86
|
+
Not yet supported -- Zed requires an extension package (which registers the
|
|
87
|
+
language, grammar and server). See the follow-up notes in the repository.
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
This package is part of the Torpor pnpm workspace:
|
|
92
|
+
|
|
93
|
+
- `@torpor/view` (`workspace:^`) provides the compiler used to transform
|
|
94
|
+
`.torp` files into TypeScript
|
|
95
|
+
- TypeScript is kept as an external dependency -- the language server reads
|
|
96
|
+
TypeScript's `lib/*.d.ts` files from disk at runtime (via
|
|
97
|
+
`@typescript/vfs`)
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
pnpm build # build dist/ (tsdown via vp pack)
|
|
101
|
+
pnpm build:watch # rebuild on change
|
|
102
|
+
pnpm check # typecheck and lint
|
|
103
|
+
pnpm test # run the tests
|
|
104
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import { t as start } from "../src-DXbwpiIY.mjs";
|
|
3
|
+
//#region src/bin/index.ts
|
|
4
|
+
if (!process.argv.slice(2).some((arg) => arg === "--stdio" || arg === "--node-ipc" || arg.startsWith("--socket"))) process.argv.push("--stdio");
|
|
5
|
+
start();
|
|
6
|
+
//#endregion
|
|
7
|
+
export {};
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/bin/index.ts"],"sourcesContent":["#! /usr/bin/env node\nimport { start } from \"../index\";\n\n// Editors launch the server with an explicit transport argument\n// (--node-ipc, --stdio or --socket={number}). Default to stdio, so that the\n// server can be used by any editor or LSP client.\nconst args = process.argv.slice(2);\nif (!args.some((arg) => arg === \"--stdio\" || arg === \"--node-ipc\" || arg.startsWith(\"--socket\"))) {\n\tprocess.argv.push(\"--stdio\");\n}\n\nstart();\n"],"mappings":";;;AAOA,IAAI,CADS,QAAQ,KAAK,MAAM,CACxB,CAAC,CAAC,MAAM,QAAQ,QAAQ,aAAa,QAAQ,gBAAgB,IAAI,WAAW,UAAU,CAAC,GAC9F,QAAQ,KAAK,KAAK,SAAS;AAG5B,MAAM"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/server.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Starts the Torpor language server on the current process, wiring up all
|
|
4
|
+
* handlers to a new connection.
|
|
5
|
+
*
|
|
6
|
+
* The transport (stdio, node-ipc or socket) is detected from the command
|
|
7
|
+
* line arguments, with the `torpor-lsp` bin defaulting to stdio.
|
|
8
|
+
*/
|
|
9
|
+
declare function start(): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { start };
|
|
12
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/server.ts"],"mappings":";;;;;;;;iBA0BgB"}
|
package/dist/index.mjs
ADDED