# Adding Custom Language Support to Shiki

til · 2025-08-06 · #meta

While writing my [Ghostty blog post](/posts/enabling-font-ligatures-ghostty/), I wanted syntax highlighting for the configuration snippets. Since Shiki doesn't support Ghostty's config format, I added a custom language definition.

```typescript
const ghostty = {
  name: 'ghostty',
  scopeName: 'source.ghostty',
  fileTypes: ['ghostty'],
  repository: {},
  patterns: [
    {
      include: '#strings',
    },
    {
      name: 'comment.line.number-sign.ghostty',
      match: '^\\s*#.*$',
    },
    {
      match: '\\b(font-family|font-feature)\\b',
      name: 'keyword.other.ghostty',
    },
  ],
};
```

I only defined patterns for comments (`#`) and the font keywords I was actually using. The grammar follows TextMate rules but doesn't try to implement the full Ghostty spec - just enough for my examples.

```typescript
highlighter = await createHighlighter({
  themes: ['github-dark', 'github-light'],
  langs: ['ruby', 'javascript', 'json', 'elixir', 'typescript', ghostty],
});
```
