-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add erlfmt fixer to the registry and use it with stdin (#4868)
* Add erlfmt fixer to the registry Without this, the fixer will not appear in the list of suggested tools and cannot be used without additional configuration. * Handle stdin in the erlfmt fixer command Previously, the full path to the file being edited was used, which resulted in the loss of unsaved changes. * Add executable selection tests for erlfmt fixer
- Loading branch information
1 parent
c9df465
commit 0551602
Showing
4 changed files
with
33 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
Before: | ||
Save b:ale_elm_format_executable | ||
Save b:ale_elm_format_options | ||
|
||
let b:ale_elm_format_executable = 'erlfmt' | ||
let b:ale_elm_format_options = '' | ||
call ale#assert#SetUpFixerTest('erlang', 'erlfmt') | ||
|
||
After: | ||
Restore | ||
unlet! b:root | ||
|
||
call ale#assert#TearDownFixerTest() | ||
|
||
Execute(The local erlfmt executable should be used by default): | ||
" Not sure if this is a good default though. It seems to imply | ||
" that the executable is committed to the repository. | ||
|
||
let b:root = '../test-files/erlang/app_with_erlfmt' | ||
|
||
call ale#test#SetFilename(b:root . '/src/app.erl') | ||
AssertFixer { | ||
\ 'command': ale#Escape(ale#test#GetFilename(b:root . '/erlfmt')) . ' -', | ||
\} | ||
|
||
Execute(The global erlfmt executable should be configurable): | ||
let b:root = '../test-files/erlang/app_with_erlfmt' | ||
|
||
let b:ale_erlang_erlfmt_executable = '/path/to/erlfmt' | ||
let b:ale_erlang_erlfmt_use_global = 1 | ||
|
||
call ale#test#SetFilename(b:root . '/src/app.erl') | ||
AssertFixer {'command': ale#Escape('/path/to/erlfmt') . ' -'} | ||
|
||
Execute(The erlfmt command should handle empty options): | ||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('erlfmt') . ' %s' | ||
\ }, | ||
\ ale#fixers#erlfmt#Fix(bufnr('')) | ||
AssertFixer {'command': ale#Escape('erlfmt') . ' -'} | ||
|
||
Execute(The erlfmt command should handle custom options): | ||
let b:ale_erlang_erlfmt_options = '--insert-pragma' | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('erlfmt') . ' --insert-pragma %s' | ||
\ }, | ||
\ ale#fixers#erlfmt#Fix(bufnr('')) | ||
AssertFixer {'command': ale#Escape('erlfmt') . ' --insert-pragma -'} |
Empty file.