Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
'use strict';
import {
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
} from 'vscode-languageserver';
// Creates the LSP connection
let connection = createConnection(ProposedFeatures.all);
// Create a manager for open text documents
let documents = new TextDocuments();
// The workspace folder this server is operating on
let workspaceFolder: string;
documents.onDidOpen((event) => {
connection.console.log(`[Server(${process.pid}) ${workspaceFolder ? workspaceFolder : 'generic'}] Document opened: ${event.document.uri}`);
})
documents.listen(connection);
connection.onInitialize((params) => {
if (params.initializationOptions && params.initializationOptions.genericServer) {
connection.console.log(`[Server(${process.pid}) generic] Started and initialize received`);
} else {
workspaceFolder = params.rootUri;
connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Started and initialize received`);
}
import { IConfig } from './common/types';
import {
next as diagnosticNext,
unsubscribe as diagnosticUnsubscribe
} from './handles/handleDiagnostic'
import logger from './common/logger';
import { formatDocument } from './handles/handleFormat';
// create connection by command argv
const connection: IConnection = createConnection();
// init logger
logger.init(connection)
// sync text document manager
const documents: TextDocuments = new TextDocuments();
// config of initializationOptions
let config: IConfig
// lsp initialize
connection.onInitialize((param: InitializeParams) => {
const { initializationOptions = {} } = param
config = initializationOptions
return {
capabilities: {
textDocumentSync: documents.syncKind,
documentFormattingProvider: true
}
};
/**
* Instance of the schemastore, which handles the xml schemas
*/
export let schemastore: XmlStorage;
/**
* Root folder of the current workspace
*/
export let workspaceRoot: string;
}
// Create a connection for the server. The connection uses Node's IPC as a transport
const connection: IConnection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process));
// Create a simple text document manager. The text document manager
// supports full document sync only
const documents: TextDocuments = new TextDocuments();
connection.onInitialize((params): InitializeResult => {
connection.console.info("Initializing XML language server");
// connection.console.log("params: " + JSON.stringify(params));
Global.serverSettings = params.initializationOptions;
Global.workspaceRoot = params.rootPath;
Global.schemastore = new XmlStorage(Global.serverSettings.storagepath, connection, LogLevel.None);
connection.console.info("Starting Listener");
// Make the text document manager listen on the connection
// for open, change and close text document events
documents.listen(connection);
return {
capabilities: {
const requestMethodApi: RequestMethodApi = {
isSpellCheckEnabled: handleIsSpellCheckEnabled,
getConfigurationForDocument: handleGetConfigurationForDocument,
splitTextIntoWords: handleSplitTextIntoWords,
spellingSuggestions: handleSpellingSuggestions,
};
// Create a connection for the server. The connection uses Node's IPC as a transport
log('Create Connection');
const connection = createConnection(vscode.ProposedFeatures.all);
const documentSettings = new DocumentSettings(connection, defaultSettings);
// Create a simple text document manager. The text document manager
// supports full document sync only
const documents: TextDocuments = new TextDocuments();
connection.onInitialize((params: InitializeParams, token: CancellationToken): InitializeResult => {
// Hook up the logger to the connection.
log('onInitialize');
setWorkspaceBase(params.rootUri ? params.rootUri : '');
const capabilities: ServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: {
openClose: true,
change: documents.syncKind,
willSave: true,
save: { includeText: true },
},
codeActionProvider: {
codeActionKinds: [
CodeActionKind.QuickFix
let diagnostics = await doValidate(connection, library, document)
connection.sendDiagnostics({uri, diagnostics})
} catch (err) {
connection.window.showErrorMessage(getErrorMessage(err, document))
}
})
}
let connection: server.IConnection = server.createConnection(
new server.IPCMessageReader(process),
new server.IPCMessageWriter(process)
)
console.log = connection.console.log.bind(connection.console)
console.error = connection.console.error.bind(connection.console)
let documents: server.TextDocuments = new server.TextDocuments()
documents.listen(connection)
function trace(message: string, verbose?: string): void {
connection.tracer.log(message, verbose)
}
connection.onInitialize(params => {
function hasClientCapability(name: string) {
let keys = name.split('.')
let c = params.capabilities
for (let i = 0; c && i < keys.length; i++) {
c = c[keys[i]]
}
return !!c
}
"use strict";
import { createConnection, ProposedFeatures, TextDocuments, InitializeParams, DidChangeConfigurationNotification, TextDocument, TextDocumentPositionParams, CompletionItem, CompletionParams, CompletionItemKind } from "vscode-languageserver";
import { compileGrammar, matchGrammar } from "./grammar";
import grammarShaderLab from "./shaderlab.grammar";
const connection = createConnection(ProposedFeatures.all);
const documents: TextDocuments = new TextDocuments();
const compiledGrammarShaderLab = compileGrammar(grammarShaderLab);
let documentList = new Map();
connection.onInitialize((params: InitializeParams) =>
{
connection.console.log("Init Server");
return {
capabilities: {
textDocumentSync: documents.syncKind,
completionProvider: {
resolveProvider: true,
triggerCharacters: ["."," ","="]
},
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
const vscode_languageserver_1 = require("vscode-languageserver");
const aureliaLanguageService_1 = require("./aurelia-languageservice/aureliaLanguageService");
const languageModelCache_1 = require("./languageModelCache");
let connection = vscode_languageserver_1.createConnection();
console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);
let documents = new vscode_languageserver_1.TextDocuments();
documents.listen(connection);
let htmlDocuments = languageModelCache_1.getLanguageModelCache(10, 60, document => aureliaLanguageService_1.getLanguageService().parseHTMLDocument(document));
documents.onDidClose(e => {
htmlDocuments.onDocumentRemoved(e.document);
});
connection.onShutdown(() => {
htmlDocuments.dispose();
});
let workspacePath;
connection.onInitialize((params) => {
workspacePath = params.rootPath;
return {
capabilities: {
completionProvider: { resolveProvider: false, triggerCharacters: ['.', '<'] },
textDocumentSync: documents.syncKind,
},
import { createConnection, TextDocuments, ProposedFeatures } from "vscode-languageserver";
import { NestedYamlParser, VsCodeFileAccessor } from "./yamlDiscovery";
import { HomeAssistantLanguageService } from "./haLanguageService";
let connection = createConnection(ProposedFeatures.all);
let documents = new TextDocuments();
documents.listen(connection);
connection.onInitialize(params => {
connection.console.log(`[Server(${process.pid})] Started and initialize received`);
var vsCodeFileAccessor = new VsCodeFileAccessor(params.rootUri, connection);
var nestedYamlParser = new NestedYamlParser(vsCodeFileAccessor);
var homeAsisstantLanguageService = new HomeAssistantLanguageService(
documents,
params.rootUri,
nestedYamlParser
);
documents.onDidChangeContent(async e => {
'use strict';
const langServer = require('vscode-languageserver');
const alexVSCode = require('alex-vscode');
const connection = langServer.createConnection(process.stdin, process.stdout);
const documents = new langServer.TextDocuments();
function validate(document) {
const results = alexVSCode(document);
if (results.length === 0) {
return;
}
connection.sendDiagnostics({
uri: document.uri,
diagnostics: results.map(result => {
result.message = 'alex: ' + result.message;
return result;
})
});
}
}
s["parameters"] = subParams;
return s;
}
function getStdHelp(word, nC) {
var signatures = [];
for (var i = 0; i < docs.length; i++) {
if (docs[i].name.toLowerCase() == word) {
signatures.push(GetHelpFromDoc(docs[i]));
}
}
return signatures;
}
var documents = new server.TextDocuments();
documents.listen(connection);
documents.onDidChangeContent((e) => {
var uri = Uri.parse(e.document.uri);
if (uri.scheme != "file") return;
var found = false;
for (var i = 0; i < workspaceRoots.length; i++)
if (e.document.uri.startsWith(workspaceRoots[i]))
found = true;
if (!found) return; //not include file outside the current workspace
var ext = path.extname(uri.fsPath).toLowerCase();
var cMode = (ext.startsWith(".c") && ext != ".ch")
if (ext == ".prg" || ext == ".ch" || cMode) {
var doGroups = false;
if (uri in files) doGroups = files[uri].doGroups;
var pp = parseDocument(e.document, (p) => { p.cMode = cMode; p.doGroups = doGroups; })