hjwylde / git-fmt Goto Github PK
View Code? Open in Web Editor NEWWIP: A custom git command for formatting code
License: BSD 3-Clause "New" or "Revised" License
WIP: A custom git command for formatting code
License: BSD 3-Clause "New" or "Revised" License
The --list-modified
option should list any files that are modified and their status.
The --patch
option should generate a patch and spit it to stdout.
Rather than having quite rigid requirements on pretty instances (e.g., tabs and maximum 100 character line length), make this tool modular in that it uses other binaries for pretty printing.
A configuration file can be used to define delegates and this tool can hook them together with a git repository by providing statuses and dry-runs.
(Thanks @purcell for the feedback!)
I would like to use the pipes
package to rewrite the handle
method in terms of producers (input files) and consumers (modes).
This will ensure a bit more safety in case of newline characters.
The --operate-on
option should take a mode (tracked
, index
or working-tree
) to alter which files it works on.
I'd like to test out the Travis allow failure for the --resolver lts
and --resolver nightly
options.
Ideally if these builds failed then I don't care, but it'd be something I'd need to fix before bumping the resolver.
The output style should (when verbose) include the log level and a timestamp.
Some languages are going to be quite complex to format, e.g., ones with operator overloading or where method order is important.
The fact that I require comments and newlines to be maintained (#4, #9) means that most parsers and Pretty
instances that are available from Hackage probably won't do. This will mean a lot of work will have to be done manually. So, to begin with I'm going to start with very simple languages - such as JSON, YAML, CSS and HTML!
Discussion on call style
I would like to avoid any config files. By default git-fmt
should format all supported languages. The user may be able to override these by either specifying the languages manually (maybe via a --languages
option) or excluding a language (maybe via a --exclude-language
option).
Create an initial shell command (git-fmt
) that does nothing.
Update the git-fmt
command to print out all git files. This is an intermediary step until we actually do something with them.
Fix this to be integers.
The --list-all
option should list all files looked at and their status.
https://github.com/hjwylde/git-fmt/tree/321170833dd1c4a70b1a89cc2909bf4f4143b885 contains the last version of the JSON pretty printer.
After #4 I would like a formal document that describes exactly what formatting steps git-fmt
will do. This will provide a reference for adding languages to support.
Discussion on format style
I would like to leverage the format off the pretty library. From the outside, you can only control the line length, ribbon width and render mode. This is fine, but it may mean that I need custom instances of Pretty
that provide sorting or other formatting styles. To determine what's needed, I'm going to try list what I would like the formatter to do.
The formatter will:
Further, the formatter must ensure:
Ideally I'd have an Emacs plugin which will run omnifmt
on the current file whenever I save it, and omnifmt
will use its smarts to Do The Right Thing in the context of my current project. I'll happily write such a plugin when the time comes.
The home config could reside in ~/.omnifmt.yaml
.
The --dry-run
option will not write to any files.
E.g.,
[2015-11-18 12:21:36.767468] debug "foo/baz/quux.json" (line 1, column 1):
unexpected end of input
expecting white space or top level JSON value
The JSON pretty printer doesn't properly handle UTF-8 characters.
Create an empty test suite.
Normal running, patch and dry run feel more like modes to me -> they each have different behaviour that don't intersect. Change the flags to be a single mode option.
As part of this, remove --list-files
and make that the default for the normal mode.
Currently a file may be in the index but not exist.
Verbose mode should print out external commands called, full parse errors and should include the same output as --list-all
.
It should also alter all output to include the log level and timestamp.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.