-
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: support for
nickel format
as Nickel
fixer
Nickel(https://nickel-lang.org/) is a configuration language, like Jsonnet, Cue, Dhall. `nickel`(https://github.com/tweag/nickel) is the main command to run, export and also format Nickel code. this commit adds `nickel format` as a Nickel fixer, together with some tests and documentation.
- Loading branch information
Showing
7 changed files
with
80 additions
and
1 deletion.
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,16 @@ | ||
" Author: Yining <[email protected]> | ||
" Description: nickel format as ALE fixer for Nickel files | ||
|
||
call ale#Set('nickel_nickel_format_executable', 'nickel') | ||
call ale#Set('nickel_nickel_format_options', '') | ||
|
||
function! ale#fixers#nickel_format#Fix(buffer) abort | ||
let l:executable = ale#Var(a:buffer, 'nickel_nickel_format_executable') | ||
let l:options = ale#Var(a:buffer, 'nickel_nickel_format_options') | ||
|
||
return { | ||
\ 'command': ale#Escape(l:executable) . ' format' | ||
\ . (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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=============================================================================== | ||
ALE Nickel Integration *ale-nickel-options* | ||
|
||
|
||
=============================================================================== | ||
nickel_format *ale-nickel-nickel-format* | ||
|
||
g:ale_nickel_nickel_format_executable *g:ale_nickel_nickel_format_executable* | ||
*b:ale_nickel_nickel_format_executable* | ||
Type: |String| | ||
Default: `'nickel'` | ||
|
||
This option can be changed to change the path for `nickel`. | ||
|
||
|
||
g:ale_nickel_nickel_format_options *g:ale_nickel_nickel_format_options* | ||
*b:ale_nickel_nickel_format_options* | ||
Type: |String| | ||
Default: `''` | ||
|
||
This option can be changed to pass extra options to `'nickel format'` | ||
|
||
|
||
=============================================================================== | ||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: |
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 |
---|---|---|
|
@@ -381,6 +381,8 @@ Notes: | |
* `mmc`!! | ||
* NASM | ||
* `nasm`!! | ||
* Nickel | ||
* `nickel_format` | ||
* Nim | ||
* `nim check`!! | ||
* `nimlsp` | ||
|
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,27 @@ | ||
Before: | ||
Save g:ale_nickel_nickel_format_executable | ||
Save g:ale_nickel_nickel_format_options | ||
Save &l:expandtab | ||
Save &l:shiftwidth | ||
Save &l:tabstop | ||
|
||
After: | ||
Restore | ||
|
||
Execute(The nickel_format callback should return 'nickel format' as default command): | ||
setlocal noexpandtab | ||
Assert | ||
\ ale#fixers#nickel_format#Fix(bufnr('')).command =~# '^' . ale#Escape('nickel') . ' format', | ||
\ "Default command name is expected to be 'nickel format'" | ||
|
||
Execute(The nickel executable and options should be configurable): | ||
let g:ale_nickel_nickel_format_executable = 'foobar' | ||
let g:ale_nickel_nickel_format_options = '--some-option' | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('foobar') | ||
\ . ' format' | ||
\ . ' --some-option', | ||
\ }, | ||
\ ale#fixers#nickel_format#Fix(bufnr('')) |