54 lines
No EOL
2.4 KiB
JavaScript
54 lines
No EOL
2.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.activate = void 0;
|
|
const tslib_1 = require("tslib");
|
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
const pkg_dir_1 = tslib_1.__importDefault(require("pkg-dir"));
|
|
const coc_nvim_1 = require("coc.nvim");
|
|
function activate(context) {
|
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
const config = coc_nvim_1.workspace.getConfiguration().get('sh', {});
|
|
if (config.enable === false) {
|
|
return;
|
|
}
|
|
// TODO add config options:
|
|
const serverOptions = {
|
|
command: (config.commandPath || (yield serverBin())),
|
|
args: ['start'],
|
|
transport: coc_nvim_1.TransportKind.stdio,
|
|
options: {
|
|
env: {
|
|
// => https://github.com/bash-lsp/bash-language-server/blob/master/server/src/config.ts
|
|
EXPLAINSHELL_ENDPOINT: config.explainshellEndpoint,
|
|
GLOB_PATTERN: config.globPattern,
|
|
HIGHLIGHT_PARSING_ERRORS: config.highlightParsingErrors.toString()
|
|
}
|
|
}
|
|
};
|
|
const clientOptions = {
|
|
documentSelector: ['sh']
|
|
};
|
|
const client = new coc_nvim_1.LanguageClient('sh', 'bash-language-server', serverOptions, clientOptions);
|
|
context.subscriptions.push(coc_nvim_1.services.registLanguageClient(client), coc_nvim_1.commands.registerCommand("sh.version", () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
const rootDir = yield pkg_dir_1.default(__dirname);
|
|
const { version } = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(rootDir, 'package.json'), 'utf-8'));
|
|
coc_nvim_1.workspace.showMessage(`Version: ${version} [node: ${process.versions.node}]`, 'more');
|
|
})));
|
|
});
|
|
}
|
|
exports.activate = activate;
|
|
function serverBin() {
|
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
const rootDir = yield pkg_dir_1.default(__dirname);
|
|
let bin = path_1.default.join(rootDir, 'node_modules', 'bash-language-server', 'bin', 'main.js');
|
|
try {
|
|
bin = fs_1.default.realpathSync(bin);
|
|
}
|
|
catch (e) {
|
|
// ignore
|
|
}
|
|
return bin;
|
|
});
|
|
}
|
|
//# sourceMappingURL=extension.js.map
|