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:
Henrique Barcelos
2023-09-05 19:34:39 +02:00
committed by GitHub
parent 59e455b4d8
commit 64ddf457e1
7 changed files with 43 additions and 0 deletions

View File

@@ -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'],

View 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