Created
September 23, 2023 15:40
-
-
Save kevinswiber/38274d0b962463490d4e3d19d44e7ccc to your computer and use it in GitHub Desktop.
Patches for yaml-language-server and spectral-language-server to work with Neovim's lsp and lsp-config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changing configuration.workspaceFolder to connection.workspace.getWorkspaceFolders() to support non-VSCode workspace folders. | |
diff --git a/dist/spectral-language-server/src/server.js b/dist/spectral-language-server/src/server.js | |
index 8878d95..7ec85d6 100644 | |
--- a/dist/spectral-language-server/src/server.js | |
+++ b/dist/spectral-language-server/src/server.js | |
@@ -118,19 +118,21 @@ function resolveSettings(document) { | |
} | |
let rulesetFile = null; | |
connection.console.log(`Using ruleset file: ${configuration.rulesetFile}.`); | |
+ const workspaceFolder = (await connection.workspace.getWorkspaceFolders())[0]; | |
let rulesetFileIsUrl = false; | |
if (configuration.rulesetFile) { | |
const ruleSetUri = vscode_uri_1.URI.parse(configuration.rulesetFile); | |
rulesetFileIsUrl = vscode_uri_1.URI.isUri(ruleSetUri) && (ruleSetUri.scheme === 'https' || ruleSetUri.scheme === 'http'); | |
- if (configuration.workspaceFolder && !rulesetFileIsUrl) { | |
- rulesetFile = path.resolve((_a = getDocumentPath(configuration.workspaceFolder.uri)) !== null && _a !== void 0 ? _a : '', configuration.rulesetFile); | |
+ if (workspaceFolder && !rulesetFileIsUrl) { | |
+ rulesetFile = path.resolve((_a = getDocumentPath(workspaceFolder.uri)) !== null && _a !== void 0 ? _a : '', configuration.rulesetFile); | |
} | |
else { | |
rulesetFile = configuration.rulesetFile; | |
} | |
} | |
else { | |
- rulesetFile = (_c = (await getDefaultRulesetFile((_b = configuration.workspaceFolder) === null || _b === void 0 ? void 0 : _b.uri))) !== null && _c !== void 0 ? _c : null; | |
+ connection.console.log(`Workspace folder: ${workspaceFolder || 'none'}`) | |
+ rulesetFile = (_c = (await getDefaultRulesetFile((_b = workspaceFolder) === null || _b === void 0 ? void 0 : _b.uri))) !== null && _c !== void 0 ? _c : null; | |
} | |
if (rulesetFile && (rulesetFileIsUrl || fs.existsSync(rulesetFile))) { | |
if (docPath === rulesetFile) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment