Support 'gleam format' as Gleam fixer (#4710)

This commit is contained in:
Jonathan Palardy 2024-02-05 17:16:25 -08:00 committed by GitHub
parent 8922478a83
commit 1b24bd3f5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 65 additions and 3 deletions

View File

@ -291,6 +291,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['solidity'], \ 'suggested_filetypes': ['solidity'],
\ 'description': 'Fix Solidity files with forge fmt.', \ 'description': 'Fix Solidity files with forge fmt.',
\ }, \ },
\ 'gleam_format': {
\ 'function': 'ale#fixers#gleam_format#Fix',
\ 'suggested_filetypes': ['gleam'],
\ 'description': 'Fix Gleam files with gleam format.',
\ },
\ 'gofmt': { \ 'gofmt': {
\ 'function': 'ale#fixers#gofmt#Fix', \ 'function': 'ale#fixers#gofmt#Fix',
\ 'suggested_filetypes': ['go'], \ 'suggested_filetypes': ['go'],

View File

@ -0,0 +1,19 @@
" Author: Jonathan Palardt https://github.com/jpalardy
" Description: Integration of 'gleam format' with ALE.
call ale#Set('gleam_format_executable', 'gleam')
function! ale#fixers#gleam_format#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'gleam_format_executable')
return ale#Escape(l:executable)
endfunction
function! ale#fixers#gleam_format#Fix(buffer) abort
let l:executable = ale#fixers#gleam_format#GetExecutable(a:buffer)
return {
\ 'command': l:executable . ' format %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -2,10 +2,17 @@
ALE Gleam Integration *ale-gleam-options* ALE Gleam Integration *ale-gleam-options*
*ale-integration-gleam* *ale-integration-gleam*
===============================================================================
Integration Information
Currently, the only supported linter for gleam is gleamlsp. ===============================================================================
gleam_format *ale-gleam-gleam_format*
g:ale_gleam_gleam_format_executable *g:ale_gleam_gleam_format_executable*
*b:ale_gleam_gleam_format_executable*
Type: |String|
Default: `'gleam'`
This variable can be modified to change the executable path for
`gleam format`.
=============================================================================== ===============================================================================

View File

@ -203,6 +203,7 @@ Notes:
* Git Commit Messages * Git Commit Messages
* `gitlint` * `gitlint`
* Gleam * Gleam
* `gleam_format`
* `gleamlsp` * `gleamlsp`
* GLSL * GLSL
* `glslang` * `glslang`

View File

@ -3032,6 +3032,7 @@ documented in additional help files.
git commit..............................|ale-gitcommit-options| git commit..............................|ale-gitcommit-options|
gitlint...............................|ale-gitcommit-gitlint| gitlint...............................|ale-gitcommit-gitlint|
gleam...................................|ale-gleam-options| gleam...................................|ale-gleam-options|
gleam_format..........................|ale-gleam-gleam_format|
gleamlsp..............................|ale-gleam-gleamlsp| gleamlsp..............................|ale-gleam-gleamlsp|
glsl....................................|ale-glsl-options| glsl....................................|ale-glsl-options|
glslang...............................|ale-glsl-glslang| glslang...............................|ale-glsl-glslang|

View File

@ -212,6 +212,7 @@ formatting.
* Git Commit Messages * Git Commit Messages
* [gitlint](https://github.com/jorisroovers/gitlint) * [gitlint](https://github.com/jorisroovers/gitlint)
* Gleam * Gleam
* [gleam_format](https://github.com/gleam-lang/gleam)
* [gleamlsp](https://github.com/gleam-lang/gleam) * [gleamlsp](https://github.com/gleam-lang/gleam)
* GLSL * GLSL
* [glslang](https://github.com/KhronosGroup/glslang) * [glslang](https://github.com/KhronosGroup/glslang)

View File

@ -0,0 +1,28 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The gleam_format command should have default values):
call ale#test#SetFilename('../test-files/elixir/testfile.gleam')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('gleam') . ' format %t',
\ },
\ ale#fixers#gleam_format#Fix(bufnr(''))
Execute(The gleam_format executable should be configurable):
let g:ale_gleam_format_executable = 'xxxinvalid'
call ale#test#SetFilename('../test-files/elixir/testfile.gleam')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid') . ' format %t',
\ },
\ ale#fixers#gleam_format#Fix(bufnr(''))

View File