Skip to content

Commit aed86ad

Browse files
committed
Add integration for Atomic project FHIRPath LSP server
1 parent a7a3e37 commit aed86ad

19 files changed

Lines changed: 1666 additions & 20 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/node_modules
2+
/dist
3+
4+
*storybook.log
5+
storybook-static
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "https://swc.rs/schema.json",
3+
"module": {
4+
"type": "es6",
5+
"strict": true,
6+
"strictMode": true,
7+
"lazy": false,
8+
"noInterop": true,
9+
"resolveFully": true
10+
},
11+
"jsc": {
12+
"parser": {
13+
"syntax": "typescript",
14+
"tsx": false,
15+
"decorators": false,
16+
"dynamicImport": false
17+
},
18+
"transform": {
19+
"legacyDecorator": false,
20+
"decoratorMetadata": false,
21+
"react": {
22+
"runtime": "automatic",
23+
"development": false,
24+
"useBuiltins": false
25+
}
26+
},
27+
"target": "esnext",
28+
"loose": false,
29+
"externalHelpers": false,
30+
"keepClassNames": false,
31+
"baseUrl": "."
32+
},
33+
"isModule": true,
34+
"sourceMaps": true
35+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
3+
"vcs": {
4+
"enabled": false,
5+
"clientKind": "git",
6+
"useIgnoreFile": false
7+
},
8+
"files": {
9+
"includes": [
10+
".storybook/**",
11+
"src/**",
12+
"example/**",
13+
".vscode/**",
14+
"biome.json",
15+
"index.html",
16+
"package.json",
17+
"tsconfig.app.json",
18+
"tsconfig.json",
19+
"tsconfig.node.json",
20+
"vite.config.ts",
21+
"scripts/**"
22+
],
23+
"ignoreUnknown": false
24+
},
25+
"formatter": {
26+
"enabled": true,
27+
"indentStyle": "tab"
28+
},
29+
"linter": {
30+
"enabled": true,
31+
"domains": {
32+
"project": "recommended",
33+
"react": "recommended",
34+
"test": "recommended"
35+
},
36+
"rules": {
37+
"recommended": true
38+
}
39+
},
40+
"javascript": {
41+
"formatter": {
42+
"quoteStyle": "double"
43+
}
44+
},
45+
"assist": {
46+
"enabled": true,
47+
"actions": {
48+
"source": {
49+
"organizeImports": "on"
50+
}
51+
}
52+
}
53+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import {
2+
autocompletion,
3+
closeBrackets,
4+
closeBracketsKeymap,
5+
completionKeymap,
6+
} from "@codemirror/autocomplete";
7+
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
8+
import {
9+
bracketMatching,
10+
defaultHighlightStyle,
11+
foldGutter,
12+
foldKeymap,
13+
indentOnInput,
14+
syntaxHighlighting,
15+
} from "@codemirror/language";
16+
import { lintKeymap } from "@codemirror/lint";
17+
import { highlightSelectionMatches, searchKeymap } from "@codemirror/search";
18+
import { EditorState } from "@codemirror/state";
19+
import {
20+
crosshairCursor,
21+
drawSelection,
22+
dropCursor,
23+
EditorView,
24+
highlightActiveLine,
25+
highlightActiveLineGutter,
26+
highlightSpecialChars,
27+
keymap,
28+
lineNumbers,
29+
rectangularSelection,
30+
} from "@codemirror/view";
31+
import {
32+
type AidboxClient,
33+
type AuthProvider,
34+
BrowserAuthProvider,
35+
makeClient,
36+
} from "@health-samurai/aidbox-client";
37+
import { createCodeMirrorLsp } from "../src/index";
38+
39+
const initialText = `Patient
40+
.name
41+
.where( use = 'official' )
42+
.first()`;
43+
44+
const aidboxUrl = "http://localhost:8080";
45+
const authProvider: AuthProvider = new BrowserAuthProvider(aidboxUrl);
46+
const client: AidboxClient = makeClient({
47+
baseUrl: aidboxUrl,
48+
authProvider: authProvider,
49+
});
50+
const { extension: lspExtension } = createCodeMirrorLsp(client, {
51+
debug: true,
52+
});
53+
54+
const editorState = EditorState.create({
55+
doc: initialText,
56+
extensions: [
57+
lineNumbers(),
58+
highlightActiveLineGutter(),
59+
highlightSpecialChars(),
60+
history(),
61+
foldGutter(),
62+
drawSelection(),
63+
dropCursor(),
64+
EditorState.allowMultipleSelections.of(true),
65+
indentOnInput(),
66+
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
67+
bracketMatching(),
68+
closeBrackets(),
69+
autocompletion(),
70+
rectangularSelection(),
71+
crosshairCursor(),
72+
highlightActiveLine(),
73+
highlightSelectionMatches(),
74+
keymap.of([
75+
...closeBracketsKeymap,
76+
...defaultKeymap,
77+
...searchKeymap,
78+
...historyKeymap,
79+
...foldKeymap,
80+
...completionKeymap,
81+
...lintKeymap,
82+
]),
83+
// Theme for better visibility
84+
EditorView.theme({
85+
"&": {
86+
fontSize: "14px",
87+
},
88+
".cm-tooltip.cm-tooltip-autocomplete": {
89+
"& > ul": {
90+
fontFamily: "monospace",
91+
maxHeight: "200px",
92+
maxWidth: "400px",
93+
},
94+
},
95+
}),
96+
// autocompletion({
97+
// activateOnTyping: true,
98+
// activateOnTypingDelay: 0, // No delay for triggers
99+
// selectOnOpen: true, // Auto-select first item
100+
// closeOnBlur: true, // Close on blur
101+
// maxRenderedOptions: 100, // Max items to render
102+
// defaultKeymap: true, // Use default keybindings
103+
// icons: true, // Add icons for completion types
104+
// }),
105+
// syntaxHighlighting(defaultHighlightStyle),
106+
lspExtension,
107+
],
108+
});
109+
110+
const cmElement = document.getElementById("cm");
111+
if (cmElement === null) {
112+
throw Error("No #cm element");
113+
}
114+
115+
const _editorView = new EditorView({
116+
state: editorState,
117+
parent: cmElement,
118+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>test1</title>
9+
</head>
10+
11+
<body>
12+
<div id="cm"></div>
13+
<div id="log"></div>
14+
<script type="module" src="/example/main.ts"></script>
15+
</body>
16+
17+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@health-samurai/aidbox-fhirpath-lsp",
3+
"version": "0.0.0-alpha.1",
4+
"type": "module",
5+
"files": [
6+
"dist",
7+
"src"
8+
],
9+
"exports": {
10+
".": "./dist/src/index.js"
11+
},
12+
"scripts": {
13+
"build": "rm -rf dist && mkdir -p dist && swc src -d dist -D && tsc -b --force && echo success",
14+
"build:watch": "tsx scripts/watch.node.ts",
15+
"format": "biome format",
16+
"format:check": "biome format",
17+
"format:fix": "biome format --write",
18+
"lint": "biome check",
19+
"lint:check": "biome check",
20+
"lint:fix": "biome check --write",
21+
"tsc:check": "tsc -b --noEmit"
22+
},
23+
"dependencies": {
24+
"@atomic-ehr/fhirpath": "0.0.5",
25+
"@atomic-ehr/fhirpath-lsp": "0.0.2",
26+
"@health-samurai/aidbox-client": "workspace:*",
27+
"react": "^19.1.0",
28+
"react-dom": "^19.1.0"
29+
},
30+
"devDependencies": {
31+
"@codemirror/autocomplete": "^6.20.0",
32+
"@codemirror/commands": "^6.8.1",
33+
"@codemirror/language": "^6.11.3",
34+
"@codemirror/lint": "^6.8.5",
35+
"@codemirror/lsp-client": "^6.2.0",
36+
"@codemirror/search": "^6.5.11",
37+
"@codemirror/state": "^6.5.2",
38+
"@codemirror/theme-one-dark": "^6.1.3",
39+
"@codemirror/view": "^6.38.1",
40+
"@swc/cli": "^0.7.8",
41+
"@swc/core": "^1.13.5",
42+
"@types/react": "^19.1.9",
43+
"chokidar": "^4.0.3",
44+
"tsdown": "^0.16.6",
45+
"tsx": "^4.20.4",
46+
"typescript": "~5.8.3",
47+
"vite": "^7.0.6",
48+
"vitest": "^3.2.4"
49+
},
50+
"publishConfig": {
51+
"access": "public"
52+
},
53+
"repository": {
54+
"type": "git",
55+
"url": "https://github.com/HealthSamurai/aidbox-ts-sdk"
56+
}
57+
}

0 commit comments

Comments
 (0)