Skip to content

Commit

Permalink
Show status when running lua.update.lua-lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
josa42 committed Sep 30, 2020
1 parent cae4d61 commit 3ce6f66
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
15 changes: 6 additions & 9 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'path'
import fs from 'fs'
import {workspace, LanguageClient} from 'coc.nvim'
import {installLuaLsp} from './utils/tools'
import path from "path"
import fs from "fs"
import { workspace, LanguageClient } from "coc.nvim"
import { installLuaLsp } from "./utils/tools"

export async function version(): Promise<void> {
const { version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', 'package.json'), 'utf-8'))
workspace.showMessage(`Version: ${version}`, 'more')
const { version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, "..", "package.json"), "utf-8"))
workspace.showMessage(`Version: ${version}`, "more")
}

export async function updateLuaLsp(client: LanguageClient): Promise<void> {
Expand All @@ -16,6 +16,3 @@ export async function updateLuaLsp(client: LanguageClient): Promise<void> {
await client.start()
}
}



10 changes: 6 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export async function activate(context: ExtensionContext): Promise<void> {

const [command, args] = config.commandPath ? [config.commandPath, []] : await luaLspBin()

if (!(await commandExists(command))) {
const useSumnekoLs = workspace.getConfiguration().get("lua.useSumnekoLs", false)
const useSumnekoLs = workspace.getConfiguration().get("lua.useSumnekoLs", false)
const name = useSumnekoLs ? "sumneko/lua-language-server" : "Alloyed/lua-lsp"

const name = useSumnekoLs ? "sumneko/lua-language-server" : "Alloyed/lua-lsp"
if (!(await commandExists(command))) {
await showInstallStatus(name, async () => {
await installLuaLsp()
})
Expand All @@ -46,7 +46,9 @@ export async function activate(context: ExtensionContext): Promise<void> {
context.subscriptions.push(
services.registLanguageClient(client),
commands.registerCommand("lua.version", () => version()),
commands.registerCommand("lua.update.lua-lsp", () => updateLuaLsp(client))
commands.registerCommand("lua.update.lua-lsp", async () =>
showInstallStatus(name, async () => await updateLuaLsp(client))
)
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const tmpBaseDir = os.tmpdir()
const { join } = path

export async function install(dir: string): Promise<void> {
const { path: tmpDir, dispose } = await mkTmpDir("coc-lua")
const { path: tmpDir, dispose } = await mkTmpDir(`coc-lua-${new Date().getTime()}`)
const { ninjaZip, buildFile } = osEnv()

const ninjaUrl = `https://github.com/ninja-build/ninja/releases/download/${ninjaVersion}/${ninjaZip}`
Expand Down

0 comments on commit 3ce6f66

Please sign in to comment.