Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
mohkale authored Apr 22, 2023
2 parents 29e20b1 + bc6b72c commit 673db87
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ The format is based on [Keep a Changelog].
### Formatters

* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
* [`jq`](https://stedolan.github.io/jq/) for
[JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON)
([#174]).
* [`gawk`](https://www.gnu.org/software/gawk/) for
[awk](https://en.wikipedia.org/wiki/AWK) ([#187]).
* [`asmfmt`](https://github.com/klauspost/asmfmt) for assembly ([#168]).
* [`astyle`](https://github.com/steinwurf/astyle) for C ([#169]).

[#169]: https://github.com/radian-software/apheleia/issues/169
[#168]: https://github.com/radian-software/apheleia/pull/168
[#169]: https://github.com/radian-software/apheleia/pull/169
[#174]: https://github.com/radian-software/apheleia/pull/174
[#182]: https://github.com/radian-software/apheleia/pull/182
[#187]: https://github.com/radian-software/apheleia/pull/187


## 3.2 (released 2023-02-25)
### Features
Expand Down
7 changes: 7 additions & 0 deletions apheleia.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
(defcustom apheleia-formatters
'((astyle . ("astyle" (apheleia-formatters-locate-file
"--options" ".astylerc")))
(asmfmt . ("asmfmt"))
(bean-format . ("bean-format"))
(black . ("black"
(when (apheleia-formatters-extension-p "pyi") "--pyi")
Expand All @@ -50,11 +51,14 @@
(dart-format . ("dart" "format"))
(elm-format . ("elm-format" "--yes" "--stdin"))
(fish-indent . ("fish_indent"))
(gawk . ("gawk" "-f" "-" "--pretty-print=-"))
(gofmt . ("gofmt"))
(gofumpt . ("gofumpt"))
(goimports . ("goimports"))
(google-java-format . ("google-java-format" "-"))
(isort . ("isort" "-"))
(jq "jq" "."
(apheleia-formatters-js-indent "--tab" "--indent"))
(lisp-indent . apheleia-indent-lisp-buffer)
(ktlint . ("ktlint" "--log-level=none" "--stdin" "-F" "-"))
(latexindent . ("latexindent" "--logfile=/dev/null"))
Expand Down Expand Up @@ -188,6 +192,8 @@ rather than using this system."
(json-mode . prettier-json)
(json-ts-mode . prettier-json)
;; rest are alphabetical
(asm-mode . asmfmt)
(awk-mode . gawk)
(bash-ts-mode . shfmt)
(beancount-mode . bean-format)
(c++-ts-mode . clang-format)
Expand Down Expand Up @@ -222,6 +228,7 @@ rather than using this system."
(LaTeX-mode . latexindent)
(lua-mode . stylua)
(lisp-mode . lisp-indent)
(nasm-mode . asmfmt)
(nix-mode . nixfmt)
(purescript-mode . purs-tidy)
(python-mode . black)
Expand Down
6 changes: 6 additions & 0 deletions test/formatters/installers/asmfmt.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version=1.3.2

dest=$(mktemp -d)
curl -L "https://github.com/klauspost/asmfmt/releases/download/v$version/asmfmt-Linux_x86_64_$version.tar.gz" | tar -xvzC "$dest"
mv "$dest/asmfmt" /usr/local/bin/asmfmt
rm -rf "$dest"
1 change: 1 addition & 0 deletions test/formatters/installers/gawk.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-get install -y gawk
1 change: 1 addition & 0 deletions test/formatters/installers/jq.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-get install -y jq
45 changes: 45 additions & 0 deletions test/formatters/samplecode/asmfmt/in.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Taken from https://files.klauspost.com/diff.html

#include "zasm_GOOS_GOARCH.h"
#include "funcdata.h"
#include "textflag.h"

TEXT runtime·rt0_go(SB),NOSPLIT,$0
// copy arguments forward on an even stack
MOVQ DI, AX // argc
MOVQ SI, BX // argv
SUBQ $(4*8+7), SP // 2args 2auto
ANDQ $~15, SP
MOVQ AX, 16(SP)
MOVQ BX, 24(SP)
// create istack out of the given (operating system) stack.
// _cgo_init may update stackguard.
MOVQ $runtime·g0(SB), DI
LEAQ (-64*1024+104)(SP), BX
MOVQ BX, g_stackguard0(DI)
MOVQ BX, g_stackguard1(DI)
MOVQ BX, (g_stack+stack_lo)(DI)
MOVQ SP, (g_stack+stack_hi)(DI)

// find out information about the processor we're on
MOVQ $0, AX
CPUID
CMPQ AX, $0
JE nocpuinfo
MOVQ $1, AX
CPUID
MOVL CX, runtime·cpuid_ecx(SB)
MOVL DX, runtime·cpuid_edx(SB)
nocpuinfo:
// if there is an _cgo_init, call it.
MOVQ _cgo_init(SB), AX
TESTQ AX, AX
JZ needtls
// g0 already in DI
MOVQ DI, CX // Win64 uses CX for first parameter
MOVQ $setg_gcc<>(SB), SI
CALL AX


46 changes: 46 additions & 0 deletions test/formatters/samplecode/asmfmt/out.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Taken from https: // files.klauspost.com/diff.html

#include "zasm_GOOS_GOARCH.h"
#include "funcdata.h"
#include "textflag.h"

TEXT runtime·rt0_go(SB), NOSPLIT, $0
// copy arguments forward on an even stack
MOVQ DI, AX // argc
MOVQ SI, BX // argv
SUBQ $(4*8+7), SP // 2args 2auto
ANDQ $~15, SP
MOVQ AX, 16(SP)
MOVQ BX, 24(SP)

// create istack out of the given (operating system) stack.
// _cgo_init may update stackguard.
MOVQ $runtime·g0(SB), DI
LEAQ (-64*1024+104)(SP), BX
MOVQ BX, g_stackguard0(DI)
MOVQ BX, g_stackguard1(DI)
MOVQ BX, (g_stack+stack_lo)(DI)
MOVQ SP, (g_stack+stack_hi)(DI)

// find out information about the processor we're on
MOVQ $0, AX
CPUID
CMPQ AX, $0
JE nocpuinfo
MOVQ $1, AX
CPUID
MOVL CX, runtime·cpuid_ecx(SB)
MOVL DX, runtime·cpuid_edx(SB)

nocpuinfo:

// if there is an _cgo_init, call it.
MOVQ _cgo_init(SB), AX
TESTQ AX, AX
JZ needtls

// g0 already in DI
MOVQ DI, CX // Win64 uses CX for first parameter
MOVQ $setg_gcc<>(SB), SI
CALL AX

26 changes: 26 additions & 0 deletions test/formatters/samplecode/gawk/in.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
BEGIN {

print "Users and thier corresponding home"

print " UserName \t HomePath"

print "___________ \t __________"

FS=":"

}

{

if ($2 == "foo") {
print $2
}
print $1 " \t " $6

}

END {

print "The end"

}
18 changes: 18 additions & 0 deletions test/formatters/samplecode/gawk/out.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BEGIN {
print "Users and thier corresponding home"
print " UserName \t HomePath"
print "___________ \t __________"
FS = ":"
}

{
if ($2 == "foo") {
print $2
}
print $1 " \t " $6
}

END {
print "The end"
}

1 change: 1 addition & 0 deletions test/formatters/samplecode/jq/in.json
19 changes: 19 additions & 0 deletions test/formatters/samplecode/jq/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}

0 comments on commit 673db87

Please sign in to comment.