linear-ls 0.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 wilhelm
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,2 @@
1
+ # lls
2
+ Linear Language Server
package/dist/server.js ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_1 = require("vscode-languageserver/node");
4
+ const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
5
+ const defaultSettings = { projectPrefixes: [] };
6
+ let globalSettings = defaultSettings;
7
+ const connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
8
+ const documents = new node_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
9
+ const documentSettings = new Map();
10
+ let supportsConfiguration = false;
11
+ let supportsWorkspaceFolder = false;
12
+ connection.onInitialize((params) => {
13
+ const capabilities = params.capabilities;
14
+ const workspace = capabilities.workspace;
15
+ supportsConfiguration = !!workspace?.configuration;
16
+ supportsWorkspaceFolder = !!workspace?.workspaceFolders;
17
+ const result = {
18
+ capabilities: {
19
+ textDocumentSync: node_1.TextDocumentSyncKind.Incremental,
20
+ completionProvider: {
21
+ resolveProvider: true,
22
+ },
23
+ },
24
+ };
25
+ if (supportsWorkspaceFolder) {
26
+ result.capabilities.workspace = {
27
+ workspaceFolders: {
28
+ supported: true,
29
+ },
30
+ };
31
+ }
32
+ return result;
33
+ });
34
+ connection.onInitialized(() => {
35
+ if (supportsConfiguration) {
36
+ connection.client.register(node_1.DidChangeConfigurationNotification.type, undefined);
37
+ }
38
+ });
39
+ connection.onDidChangeConfiguration((change) => {
40
+ if (supportsConfiguration) {
41
+ documentSettings.clear();
42
+ }
43
+ else {
44
+ // TODO: Validate this and send notification if cooked.
45
+ globalSettings = (change.settings.lls || defaultSettings);
46
+ }
47
+ documents.all().forEach(identifyTickets);
48
+ });
49
+ function getDocumentSettings(resource) {
50
+ if (!supportsConfiguration) {
51
+ return Promise.resolve(globalSettings);
52
+ }
53
+ let result = documentSettings.get(resource);
54
+ if (!result) {
55
+ result = connection.workspace.getConfiguration({
56
+ scopeUri: resource,
57
+ section: "lls",
58
+ });
59
+ documentSettings.set(resource, result);
60
+ }
61
+ return result;
62
+ }
63
+ documents.onDidClose((e) => {
64
+ documentSettings.delete(e.document.uri);
65
+ });
66
+ documents.onDidChangeContent((change) => {
67
+ identifyTickets(change.document);
68
+ });
69
+ async function identifyTickets(textDocument) {
70
+ const settings = await getDocumentSettings(textDocument.uri);
71
+ if (settings.projectPrefixes.length === 0) {
72
+ return;
73
+ }
74
+ const text = textDocument.getText();
75
+ const diagnostics = [];
76
+ settings.projectPrefixes.forEach((prefix) => {
77
+ Array.from(text.matchAll(new RegExp(`${prefix}-[0-9]*`, "g"))).forEach((m) => {
78
+ diagnostics.push({
79
+ source: "Linear",
80
+ message: m[0],
81
+ severity: node_1.DiagnosticSeverity.Hint,
82
+ range: {
83
+ start: textDocument.positionAt(m.index ?? 0),
84
+ end: textDocument.positionAt((m.index ?? 0) + m[0].length),
85
+ },
86
+ });
87
+ });
88
+ });
89
+ connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
90
+ }
91
+ connection.onCompletion(
92
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
93
+ (_textDocumentPosition) => {
94
+ return [
95
+ {
96
+ label: "MOB-1",
97
+ data: "MOB-1",
98
+ kind: node_1.CompletionItemKind.Reference,
99
+ },
100
+ ];
101
+ });
102
+ connection.onCompletionResolve((item) => {
103
+ if (item.data === "MOB-1") {
104
+ item.detail = "Install the application";
105
+ item.documentation = "Details details";
106
+ }
107
+ return item;
108
+ });
109
+ documents.listen(connection);
110
+ connection.listen();
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("./dist/server.js");
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "linear-ls",
3
+ "version": "0.0.1",
4
+ "description": "Linear Language Server",
5
+ "bin": "index.js",
6
+ "main": "index.js",
7
+ "repository": "https://github.com/wilhelmeek/lls",
8
+ "author": "wilhelm <helm@hey.com>",
9
+ "license": "MIT",
10
+ "files": [
11
+ "dist/*.js",
12
+ "index.js"
13
+ ],
14
+ "dependencies": {
15
+ "vscode-languageserver": "^8.0.2",
16
+ "vscode-languageserver-textdocument": "^1.0.8"
17
+ },
18
+ "devDependencies": {
19
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
20
+ "@typescript-eslint/parser": "^5.50.0",
21
+ "eslint": "^8.33.0",
22
+ "prettier": "^2.8.3",
23
+ "typescript": "^4.9.5"
24
+ },
25
+ "eslintConfig": {
26
+ "parser": "@typescript-eslint/parser",
27
+ "plugins": [
28
+ "@typescript-eslint"
29
+ ],
30
+ "extends": [
31
+ "eslint:recommended",
32
+ "plugin:@typescript-eslint/recommended"
33
+ ],
34
+ "rules": {
35
+ "@typescript-eslint/no-unused-vars": "error",
36
+ "@typescript-eslint/no-explicit-any": "error",
37
+ "@typescript-eslint/explicit-module-boundary-types": "error",
38
+ "@typescript-eslint/no-non-null-assertion": "error"
39
+ }
40
+ }
41
+ }