Git Product home page Git Product logo

vscode-tree-sitter's Introduction

Tree Sitter for VSCode [Deprecated]

With the improving support for custom syntax coloring through language server, this extension is no longer needed

This extension gives VSCode support for tree-sitter syntax coloring. Examples with tree-sitter coloring on the right:

Go

Go

Rust

Rust

C++

C++

Ruby

Ruby

Javascript / Typescript

Typescript

Contributing

Fixing colorization of an existing language

If you see something getting colored wrong, or something that should be colored but isn't, you can help! The simplest way to help is to create an issue with a simple example, a screenshot, and an explanation of what is wrong.

You are also welcome to fix the problem yourself and submit a PR. Colorization is performed by the various colorLanguage(x, editor) functions in src/colors.ts. When working on the colorization rules, please keep in mind two core principles:

  1. Good colorization is consistent. It's better to not color at all than to color inconsistently.
  2. Good colorization is selective. The fewer things that we color, the more emphasis the color gives.

Adding a new language

It's straightforward to add any language with a tree-sitter grammar.

  1. Add a dependency on the npm package for that language: npm install tree-sitter-yourlang.
  2. Add a color function to ./src/colors.ts
  3. Add a language to the dictionary at the top of ./src/extension.ts
  4. Add a simplified TextMate grammar to ./textmate/yourlang.tmLanguage.json. The job of this textmate grammar is just to color keywords and simple literals; anything tricky should be left white and colored by your color function.
  5. Add a reference to the grammar to the contributes.grammars section of package.json. yourlang must be a VSCode language identifier.
  6. Add a reference to onLanguage:yourlang to the activationEvents section of package.json. yourlang must be a VSCode language identifier.
  7. Add an example to examples/yourlang.
  8. Hit F5 in VSCode, with this project open, to test your changes.
  9. Take a screenshot comparing before-and-after and add it to the above list.
  10. Submit a PR!

vscode-tree-sitter's People

Contributors

georgewfraser avatar connorshea avatar aaronjanse avatar ztlpn avatar linus-skold avatar dependabot[bot] avatar srijan-paul avatar certainlach avatar

Watchers

James Cloos 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.