@herb-tools/language-server 0.4.0 → 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.
- package/README.md +42 -10
- package/dist/formatting_service.js +4 -6
- package/dist/formatting_service.js.map +1 -1
- package/dist/herb-language-server.js +308 -144
- package/dist/herb-language-server.js.map +1 -1
- package/dist/index.cjs +308 -144
- package/dist/index.cjs.map +1 -1
- package/dist/linter_service.js +1 -1
- package/dist/linter_service.js.map +1 -1
- package/dist/settings.js +3 -0
- package/dist/settings.js.map +1 -1
- package/package.json +10 -6
- package/src/formatting_service.ts +5 -6
- package/src/linter_service.ts +1 -1
- package/src/settings.ts +3 -0
package/dist/linter_service.js
CHANGED
|
@@ -12,7 +12,7 @@ class LinterService {
|
|
|
12
12
|
async lintDocument(document, textDocument) {
|
|
13
13
|
var _a, _b;
|
|
14
14
|
const settings = await this.settings.getDocumentSettings(textDocument.uri);
|
|
15
|
-
const linterEnabled = (_b = (_a = settings.linter) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true;
|
|
15
|
+
const linterEnabled = (_b = (_a = settings === null || settings === void 0 ? void 0 : settings.linter) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true;
|
|
16
16
|
if (!linterEnabled) {
|
|
17
17
|
return { diagnostics: [] };
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter_service.js","sourceRoot":"","sources":["../src/linter_service.ts"],"names":[],"mappings":";;;AAAA,qDAA6G;AAE7G,+CAA2C;AAU3C,MAAa,aAAa;IAKxB,YAAY,QAAkB;QAHb,WAAM,GAAG,cAAc,CAAA;QAItC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,EAAE,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAsB,EAAE,YAA0B;;QACnE,MAA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AI,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAC/E,eAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAC5E,CAAA;YAED,MAAM,eAAe,GAAoB;gBACvC,IAAI,EAAE,uCAAuC,OAAO,CAAC,IAAI,EAAE;aAC5D,CAAA;YAED,MAAM,UAAU,GAAe;gBAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ;gBACR,KAAK;gBACL,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;gBAC5B,eAAe;aAChB,CAAA;YAED,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC9B,CAAC,CAAC,CAAA;QAEF,OAAO,EAAE,WAAW,EAAE,CAAA;IACxB,CAAC;CACF;AAlDD,sCAkDC"}
|
package/dist/settings.js
CHANGED
|
@@ -8,6 +8,9 @@ class Settings {
|
|
|
8
8
|
// Please note that this is not the case when using this server with the client provided in this example
|
|
9
9
|
// but could happen with other clients.
|
|
10
10
|
this.defaultSettings = {
|
|
11
|
+
linter: {
|
|
12
|
+
enabled: true
|
|
13
|
+
},
|
|
11
14
|
formatter: {
|
|
12
15
|
enabled: false,
|
|
13
16
|
indentWidth: formatter_1.defaultFormatOptions.indentWidth,
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AACA,qDAA4D;AAgB5D,MAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AACA,qDAA4D;AA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A,MAAA,IAAI,CAAC,MAAM,CAAC,gBAAgB,0CAAE,EAAE,CAAC,CAAC,CAAC,0CAAE,GAAG,KAAI,EAAE,CAAA;IACvD,CAAC;IAED,mBAAmB,CAAC,QAAgB;QAClC,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,CAAC;YACrC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QAC7C,CAAC;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAEhD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC;gBAClD,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,oBAAoB;aAC9B,CAAC,CAAA;YAEF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAnED,4BAmEC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/language-server",
|
|
3
3
|
"description": "Herb HTML+ERB Language Tools and Language Server Protocol integration.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"author": "Marco Roth",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"clean": "rimraf dist",
|
|
35
35
|
"build": "yarn clean && tsc -b && rollup -c",
|
|
36
36
|
"dev": "tsc -b -w",
|
|
37
|
-
"test": "
|
|
38
|
-
"
|
|
37
|
+
"test": "vitest",
|
|
38
|
+
"test:run": "vitest run",
|
|
39
|
+
"prepublishOnly": "yarn clean && yarn build && yarn test:run"
|
|
39
40
|
},
|
|
40
41
|
"files": [
|
|
41
42
|
"package.json",
|
|
@@ -45,11 +46,14 @@
|
|
|
45
46
|
"dist/"
|
|
46
47
|
],
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@herb-tools/formatter": "0.4.
|
|
49
|
-
"@herb-tools/linter": "0.4.
|
|
50
|
-
"@herb-tools/node-wasm": "0.4.
|
|
49
|
+
"@herb-tools/formatter": "0.4.1",
|
|
50
|
+
"@herb-tools/linter": "0.4.1",
|
|
51
|
+
"@herb-tools/node-wasm": "0.4.1",
|
|
51
52
|
"dedent": "^1.6.0",
|
|
52
53
|
"vscode-languageserver": "^9.0.1",
|
|
53
54
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"vitest": "^1.0.0"
|
|
54
58
|
}
|
|
55
59
|
}
|
|
@@ -83,13 +83,10 @@ export class FormattingService {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
private async getFormatterOptions(uri: string) {
|
|
86
|
-
// Get VS Code settings
|
|
87
86
|
const settings = await this.settings.getDocumentSettings(uri)
|
|
88
87
|
|
|
89
|
-
// Get project config options
|
|
90
88
|
const projectFormatter = this.config?.options.formatter || {}
|
|
91
89
|
|
|
92
|
-
// Merge options with precedence: project config > VS Code settings > defaults
|
|
93
90
|
return {
|
|
94
91
|
indentWidth: projectFormatter.indentWidth ?? settings.formatter?.indentWidth ?? defaultFormatOptions.indentWidth,
|
|
95
92
|
maxLineLength: projectFormatter.maxLineLength ?? settings.formatter?.maxLineLength ?? defaultFormatOptions.maxLineLength
|
|
@@ -108,7 +105,11 @@ export class FormattingService {
|
|
|
108
105
|
const formatter = new Formatter(this.project.herbBackend, options)
|
|
109
106
|
|
|
110
107
|
const text = document.getText()
|
|
111
|
-
|
|
108
|
+
let newText = formatter.format(text)
|
|
109
|
+
|
|
110
|
+
if (!newText.endsWith('\n')) {
|
|
111
|
+
newText = newText + '\n'
|
|
112
|
+
}
|
|
112
113
|
|
|
113
114
|
if (newText === text) {
|
|
114
115
|
return []
|
|
@@ -128,14 +129,12 @@ export class FormattingService {
|
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
async formatDocument(params: DocumentFormattingParams): Promise<TextEdit[]> {
|
|
131
|
-
// Check VS Code settings first
|
|
132
132
|
const settings = await this.settings.getDocumentSettings(params.textDocument.uri)
|
|
133
133
|
|
|
134
134
|
if (settings.formatter?.enabled === false) {
|
|
135
135
|
return []
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
// Check project config and file patterns
|
|
139
138
|
const filePath = params.textDocument.uri.replace(/^file:\/\//, '')
|
|
140
139
|
|
|
141
140
|
if (!(await this.shouldFormatFile(filePath))) {
|
package/src/linter_service.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class LinterService {
|
|
|
22
22
|
|
|
23
23
|
async lintDocument(document: DocumentNode, textDocument: TextDocument): Promise<LintServiceResult> {
|
|
24
24
|
const settings = await this.settings.getDocumentSettings(textDocument.uri)
|
|
25
|
-
const linterEnabled = settings
|
|
25
|
+
const linterEnabled = settings?.linter?.enabled ?? true
|
|
26
26
|
|
|
27
27
|
if (!linterEnabled) {
|
|
28
28
|
return { diagnostics: [] }
|
package/src/settings.ts
CHANGED
|
@@ -20,6 +20,9 @@ export class Settings {
|
|
|
20
20
|
// Please note that this is not the case when using this server with the client provided in this example
|
|
21
21
|
// but could happen with other clients.
|
|
22
22
|
defaultSettings: HerbSettings = {
|
|
23
|
+
linter: {
|
|
24
|
+
enabled: true
|
|
25
|
+
},
|
|
23
26
|
formatter: {
|
|
24
27
|
enabled: false,
|
|
25
28
|
indentWidth: defaultFormatOptions.indentWidth,
|