All Projects → tonsky → Clojure-Sublimed

tonsky / Clojure-Sublimed

Licence: MIT license
Clojure support for Sublime Text 4

Programming Languages

python
139335 projects - #7 most used programming language
clojure
4091 projects

Projects that are alternatives of or similar to Clojure-Sublimed

ST-ASS
ASS/SSA subtitles syntax highlight for Sublime Text.
Stars: ✭ 23 (-91.42%)
Mutual labels:  syntax-highlighting, sublime-text
gray-matter
A colour scheme for Sublime Text and Visual Studio Code that takes design cues from popular minimalist Markdown text editors.
Stars: ✭ 69 (-74.25%)
Mutual labels:  syntax-highlighting, sublime-text
Tutkain
A Sublime Text package for interactive Clojure development
Stars: ✭ 62 (-76.87%)
Mutual labels:  sublime-text, repl
Inspiredgithub.tmtheme
A color scheme for Sublime Text 3.
Stars: ✭ 117 (-56.34%)
Mutual labels:  syntax-highlighting, sublime-text
Better-Less
Cross-compatible syntax highlighting for Less
Stars: ✭ 13 (-95.15%)
Mutual labels:  syntax-highlighting, sublime-text
Biosyntax
Syntax highlighting for computational biology
Stars: ✭ 164 (-38.81%)
Mutual labels:  syntax-highlighting, sublime-text
elm-syntax-highlighting
Syntax Highlighting for Elm in Sublime Text
Stars: ✭ 27 (-89.93%)
Mutual labels:  syntax-highlighting, sublime-text
Sublimetext
Caddyfile syntax highlighting for Sublime Text 3
Stars: ✭ 17 (-93.66%)
Mutual labels:  syntax-highlighting, sublime-text
opentype-feature-bundle
Syntax highlighting and snippets for OpenType feature development in TextMate/Sublime Text
Stars: ✭ 35 (-86.94%)
Mutual labels:  syntax-highlighting, sublime-text
SublimeText-GameMaker-Plugin
GML Snippets & Syntax Highlighting for SublimeText 2
Stars: ✭ 20 (-92.54%)
Mutual labels:  syntax-highlighting, sublime-text
Nord Sublime Text
An arctic, north-bluish clean and elegant Sublime Text theme.
Stars: ✭ 109 (-59.33%)
Mutual labels:  syntax-highlighting, sublime-text
sublime-PICO-8
PICO-8 plugin for the Sublime Text 3 editor.
Stars: ✭ 42 (-84.33%)
Mutual labels:  syntax-highlighting, sublime-text
Pythonimproved
The best Python language definition for Sublime Text - ever. Includes full support for Unicode, as well as both Python 2 and Python 3 syntax. Check out the Neon Color Scheme for highlighting.
Stars: ✭ 95 (-64.55%)
Mutual labels:  syntax-highlighting, sublime-text
Css3
The most complete CSS support for Sublime Text
Stars: ✭ 178 (-33.58%)
Mutual labels:  syntax-highlighting, sublime-text
Ecmascript Sublime
ECMAScript/JavaScript syntax (ES2015-ES2018, JSX, template highlighting, etc) with absurdly specific scopes
Stars: ✭ 78 (-70.9%)
Mutual labels:  syntax-highlighting, sublime-text
sublime-coconut
Coconut syntax highlighting for Sublime Text and VSCode.
Stars: ✭ 18 (-93.28%)
Mutual labels:  syntax-highlighting, sublime-text
Sublime Monokai Extended
Extends Monokai from Soda with additional syntax highlighting for Markdown, LESS, HTML, Handlebars and more.
Stars: ✭ 505 (+88.43%)
Mutual labels:  syntax-highlighting, sublime-text
Sublime Markdown Extended
Top 100 Sublime Text plugin! Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3. Goes great with Assemble.
Stars: ✭ 645 (+140.67%)
Mutual labels:  syntax-highlighting, sublime-text
Assembly-Syntax-Definition
This is the greatest syntax definition of All Time
Stars: ✭ 23 (-91.42%)
Mutual labels:  syntax-highlighting, sublime-text
SubLilyPond
LilyPond syntax highlighting in Sublime Text 2 and 3.
Stars: ✭ 26 (-90.3%)
Mutual labels:  syntax-highlighting, sublime-text

Clojure support for Sublime Text 4

This package provides Clojure support for Sublime Text and includes:

  • Clojure and EDN syntax grammars (Sublime Text 3+)
  • Clojure code formatter/indenter (Sublime Text 4075+)
  • Clojure nREPL client (Sublime Text 4075+, nREPL 0.8+)

Clojure syntax

Syntaxes

Clojure Sublimed ships with its own syntax definition for Clojure and EDN. Unlike default Clojure syntax, this package is:

  • slightly more pedantic as per EDN spec and Clojure Reader,
  • rigorously tested,
  • can be used to highlight rainbow parentheses,
  • punctuation and validation inside regexps,
  • quoted and unquoted regions are marked for highlighting,
  • semantically correct tokenization, perfect for fonts with ligatures,
  • has separate EDN syntax, same way JSON is separate from JavaScript in Sublime Text.

Want to put your parser to test? Check out syntax_test_edn.edn and syntax_test_clojure.cljc.

Clojure Sublimed syntax is also used by nREPL client to find form boundaries and namespaces (might be changed in the future).

Formatter/indenter

Clojure Sublimed includes optional support for Simple Clojure Formatting rules. It doesn’t require nREPL connection but does require Clojure (Sublimed) syntax to be selected for buffer.

To reformat whole file, run Clojure Sublimed: Reindent Buffer.

To reindent only current line(s), run Clojure Sublimed: Reindent Lines.

To enable correct indentations as you type code, rebind Enter to Clojure Sublimed: Insert Newline:

{"keys":    ["enter"],
 "command": "clojure_sublimed_insert_newline",
 "context": [{"key": "selector", "operator": "equal", "operand": "source.edn | source.clojure"},
             {"key": "auto_complete_visible", "operator": "equal", "operand": false},
             {"key": "panel_has_focus", "operator": "equal", "operand": false}]}

Best way to do it is through running Preferences: Clojure Sublimed Key Bindings.

nREPL Client

Clojure Sublimed nREPL client enables interactive development from the comfort of your editor.

Principles:

  • Minimal distraction. Display evaluation results inline.
  • Decomplected. Eval code and nothing more.
  • Server-agnostic. We work with any nREPL socket, local or over network.

Features:

  • evaluate code,
  • display evaluation results inline.
  • display stack traces inline,
  • interrupt evaluation,
  • eval multiple forms at once (parallel evaluation),
  • lookup symbol info,
  • show evaluation time,
  • bind keys to eval arbitrary code.

We intentionally excluded following features:

  • Autocomplete. Static analysis is much simpler and much more reliable than requiring an always-live connection to the working app.

Look at Sublime LSP with Clojure LSP or SublimeLinter with clj-kondo if you need autocompletion.

Why nREPL and not Socket Server REPL/pREPL/unREPL?

  • nREPL has the widest adoption,
  • nREPL is machine-friendly,
  • nREPL comes with batteries included (interrupt, load-file, sideload),
  • nREPL is extensible via middleware,
  • nREPL serialization is easier to access from Python than EDN.

Differences from Tutkain:

  • nREPL instead of Socket Server REPL
  • Does not have separate REPL panel
  • Keeps multiple eval results on a screen simultaneously
  • Can show stack traces inline in editor
  • Can eval several forms in parallel
  • Can eval non well-formed forms (e.g. (+ 1 2)
  • Can eval infinite sequences
  • Redirects all *out*/*err* to System.out/System.err

Installation

  1. Package Control: Install PackageClojure Sublimed

  2. Assign syntax to Clojure files:

    • open any clj/cljc/cljs file,
    • run ViewSyntaxOpen all with current extension as...Clojure SublimedClojure (Sublimed).

How to use

Important! Make sure you switched your syntax to Clojure (Sublimed).

  1. Run nREPL server.
  2. Run Clojure Sublimed: Connect command.

Evaluating code from buffer

From here you have three options:

Clojure Sublimed: Evaluate without selection evaluates topmost form around your cursor:

Evaluate Topmost

Clojure Sublimed: Evaluate with selection evaluates selected text:

Evaluate Selection

Clojure Sublimed: Evaluate Buffer will evaluate the entire file:

Evaluate Buffer

You don’t have to wait for one form to finish evaluating to evaluate something else. Multiple things can be executed in parallel:

Evaluate in Parallel

By default, Clojure Sublimed will also print evaluation time if it took more than 100 ms:

Elapsed time

Copying evaluation results

Sometimes you want to copy evaluation result. It is recommended to rebind Cmd+C/Ctrl+C from copy to sublime_clojure_copy. This will copy evaluation result if inside evaluated region and fallback to default copy otherwise.

Interrupting

If your evaluation runs too long and you want to interrupt it, run Clojure Sublimed: Interrupt Pending Evaluations:

Interrupt

Opening stacktrace

If your evaluation failed, put your cursor inside failed region and run Clojure Sublimed: Toggle Stacktrace:

Toggle Stacktrace

Clojure Sublimed will display stacktraces in a Clojure-friendly way. Compare with the default REPL:

Stacktraces

Looking up symbol

To show symbol info, run Clojure Sublimed: Toggle Symbol Info:

Toggle Symbol Info

Universal Clojure Sublimed: Toggle Info command acts as either Toggle Stacktrace or Toggle Symbol Info, depending on context.

Binding keys to eval code

Every project is different, and sometimes it’s convenient to run a piece of code so often you’d want it on a shortcut. It might be a namespace reload, test execution, database reconnect, linter, formatter — possibilities are endless.

To support such use cases, Clojure Sublimed allows you to bind arbitrary piece of code to a keyboard shortcut. Run Preferences: Clojure Sublimed Key Bindings and add something like this:

{"keys": ["ctrl+t"],
 "command": "clojure_sublimed_eval_code",
 "args": {"code": "(clojure.test/run-all-tests)"}}

Then, whenever you press Ctrl + T, you’ll see the result in the status bar, like this:

Eval Code

Clearing results

Finally, to clear evaluation results run Clojure Sublimed: Clear Evaluation Results.

Editing settings

To edit settings, run Preferences: Clojure Sublimed Settings command.

Default Key Bindings

Clojure Sublimed comes with no keybindings enabled by default to guarantee they won’t conflict with any other extension.

This is the recommended keymap:

Command macOS Windows/Linux Mnemonic
Evaluate Ctrl Enter Ctrl Alt Enter
Evaluate Buffer Ctrl B Ctrl Alt B [B]uffer
Interrupt Pending Evaluations Ctrl C Ctrl Alt C [C]ancel
Toggle Info Ctrl I Ctrl Alt I [I]nfo
Clear Evaluation Results Ctrl L Ctrl Alt L c[L]ear
Copy Evaluation Results Command C Ctrl C [C]opy
Reindent Lines Ctrl F Ctrl Alt F [F]ormat
Reindent Buffer Ctrl Shift F Ctrl Alt Shift F Capital [F]ormat

To set it up, run Preferences: Clojure Sublimed Key Bindings command and copy example keybindings to your local Key Bindings file.

Frequently Asked Questions

Q: REPL/eval doesn’t work

A: Make sure you are using nREPL 0.8 or later. A: Make sure you have assigned Clojure (Sublimed) syntax to the file.

Credits

Made by Niki Tonsky.

With contributions by Jaihindh Reddy.

See also

Writer Color Scheme: A color scheme optimized for long-form writing.

Alabaster Color Scheme: Minimal color scheme for coding.

Sublime Profiles: Profile switcher.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].