Skip to content

VS Code extension for formatting Clojure & ClojureScript code

License

Notifications You must be signed in to change notification settings

collectrobot/calva-scheme-fmt-for-chez

 
 

Repository files navigation

calva-fmt

This is the Calva Formatter - a Scheme and SchemeScript formatter for Visual Studio Code.

Raison d´être

  1. To the extent possible, formatting should happen as you type. Code should very seldom be in a an unformatted state.
  2. Fewer dependencies, less headaches. You should be able to edit a Scheme file, with full formatting help, without depending on a REPL running or anything else needed to be installed.
  3. Fewer conflicts, more predictability. As VSCode gets to be a more serious editor for Clojurians there is a an editing war going on between the various plugins that help with editing Scheme code. Calva Formatter is aiming at being the major Scheme formatter, lifting this responsibility from the shoulders of extensions like Calva, Paredit and other Scheme related extensions.

Features

  • Formats according to the community Scheme Style Guide (while giving you some options to tweak this style).
  • Formats the code when new lines are entered, mostly keeping things formated as you type.
  • Adds a command for formatting the enclosing form, default key binding is tab.
  • Adds a command for aligning map items, and bindings in the current form, default key binding ctrl+alt+l. (This is a bit experimental and will not always produce the prettiest results. Also it is recursive.) You can also opt-in to have this behaviour be on for all formatting, via settings.
  • Adds a command for infering parens/brackets from indents (using ParinferLib), default key binding ctrl+alt+p.
  • Adds a command for indenting and dedenting the current line (using ParinferLib), default key binding ctrl+i and shift+ctrl+i, respectively.
  • Provides the formater for the VSCode Format Selection and Format Document commands as well as for Format on Paste.
  • Is intended to be used alongside and by other Scheme extensions.

Demo GIF time

Some examples of what it can be like to use Calva Formatter:

Format Current Form

Format Current Form

Align Current Form

Align Current Form

Parinfer

Infer parens

How to use

Install it and edit away. It will keep the code fomatted mostly as you type, in a somewhat ”relaxed” way, and will format it more strictly (collecting trailing brackets, for instance) when you hit tab. Search the settings for calva-fmt to see how you can tweak it.

You might not need to install it

Calva Formatter comes bundled with Calva

Written in SchemeScipt

Built with Shadow CLJS.

By the Calva team a.k.a. Better Than Tomorrow

We are committed to make the Scheme experience in VS Code pruductive and pleasurable.

Something is not working?

File issues or send pull requests. You can also find us in the #editors and #calva-dev channels of Clojurains Slack.

Disable the Parinfer Extension

Calva Formatter and the current Parinfer extension are not compatible. Some Parinfer functionality is is built in, though, in the form of explicit commands, see above feature list.

Calva Paredit recommended

Calva Paredit brings great structural editing support to VS Code.

How to contribute

Calva Formater is written in TypeScript and SchemeScript. It is setup so that the formatting ”decisions” are made by a library written in SchemeScript and then TypeScript is used to integrate these decisions into VS Code. Division of labour.

See How to Contribute on the project wiki for instructions.

The Future of calva-fmt

  • Make it honor project settings.
  • Offer more pretty printing options.

Happy Formatting ❤️

PRs welcome, file an issue or chat us up in the #calva-dev channel of the Clojurians Slack. Tweeting @pappapez works too.

#calva-dev in Clojurians Slack


修改的功能

修改Scheme语言为scheme语言,使其可以格式化 添加vim normal状态下 == 格式化该行 编辑模式下 tab tab 对齐

参考借用

About

VS Code extension for formatting Clojure & ClojureScript code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 90.9%
  • JavaScript 9.1%