Repository metrics
- Stars
- (36 stars)
- PR merge metrics
- (30d に merged PR はありません)
説明
From @lassik on June 26, 2018 11:56
Greetings from Emacs-land,
We would like to have the main functionality of Unibeautify in Emacs. Before discovering Unibeautify I started writing the format-all package. Right now it's a very bare-bones Unibeautify workalike: it calls pre-defined formatters with their default options. There's also a similar and older package for Vim called Neoformat with more features than we have.
Our Emacs package could simply use Unibeautify as its sole backend. However, currently that wouldn't work for us since installing NPM modules as extra dependencies is too difficult for users. Currently our users only have to install one Emacs package, plus whatever external formatters they use. There is no required dependency on anything outside Emacs.
If I understand correctly, the core of Unibeautify is essentially a huge data structure that maps programming languages and formatting options to compatible external formatters and their command line flags. Would you be interested in explicitly encoding this data structure in a JSON file? The file could be shared by Unibeautify and different editor plugins - each plugin project would simply have a script to convert the common JSON file into whatever representation is needed in its implementation language. E.g. in Emacs Lisp we could convert it into nested lists to store in a variable in Emacs.
Of course, in a perfect world Unibeautify would be the only universal formatting package anyone needed, but currently relying on Node and NPM makes deployment prohibitively difficult in many situations. (NPM is part of the standard workflow of JavaScript developers but many others are not comfortable using it and frequently encounter errors they do not understand.) Hence I think it still makes sense to have editor-specific packages, and extract as many common parts as we can into a shared specification file.
To recap, the common JSON file would specify:
- All the external formatters that exist.
- Common names for those external formatters.
- Common names for programming languages.
- Common names for formatting options (e.g.
arrow_parens,multiline_ternary). - A common specification of the valid range of values for all those formatting options (for machine validation).
- A mapping to convert the common option names to the command line flags expected by each external formatter.
- Maybe some human-readable help text for the formatting options.
Then Unibeautify and various editor plugins could mainly consist of some plumbing to construct command lines from this data structure.
For my part, I would be happy to contribute to the maintenance of such a JSON file. The master copy could be hosted in its own Git repo or in the Unibeautify repo. I don't really mind which approach is taken if people are willing to do this. What do you think?
Copied from original issue: Unibeautify/unibeautify#111