Syntax Highlighting - rzukic/zed-latex GitHub Wiki

This extension provides syntax highlighting for LaTeX and BibTeX files. Common file extensions for these languages are recognised, however the user can also manually set the language to LaTeX or BibTeX for other file extensions. This can be done by adjusting the Zed settings:

{
  // ...
  "file_types": {
    // say you have a make4ht project with .cfg files for which you want LaTeX syntax highlighting:
    "LaTeX": ["cfg"]
  },
  // ...
}

Some configuration files (such as latexmkrc) used in LaTeX projects are actually Perl. Perl syntax highlighting is provided by a different extension, and you can add the following to your Zed settings to enable Perl syntax highlighting for these files:

{
  // ...
  "file_types": {
    "Perl": ["latexmkrc"]
  },
  // ...
}

Dev notes

The relevant files for syntax highlighting are found at languages/latex/highlights.scm (and correspondingly latex -> bibtex for bibtex highlighting)

LaTeX highlights

Zed provides a list of captures for which themes should provide colours for. With LaTeX language items not matching up perfectly with the captures in the list linked above, choices were made to repurpose some common but irrelevant captures to other purposes specifically to latex. A benefit to this over settling with the closest fitting capture description is that the most common captures have clear contrasting colours.

Here are some of these choices for future reference to keep consistency:

Capture Usage in LaTeX
@function generic commands (\command)
@keyword special commands (\begin, \end, \section,...)
@type environment names
@attribute square bracket content to commands
@constant reference, citation and other labels
@number mathmode content
@string file paths
@title part, chapter, section,... titles

n.b. @tag in html might be the most analoguous to environment names in latex. But languages don't usually have both tags and functions so they do not contrast, and latex has no strict types.