Skip to content

Commit

Permalink
Merge pull request #54 from johnsoncodehk/main
Browse files Browse the repository at this point in the history
feat: upgrade @volar/vue-language-server to v1.0
  • Loading branch information
tommasongr committed Apr 26, 2023
2 parents 313102a + e0cc057 commit 9f5ef69
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
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

0 comments on commit 9f5ef69

Please sign in to comment.