How do install a local syntax theme?


#1

I have used the Base 16 builder to generate some Base 16 syntax themes. The result is a pair of files:

base16-default-dark-base.less
base16-default-dark-syntax-variables.less

How do I install this?


#2

You should just be able to take the contents of both files and dump them into your ~/.atom/styles.less file, I assume. But really, isn’t this a question for the person who built the Base 16 Builder?


#3

But really, isn’t this a question for the person who built the Base 16 Builder?

Sure, I was considering opening an issue against that project instead. But then I thought: I should be able to answer this as well as they can. They don’t have access to anything (re. Atom) that I don’t.

So I spent quite a while looking through Atom’s documentation, and the only documented way to install syntax themes is through the package manager. There’s nothing about local installation at all, nor is there a description of the structure of a theme (even on the page about creating them).

Maybe my question should be: if I am the author of a tool that generates syntax themes from a template, what does my tool need to generate (in addition to what I described above) and what instructions can I give to my users to install the generated theme?


#4

There are a couple answers to your questions. There are a couple well-supported scenarios and then there is what it seems like you’re asking for. But let’s start with the supported scenarios:

  1. Theme packages
  2. Style tweaks

Scenario #1 is the typical situation when you’re creating something for someone else to use:

  1. I create a theme out of a bunch of style information
  2. I package it up (using the Creating a Theme documentation)
  3. I publish the theme to https://atom.io/packages using the apm command-line tool
  4. Someone installs the theme like any other Atom package (either using the Settings View or the apm command-line tool)

Scenario #2 is typical for someone that just wants to add something special just for themselves.

  1. I open the ~/.atom/styles.less file
  2. I add my tweak
  3. I save the file
  4. It is automatically reflected in the application

The scenario you’re describing is not one of those two scenarios. You went to a website, you generated some style information and now you have a couple files. I don’t know what the author of that tool intended for you to do with the contents of those two files. Did they intend for you to create your own package? Did they intend for you to add the contents to the styles.less? Without seeing the contents of the files … I have no way of knowing. And the repository and related pages that I could find didn’t seem to be forthcoming with the answers.

Now, if I was going to write a tool of the kind I believe you’re describing, where the requirement is to create a complete theme that is not designed to be published but only installed locally … I would probably do the following:

  1. I would allow you to generate your theme out of my tool
  2. The tool would then give you:
    1. An archive file (probably .zip) of the generated package or packages
    2. Instructions on how to unzip the archive to the ~/.atom/packages directory
    3. Instructions on how to edit your ~/.atom/config.cson to load your new theme package or packages
    4. Instruct you to restart Atom when you’re done

And even this is more complicated than it should be … it would probably just be easier to generate the package (if that theme combination hadn’t been created before), publish the package straight from the tool and then just supply you with instructions on how to install your very own custom theme package.


#5

Fair enough… I don’t know the Base 16 builder author, but I’m presuming that what they intend is for users to generate a syntax theme for Atom that they can install from their own machine with a minimum of fuss. That is, it should be as easy as installing a .ksf file in Komodo Edit (open it), or installing a .tmTheme in Sublime Text (copy it to Packages/User).

The builder works by having a bunch of templates (for different tools eg. editors, terminals) and a bunch of variations on the basic style (eg. “default”, “tomorrow”, “chalk”). A user can generate a theme they like by doing ./base16 schemes/tomorrow.yml. There’s a template for Atom that generates the .less files I mentioned above.

Perhaps, at some point, some nice person might generate them all and publish them and maintain them, but they still need something to publish. Since there are many variations on the basic structure (~60), automation is desirable.

So better question might be: if I wanted to patch Base 16 to do make it as easy as possible for the user to install a generated theme, what should it produce? Perhaps this reduces to: what are some easily automatable steps between having the .less files that define a syntax theme, and making a package that is publishable or able to be installed locally?

So if the tool were to generate files in the structure described in Creating Packages… that would be good? Could a user drop such a directory in .atom/packages and have the theme appear in the “Syntax Theme” drop down box? I still can’t find any information on installing packages locally, but you mentioned editing .atom/config.cson — what edits would be needed?


#6

The honest answer to this question is that it should produce a package that is published to https://atom.io so that they can simply go to the command line and type apm install detlys-awesome-theme.

Thanks for linking that. From what it appears that it generates, you should be able to just dump the contents into your styles.less like I originally suggested.


#7

The honest answer to this question is that it should produce a package that is published to https://atom.io

Right. But if I were to do that… I’d want to know how it should produce such packages in the first place. I don’t want to go through a manual process 60 times to do it.

And if I didn’t want to be maintainer for a bunch of packages for an editor I’m not too familiar with, I’d prefer to try them out on my own machine for a while before publishing them. (In a way that makes it reasonably easy to open, update, switch between, doesn’t harm existing config, etc.)

Although… poking around some of the themes that come with Atom by default, I can infer what is and isn’t required for a syntax theme package eg. the necessary contents of package.json, the name of the stylesheet that Atom looks for. That should be enough to get me started.


#8

Did you ever figure this out? I have the same question.

You should not have to publish a package to use it locally, and I do not believe that to be the case.


#9

No, you don’t have to publish a package (whether a theme or not) to use it locally. You can use the apm link command to link a package stored anywhere on your system into your active set of packages. See apm help link for details.


#10

So I tried to find it on OS X and found nothing like “styles.less”


#11

You can open styles.less form the Atom menu…

03

…or you can use the command palette:

31

The location of the file is ~/.atom/styles.less. If it’s missing, it should be created by Atom on first open.