@nowline/lsp 0.4.1

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.
Files changed (53) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +49 -0
  3. package/dist/index.d.ts +9 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +9 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/nowline-lsp-module.d.ts +29 -0
  8. package/dist/nowline-lsp-module.d.ts.map +1 -0
  9. package/dist/nowline-lsp-module.js +49 -0
  10. package/dist/nowline-lsp-module.js.map +1 -0
  11. package/dist/providers/completion.d.ts +28 -0
  12. package/dist/providers/completion.d.ts.map +1 -0
  13. package/dist/providers/completion.js +175 -0
  14. package/dist/providers/completion.js.map +1 -0
  15. package/dist/providers/definition.d.ts +18 -0
  16. package/dist/providers/definition.d.ts.map +1 -0
  17. package/dist/providers/definition.js +39 -0
  18. package/dist/providers/definition.js.map +1 -0
  19. package/dist/providers/document-symbols.d.ts +24 -0
  20. package/dist/providers/document-symbols.d.ts.map +1 -0
  21. package/dist/providers/document-symbols.js +126 -0
  22. package/dist/providers/document-symbols.js.map +1 -0
  23. package/dist/providers/hover.d.ts +18 -0
  24. package/dist/providers/hover.d.ts.map +1 -0
  25. package/dist/providers/hover.js +78 -0
  26. package/dist/providers/hover.js.map +1 -0
  27. package/dist/providers/references.d.ts +19 -0
  28. package/dist/providers/references.d.ts.map +1 -0
  29. package/dist/providers/references.js +70 -0
  30. package/dist/providers/references.js.map +1 -0
  31. package/dist/providers/rename.d.ts +16 -0
  32. package/dist/providers/rename.d.ts.map +1 -0
  33. package/dist/providers/rename.js +72 -0
  34. package/dist/providers/rename.js.map +1 -0
  35. package/dist/references/ast-utils.d.ts +126 -0
  36. package/dist/references/ast-utils.d.ts.map +1 -0
  37. package/dist/references/ast-utils.js +313 -0
  38. package/dist/references/ast-utils.js.map +1 -0
  39. package/dist/server.d.ts +9 -0
  40. package/dist/server.d.ts.map +1 -0
  41. package/dist/server.js +35 -0
  42. package/dist/server.js.map +1 -0
  43. package/package.json +47 -0
  44. package/src/index.ts +26 -0
  45. package/src/nowline-lsp-module.ts +102 -0
  46. package/src/providers/completion.ts +202 -0
  47. package/src/providers/definition.ts +58 -0
  48. package/src/providers/document-symbols.ts +152 -0
  49. package/src/providers/hover.ts +98 -0
  50. package/src/providers/references.ts +86 -0
  51. package/src/providers/rename.ts +109 -0
  52. package/src/references/ast-utils.ts +378 -0
  53. package/src/server.ts +33 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Lolay, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @nowline/lsp
2
+
3
+ Language Server Protocol implementation for the Nowline DSL. Built on top of
4
+ [`@nowline/core`](../core)'s Langium grammar, validator, and AST. The
5
+ [`@nowline/vscode-extension`](../vscode-extension) bundles this server; other
6
+ LSP-capable editors (Neovim, JetBrains, Helix, Emacs, …) can spawn the bundled
7
+ `nowline-lsp` binary directly.
8
+
9
+ ## What it provides
10
+
11
+ - **Validation** — every diagnostic from `@nowline/core`'s validator surfaces in
12
+ the editor in real time.
13
+ - **Definition** — jump from `after:audit-log`, `owner:sam`, `depends:[…]`,
14
+ `on:…`, `before:…`, etc. to the entity that owns the id.
15
+ - **References** — every text-matching usage of an entity id across the open
16
+ file.
17
+ - **Rename** — rename an entity id and fan the edit out to all references.
18
+ - **Hover** — entity title, status, owner, and link surfaced when the cursor
19
+ hovers a name node or a reference.
20
+ - **Document symbols** — outline tree mirroring `roadmap → swimlane → item`
21
+ (with `parallel` / `group` nesting).
22
+ - **Completion** — id completion inside `after:` / `before:` / `owner:` /
23
+ `on:` / `depends:[]` plus value completion for `status:`. Keyword and
24
+ property-key completion comes from Langium's default provider.
25
+ - **Folding** — block folding driven by Langium's default provider over the
26
+ INDENT/DEDENT-based grammar.
27
+
28
+ The server is **single-file scoped** in m3 — cross-file references through
29
+ `include` are intentionally not resolved by the LSP. Diagnostics and navigation
30
+ operate on the document the user is editing.
31
+
32
+ ## Running the server
33
+
34
+ The package ships a `nowline-lsp` binary. Editors connect over stdio:
35
+
36
+ ```sh
37
+ npx nowline-lsp
38
+ ```
39
+
40
+ Programmatic embedding (e.g. inside a VS Code extension):
41
+
42
+ ```ts
43
+ import { startNowlineServer } from '@nowline/lsp/server';
44
+
45
+ startNowlineServer();
46
+ ```
47
+
48
+ For headless / in-memory usage (tests, MCP, …) use `createNowlineLspServices`
49
+ with an `EmptyFileSystem`.
@@ -0,0 +1,9 @@
1
+ export { type CreateNowlineLspServicesContext, createNowlineLspServices, type NowlineLspServices, } from './nowline-lsp-module.js';
2
+ export { NowlineCompletionProvider } from './providers/completion.js';
3
+ export { NowlineDefinitionProvider } from './providers/definition.js';
4
+ export { NowlineDocumentSymbolProvider } from './providers/document-symbols.js';
5
+ export { NowlineHoverProvider } from './providers/hover.js';
6
+ export { NowlineReferencesProvider } from './providers/references.js';
7
+ export { NowlineRenameProvider } from './providers/rename.js';
8
+ export { BUILTIN_STATUSES, buildEntityIndex, collectNamedEntities, declarationAt, entityKind, fileFromDocument, leafAt, type NamedEntity, propertyValueAt, propKey, REFERENCE_PROP_KEYS, visitAllProperties, visitProperties, } from './references/ast-utils.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,+BAA+B,EACpC,wBAAwB,EACxB,KAAK,kBAAkB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,KAAK,WAAW,EAChB,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAClB,MAAM,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { createNowlineLspServices, } from './nowline-lsp-module.js';
2
+ export { NowlineCompletionProvider } from './providers/completion.js';
3
+ export { NowlineDefinitionProvider } from './providers/definition.js';
4
+ export { NowlineDocumentSymbolProvider } from './providers/document-symbols.js';
5
+ export { NowlineHoverProvider } from './providers/hover.js';
6
+ export { NowlineReferencesProvider } from './providers/references.js';
7
+ export { NowlineRenameProvider } from './providers/rename.js';
8
+ export { BUILTIN_STATUSES, buildEntityIndex, collectNamedEntities, declarationAt, entityKind, fileFromDocument, leafAt, propertyValueAt, propKey, REFERENCE_PROP_KEYS, visitAllProperties, visitProperties, } from './references/ast-utils.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,GAE3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,MAAM,EAEN,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAClB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type NowlineAddedServices } from '@nowline/core';
2
+ import { type FileSystemProvider, type LangiumSharedCoreServices } from 'langium';
3
+ import { type DefaultSharedModuleContext, type LangiumServices, type LangiumSharedServices } from 'langium/lsp';
4
+ /**
5
+ * Combined Langium LSP services + Nowline-specific additions.
6
+ *
7
+ * `LangiumServices` already covers parser, validation, and the LSP service
8
+ * slots (`lsp.DefinitionProvider`, `lsp.HoverProvider`, …). We layer the
9
+ * Nowline validator on top via `NowlineAddedServices`.
10
+ */
11
+ export type NowlineLspServices = LangiumServices & NowlineAddedServices;
12
+ export interface CreateNowlineLspServicesContext {
13
+ /** Optional shared services container (e.g. when reusing across languages). */
14
+ shared?: LangiumSharedServices;
15
+ /** Either a `NodeFileSystem` (real disk) or `EmptyFileSystem` (tests). */
16
+ fileSystemProvider: (services: LangiumSharedCoreServices) => FileSystemProvider;
17
+ /** Optional LSP connection (omit for headless / in-memory usage). */
18
+ connection?: DefaultSharedModuleContext['connection'];
19
+ }
20
+ /**
21
+ * Build the full Langium LSP service container plus the Nowline language
22
+ * services. Returns the shared container (used to start the language server)
23
+ * and the language-specific services (used by tests + provider call sites).
24
+ */
25
+ export declare function createNowlineLspServices(context: CreateNowlineLspServicesContext): {
26
+ shared: LangiumSharedServices;
27
+ Nowline: NowlineLspServices;
28
+ };
29
+ //# sourceMappingURL=nowline-lsp-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nowline-lsp-module.d.ts","sourceRoot":"","sources":["../src/nowline-lsp-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,oBAAoB,EAK5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,KAAK,kBAAkB,EAEvB,KAAK,yBAAyB,EAEjC,MAAM,SAAS,CAAC;AACjB,OAAO,EAGH,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAE7B,MAAM,aAAa,CAAC;AAQrB;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAqBxE,MAAM,WAAW,+BAA+B;IAC5C,+EAA+E;IAC/E,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,0EAA0E;IAC1E,kBAAkB,EAAE,CAAC,QAAQ,EAAE,yBAAyB,KAAK,kBAAkB,CAAC;IAChF,qEAAqE;IACrE,UAAU,CAAC,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG;IAChF,MAAM,EAAE,qBAAqB,CAAC;IAC9B,OAAO,EAAE,kBAAkB,CAAC;CAC/B,CA4BA"}
@@ -0,0 +1,49 @@
1
+ import { NowlineGeneratedModule, NowlineGeneratedSharedModule, NowlineModule, registerValidationChecks, } from '@nowline/core';
2
+ import { inject, } from 'langium';
3
+ import { createDefaultModule, createDefaultSharedModule, } from 'langium/lsp';
4
+ import { NowlineCompletionProvider } from './providers/completion.js';
5
+ import { NowlineDefinitionProvider } from './providers/definition.js';
6
+ import { NowlineDocumentSymbolProvider } from './providers/document-symbols.js';
7
+ import { NowlineHoverProvider } from './providers/hover.js';
8
+ import { NowlineReferencesProvider } from './providers/references.js';
9
+ import { NowlineRenameProvider } from './providers/rename.js';
10
+ /**
11
+ * Language-specific module. Carries the Nowline LSP provider overrides on top
12
+ * of whatever the cross-package `NowlineModule` (parser config + validator
13
+ * factory, lifted from `@nowline/core`) already contributes.
14
+ *
15
+ * Keeping the parser/validation slots on the core-side `NowlineModule` means
16
+ * the LSP and the headless `@nowline/cli` parse path stay byte-identical.
17
+ */
18
+ const NowlineLspProviderModule = {
19
+ lsp: {
20
+ CompletionProvider: (services) => new NowlineCompletionProvider(services),
21
+ DefinitionProvider: (services) => new NowlineDefinitionProvider(services),
22
+ DocumentSymbolProvider: (services) => new NowlineDocumentSymbolProvider(services),
23
+ HoverProvider: (services) => new NowlineHoverProvider(services),
24
+ ReferencesProvider: (services) => new NowlineReferencesProvider(services),
25
+ RenameProvider: (services) => new NowlineRenameProvider(services),
26
+ },
27
+ };
28
+ /**
29
+ * Build the full Langium LSP service container plus the Nowline language
30
+ * services. Returns the shared container (used to start the language server)
31
+ * and the language-specific services (used by tests + provider call sites).
32
+ */
33
+ export function createNowlineLspServices(context) {
34
+ const shared = context.shared ??
35
+ inject(createDefaultSharedModule({
36
+ connection: context.connection,
37
+ fileSystemProvider: context.fileSystemProvider,
38
+ }), NowlineGeneratedSharedModule);
39
+ const Nowline = inject(createDefaultModule({ shared }), NowlineGeneratedModule,
40
+ // `NowlineModule` is typed against `NowlineServices` (core only); cast
41
+ // through `unknown` because the LSP injector is strictly broader and
42
+ // Langium's `inject()` accepts that at runtime. See
43
+ // `packages/core/src/language/nowline-module.ts` for the source.
44
+ NowlineModule, NowlineLspProviderModule);
45
+ shared.ServiceRegistry.register(Nowline);
46
+ registerValidationChecks(Nowline);
47
+ return { shared, Nowline };
48
+ }
49
+ //# sourceMappingURL=nowline-lsp-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nowline-lsp-module.js","sourceRoot":"","sources":["../src/nowline-lsp-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,sBAAsB,EACtB,4BAA4B,EAC5B,aAAa,EACb,wBAAwB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAEH,MAAM,GAGT,MAAM,SAAS,CAAC;AACjB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,GAK5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAW9D;;;;;;;GAOG;AACH,MAAM,wBAAwB,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, type NextFeature } from 'langium/lsp';
3
+ import type { NowlineLspServices } from '../nowline-lsp-module.js';
4
+ /**
5
+ * Custom completion provider. Defers to Langium's keyword + property-key
6
+ * completion (free from the grammar) and adds:
7
+ *
8
+ * - Id-reference completion when the cursor sits in a reference property's
9
+ * value position (`after:`, `before:`, `style:`, `size:`, `labels:[...]`,
10
+ * etc.). Each key only suggests entities whose kind makes sense for it
11
+ * (see `REF_KEY_TO_KINDS`).
12
+ * - Status-value completion: built-in values plus custom `status`
13
+ * declarations.
14
+ * - Icon / capacity-icon built-in vocabulary plus user-declared symbols.
15
+ */
16
+ export declare class NowlineCompletionProvider extends DefaultCompletionProvider {
17
+ constructor(services: NowlineLspServices);
18
+ protected completionFor(context: CompletionContext, next: NextFeature, acceptor: CompletionAcceptor): MaybePromise<void>;
19
+ /**
20
+ * Public so subclasses (and tests) can extend the value-completion table
21
+ * without rewriting the dispatch logic.
22
+ */
23
+ protected acceptValueCompletions(context: CompletionContext, hint: PropertyValueContext, acceptor: CompletionAcceptor): void;
24
+ }
25
+ export interface PropertyValueContext {
26
+ key: string;
27
+ }
28
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/providers/completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACH,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,yBAAyB,EACzB,KAAK,WAAW,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAmCnE;;;;;;;;;;;GAWG;AACH,qBAAa,yBAA0B,SAAQ,yBAAyB;gBACxD,QAAQ,EAAE,kBAAkB;cAIrB,aAAa,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,kBAAkB,GAC7B,YAAY,CAAC,IAAI,CAAC;IAQrB;;;OAGG;IACH,SAAS,CAAC,sBAAsB,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,kBAAkB,GAC7B,IAAI;CA4CV;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,175 @@
1
+ import { DefaultCompletionProvider, } from 'langium/lsp';
2
+ import { CompletionItemKind } from 'vscode-languageserver';
3
+ import { BUILTIN_CAPACITY_ICONS, BUILTIN_ICON_NAMES, BUILTIN_STATUSES, collectNamedEntities, entityKind, fileFromDocument, REFERENCE_PROP_KEYS, } from '../references/ast-utils.js';
4
+ /**
5
+ * Per-key allowlist of entity kinds that make sense as values. Keeps
6
+ * suggestions focused — typing `style:` only shows styles instead of every
7
+ * declared id in the file.
8
+ *
9
+ * The string values match the output of `entityKind()`
10
+ * (`StyleDeclaration` → `style`, `ItemDeclaration` → `item`, …).
11
+ */
12
+ const REF_KEY_TO_KINDS = {
13
+ after: new Set(['item', 'milestone', 'anchor', 'parallel', 'group']),
14
+ before: new Set(['item', 'milestone', 'anchor', 'parallel', 'group']),
15
+ depends: new Set(['item', 'milestone', 'anchor', 'parallel', 'group']),
16
+ on: new Set(['item', 'swimlane', 'parallel', 'group', 'milestone']),
17
+ owner: new Set(['person', 'team']),
18
+ team: new Set(['team']),
19
+ style: new Set(['style']),
20
+ size: new Set(['size']),
21
+ status: new Set(['status']),
22
+ labels: new Set(['label']),
23
+ icon: new Set(['symbol']),
24
+ 'capacity-icon': new Set(['symbol']),
25
+ };
26
+ /**
27
+ * Custom completion provider. Defers to Langium's keyword + property-key
28
+ * completion (free from the grammar) and adds:
29
+ *
30
+ * - Id-reference completion when the cursor sits in a reference property's
31
+ * value position (`after:`, `before:`, `style:`, `size:`, `labels:[...]`,
32
+ * etc.). Each key only suggests entities whose kind makes sense for it
33
+ * (see `REF_KEY_TO_KINDS`).
34
+ * - Status-value completion: built-in values plus custom `status`
35
+ * declarations.
36
+ * - Icon / capacity-icon built-in vocabulary plus user-declared symbols.
37
+ */
38
+ export class NowlineCompletionProvider extends DefaultCompletionProvider {
39
+ constructor(services) {
40
+ super(services);
41
+ }
42
+ completionFor(context, next, acceptor) {
43
+ const valueHint = detectPropertyValueContext(context);
44
+ if (valueHint) {
45
+ this.acceptValueCompletions(context, valueHint, acceptor);
46
+ }
47
+ return super.completionFor(context, next, acceptor);
48
+ }
49
+ /**
50
+ * Public so subclasses (and tests) can extend the value-completion table
51
+ * without rewriting the dispatch logic.
52
+ */
53
+ acceptValueCompletions(context, hint, acceptor) {
54
+ const file = fileFromDocument(context.document);
55
+ if (!file)
56
+ return;
57
+ if (hint.key === 'status') {
58
+ for (const status of BUILTIN_STATUSES) {
59
+ acceptor(context, {
60
+ label: status,
61
+ kind: CompletionItemKind.EnumMember,
62
+ detail: 'built-in status',
63
+ insertText: status,
64
+ });
65
+ }
66
+ }
67
+ if (hint.key === 'icon') {
68
+ for (const icon of BUILTIN_ICON_NAMES) {
69
+ acceptor(context, {
70
+ label: icon,
71
+ kind: CompletionItemKind.EnumMember,
72
+ detail: 'built-in icon',
73
+ insertText: icon,
74
+ });
75
+ }
76
+ }
77
+ if (hint.key === 'capacity-icon') {
78
+ for (const icon of BUILTIN_CAPACITY_ICONS) {
79
+ acceptor(context, {
80
+ label: icon,
81
+ kind: CompletionItemKind.EnumMember,
82
+ detail: 'built-in capacity icon',
83
+ insertText: icon,
84
+ });
85
+ }
86
+ }
87
+ if (REFERENCE_PROP_KEYS.has(hint.key)) {
88
+ const allowed = REF_KEY_TO_KINDS[hint.key];
89
+ for (const ent of collectNamedEntities(file)) {
90
+ if (!ent.name)
91
+ continue;
92
+ if (allowed && !allowed.has(entityKind(ent)))
93
+ continue;
94
+ acceptor(context, buildEntityItem(ent));
95
+ }
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * Best-effort detection of "we're typing inside a property value".
101
+ *
102
+ * The grammar tokenises `key:` as a single PROPERTY_KEY_WITH_COLON, so we
103
+ * walk the text backwards from the cursor over identifier characters, list
104
+ * separators, and `[` to find the closest `key:` token. If we hit `\n` or any
105
+ * other terminator before finding one, the cursor isn't inside a property
106
+ * value.
107
+ *
108
+ * Returns the property key (without the trailing colon) when a match is
109
+ * found.
110
+ */
111
+ function detectPropertyValueContext(context) {
112
+ const text = context.textDocument.getText();
113
+ let i = context.tokenOffset - 1;
114
+ while (i >= 0) {
115
+ const ch = text[i];
116
+ if (ch === ':')
117
+ break;
118
+ if (ch === '\n' || ch === '\r')
119
+ return undefined;
120
+ if (!/[A-Za-z0-9_\-,. \t[\]"'%/]/.test(ch))
121
+ return undefined;
122
+ i--;
123
+ }
124
+ if (i < 0)
125
+ return undefined;
126
+ let j = i - 1;
127
+ while (j >= 0 && /[A-Za-z0-9_-]/.test(text[j]))
128
+ j--;
129
+ const key = text.slice(j + 1, i);
130
+ if (!key)
131
+ return undefined;
132
+ return { key };
133
+ }
134
+ function buildEntityItem(entity) {
135
+ const kind = entityKind(entity);
136
+ return {
137
+ label: entity.name,
138
+ kind: kindFor(kind),
139
+ detail: entity.title ? `${kind} — ${entity.title}` : kind,
140
+ insertText: entity.name,
141
+ };
142
+ }
143
+ function kindFor(kind) {
144
+ switch (kind) {
145
+ case 'item':
146
+ return CompletionItemKind.Field;
147
+ case 'swimlane':
148
+ return CompletionItemKind.Class;
149
+ case 'parallel':
150
+ case 'group':
151
+ return CompletionItemKind.Module;
152
+ case 'anchor':
153
+ case 'milestone':
154
+ return CompletionItemKind.Event;
155
+ case 'person':
156
+ return CompletionItemKind.Constant;
157
+ case 'team':
158
+ return CompletionItemKind.Module;
159
+ case 'label':
160
+ return CompletionItemKind.EnumMember;
161
+ case 'size':
162
+ return CompletionItemKind.Value;
163
+ case 'status':
164
+ return CompletionItemKind.Enum;
165
+ case 'style':
166
+ return CompletionItemKind.Color;
167
+ case 'symbol':
168
+ return CompletionItemKind.Snippet;
169
+ case 'footnote':
170
+ return CompletionItemKind.Text;
171
+ default:
172
+ return CompletionItemKind.Reference;
173
+ }
174
+ }
175
+ //# sourceMappingURL=completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/providers/completion.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,yBAAyB,GAE5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAuB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAEhB,mBAAmB,GACtB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAwC;IAC1D,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACpE,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACrE,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACtE,EAAE,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACnE,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACvB,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IACzB,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC3B,MAAM,EAAE,IAAI,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,CAAC;QACd,KAAK,WAAW;YACZ,OAAO,kBAAkB,CAAC,KAAK,CAAC;QACpC,KAAK,QAAQ;YACT,OAAO,kBAAkB,CAAC,QAAQ,CAAC;QACvC,KAAK,MAAM;YACP,OAAO,kBAAkB,CAAC,MAAM,CAAC;QACrC,KAAK,OAAO;YACR,OAAO,kBAAkB,CAAC,UAAU,CAAC;QACzC,KAAK,MAAM;YACP,OAAO,kBAAkB,CAAC,KAAK,CAAC;QACpC,KAAK,QAAQ;YACT,OAAO,kBAAkB,CAAC,IAAI,CAAC;QACnC,KAAK,OAAO;YACR,OAAO,kBAAkB,CAAC,KAAK,CAAC;QACpC,KAAK,QAAQ;YACT,OAAO,kBAAkB,CAAC,OAAO,CAAC;QACtC,KAAK,UAAU;YACX,OAAO,kBAAkB,CAAC,IAAI,CAAC;QACnC;YACI,OAAO,kBAAkB,CAAC,SAAS,CAAC;IAC5C,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { LangiumDocument, MaybePromise } from 'langium';
2
+ import type { DefinitionProvider } from 'langium/lsp';
3
+ import type { CancellationToken, DefinitionParams } from 'vscode-languageserver';
4
+ import { LocationLink } from 'vscode-languageserver';
5
+ import type { NowlineLspServices } from '../nowline-lsp-module.js';
6
+ /**
7
+ * Custom definition provider. The Nowline grammar uses `PropertyAtom` (plain
8
+ * text) for cross-references, so Langium's default cross-ref-aware provider
9
+ * has nothing to follow. We walk the AST instead: when the cursor sits on a
10
+ * value of a reference property (`after:`, `before:`, `owner:`, `on:`,
11
+ * `depends:[]`), look up the target id in the file-level entity index and
12
+ * return its declaration site.
13
+ */
14
+ export declare class NowlineDefinitionProvider implements DefinitionProvider {
15
+ constructor(_services: NowlineLspServices);
16
+ getDefinition(document: LangiumDocument, params: DefinitionParams, _cancelToken?: CancellationToken): MaybePromise<LocationLink[] | undefined>;
17
+ }
18
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/providers/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAWnE;;;;;;;GAOG;AACH,qBAAa,yBAA0B,YAAW,kBAAkB;gBACpD,SAAS,EAAE,kBAAkB;IAIzC,aAAa,CACT,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,gBAAgB,EACxB,YAAY,CAAC,EAAE,iBAAiB,GACjC,YAAY,CAAC,YAAY,EAAE,GAAG,SAAS,CAAC;CAyB9C"}
@@ -0,0 +1,39 @@
1
+ import { LocationLink } from 'vscode-languageserver';
2
+ import { buildEntityIndex, fileFromDocument, leafAt, nameRangeOf, propertyValueAt, propKey, REFERENCE_PROP_KEYS, } from '../references/ast-utils.js';
3
+ /**
4
+ * Custom definition provider. The Nowline grammar uses `PropertyAtom` (plain
5
+ * text) for cross-references, so Langium's default cross-ref-aware provider
6
+ * has nothing to follow. We walk the AST instead: when the cursor sits on a
7
+ * value of a reference property (`after:`, `before:`, `owner:`, `on:`,
8
+ * `depends:[]`), look up the target id in the file-level entity index and
9
+ * return its declaration site.
10
+ */
11
+ export class NowlineDefinitionProvider {
12
+ constructor(_services) {
13
+ /* No collaborator dependencies; AST helpers are pure. */
14
+ }
15
+ getDefinition(document, params, _cancelToken) {
16
+ const file = fileFromDocument(document);
17
+ if (!file)
18
+ return undefined;
19
+ const offset = document.textDocument.offsetAt(params.position);
20
+ const leaf = leafAt(document, offset);
21
+ const hit = propertyValueAt(leaf);
22
+ if (!hit)
23
+ return undefined;
24
+ if (!REFERENCE_PROP_KEYS.has(propKey(hit.prop)))
25
+ return undefined;
26
+ const index = buildEntityIndex(file);
27
+ const target = index.get(hit.value);
28
+ if (!target)
29
+ return undefined;
30
+ const targetCst = target.$cstNode;
31
+ if (!targetCst)
32
+ return undefined;
33
+ const nameRange = nameRangeOf(target) ?? targetCst.range;
34
+ return [
35
+ LocationLink.create(document.uri.toString(), targetCst.range, nameRange, hit.valueNode.range),
36
+ ];
37
+ }
38
+ }
39
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/providers/definition.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,WAAW,EACX,eAAe,EACf,OAAO,EACP,mBAAmB,GACtB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IAClC,YAAY,SAA6B;QACrC,yDAAyD;IAC7D,CAAC;IAED,aAAa,CACT,QAAyB,EACzB,MAAwB,EACxB,YAAgC;QAEhC,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QAC3B,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QAElE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI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