How to use the vscode-languageserver.ProposedFeatures.all 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 elm-tooling / elm-language-server / src / index.ts View on Github external
import { ILanguageServer } from "./server";

// Show version for `-v` or `--version` arguments
if (process.argv[2] === "-v" || process.argv[2] === "--version") {
  // require is used to avoid loading package if not necessary (~30ms time difference)
  // tslint:disable-next-line no-var-requires
  process.stdout.write(`${require("pjson").version}\n`);
  process.exit(0);
}

// default argument `--stdio`
if (process.argv.length === 2) {
  process.argv.push("--stdio");
}

const connection: IConnection = createConnection(ProposedFeatures.all);
let server: ILanguageServer;

connection.onInitialize(
  async (params: InitializeParams): Promise => {
    await Parser.init();
    const absolute = Path.join(__dirname, "tree-sitter-elm.wasm");
    const pathToWasm = Path.relative(process.cwd(), absolute);
    connection.console.info(
      `Loading Elm tree-sitter syntax from ${pathToWasm}`,
    );
    const language = await Parser.Language.load(pathToWasm);
    const parser = new Parser();
    parser.setLanguage(language);

    const { Server } = await import("./server");
    server = new Server(connection, params, parser);
github antew / elm-lsp / lib / language-server.ts View on Github external
function start(project: {}) {
  // Disable console logging while in language server mode
  // otherwise in stdio mode we will not be sending valid JSON
  console.log = console.warn = console.error = () => {};

  let connection = createConnection(ProposedFeatures.all);

  run(project, function(elm: ElmApp) {
    let documents: TextDocuments = new TextDocuments();
    let filesWithDiagnostics = new Set();

    documents.listen(connection);
    connection.listen();

    connection.onInitialize((params: InitializeParams) => ({
      capabilities: {
        textDocumentSync: {
          openClose: true,
          willSave: true,
          change: TextDocumentSyncKind.Full
        },
        textDocument: {
github microsoft / vscode-extension-samples / lsp-multi-server-sample / server / src / server.ts View on Github external
/*---------------------------------------------------------
 * 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 {
github marko-js / language-server / server / src / server.ts View on Github external
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.
let workspaceRoot: string;
github webhintio / hint / packages / extension-vscode / src / server.ts View on Github external
import * as https from 'https';
import { createConnection, ProposedFeatures, TextDocuments } from 'vscode-languageserver';
import { initTelemetry, updateTelemetry } from '@hint/utils-telemetry';

import { trackClose, trackSave, trackOptIn, TelemetryState } from './utils/analytics';
import { Analyzer } from './utils/analyze';
import * as notifications from './utils/notifications';

// Look two-levels up for `package.json` as this will be in `dist/src/` post-build.
const { version } = require('../../package.json');

const defaultProperties = { 'extension-version': version };

const [,, globalStoragePath, telemetryEnabled, everEnabledTelemetryStr] = process.argv;
const everEnabledTelemetry = everEnabledTelemetryStr === 'true';
const connection = createConnection(ProposedFeatures.all);
const analyzer = new Analyzer(globalStoragePath, connection);
const documents = new TextDocuments();

let workspace = '';

connection.onInitialize((params) => {
    /*
     * TODO: Cache multiple webhint instances based on analyzed document paths,
     * which should allow ignoring workspaces entirely.
     */
    workspace = params.rootPath || '';

    return { capabilities: { textDocumentSync: documents.syncKind } };
});

connection.onNotification(notifications.telemetryEnabledChanged, (telemetryEnabled: TelemetryState) => {
github znck / grammarly / src / server.ts View on Github external
Diagnostic,
  Hover,
  InitializeResult,
  ProposedFeatures,
  Range,
  TextDocument,
  TextDocuments,
} from 'vscode-languageserver'
import { DiagnosticSeverity } from 'vscode-languageserver-protocol'
import { Grammarly } from './grammarly'
import { AuthParams } from './socket'

process.env.DEBUG = 'grammarly:*'

const debug = createLogger('grammarly:server')
const connection = createConnection(ProposedFeatures.all)
const documents = new TextDocuments(2 /* TextDocumentSyncKind.Incremental */)

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

connection.onInitialize(
  (params): InitializeResult => {
    const capabilities = params.capabilities

    // Does the client support the `workspace/configuration` request?
    // If not, we will fall back using global settings.
    hasConfigurationCapability = !!(capabilities.workspace && capabilities.workspace.configuration)
    hasWorkspaceFolderCapability = !!(capabilities.workspace && capabilities.workspace.workspaceFolders)
    hasDiagnosticRelatedInformationCapability = !!(
      capabilities.textDocument &&
github recca0120 / vscode-phpunit / server / src / lang-server.ts View on Github external
constructor(
        private connection: IConnection = createConnection(ProposedFeatures.all),
        private documents: TextDocuments = new TextDocuments(),
        private phpUnit: PhpUnit = new PhpUnit(),
        private files: FilesystemContract = new Filesystem(),
        private snippetManager: SnippetManager = new SnippetManager()
    ) {}
github GoogleCloudPlatform / healthcare-data-harmonization / tools / notebook / wstl-language-server / server / src / server.ts View on Github external
run() {
    const connection = createConnection(ProposedFeatures.all);

    this.documents.listen(connection);

    connection.onInitialize(this.onInitialize.bind(this));

    connection.onCompletion(this.onCompletion.bind(this));

    connection.onCompletionResolve((item: CompletionItem): CompletionItem => {
      return item;
    });

    connection.listen();
  }
}
github SPGoding / datapack-language-server / src / server.ts View on Github external
import * as fs from 'fs-extra'
import * as path from 'path'
import { URI } from 'vscode-uri'
import { createConnection, ProposedFeatures, TextDocumentSyncKind, Range, FoldingRange, FoldingRangeKind, SignatureInformation, Position, ColorInformation, Color, ColorPresentation, WorkspaceFolder, TextDocumentEdit, TextEdit, FileChangeType, RenameFile, DocumentLink, DocumentHighlight, InitializeResult, DiagnosticSeverity, TextDocument } from 'vscode-languageserver'
import { getSafeCategory, CacheUnit, CacheFile, ClientCache, combineCache, CacheKey, removeCacheUnit, removeCachePosition, trimCache, getCacheFromChar, isFileType, CachePosition, isNamespacedType, LatestCacheFileVersion, getFromCachedFileTree, setForCachedFileTree, walkInCachedFileTree, delFromCachedFileTree, CachedFileTree } from './types/ClientCache'
import Config, { VanillaConfig } from './types/Config'
import ArgumentParserManager from './parsers/ArgumentParserManager'
import Line, { lineToLintedString } from './types/Line'
import LineParser from './parsers/LineParser'
import StringReader from './utils/StringReader'
import { Files } from 'vscode-languageserver'
import Identity from './types/Identity'

const connection = createConnection(ProposedFeatures.all)
const linesOfRel = new Map()
const stringsOfRel = new Map()
const lineBreakOfRel = new Map()
const versionOfRel = new Map()
const hasParsedInRealConfigOfRel = new Map()
const configOfRel = new Map()

const manager = new ArgumentParserManager()
let hasRealConfig = false
let cacheFile: CacheFile = { cache: {}, files: {}, version: LatestCacheFileVersion }
let workspaceFolder: WorkspaceFolder | undefined
let workspaceFolderPath: string | undefined
let dotPath: string | undefined
let cachePath: string | undefined
let dataPath: string | undefined
github linkedin / css-blocks / packages / @css-blocks / language-server / src / run.ts View on Github external
import { ProposedFeatures, TextDocuments, createConnection } from "vscode-languageserver";

import { Server } from "./Server";

const connection = createConnection(ProposedFeatures.all);
const documents = new TextDocuments();

let server = new Server(connection, documents);

server.listen();