Skip to content

Commit

Permalink
Automatically formats all the files using ocamlformat
Browse files Browse the repository at this point in the history
  • Loading branch information
modlfo committed Aug 31, 2019
1 parent 7f3ace7 commit 9cff854
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
profile=sparse
margin=120
parens-tuple=multi-line-only
nested-match=align
match-indent-nested=always
break-infix=fit-or-vertical
break-fun-sig=fit-or-vertical
break-fun-decl=fit-or-vertical
align-variants-decl=true
align-constructors-decl=true
cases-matching-exp-indent=normal
exp-grouping=preserve
if-then-else=fit-or-vertical
break-cases=all
comment-check=false
wrap-comments=false
doc-comments-padding=3
14 changes: 11 additions & 3 deletions .ocp-indent
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ with = 0
# the default is 2, which aligns the pattern and the expression
match_clause = 3 # this is non-default

# Indentation for items inside extension nodes:
# [%% id.id
# ^^^^contents ]
# [@@id
# ^^^^foo
# ]
ppx_stritem_ext = 3

# When nesting expressions on the same line, their indentation are in
# some cases stacked, so that it remains correct if you close them one
# at a line. This may lead to large indents in complex code though, so
Expand All @@ -52,7 +60,7 @@ match_clause = 3 # this is non-default
# x) # x)
# ) # )
# ) # )
max_indent = 6
max_indent = 12


#
Expand All @@ -69,7 +77,7 @@ max_indent = 6
# For example, the following is not indented if set to `always`:
# let f = function
# ^^| Foo -> bar
strict_with = never
strict_with = auto

# Controls indentation after the `else` keyword. `always` indents after the
# `else` keyword normally, like after `then`.
Expand All @@ -90,7 +98,7 @@ strict_else = always
# Ocp-indent will normally try to preserve your in-comment indentation, as long
# as it respects the left-margin or starts with `(*\n`. Setting this to `true`
# forces alignment within comments.
strict_comments = false
strict_comments = true

# Toggles preference of column-alignment over line indentation for most
# of the common operators and after mid-line opening parentheses.
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
PREFIX ?= /usr/local/bin

VULT_SRC = $(wildcard src/*.ml) $(wildcard src/core/*.ml) $(wildcard src/generators/*.ml) $(wildcard src/js/*.ml) $(wildcard src/parser/*.ml) $(wildcard src/passes/*.ml) $(wildcard src/util/*.ml) $(wildcard test/*.ml)

OCB = ocamlbuild -j 4 -use-ocamlfind

compiler: version
ifeq (, $(shell which ocamlformat))
OCAMLFORMAT = echo
else
OCAMLFORMAT = ocamlformat
endif

ifeq (, $(shell which ocp-indent))
OCPINDENT = echo
else
OCPINDENT = ocp-indent
endif

format: $(VULT_SRC)
@$(OCAMLFORMAT) -i --enable-outside-detected-project $(VULT_SRC)
@$(OCPINDENT) -i $(VULT_SRC)

compiler: version format
$(OCB) src/vultc.native src/vultc.byte

js: jscompiler
Expand Down

0 comments on commit 9cff854

Please sign in to comment.