mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 13:14:29 +08:00
Feature: add forge fmt as a fixer for Solidity files (#4598)
* feat: add `forge fmt` as a fixer for Solidity
This commit is contained in:
committed by
GitHub
parent
59e455b4d8
commit
64ddf457e1
@@ -286,6 +286,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['fish'],
|
\ 'suggested_filetypes': ['fish'],
|
||||||
\ 'description': 'Format fish scripts using fish_indent.',
|
\ 'description': 'Format fish scripts using fish_indent.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'forge': {
|
||||||
|
\ 'function': 'ale#fixers#forge#Fix',
|
||||||
|
\ 'suggested_filetypes': ['solidity'],
|
||||||
|
\ 'description': 'Fix Solidity files with forge fmt.',
|
||||||
|
\ },
|
||||||
\ 'gofmt': {
|
\ 'gofmt': {
|
||||||
\ 'function': 'ale#fixers#gofmt#Fix',
|
\ 'function': 'ale#fixers#gofmt#Fix',
|
||||||
\ 'suggested_filetypes': ['go'],
|
\ 'suggested_filetypes': ['go'],
|
||||||
|
|||||||
11
autoload/ale/fixers/forge.vim
Normal file
11
autoload/ale/fixers/forge.vim
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
call ale#Set('solidity_forge_executable', 'forge')
|
||||||
|
|
||||||
|
function! ale#fixers#forge#Fix(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'solidity_forge_executable')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . ' fmt %t',
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\}
|
||||||
|
endfunction
|
||||||
@@ -36,6 +36,15 @@ solium *ale-solidity-solium*
|
|||||||
See the corresponding solium usage for detailed instructions
|
See the corresponding solium usage for detailed instructions
|
||||||
(https://github.com/duaraghav8/Solium#usage).
|
(https://github.com/duaraghav8/Solium#usage).
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
forge *ale-solidity-forge*
|
||||||
|
|
||||||
|
`forge fmt` is not a linter, only a formatter. It should be used only as a
|
||||||
|
fixer.
|
||||||
|
|
||||||
|
`forge fmt` should work out-of-the-box. You can further configure it using
|
||||||
|
`foundry.toml`. See the corresponding documentation for detailed
|
||||||
|
instructions (https://book.getfoundry.sh/reference/config/formatter).
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|||||||
@@ -586,6 +586,7 @@ Notes:
|
|||||||
* SML
|
* SML
|
||||||
* `smlnj`
|
* `smlnj`
|
||||||
* Solidity
|
* Solidity
|
||||||
|
* `forge`
|
||||||
* `solc`
|
* `solc`
|
||||||
* `solhint`
|
* `solhint`
|
||||||
* `solium`
|
* `solium`
|
||||||
|
|||||||
@@ -3326,6 +3326,7 @@ documented in additional help files.
|
|||||||
solc..................................|ale-solidity-solc|
|
solc..................................|ale-solidity-solc|
|
||||||
solhint...............................|ale-solidity-solhint|
|
solhint...............................|ale-solidity-solhint|
|
||||||
solium................................|ale-solidity-solium|
|
solium................................|ale-solidity-solium|
|
||||||
|
forge.................................|ale-solidity-forge|
|
||||||
spec....................................|ale-spec-options|
|
spec....................................|ale-spec-options|
|
||||||
rpmlint...............................|ale-spec-rpmlint|
|
rpmlint...............................|ale-spec-rpmlint|
|
||||||
sql.....................................|ale-sql-options|
|
sql.....................................|ale-sql-options|
|
||||||
|
|||||||
@@ -595,6 +595,7 @@ formatting.
|
|||||||
* SML
|
* SML
|
||||||
* [smlnj](http://www.smlnj.org/)
|
* [smlnj](http://www.smlnj.org/)
|
||||||
* Solidity
|
* Solidity
|
||||||
|
* [forge](https://github.com/foundry-rs/forge)
|
||||||
* [solc](https://solidity.readthedocs.io/)
|
* [solc](https://solidity.readthedocs.io/)
|
||||||
* [solhint](https://github.com/protofire/solhint)
|
* [solhint](https://github.com/protofire/solhint)
|
||||||
* [solium](https://github.com/duaraghav8/Solium)
|
* [solium](https://github.com/duaraghav8/Solium)
|
||||||
|
|||||||
15
test/fixers/test_forge_fixer_callback.vader
Normal file
15
test/fixers/test_forge_fixer_callback.vader
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Before:
|
||||||
|
Save g:ale_solidity_forge_executable
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
Execute(The forge fmt callback should return the correct default values):
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('forge')
|
||||||
|
\ . ' fmt %t',
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#forge#Fix(bufnr(''))
|
||||||
|
|
||||||
Reference in New Issue
Block a user