This commit is contained in:
Shibo Lyu 2020-11-01 07:28:58 +00:00
parent 694049180f
commit f55a5ca26a
7 changed files with 32 additions and 7 deletions

View file

@ -1,4 +1,5 @@
import { dependencyManagement } from 'nova-extension-utils'
import { makeFileExecutable } from './utils'
var langServer: SvelteLanguageServer | null = null
@ -46,7 +47,7 @@ class SvelteLanguageServer {
this.stop()
}
start(path: string) {
async start(path: string) {
if (this.languageClient) {
this.languageClient.stop()
nova.subscriptions.remove(this.languageClient)
@ -63,13 +64,17 @@ class SvelteLanguageServer {
console.log('using server at', path)
}
let runShPath = nova.path.join(nova.extension.path, 'run.sh')
await makeFileExecutable(runShPath)
// Create the client
var client = new DisposableLanguageClient(
'svelte-langserver',
'Svelte Language Server',
{
type: 'stdio',
path: nova.path.join(nova.extension.path, 'run.sh'),
path: runShPath,
env: {
SVELTE_SERVER: path,
WORKDIR: nova.workspace.path || '.',

16
src/utils.ts Normal file
View file

@ -0,0 +1,16 @@
// https://github.com/apexskier/nova-json-language-server/blob/a64f704bee06071ad6fd82062a3656669d62b0a8/src/main.ts#L18-L32
export async function makeFileExecutable(file: string) {
return new Promise((resolve, reject) => {
const process = new Process('/usr/bin/env', {
args: ['chmod', 'u+x', file],
})
process.onDidExit((status) => {
if (status === 0) {
resolve()
} else {
reject(status)
}
})
process.start()
})
}