UNPKG

fish-lsp

Version:

LSP implementation for fish/fish-shell

26 lines (25 loc) 968 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.initializeParser = initializeParser; exports.getLanguageWasmPath = getLanguageWasmPath; const path_1 = require("path"); const web_tree_sitter_1 = __importDefault(require("web-tree-sitter")); const _global = global; async function initializeParser() { if (_global.fetch) { delete _global.fetch; } await web_tree_sitter_1.default.init(); const parser = new web_tree_sitter_1.default(); const fishLangPath = getLanguageWasmPath(); const lang = await web_tree_sitter_1.default.Language.load(fishLangPath); parser.setLanguage(lang); return parser; } function getLanguageWasmPath() { const fishLangPath = (0, path_1.resolve)(__dirname, '..', 'tree-sitter-fish.wasm'); return fishLangPath.toString(); }