mirror of https://github.com/dense-analysis/ale
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:
parent
59e455b4d8
commit
64ddf457e1
|
@ -286,6 +286,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['fish'],
|
||||
\ 'description': 'Format fish scripts using fish_indent.',
|
||||
\ },
|
||||
\ 'forge': {
|
||||
\ 'function': 'ale#fixers#forge#Fix',
|
||||
\ 'suggested_filetypes': ['solidity'],
|
||||
\ 'description': 'Fix Solidity files with forge fmt.',
|
||||
\ },
|
||||
\ 'gofmt': {
|
||||
\ 'function': 'ale#fixers#gofmt#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
|
|
|
@ -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
|
||||
(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:
|
||||
|
|
|
@ -586,6 +586,7 @@ Notes:
|
|||
* SML
|
||||
* `smlnj`
|
||||
* Solidity
|
||||
* `forge`
|
||||
* `solc`
|
||||
* `solhint`
|
||||
* `solium`
|
||||
|
|
|
@ -3326,6 +3326,7 @@ documented in additional help files.
|
|||
solc..................................|ale-solidity-solc|
|
||||
solhint...............................|ale-solidity-solhint|
|
||||
solium................................|ale-solidity-solium|
|
||||
forge.................................|ale-solidity-forge|
|
||||
spec....................................|ale-spec-options|
|
||||
rpmlint...............................|ale-spec-rpmlint|
|
||||
sql.....................................|ale-sql-options|
|
||||
|
|
|
@ -595,6 +595,7 @@ formatting.
|
|||
* SML
|
||||
* [smlnj](http://www.smlnj.org/)
|
||||
* Solidity
|
||||
* [forge](https://github.com/foundry-rs/forge)
|
||||
* [solc](https://solidity.readthedocs.io/)
|
||||
* [solhint](https://github.com/protofire/solhint)
|
||||
* [solium](https://github.com/duaraghav8/Solium)
|
||||
|
|
|
@ -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(''))
|
||||
|
Loading…
Reference in New Issue