@bascik/language-server 0.1.0-rc.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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/analyzer.d.ts +29 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +1160 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/api-rules.d.ts +12 -0
- package/dist/api-rules.d.ts.map +1 -0
- package/dist/api-rules.js +62 -0
- package/dist/api-rules.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +15 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +122 -0
- package/dist/cli.js.map +1 -0
- package/dist/compatibility-rules.json +50 -0
- package/dist/component-metadata.d.ts +24 -0
- package/dist/component-metadata.d.ts.map +1 -0
- package/dist/component-metadata.js +158 -0
- package/dist/component-metadata.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +29 -0
- package/dist/config.js.map +1 -0
- package/dist/ignore-comments.d.ts +8 -0
- package/dist/ignore-comments.d.ts.map +1 -0
- package/dist/ignore-comments.js +65 -0
- package/dist/ignore-comments.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/module-specifiers.d.ts +7 -0
- package/dist/module-specifiers.d.ts.map +1 -0
- package/dist/module-specifiers.js +197 -0
- package/dist/module-specifiers.js.map +1 -0
- package/dist/project.d.ts +20 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +133 -0
- package/dist/project.js.map +1 -0
- package/dist/rules.d.ts +9 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +15 -0
- package/dist/rules.js.map +1 -0
- package/dist/server-script-rules.d.ts +13 -0
- package/dist/server-script-rules.d.ts.map +1 -0
- package/dist/server-script-rules.js +253 -0
- package/dist/server-script-rules.js.map +1 -0
- package/dist/server.d.ts +18 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +156 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Collin Thomas
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @bascik/language-server
|
|
2
|
+
|
|
3
|
+
Official Language Server Protocol (LSP) server for Bascik projects.
|
|
4
|
+
|
|
5
|
+
Provides editor-agnostic intelligence for Bascik HTML components, props, slots, mutually exclusive script directives, and scoping diagnostics across any LSP-compatible editor.
|
|
6
|
+
|
|
7
|
+
## Capabilities
|
|
8
|
+
|
|
9
|
+
- **Autocompletion (`textDocument/completion`)**:
|
|
10
|
+
- Discovers custom component tags (e.g. `<site-nav>`, `<docs-head>`).
|
|
11
|
+
- Auto-inserts self-closing tags for void components (`<docs-head />`) or slot containers (`<site-nav>$0</site-nav>`).
|
|
12
|
+
- Auto-completes inferred and declared component props (`data-bascik-prop-*`).
|
|
13
|
+
- Auto-completes contextual script directives (`data-bascik-build`, `data-bascik-routes`, `data-bascik-server`, `data-bascik-stream`) with mutual exclusion.
|
|
14
|
+
- **Hover Documentation (`textDocument/hover`)**:
|
|
15
|
+
- Displays docblock summaries, prop descriptions, and slot requirements from `<!-- @bascik -->` metadata headers.
|
|
16
|
+
- **Jump to Definition (`textDocument/definition`)**:
|
|
17
|
+
- Jump from a component tag directly to its HTML component source file.
|
|
18
|
+
- Jump from build/server script imports (`@/...` or `./...`) to their target source files.
|
|
19
|
+
- **Diagnostics (`textDocument/diagnostic`)**:
|
|
20
|
+
- Unclosed component tag warnings.
|
|
21
|
+
- Paired closing tag warnings on zero-slot components (`prefer-self-closing-component`).
|
|
22
|
+
- Misplaced script directives on non-`<script>` tags.
|
|
23
|
+
- Undeclared prop attributes on component tags.
|
|
24
|
+
- Misplaced `data-bascik-slot` attributes.
|
|
25
|
+
- Scoping compatibility checks in CSS and JavaScript.
|
|
26
|
+
- In-file ignore comment support (`<!-- bascik-ignore -->`, `/* bascik-ignore */`, `// bascik-ignore`).
|
|
27
|
+
- Configuration support via `bascik.ext.json` or `bascik.ext.ts`.
|
|
28
|
+
|
|
29
|
+
## Installation & CLI Usage
|
|
30
|
+
|
|
31
|
+
Run directly via `npx`:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx @bascik/language-server --stdio
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or install globally:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install -g @bascik/language-server
|
|
41
|
+
bascik-language-server --stdio
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Editor Configurations
|
|
45
|
+
|
|
46
|
+
### Neovim (`nvim-lspconfig`)
|
|
47
|
+
|
|
48
|
+
In your Neovim configuration (`lua`):
|
|
49
|
+
|
|
50
|
+
```lua
|
|
51
|
+
local lspconfig = require('lspconfig')
|
|
52
|
+
local configs = require('lspconfig.configs')
|
|
53
|
+
|
|
54
|
+
if not configs.bascik then
|
|
55
|
+
configs.bascik = {
|
|
56
|
+
default_config = {
|
|
57
|
+
cmd = { 'npx', '@bascik/language-server', '--stdio' },
|
|
58
|
+
filetypes = { 'html' },
|
|
59
|
+
root_dir = lspconfig.util.root_pattern('bascik.config.ts', 'bascik.config.js', '.git'),
|
|
60
|
+
settings = {},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
lspconfig.bascik.setup{}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Helix
|
|
69
|
+
|
|
70
|
+
In your `languages.toml`:
|
|
71
|
+
|
|
72
|
+
```toml
|
|
73
|
+
[language-server.bascik]
|
|
74
|
+
command = "npx"
|
|
75
|
+
args = ["@bascik/language-server", "--stdio"]
|
|
76
|
+
|
|
77
|
+
[[language]]
|
|
78
|
+
name = "html"
|
|
79
|
+
language-servers = ["vscode-html-language-server", "bascik"]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Zed
|
|
83
|
+
|
|
84
|
+
In your Zed settings:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"lsp": {
|
|
89
|
+
"bascik": {
|
|
90
|
+
"binary": {
|
|
91
|
+
"path": "npx",
|
|
92
|
+
"arguments": ["@bascik/language-server", "--stdio"]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Claude Code / AI Agents
|
|
100
|
+
|
|
101
|
+
Claude Code, Cursor, and AI agents supporting the Model Context Protocol (MCP) or standard language server communication can launch `bascik-language-server --stdio` as an external language server process to query component contracts, props, and diagnostics programmatically.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Diagnostic, type Position, type Range, type CompletionItem, type LocationLink, type Hover } from 'vscode-languageserver';
|
|
2
|
+
import { type TextDocumentLike } from './types.js';
|
|
3
|
+
import { type ProjectSnapshot } from './project.js';
|
|
4
|
+
import { type ComponentMetadata } from './component-metadata.js';
|
|
5
|
+
export declare const BUILT_IN_HTML_ELEMENTS: Set<string>;
|
|
6
|
+
export declare const SCRIPT_DIRECTIVES: {
|
|
7
|
+
name: string;
|
|
8
|
+
detail: string;
|
|
9
|
+
documentation: string;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const SCRIPT_BLOCK_RE: RegExp;
|
|
12
|
+
export declare function maskHtmlRawTextContents(html: string): string;
|
|
13
|
+
export declare function escapeRegExp(value: string): string;
|
|
14
|
+
export declare function findMatchingClose(html: string, tagName: string, contentStart: number): number;
|
|
15
|
+
export declare function findNearestParentComponent(source: string, componentMap: Map<string, string>): string | undefined;
|
|
16
|
+
export declare function parseScriptOpenTagAttributes(openTag: string): Map<string, string | true>;
|
|
17
|
+
export declare function resolveScriptTarget(value: string, documentDir: string, importRootAbs: string, kind: 'specifier' | 'src'): string | undefined;
|
|
18
|
+
export declare function leadingSlashSpecifierMessage(specifier: string): string;
|
|
19
|
+
export declare function collectLeadingSlashDiagnostics(document: TextDocumentLike, openTag: string, scriptBody: string, blockStart: number, attrs: Map<string, string | true>): Diagnostic[];
|
|
20
|
+
export declare function createComponentDocumentationMarkdown(relativePath: string, metadata: ComponentMetadata | undefined): string;
|
|
21
|
+
export declare function completionReplacementRange(document: TextDocumentLike, position: Position): Range;
|
|
22
|
+
export declare function createDiagnostics(document: TextDocumentLike, fsPath: string, snapshot: ProjectSnapshot | undefined, openDocumentTexts?: {
|
|
23
|
+
fsPath: string;
|
|
24
|
+
text: string;
|
|
25
|
+
}[]): Diagnostic[];
|
|
26
|
+
export declare function createCompletions(document: TextDocumentLike, position: Position, snapshot: ProjectSnapshot): CompletionItem[] | undefined;
|
|
27
|
+
export declare function createHover(document: TextDocumentLike, position: Position, snapshot: ProjectSnapshot): Hover | undefined;
|
|
28
|
+
export declare function createDefinition(document: TextDocumentLike, position: Position, snapshot: ProjectSnapshot, fsPath: string): LocationLink[] | undefined;
|
|
29
|
+
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,KAAK,EAEX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC,eAAO,MAAM,sBAAsB,aAgHjC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;GAyB7B,CAAC;AAEF,eAAO,MAAM,eAAe,QACwC,CAAC;AAErE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW5D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CA8CR;AAED,wBAAgB,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