fish-lsp
Version:
LSP implementation for fish/fish-shell
39 lines (38 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatDocumentContent = formatDocumentContent;
exports.formatDocumentRangeContent = formatDocumentRangeContent;
const child_process_1 = require("child_process");
const logger_1 = require("./logger");
async function formatDocumentContent(content) {
return new Promise((resolve, _reject) => {
const process = (0, child_process_1.exec)('fish_indent', (error, stdout, stderr) => {
if (error) {
logger_1.logger.log('Formatting Error:', stderr);
}
else {
resolve(stdout);
}
});
if (process.stdin) {
process.stdin.write(content);
process.stdin.end();
}
});
}
async function formatDocumentRangeContent(content) {
return new Promise((resolve, _reject) => {
const process = (0, child_process_1.exec)('fish_indent --only-indent --only-unindent', (error, stdout, stderr) => {
if (error) {
logger_1.logger.log('Formatting Error:', stderr);
}
else {
resolve(stdout);
}
});
if (process.stdin) {
process.stdin.write(content);
process.stdin.end();
}
});
}