1.0.2 • Published 3 years ago

vscat v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

vscat

Bringing VS Code syntax highlighting to the terminal!

npm.io npm.io npm.io

Why?

VS Code has developed phenomenally over the last few years, making it the de facto code editor for millions of developers. With extensive styling and theming, developers quickly became comfortable with its syntax highlighting. Having consistent highlighting means:

  1. Improved code readability.
  2. Easier and faster code reviews.
  3. Consistent and clear diagnostic messages.

Unfortunately, this did not translate to CLI tools that the same developers use. This library aims to bridge the gap by bringing VS Code grammars and themes to the terminal. We hope that future build tools, apis, and linters can adopt it to provide a consistent experience accross all surfaces.

Features

Highlighting Source Files

Highlighting Diffs and Patches

Highlighting Diagnostics

57 Available languages

We support all built in VS Code languages. You can also pass the explicit path to a text mate grammar file if you would like to use a custom language. By default, we try to automatically detect the file's language based on VS Code's file detection rules.

14 Available Themes

We support all built in VS Code themes. You can also pass the explicit path to a custom theme file if you would like to use a custom theme.

IDNameExample
abyssAbyssnpm.io
default-dark-plusDefault Dark+npm.io
kimbie-darkKimbie Darknpm.io
monokaiMonokainpm.io
monokai-dimmedMonokai Dimmednpm.io
redRednpm.io
solarized-darkSolarized Darknpm.io
tomorrow-night-blueTomorrow Night Bluenpm.io
visual-studio-darkVisual Studio Darknpm.io
default-high-contrastDefault High Contrastnpm.io
default-light-plusDefault Light+npm.io
quiet-lightQuiet Lightnpm.io
solarized-lightSolarized Lightnpm.io
visual-studio-lightVisual Studio Lightnpm.io

Roadmap

We released the first version of this library to gauge interest and assess further investment areas. Please open an issue to give feedback on your use-case, or how can this library serve you better. Here are some of the features on our roadmap:

  • Supporting nested languages (#2)
  • Supporting advanced decorators, like underlines, background colors (#3)
  • Supporting diffing individual characters in diff view (#4)

Testing

You can write automated tests for the output of this library, either by taking snapshots and comparing the raw ANSI output, or by combining this with a library like terminal-screenshot. This library uses XTerm.js to render real terminal output, and saves a screenshot as an image. You can also combine it with jest-image-snapshot to persist and diff these images using Jest.

import vscat from "vscat";
import {renderScreenshot} from "terminal-screenshot";

it("can highlight source code", async () => {
  const output = await vscat.highlightSource({sourceCode, ...});
  const image = await renderScreenshot({output, ...});

  expect(image).toMatchImageSnapshot();
});

Help and Support

Please use GitHub Issues to report any issues, or ask questions.