Skip to content

Commit 3bf6319

Browse files
committed
initial commit
0 parents  commit 3bf6319

23 files changed

+7838
-0
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [16.x, 18.x, 20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: "npm"
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run compile
31+
32+
- name: Lint
33+
run: npm run lint
34+
if: ${{ false }} # Disable linting for now
35+
36+
- name: Test
37+
run: npm test
38+
if: ${{ false }} # Disable testing for now
39+
40+
package:
41+
runs-on: ubuntu-latest
42+
needs: build
43+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
44+
45+
steps:
46+
- uses: actions/checkout@v3
47+
48+
- name: Use Node.js
49+
uses: actions/setup-node@v3
50+
with:
51+
node-version: "18.x"
52+
cache: "npm"
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Build
58+
run: npm run compile
59+
60+
- name: Install tree-sitter CLI
61+
run: npm install -g tree-sitter-cli
62+
63+
- name: Build WASM
64+
run: cd server && npm run build-wasm && cd ..
65+
66+
- name: Package Extension
67+
run: npx vsce package
68+
69+
- name: Upload Extension Artifact
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: scrapscript-lsp-extension
73+
path: "*.vsix"

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Dependency directories
2+
node_modules/
3+
4+
# Compiled output
5+
out/
6+
*.js
7+
!syntaxes/*.js
8+
9+
# Logs
10+
*.log
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
15+
# VS Code specific files
16+
.vscode-test/
17+
*.vsix
18+
19+
# Build files
20+
tree-sitter-*.wasm
21+
22+
# OS specific files
23+
.DS_Store
24+
Thumbs.db
25+
26+
# Environment variables
27+
.env
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# Cache
34+
.npm
35+
.eslintcache
36+
37+
tsconfig.tsbuildinfo
38+
.aider*
39+
40+
/tree-sitter-scrapscript

client/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "scrapscript-lsp-client",
3+
"description": "ScrapScript VSCode client",
4+
"version": "0.1.0",
5+
"publisher": "scrapscript",
6+
"license": "MIT",
7+
"engines": {
8+
"vscode": "^1.75.0"
9+
},
10+
"dependencies": {
11+
"vscode-languageclient": "^9.0.1"
12+
},
13+
"devDependencies": {
14+
"@types/vscode": "^1.100.0",
15+
"@vscode/test-electron": "^2.5.2"
16+
}
17+
}

client/src/extension.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import * as path from "path";
2+
import { workspace, ExtensionContext } from "vscode";
3+
4+
import {
5+
LanguageClient,
6+
LanguageClientOptions,
7+
ServerOptions,
8+
TransportKind,
9+
} from "vscode-languageclient/node";
10+
11+
let client: LanguageClient;
12+
13+
export function activate(context: ExtensionContext) {
14+
// The server is implemented in node
15+
const serverModule = context.asAbsolutePath(
16+
path.join("server", "out", "server.js")
17+
);
18+
19+
// The debug options for the server
20+
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
21+
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
22+
23+
// If the extension is launched in debug mode then the debug server options are used
24+
// Otherwise the run options are used
25+
const serverOptions: ServerOptions = {
26+
run: { module: serverModule, transport: TransportKind.ipc },
27+
debug: {
28+
module: serverModule,
29+
transport: TransportKind.ipc,
30+
options: debugOptions,
31+
},
32+
};
33+
34+
// Options to control the language client
35+
const clientOptions: LanguageClientOptions = {
36+
// Register the server for ScrapScript documents
37+
documentSelector: [{ scheme: "file", language: "scrapscript" }],
38+
synchronize: {
39+
// Notify the server about file changes to '.clientrc files contained in the workspace
40+
fileEvents: workspace.createFileSystemWatcher("**/.clientrc"),
41+
},
42+
};
43+
44+
// Create and start the client
45+
client = new LanguageClient(
46+
"scrapscriptLanguageServer",
47+
"ScrapScript Language Server",
48+
serverOptions,
49+
clientOptions
50+
);
51+
52+
// Start the client. This will also launch the server
53+
client.start();
54+
}
55+
56+
export function deactivate(): Thenable<void> | undefined {
57+
return client && client.stop();
58+
}

client/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2020",
5+
"lib": ["es2020"],
6+
"outDir": "out",
7+
"rootDir": "src",
8+
"sourceMap": true,
9+
"strict": true,
10+
"composite": true
11+
},
12+
"include": ["src"],
13+
"exclude": ["node_modules", ".vscode-test"]
14+
}

example.ss

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
()
2+
3+
; xyz = x + y * z
4+
; x = 10
5+
; y = 20
6+
; z = 30
7+
8+
; double = x -> x * 2
9+
10+
; is-zero =
11+
| 0 -> #true ()
12+
| _ -> #false ()
13+
14+
; person =
15+
{ name = "John"
16+
, age = 30
17+
, address =
18+
{ street = "123 Main St"
19+
, city = "Anytown"
20+
, country = "USA"
21+
}
22+
}
23+
24+
; numbers =
25+
[1, 2, 3, 4, 5]
26+
|> list/map (x -> x * 2)
27+
|> list/map (x -> x + 1)
28+
29+
; sum = list/fold 0 (+) numbers
30+
31+
; factorial =
32+
| n ? n < 0 -> #error "negative input"
33+
| 0 -> #ok 1
34+
| n -> #ok (n * compute (n - 1))
35+
36+
; compose = f -> g -> x -> f (g x)

language-configuration.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"comments": {
3+
"lineComment": "--"
4+
},
5+
"brackets": [
6+
["{", "}"],
7+
["[", "]"],
8+
["(", ")"]
9+
],
10+
"autoClosingPairs": [
11+
{ "open": "{", "close": "}" },
12+
{ "open": "[", "close": "]" },
13+
{ "open": "(", "close": ")" },
14+
{ "open": "\"", "close": "\"" }
15+
],
16+
"surroundingPairs": [
17+
["{", "}"],
18+
["[", "]"],
19+
["(", ")"],
20+
["\"", "\""]
21+
],
22+
"indentationRules": {
23+
"increaseIndentPattern": "({[\\s]*|\\([\\s]*)$",
24+
"decreaseIndentPattern": "^[\\s]*[)}]"
25+
}
26+
}

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) 2025 Taylor Troesh
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.

0 commit comments

Comments
 (0)