Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade @volar/vue-language-server to v1.0 #54

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 9 additions & 42 deletions Scripts/servers/VolarLanguageServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ exports.VolarLanguageServer = class VolarLanguageServer {

// Observe the configuration setting for the server's location, and restart the server on change
nova.config.observe("tommasonegri.vue.config.volar.path", function(path) {
this.start(path, nova.config.get("tommasonegri.vue.config.volar.typescript.path"))
this.start(path, nova.config.get("tommasonegri.vue.config.volar.typescript.tsdk"))
}, this)
nova.config.onDidChange("tommasonegri.vue.config.volar.typescript.path", function(path) {
nova.config.onDidChange("tommasonegri.vue.config.volar.typescript.tsdk", function(path) {
this.start(nova.config.get("tommasonegri.vue.config.volar.path"), path)
}, this)
}
Expand All @@ -17,7 +17,7 @@ exports.VolarLanguageServer = class VolarLanguageServer {
this.stop()
}

async start(path, typescriptPath) {
async start(path, tsdkPath) {
if (this.languageClient) {
this.languageClient.stop()
nova.subscriptions.remove(this.languageClient)
Expand Down Expand Up @@ -51,9 +51,9 @@ exports.VolarLanguageServer = class VolarLanguageServer {
}

// Use the default TypeScript server path
if (!typescriptPath) {
if (!tsdkPath) {
try {
typescriptPath = await this.typescriptGlobalPath
tsdkPath = await this.tsdkGlobalPath
} catch (err) {
console.error(err)

Expand All @@ -74,7 +74,7 @@ exports.VolarLanguageServer = class VolarLanguageServer {
return
}
} else if (nova.inDevMode()) {
console.log("TypeScript path (custom):", typescriptPath)
console.log("TypeScript path (custom):", tsdkPath)
}

// Create the client
Expand All @@ -87,40 +87,7 @@ exports.VolarLanguageServer = class VolarLanguageServer {
syntaxes: ["vue"],
initializationOptions: {
typescript: {
serverPath: typescriptPath,
},
languageFeatures: {
references: true,
implementation: true,
definition: true,
typeDefinition: true,
callHierarchy: true,
hover: true,
rename: true,
renameFileRefactoring: true,
signatureHelp: true,
codeAction: true,
workspaceSymbol: true,
completion: {
defaultTagNameCase: "both",
defaultAttrNameCase: "kebabCase",
getDocumentNameCasesRequest: false,
getDocumentSelectionRequest: false,
},
documentHighlight: true,
documentLink: true,
codeLens: { showReferencesNotification: false },
semanticTokens: true,
diagnostics: true,
schemaRequestService: true,
},
documentFeatures: {
selectionRange: true,
foldingRange: true,
linkedEditingRange: true,
documentSymbol: true,
documentColor: true,
documentFormatting: true
tsdk: tsdkPath,
}
}
}
Expand Down Expand Up @@ -182,7 +149,7 @@ exports.VolarLanguageServer = class VolarLanguageServer {
})
}

get typescriptGlobalPath() {
get tsdkGlobalPath() {
return new Promise((resolve, reject) => {
const process = new Process("/usr/bin/env", {
cwd: nova.workspace.path,
Expand All @@ -207,7 +174,7 @@ exports.VolarLanguageServer = class VolarLanguageServer {
if (nova.fs.access(path, nova.fs.F_OK)) {
if (nova.inDevMode()) console.log("TypeScript path (global):", path)

resolve(path)
resolve(nova.path.join(npmPath, "/typescript/lib"))
} else {
reject("TypeScript server not found")
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { devLogLevel } = require("./settings/vetur/devLogLevel")
const globalSettingsKeys = [
"tommasonegri.vue.config.extension.languageServer",
"tommasonegri.vue.config.volar.path",
"tommasonegri.vue.config.volar.typescript.path",
"tommasonegri.vue.config.volar.typescript.tsdk",
"tommasonegri.vue.config.vetur.path",
"tommasonegri.vue.config.vetur.completion.autoImport",
"tommasonegri.vue.config.vetur.completion.tagCasing",
Expand Down
4 changes: 2 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
"placeholder": ".../bin/vue-language-server"
},
{
"key": "tommasonegri.vue.config.volar.typescript.path",
"key": "tommasonegri.vue.config.volar.typescript.tsdk",
"title": "TypeScript Server",
"description": "The path to the TypeScript server library (if empty, the extension will try to figure it out).",
"type": "path",
"placeholder": ".../typescript/lib/tsserverlibrary.js"
"placeholder": ".../typescript/lib"
}
]
},
Expand Down