Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Highlighting Guide for Atom

I am very pleased with the new editor by Github. Unfortunately it isn't exactly easy to customize it. I wanted to create my own Syntax Highlighting Theme, because I am not happy with the ones available to download (at least they don't seem to do well with Java)

Now the files (syntax-variables, color.less, etc.) to style seem to be in:

~/.atom/ .../packages (if you want to change existing themes)

The problem is just that I don't know which (CSS) classes style which elements of the syntax. Is there a place where I can look up how to change the color of for example variable type declarations?

like image 247
TomTom Avatar asked May 30 '14 21:05

TomTom


People also ask

How do you change the syntax in Atom theme?

You can easily change your selected UI and Syntax themes through the Settings View: Open the Settings View. Click the Themes tab. Select Syntax or UI theme in their respective drop down lists.

How do you write an Atom theme?

Create a Syntax Theme In Atom, press cmd-shift-P to bring up the command palette, then start typing "Generate Syntax Theme". When you see Package Generator: Generate Syntax Theme appear click it to execute the command: A window will appear in which you can enter the path and name for your syntax theme.

How do I change the syntax of atom stylecs?

In a recent version (v1.13.0) (the latest v1.18.0) of Atom, it seemed that there were extensive changes in the syntax of stylecs.less. Most of information I found in the Internet seems outdated. Select Atom > **Stylesheet… , and a file named styles.less will open. You add CSS code for customization into the space at the bottom of the file.

How do I highlight a class name in a chromium page?

You can use chromium web-console by pressing Ctrl+Shift+I (tested in linux) and highlighting any element. After then open your stylesheet by pressing Edit->Open Your Stylesheet and add style for element with LESS syntax. You want bold highlighting class and function name.

How do I create a syntax highlighting package in Visual Studio?

Creating a Syntax Highlighting Package. To add new syntax highlighting rules, you need to create a subfolder named grammars. In this folder, create a new CSON file named after the language you want to support (e.g. mylanguage.cson). This file will contain all your syntax highlighting rules.

How do I add syntax highlighting to a CSON file?

To add new syntax highlighting rules, you need to create a subfolder named grammars. In this folder, create a new CSON file named after the language you want to support (e.g. mylanguage.cson ). This file will contain all your syntax highlighting rules.


3 Answers

Yes, you can start Atom in Developer Mode by using the command atom --dev or by using the menu View > Developer > Open in Dev Mode .... When you do that you can right click on any element in the UI and select Inspect Element from the context menu, just like you would in your web browser.

Additionally, for syntax elements you can:

  1. Put your text cursor on the item you want to style
  2. Press Cmd+Alt+P on OS X, Ctrl+Alt+Shift+P on other platforms, or find "Editor: Log Cursor Scope" in the command palette to display the scopes of the syntax element

The scopes of the syntax element translate directly to CSS classes.

like image 61
Lee Avatar answered Oct 20 '22 00:10

Lee


You can use chromium web-console by pressing Ctrl+Shift+I (tested in linux) and highlighting any element. After then open your stylesheet by pressing Edit->Open Your Stylesheet and add style for element with LESS syntax.

For example:

You want bold highlighting class and function name. If you select class with chromium-console you can see that it have class .name

That you should add in you Stylesheet file something like this:

atom-text-editor::shadow .name{
    font-weight: bold
}

And you may create you own theme. In Atom it's not difficlt - press Ctrl+Shift+P and type "Generate Syntax Theme". In new theme you can copy some code from other theme. If you don't know CSS/LESS - don't worry! Your new theme have file in style folder named colors.less. You can change it or write new color rule on base.less file.

Atom have awesome doc, you can read about creating theme in this page https://atom.io/docs/v1.4.2/hacking-atom-creating-a-theme

like image 41
Denis Savenko Avatar answered Oct 19 '22 23:10

Denis Savenko


For others that come here because the highlighting for a filetype is not recognized for your language:

  • open the ~/.atom/config.cson file (by CTRL+SHIFT+p: type ``open config'')
  • add/edit a customFileTypes section under core for example like the following:

    core:
      customFileTypes:
        "source.lua": [
          "conf"
        ]
        "text.html.php": [
          "thtml"
        ]
    

(You find the languages scope names ("source.lua", "text.html.php"...) in the language package settings see here)

like image 1
rubo77 Avatar answered Oct 19 '22 22:10

rubo77