Code Monkey home page Code Monkey logo

vscode-theme-generator's Introduction

vscode-theme-generator

Build Status

This is a preview that leverages the new VS Code theming options in v1.12.

The Problem

  • New themes are typically forked from other themes, carrying the bugs with them
  • .tmThemes are overly verbose and difficult to maintain
  • Themes are difficult to write from scratch

The Solution

What if all you needed to do to generate a theme was specify a few colors and everything else was handled for you? Well that's what this module aims to accomplish. All you need to do is specify a set of "base colors" (background, foreground and 4 accent colors) and you have a reasonably good looking theme.

All other VS Code theme colors are then derived from those base colors, with the option to tweak each underlying color as well.

Example

This is all that's needed to generate a great looking theme:

import { generateTheme, IColorSet } from 'vscode-theme-generator';
const colorSet: IColorSet = {
  base: {
    background: '#12171F',
    foreground: '#EFEFEF',
    color1: '#399EF4',
    color2: '#DA6771',
    color3: '#4EB071',
    color4: '#FFF099',
  }
};
generateTheme('My Theme', colorSet, path.join(__dirname, 'theme.json'));

Getting started

There's a quick start repository that allows you to get started quickly, just clone and run!

git clone https://github.com/Tyriar/vscode-theme-generator-quick-start
cd vscode-theme-generator-quick-start
npm install

Make your changes to the colors in index.ts and hit F5 to build the theme and launch a new VS Code window with your theme available in the command palette (ctrl/cmd+shift+p > "Color Theme").

Advanced use

In addition to the base colors, IColorSet provides more options for syntax, ui, and terminal. There is also an overrides property, which allows you to set any color key from the Theme Color Reference directly.

Since the theme is defined in TypeScript, you can create an object to give names to colors you want to re-use.

import { generateTheme, IColorSet } from 'vscode-theme-generator';

const colors = {
  red: '#DA6771',
  green: '#4EB071',
  yellow: '#FFF099',
  blue: '#399EF4',
  blueLight: '#9FCFF9'
}

const colorSet: IColorSet = {
  base: {
    background: '#12171F',
    foreground: '#EFEFEF',
    color1: colors.blue,
    color2: colors.red,
    color3: colors.green,
    color4: colors.yellow
  },
  syntax: {
    identifier: colors.blueLight,
    string: colors.red
  },
  ui: {
    cursor: '#FFFFFF'
  },
  terminal: {
    blue: colors.blue,
    brightBlue: colors.blueLight
  },
  overrides: {
    'editorGutter.modifiedBackground': colors.green,
    'editorGutter.addedBackground': colors.blue,
    'editorGutter.deletedBackground': colors.red
  }
};

generateTheme('My Theme', colorSet, path.join(__dirname, 'theme.json'));

The syntax properties present a simplified set of token types. If not set, these will be derived from the base colors:

  • color1 determines boolean, identifier, keyword, storage, and cssClass
  • color2 determines string, stringEscape, and cssId
  • color3 determines function, class, classMember, type, and cssTag
  • color4 determines functionCall and number

By default, comment is derived from the background color, and modifier and markdownQuote are not set.

The ui properties allow you to set colors for various highlights and a few other things:

  • cursor: the cursor color
  • invisibles: used for visible whitespace (see the editor.renderWhitespace VS Code setting)
  • guide: indentation guidelines in the editor pane
  • lineHighlight: colors the line your cursor is on, in place of the boundary lines
  • findMatchHighlight and currentFindMatchHighlight: highlights matches from the find widget
  • findRangeHighlight: highlights the selected area for "find in selection"
  • rangeHighlight: background for a selected range of lines
  • selection: highlights text selected with the cursor
  • selectionHighlight: highlights text which matches the selected text
  • wordHighlight: when the cursor is on a symbol, highlights places that symbol is read
  • wordHighlightStrong: when the cursor is on a symbol, highlights places that symbol is written
  • activeLinkForeground: color of hyperlinks when clicked

By default, invisibles and guide are derived from the background color, and the rest are not set.

The terminal properties include each of the standard 16 ANSI colors (black, red, green, yellow, blue, magenta, cyan, and white, plus their "bright" counterparts). To set the background color, add the terminal.background key under overrides.

Support

Support below means that the standard VS Code grammar has explicit support for the languages, ie. the colors should match their meanings. Other languages will probably still look alright but there is no guarantee that they will.

  • ✅ C#
  • ✅ CSS
  • ✅ HTML
  • ✅ Java
  • ✅ JavaScript
  • ✅ Markdown
  • ✅ TypeScript

Roadmap

Below are several of the bigger planned items, community feedback is welcome 😃

  • Support light themes #22
  • Allow styling of text style #16
  • Finalize and commit to API #28
  • Implement syntax color fallbacks #27
  • Refine background fallback values #29
  • Add API documentation #30

Development

npm run watch

Then in VS Code press F5 to build demo and launch the debugger with the generated themes available to switch to.

vscode-theme-generator's People

Contributors

codingonhp avatar dependabot[bot] avatar mjbvz avatar rdnlsmith avatar tyriar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-theme-generator's Issues

Error message when I hit F5

macOS 10.13.1
VSCode Insiders 1.19
npm version 5.3.0

When I hit F5 with index.ts loaded, I get an error message as shown
screen shot 2017-11-11 at 22 15 39

Suggestion: Terminal Panel Background

Suggestion

Change the terminal panel background to be slightly different than the sideBar. I changed the color to match the background as the the activityBar.

// theme-extend: sapphire (dim)
"workbench.colorCustomizations": {
  "panel.background": "#0b121c"
}

Preview

Example

Thought I would throw this suggestion out there before I made my own theme extension.

very unusual request

I tried not to open an issue for this particular request, but I can't contact @Tyriar directly through github or via email address or any other private comunication channel... so only for this time I wil do this.
you have posted an image of the vscode window and I was wonder if you could tell me what is the font you where using in the code editor. I have tried to get it in most common font websites but i can't find it. This is the image you have posted:

example

sorry for the inconvenient I may caused.

Web based interface

A theme generator is a great idea! I'd like to take it further and offer a web interface for the theme generator. But a 100% accurate preview would be essential to make such a web interface really useful. My first thought was to simply use the standalone Monaco editor for the previews, but unfortunately I found out that Monaco doesn't support TextMate grammars (as described in the Monaco FAQ) Only hope seems to be WebAssembly, but I don't think it will gain that much traction anytime soon.

So my conclusion is it won't be possible to do at the moment. But maybe you have an idea how a proper preview could be implemented, outside the context of VS Code?

Cannot find theme in VSC

From the docs:

Make your changes to the colors in index.ts and hit F5 to build the theme and launch the a new VS Code window with your theme available in the command palette (ctrl/cmd+shift+p > "Color Theme").

Made my changes, hit f5. Nothing happened. Ran the build task via the tasks panel. Theme was built, but a new VSC window was never opened.

OSX, VSC v1.12.0

Add constant

eg.

        <dict>
            <key>name</key>
            <string>Constant</string>
            <key>scope</key>
            <string>constant</string>
            <key>settings</key>
            <dict>
                <key>foreground</key>
                <string>#ffe792</string>
                <key>fontStyle</key>
                <string></string>
            </dict>
        </dict>

Thoughts on Icon Theme support?

Should these be their own thing or should they be bundled?

Is this one of the uses they are adding the bundling support for?

Finalize and commit to API

Some open questions:

  • Should color1, color2, etc. be named accent1, accent2 or something more specific?
  • How do we mitigate heaps of language specific syntax color types such as markdownQuote, cssTag, etc.

Allow values to have fallbacks

For example class could fallback to keyword, meaning if class was not specified it would use keyword's color. This would allow themes to only specify a subset of colors but be fairly complete.

There is a downside to this in that it would make it harder to not set certain scopes if that is desired?

Refine background fallback values

Right now background fallback colors are very rough based on a quick run through of the Dark+ theme. Maybe we can improve upon it?

The fallbacks we land on may eventually be upstreamed to VS Code.

Related: #22

Implement a proper cli

Needs to support:

  • setting of output file
  • passing in a js/json file with the colorset(s)
  • specifying which program theme is being generated

Add API documentation

Consumers can only find the true capabilities of the generator by looking through examples or searching the interface. The bigger parts like syntax, terminal, background fallbacks etc. should be called out on the readme.

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.