How to use the vscode-languageserver.createConnection function in vscode-languageserver

To help you get started, we’ve selected a few vscode-languageserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marko-js / language-server / server / src / server.ts View on Github external
import {
  createConnection,
  TextDocuments,
  InitializeParams,
  ProposedFeatures
} from "vscode-languageserver";

import { MLS } from "./service";

let mls: MLS;

// Create a connection for the server
// Also include all preview / proposed LSP features.
const connection =
  process.argv.length <= 2
    ? createConnection(process.stdin, process.stdout) // no arg specified
    : createConnection(ProposedFeatures.all);
const DEBUG = process.env.DEBUG === 'true' || false;

console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);

// Create a simple text document manager. The text document manager
// supports full document sync only
let documents: TextDocuments = new TextDocuments();

// let hasConfigurationCapability: boolean = false;
// let hasWorkspaceFolderCapability: boolean = false;
// let hasDiagnosticRelatedInformationCapability: boolean = false;

// After the server has started the client sends an initilize request. The server receives
// in the passed params the rootPath of the workspace plus the client capabilites.
github recca0120 / vscode-phpunit / server / src / server.ts View on Github external
InitializeParams,
    DidChangeConfigurationNotification,
    ExecuteCommandParams,
    // Position,
    // MessageType,
    // LogMessageNotification,
    // WillSaveTextDocumentWaitUntilRequest,
    // TextDocumentSaveReason,
    WorkspaceFolder as _WorkspaceFolder,
    CompletionItem,
    FileChangeType,
} from 'vscode-languageserver';

// Create a connection for the server. The connection uses Node's IPC as a transport.
// Also include all preview / proposed LSP features.
let connection = createConnection(ProposedFeatures.all);

// Create a simple text document manager. The text document manager
// supports full document sync only
let documents: TextDocuments = new TextDocuments();
const snippets = new Snippets();
const workspaceFolders = new WorkspaceFolders(connection);

let hasConfigurationCapability: boolean = false;
let hasWorkspaceFolderCapability: boolean = false;
// let hasDiagnosticRelatedInformationCapability: boolean = false;

connection.onInitialize((params: InitializeParams) => {
    workspaceFolders.create(
        params.workspaceFolders || [{ uri: params.rootUri || '', name: '' }]
    );
github jbenden / vscode-c-cpp-flylint / c-cpp-flylint-server / src / server.ts View on Github external
ResponseError,
    TextDocument,
    TextDocuments,
} from 'vscode-languageserver';
import { ExecuteCommandParams } from 'vscode-languageserver/lib/protocol';
import Uri from 'vscode-uri';
import * as fs from "fs";
import * as path from "path";
import * as _ from "lodash";
import { Settings } from "./settings";
import { Linter } from "./linters/linter";
import { Flexelint } from './linters/flexelint';
import { CppCheck } from './linters/cppcheck';

// 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();

// Make the text document manager listen on the connection for open, change, and close text document events.
documents.listen(connection);

let settings: Settings;
let linters: Linter[] = [];

// After the server has started the client sends an initialize request.
// The server receives in the passed params the rootPath of the workspace plus the client capabilities.
let workspaceRoot: string;
connection.onInitialize((params): InitializeResult => {
    let workspaceUri = Uri.parse(params.rootUri!);
github neoclide / coc-tslint / server / index.ts View on Github external
document2Library.get(document.uri)!.then(async library => {
    if (!library) {
      return
    }
    try {
      trace('validateTextDocument: about to validate ' + document.uri)
      connection.sendNotification(StatusNotification.type, { state: Status.ok })
      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) {
github neoclide / coc.nvim / src / extensions / tslint / server / tslintServer.ts View on Github external
document2Library.get(document.uri)!.then(async library => {
    if (!library) {
      return
    }
    try {
      trace('validateTextDocument: about to validate ' + document.uri)
      connection.sendNotification(StatusNotification.type, {state: Status.ok})
      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) {
github SkaceKamen / vscode-sqflint / server / src / server.ts View on Github external
constructor() {
		this.loadOperators();
		this.loadDocumentation();

		this.connection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process));
		
		this.documents = new TextDocuments();
		this.documents.listen(this.connection);

		this.connection.onInitialize((params) => this.onInitialize(params));
		this.connection.onHover((params) => this.onHover(params));
		this.connection.onReferences((params) => this.onReferences(params));
		this.connection.onDefinition((params) => this.onDefinition(params));
		this.connection.onSignatureHelp((params) => this.onSignatureHelp(params));

		this.connection.onCompletion((params) => this.onCompletion(params));
		this.connection.onCompletionResolve((params) => this.onCompletionResolve(params));

		this.documents.onDidChangeContent((params) => this.parseDocument(params.document));

		this.connection.listen();
github railsware / upterm / src / language-server / ShellLanguageServer.ts View on Github external
export function start(reader: MessageReader, writer: MessageWriter): ShellLanguageServer {
    const connection = createConnection(reader, writer);
    const server = new ShellLanguageServer(connection);
    server.start();
    return server;
}
github UnwrittenFun / svelte-language-server / src / server.ts View on Github external
export function startServer() {
    const connection = process.argv.includes('--stdio') ? createConnection(process.stdin, process.stdout) : createConnection(
        new IPCMessageReader(process),
        new IPCMessageWriter(process),
    );

    const manager = new DocumentManager(
        textDocument => new SvelteDocument(textDocument.uri, textDocument.text),
    );

    manager.register(new SveltePlugin());
    manager.register(new HTMLPlugin());
    manager.register(wrapFragmentPlugin(new CSSPlugin(), CSSPlugin.matchFragment));
    manager.register(wrapFragmentPlugin(new TypeScriptPlugin(), TypeScriptPlugin.matchFragment));

    connection.onInitialize(evt => {
        return {
            capabilities: {
github APerricone / harbourCodeExtension / server / src / main.js View on Github external
var provider = require('./provider.js');
var server = require('vscode-languageserver')
var fs = require("fs");
var path = require("path");
var Uri = require("vscode-uri").default;

var connection = server.createConnection(
    new server.IPCMessageReader(process),
    new server.IPCMessageWriter(process));


/** @type {Array} */
var workspaceRoots;
/** @type {Array} */
var includeDirs;
/** @type {number} */
var workspaceDepth;
/** @type {boolean} */
var wordBasedSuggestions;
/** @type {Object.} */
var files;
/** @type {Object.} */
var includes;