Skip to content

MariuzM/quicksource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickSource

Syntax-highlighted Quick Look previews for developer files on macOS. Select a .rs, .ts, .tsx, .vue, .svelte, .go, .prisma, .graphql (and many more) file in Finder, press Space, and see the code rendered with syntax highlighting instead of a blank icon.

Built on the modern Quick Look Preview Extension API (QLPreviewingController) — not a deprecated .qlgenerator plugin — and powered by Highlightr (highlight.js).

Features

  • Syntax highlighting for dozens of languages via highlight.js.
  • Automatic light/dark theme following the system appearance.
  • Declares Uniform Type Identifiers for developer extensions macOS has no built-in type for (.ts, .tsx, .jsx, .vue, .svelte, .rs, .go, .prisma, .graphql, .toml, .kt, .dart, .sol, .zig, .lua, and more).
  • Large-file guard (previews truncate past 4 MB so Quick Look never stalls).

Requirements

  • macOS 14+
  • Xcode 16+ (provides the toolchain and swift-format)
  • XcodeGen (brew install xcodegen)

Project layout

project.yml                    XcodeGen spec — the source of truth for the Xcode project
.swift-format                  swift-format config (used by the editor and CI)
App/                           Container app (SwiftUI window + setup instructions)
  Info.plist                   UTImportedTypeDeclarations for extensions with no system type
PreviewExtension/              The Quick Look extension
  PreviewViewController.swift  Reads file -> Highlightr -> NSTextView
  Info.plist                   QLSupportedContentTypes

QuickSource.xcodeproj is generated from project.yml and is git-ignored — regenerate it with xcodegen generate.

Build & run

xcodegen generate

# Signed build. Find your identity hash with:
#   security find-identity -v -p codesigning
xcodebuild -project QuickSource.xcodeproj -scheme QuickSource \
  -configuration Debug -destination 'platform=macOS' \
  CODE_SIGN_STYLE=Manual \
  CODE_SIGN_IDENTITY="<your-Apple-Development-cert-SHA1>" \
  PROVISIONING_PROFILE_SPECIFIER="" DEVELOPMENT_TEAM="" \
  build

# Install, register, launch once
rm -rf /Applications/QuickSource.app
cp -R ~/Library/Developer/Xcode/DerivedData/QuickSource-*/Build/Products/Debug/QuickSource.app /Applications/
open /Applications/QuickSource.app

A Quick Look extension must be validly code-signed or macOS silently ignores it — an ad-hoc/unsigned build will not appear in Quick Look. A free Apple ID works.

Enable the preview

  1. Run the app once (registers the extension).
  2. System Settings -> General -> Login Items & Extensions -> Quick Look -> enable PreviewExtension.
  3. Select a source file in Finder and press Space. Run qlmanage -r to flush the Quick Look cache if an old preview is stuck.

Adding more file types

  • If the extension already has a system UTI conforming to public.source-code (.swift, .py, .go, .rb, .php, .c, .js, …) it is already covered — just add a case in PreviewViewController.language(for:) for correct highlighting.
  • If it has no system UTI (.ts, .vue, .prisma, …) add its extension to a UTImportedTypeDeclarations entry in App/Info.plist (conforming to public.source-code), rebuild, and relaunch so Launch Services re-reads the types.

Known caveat: .ts ambiguity

.ts is also the system type for MPEG-2 transport stream (video). The imported declaration competes with that and the system type sometimes wins, so .ts may be treated as video and skip the preview. .mts/.cts/.tsx are unaffected. Workaround: associate .ts with a text editor via Finder -> Get Info -> Open with -> Change All.

Development

Code is formatted with swift-format using the committed .swift-format config:

xcrun swift-format lint --recursive App PreviewExtension        # check
xcrun swift-format --in-place --recursive App PreviewExtension  # fix

License

MIT — see LICENSE.

About

Syntax-highlighted Quick Look previews for developer files on macOS.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages