-
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 fixer for OCaml ocp-indent (#2436)
- Loading branch information
Showing
7 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
" Author: Kanenobu Mitsuru | ||
" Description: Integration of ocp-indent with ALE. | ||
|
||
call ale#Set('ocaml_ocp_indent_executable', 'ocp-indent') | ||
call ale#Set('ocaml_ocp_indent_options', '') | ||
call ale#Set('ocaml_ocp_indent_config', '') | ||
|
||
function! ale#fixers#ocp_indent#Fix(buffer) abort | ||
let l:executable = ale#Var(a:buffer, 'ocaml_ocp_indent_executable') | ||
let l:config = ale#Var(a:buffer, 'ocaml_ocp_indent_config') | ||
let l:options = ale#Var(a:buffer, 'ocaml_ocp_indent_options') | ||
|
||
return { | ||
\ 'command': ale#Escape(l:executable) | ||
\ . (empty(l:config) ? '' : ' --config=' . ale#Escape(l:config)) | ||
\ . (empty(l:options) ? '': ' ' . l:options) | ||
\} | ||
endfunction |
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Before: | ||
Save g:ale_ocaml_ocp_indent_executable | ||
Save g:ale_ocaml_ocpindent_options | ||
|
||
" Use an invalid global executable | ||
let g:ale_ocaml_ocp_indent_executable = 'xxxinvalid' | ||
let g:ale_ocaml_ocp_indent_options = '' | ||
|
||
call ale#test#SetDirectory('/testplugin/test/fixers') | ||
|
||
After: | ||
Restore | ||
|
||
call ale#test#RestoreDirectory() | ||
|
||
Execute(The ocp_indent callback should return the correct default values): | ||
call ale#test#SetFilename('../ocaml-test-files/ocp_inden_testfile.re') | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('xxxinvalid') | ||
\ }, | ||
\ ale#fixers#ocp_indent#Fix(bufnr('')) | ||
|
||
Execute(The ocp_indent callback should include custom ocp_indent options): | ||
let g:ale_ocaml_ocp_indent_config = "base=4, type=4" | ||
call ale#test#SetFilename('../ocaml-test-files/ocp_inden_testfile.re') | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('xxxinvalid') | ||
\ . ' --config=' . ale#Escape(g:ale_ocaml_ocp_indent_config) | ||
\ }, | ||
\ ale#fixers#ocp_indent#Fix(bufnr('')) |