Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"clean": "rm -rf *.log */*.log */out node_modules vscode-client/node_modules server/node_modules",
"postinstall": "cd server && yarn install && cd ../vscode-client && yarn install && cd ..",
"compile": "yarn run compile:server && yarn run compile:client",
"compile:client": "cd vscode-client && yarn run compile",
"compile:server": "cd server && yarn run compile",
"compile:client": "rm -rf vscode-client/out && tsc -p ./vscode-client/tsconfig.json",
"compile:server": "rm -rf server/out && tsc -p ./server/tsconfig.json",
"lint": "tslint --project vscode-client --fix && tslint --project server --fix",
"lint:bail": "tslint --project vscode-client && tslint --project server",
"test": "jest --runInBand --forceExit",
Expand Down
21 changes: 21 additions & 0 deletions scripts/build-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -euo pipefail

export npm_config_target=1.2.3
# The architecture of Electron, can be ia32 or x64.
export npm_config_arch=x64
export npm_config_target_arch=x64
# Download headers for Electron.
export npm_config_disturl=https://atom.io/download/electron
# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron

cd vscode-client
rm -rf node_modules
yarn install

vsce package --yarn -o bash-ide.vsix

# code --uninstall-extension mads-hartmann.bash-ide-vscode
code --install-extension bash-ide.vsix
4 changes: 1 addition & 3 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
"vscode-languageserver": "^4.1.1"
},
"scripts": {
"compile": "rm -rf out && ../node_modules/.bin/tsc -p ./",
"compile:watch": "../node_modules/.bin/tsc -w -p ./",
"prepublishOnly": "yarn run compile"
"prepublishOnly": "cd .. && yarn run compile:server"
}
}
30 changes: 16 additions & 14 deletions vscode-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@
"vscode": "^1.18.x"
},
"icon": "assets/bash-logo.png",
"categories": ["Other"],
"keywords": ["shell script", "bash script", "bash"],
"activationEvents": ["onLanguage:shellscript"],
"categories": [
"Other"
],
"keywords": [
"shell script",
"bash script",
"bash"
],
"activationEvents": [
"onLanguage:shellscript"
],
"main": "./out/src/extension",
"contributes": {
"configuration": {
Expand All @@ -26,34 +34,28 @@
"bashIde.path": {
"type": "string",
"default": null,
"description":
"The path to the bash language server binary (example: /usr/local/bin/bash-language-server)"
"description": "The path to the bash language server binary (example: /usr/local/bin/bash-language-server)"
},
"bashIde.highlightParsingErrors": {
"type": "boolean",
"default": true,
"description":
"If enabled parsing errors will be highlighted as 'problems' "
"description": "If enabled parsing errors will be highlighted as 'problems' "
},
"bashIde.explainshellEndpoint": {
"type": "string",
"default": "",
"description":
"Set this to https://explainshell.com (once https://github.com/idank/explainshell/pull/125 is merged in) in order to get hover documentation on flags and options."
"description": "Set this to https://explainshell.com (once https://github.com/idank/explainshell/pull/125 is merged in) in order to get hover documentation on flags and options."
}
}
}
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "rm -rf out && ../node_modules/.bin/tsc -p ./",
"compile:watch": "../node_modules/.bin/tsc -w -p ./",
"vscode:prepublish": "cd .. && yarn run compile:client",
"update-vscode": "node ./node_modules/vscode/bin/install",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"@types/semver-compare": "^1.0.0",
"semver-compare": "^1.0.0",
"bash-language-server": "1.5.1",
"vscode": "^1.1.14",
"vscode-languageclient": "^4.1.3"
}
Expand Down
93 changes: 41 additions & 52 deletions vscode-client/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,49 @@
'use strict'

import semverCompare = require('semver-compare')
import { ExtensionContext, window, workspace } from 'vscode'
import * as path from 'path'

import { ExtensionContext, workspace } from 'vscode'
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from 'vscode-languageclient'

import { getServerInfo } from './util'

const MINIMUM_SERVER_VERSION = '1.5.2'
let client: LanguageClient

export async function activate(context: ExtensionContext) {
try {
const { command, version } = await getServerInfo()
if (semverCompare(version, MINIMUM_SERVER_VERSION) === -1) {
return handleOutdatedExecutable()
}
// FIXME: do we need this?
const serverModule = context.asAbsolutePath(
path.join('node_modules', 'bash-language-server', 'bin', 'main.js'),
)

const explainshellEndpoint = workspace
.getConfiguration('bashIde')
.get('explainshellEndpoint', '')
/*
const explainshellEndpoint = workspace
.getConfiguration('bashIde')
.get('explainshellEndpoint', '')

const highlightParsingErrors = workspace
.getConfiguration('bashIde')
.get('highlightParsingErrors', false)
const highlightParsingErrors = workspace
.getConfiguration('bashIde')
.get('highlightParsingErrors', false)

start(context, command, explainshellEndpoint, highlightParsingErrors)
} catch (error) {
handleMissingExecutable()
}
}

function start(
context: ExtensionContext,
command: string,
explainshellEndpoint: string,
highlightParsingErrors: boolean,
) {
const env: any = {
...process.env,
EXPLAINSHELL_ENDPOINT: explainshellEndpoint,
HIGHLIGHT_PARSING_ERRORS: highlightParsingErrors,
}
*/

const serverOptions: ServerOptions = {
run: {
command,
args: ['start'],
options: {
env,
},
module: serverModule,
transport: TransportKind.ipc,
// options: { env, execArgv: ['start'] },
},
debug: {
command,
args: ['start'],
options: {
env,
},
module: serverModule,
transport: TransportKind.ipc,
// options: { env, execArgv: ['start --inspect=6009'] },
},
}

Expand All @@ -76,24 +61,28 @@ function start(
},
}

const disposable = new LanguageClient(
'Bash IDE',
'Bash IDE',
serverOptions,
clientOptions,
).start()
client = new LanguageClient('Bash IDE', 'Bash IDE', serverOptions, clientOptions)

client.start()

// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable)
}
// context.subscriptions.push(client)

function handleOutdatedExecutable() {
const message = `Outdated bash server. Please upgrade by running "npm i -g bash-language-server".`
window.showErrorMessage(message, { modal: false })
/*
// FIXME: or
export function deactivate(): Thenable<void> {
if (!client) {
return undefined;
}
return client.stop();
}
*/
}

function handleMissingExecutable() {
const message = `Can't find bash-language-server on your PATH. Please install it using "npm i -g bash-language-server".`
window.showErrorMessage(message, { modal: false })
export function deactivate(): Thenable<void> {
if (!client) {
return Promise.resolve()
}
return client.stop()
}
42 changes: 0 additions & 42 deletions vscode-client/src/util.ts

This file was deleted.

Loading