Git Product home page Git Product logo

javascript-typescript-langserver's Introduction

Notice

This is a fork of: https://github.com/sourcegraph/javascript-typescript-langserver

The goal of this fork is:

  1. Simplify file system model (only use local file system)
  2. Largely Reduce memory footprint
  3. Replace Observable with promise
  4. Add APIs that specific for Elastic Code

Non goal

  1. Make it a full featured langserver that do best for all LSP calls, specifically, it will optimize for readonly use cases

Q: Why not https://github.com/theia-ide/typescript-language-server? A: the fact it calls tsserver bring a lot of overhead, making the indexing speed very slow. However, we are going to brow code from them

JavaScript/TypeScript language server

npm downloads build appveyor build codecov dependencies OpenTracing: enabled semantic-release code style: prettier license chat: on gitter

This is a language server for JavaScript and TypeScript that adheres to the Language Server Protocol (LSP). It uses TypeScript's LanguageService to perform source code analysis.

Try it out

Features

  • Hovers
  • Goto definition
  • Goto type definition
  • Find all references
  • Document symbols
  • Workspace symbol search
  • Rename
  • Completion
  • Signature help
  • Diagnostics
  • Quick fixes

Run it from source

# install dependencies
npm install

# compile
npm run build
# or compile on file changes
npm run watch

# run over STDIO
node lib/language-server-stdio
# or run over TCP
node lib/language-server

# run tests
npm test

Options

  Usage: language-server [options]

  Options:

    -h, --help            output usage information
    -V, --version         output the version number
    -s, --strict          enabled strict mode
    -p, --port [port]     specifies LSP port to use (2089)
    -c, --cluster [num]   number of concurrent cluster workers (defaults to number of CPUs, 8)
    -t, --trace           print all requests and responses
    -l, --logfile [file]  log to this file
    -j, --enable-jaeger   enable OpenTracing through Jaeger

Extensions

This language server implements some LSP extensions, prefixed with an x.

  • Files extension Allows the server to request file contents without accessing the file system
  • SymbolDescriptor extension Get a SymbolDescriptor for a symbol, search the workspace for symbols or references to it
  • Streaming Supports streaming partial results for all endpoints through JSON Patches
  • Packages extension Methods to get information about dependencies
  • TCP / multiple client support When running over TCP, the exit notification will not kill the process, but close the TCP socket

Versioning

This project follows semver for command line arguments and standard LSP methods. Any change to command line arguments, Node version or protocol breaking changes will result in a major version increase.

Debugging Performance with OpenTracing

The language server is fully traced through OpenTracing, which allows to debug what exact operations caused method calls to take long. You can pass a span context through an optional meta field on the JSON RPC message object.

For local development, there is built-in support for the open source OpenTracing implementation Jaeger, which can be set up to run on localhost with just one command (you need Docker installed):

docker run -d -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp \
  -p5778:5778 -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

After that, run the language server with the --enable-jaeger command line flag and do some requests from your client. Open http://localhost:16686 in your browser and you will see method calls broken down into spans.

javascript-typescript-langserver's People

Contributors

alexsaveliev avatar andrewnester avatar attfarhan avatar autozimu avatar beyang avatar daviwil avatar felixfbecker avatar francisschmaltz avatar ggilmore avatar greenkeeper[bot] avatar keegancsmith avatar keyboarddrummer avatar matthiaskern avatar nicot avatar renovate-bot avatar renovate[bot] avatar rothfels avatar soywod avatar sqs avatar teasp00n avatar tomv564 avatar ybiquitous avatar zfy0701 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.