Skip to content

Commit cae7ecd

Browse files
committed
Merge remote-tracking branch 'origin/master' into render-infix-3
2 parents b0c1728 + 8b261be commit cae7ecd

10 files changed

+24
-30
lines changed

.github/workflows/release.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ jobs:
7474
curl -L "https://curl.se/ca/cacert.pem" -o cacert.pem
7575
echo "$PWD" >> $GITHUB_PATH
7676
77+
- uses: jiro4989/setup-nim-action@v2
78+
with:
79+
nim-version: '2.0.2' # default is 'stable'
80+
repo-token: ${{ secrets.GITHUB_TOKEN }}
81+
7782
- name: Build nph
7883
run: |
79-
nimble setup -l
84+
nimble install -y
85+
# nimble setup -l
8086
nimble build -d:release
8187
8288
- name: Create archive

format-git-repo.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ git ls-files | grep ".nim$" | xargs -n1 nph
99

1010
! git diff --exit-code > /dev/null || { echo "This repository is already formatted" ; exit 0 ; }
1111

12-
git commit -am "Formatted with nph $(nph --version)"
12+
git commit -am "Formatted with nph $(nph --version)" --author "nph <[email protected]>"
1313

1414
echo "# Formatted with nph $(nph --version)" >> .git-blame-ignore-revs
1515
echo "$(git rev-parse HEAD)" >> .git-blame-ignore-revs
1616

1717
git add .git-blame-ignore-revs
18-
git commit -m "Add $(git rev-parse HEAD) to .git-blame-ignore-revs"
18+
git commit -m "Add $(git rev-parse HEAD) to .git-blame-ignore-revs" --author "nph <[email protected]>"
1919

2020
echo "The repo has been updated with two commits recording the reformatting and blame information."
2121
echo "You can review the changes with 'git diff HEAD^^' before pushing to a public repository."
2222
echo "If you don't want blame information, remove the last commit with 'git reset --hard HEAD^'."
23-

nph.nimble

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ proc commitProject(
9494

9595
try:
9696
exec "git checkout -b nph"
97-
exec "git commit -am \"Formatted with nph $(nph --version)\""
97+
exec "git commit -am \"Formatted with nph $(nph --version)\" --author \"nph <[email protected]>\""
9898
except:
9999
exec "git checkout nph"
100-
exec "git commit -am \"Formatted with nph $(nph --version)\" --amend"
100+
exec "git commit -am \"Formatted with nph $(nph --version)\" --amend --author \"nph <[email protected]>\""
101101

102102
cd "../.."
103103

src/phmsgs.nim

+1-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ proc fileInfoIdx*(
139139
if pseudoPath:
140140
RelativeFile filename
141141
else:
142-
relativeTo(canon, conf.projectPath)
143-
,
142+
relativeTo(canon, conf.projectPath),
144143
)
145144
)
146145

src/phrenderer.nim

+6-12
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,7 @@ proc init(T: type TSrcLen, g: TSrcGen): T =
527527
if g.tokens.len > 0:
528528
@[g.tokens[^1]]
529529
else:
530-
@[]
531-
,
530+
@[],
532531
config: g.config,
533532
)
534533

@@ -836,7 +835,8 @@ proc gsonsNL(
836835
) =
837836
for i in start .. n.len + theEnd:
838837
gsub(g, n[i], flags)
839-
g.optNL()
838+
if i != n.len + theEnd:
839+
g.optNL()
840840

841841
proc glist(
842842
g: var TOutput,
@@ -977,10 +977,6 @@ proc gstmts(g: var TOutput, n: PNode, flags: SubFlags = {}, doIndent = true) =
977977

978978
dedent(g, ind)
979979

980-
if not trivial:
981-
optNL(g)
982-
# if not trivial:
983-
# optNL(g)
984980
if needsPar:
985981
if not trivial:
986982
optNL(g)
@@ -1095,7 +1091,7 @@ proc gif(g: var TOutput, n: PNode, flags: SubFlags) =
10951091
if oneline:
10961092
# We end up here when rendering things that were parsed as expressions but
10971093
# don't match the "trivial" rule above
1098-
# TODO treat such constructs as trivail for better determinism?
1094+
# TODO treat such constructs as trivial for better determinism?
10991095
gsons(g, n, 1)
11001096
else:
11011097
optNL(g)
@@ -1133,8 +1129,7 @@ proc gtry(g: var TOutput, n: PNode) =
11331129
if trivial:
11341130
{sfOneLine}
11351131
else:
1136-
{}
1137-
,
1132+
{},
11381133
)
11391134

11401135
proc gfor(g: var TOutput, n: PNode) =
@@ -2220,8 +2215,7 @@ proc renderTree*(n: PNode, conf: ConfigRef = nil): string =
22202215
if conf == nil:
22212216
newPartialConfigRef()
22222217
else:
2223-
conf
2224-
,
2218+
conf,
22252219
)
22262220
# do not indent the initial statement list so that
22272221
# writeFile("file.nim", repr n)

tests/after/comments.nim

+1-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ discard
330330
54 # discard value
331331

332332
proc x() =
333-
discard
334-
# proc, impl and comment on one line
333+
discard # proc, impl and comment on one line
335334

336335
proc xxx() = # after proc before indented name
337336
discard

tests/after/comments.nim.nph.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ sons:
12051205
- kind: "nkDiscardStmt"
12061206
sons:
12071207
- kind: "nkEmpty"
1208-
- kind: "nkCommentStmt"
1209-
"comment": "# proc, impl and comment on one line"
1208+
postfix:
1209+
- "# proc, impl and comment on one line"
12101210
- kind: "nkProcDef"
12111211
mid:
12121212
- "# after proc before indented name"

tests/after/postexprs.nim

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ else:
9494

9595
discard (
9696
aaa.bbb.exec do(res: int64):
97-
size = res
98-
).ccc()
97+
size = res).ccc()
9998

10099
macro `->`(a, b, c: untyped) =
101100
discard

tests/after/procs.nim

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ type Ep = proc {.nimcall.}
131131
type Fp = proc(
132132
aaaaaaaaaaaaaaaaa: int,
133133
bbbbbbbbbbbbbbb = proc() =
134-
discard
135-
,
134+
discard,
136135
cccccccccccccccccc = 30,
137136
)
138137

tests/after/style.nim

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ functionCall(10000000, 2000000000, 3000000000, 40000000, 5000000000)
3939
proc f(
4040
myParameter = 0,
4141
callback: SomeCallback = proc() =
42-
discard
43-
,
42+
discard,
4443
nextParameter = 1,
4544
)
4645

0 commit comments

Comments
 (0)