mirror of https://github.com/dense-analysis/ale
add: support for `nickel format` as `Nickel` fixer (#4665)
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.
This commit is contained in:
parent
fc45a935bf
commit
32ee7039d0
|
@ -635,7 +635,12 @@ let s:default_registry = {
|
||||||
\ 'function': 'ale#fixers#erbformatter#Fix',
|
\ 'function': 'ale#fixers#erbformatter#Fix',
|
||||||
\ 'suggested_filetypes': ['eruby'],
|
\ 'suggested_filetypes': ['eruby'],
|
||||||
\ 'description': 'Apply erb-formatter -w to eruby/erb files.',
|
\ 'description': 'Apply erb-formatter -w to eruby/erb files.',
|
||||||
\ }
|
\ },
|
||||||
|
\ 'nickel_format': {
|
||||||
|
\ 'function': 'ale#fixers#nickel_format#Fix',
|
||||||
|
\ 'suggested_filetypes': ['nickel'],
|
||||||
|
\ 'description': 'Fix nickel files with nickel format',
|
||||||
|
\ },
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Reset the function registry to the default entries.
|
" Reset the function registry to the default entries.
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
" Author: Yining <zhang.yining@gmail.com>
|
||||||
|
" 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
|
||||||
|
|
|
@ -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:
|
|
@ -382,6 +382,8 @@ Notes:
|
||||||
* `mmc`!!
|
* `mmc`!!
|
||||||
* NASM
|
* NASM
|
||||||
* `nasm`!!
|
* `nasm`!!
|
||||||
|
* Nickel
|
||||||
|
* `nickel_format`
|
||||||
* Nim
|
* Nim
|
||||||
* `nim check`!!
|
* `nim check`!!
|
||||||
* `nimlsp`
|
* `nimlsp`
|
||||||
|
|
|
@ -3188,6 +3188,8 @@ documented in additional help files.
|
||||||
mmc...................................|ale-mercury-mmc|
|
mmc...................................|ale-mercury-mmc|
|
||||||
nasm....................................|ale-nasm-options|
|
nasm....................................|ale-nasm-options|
|
||||||
nasm..................................|ale-nasm-nasm|
|
nasm..................................|ale-nasm-nasm|
|
||||||
|
nickel..................................|ale-nickel-options|
|
||||||
|
nickel_format.........................|ale-nickel-nickel-format|
|
||||||
nim.....................................|ale-nim-options|
|
nim.....................................|ale-nim-options|
|
||||||
nimcheck..............................|ale-nim-nimcheck|
|
nimcheck..............................|ale-nim-nimcheck|
|
||||||
nimlsp................................|ale-nim-nimlsp|
|
nimlsp................................|ale-nim-nimlsp|
|
||||||
|
|
|
@ -391,6 +391,8 @@ formatting.
|
||||||
* [mmc](http://mercurylang.org) :floppy_disk:
|
* [mmc](http://mercurylang.org) :floppy_disk:
|
||||||
* NASM
|
* NASM
|
||||||
* [nasm](https://www.nasm.us/) :floppy_disk:
|
* [nasm](https://www.nasm.us/) :floppy_disk:
|
||||||
|
* Nickel
|
||||||
|
* [nickel_format](https://github.com/tweag/nickel#formatting)
|
||||||
* Nim
|
* Nim
|
||||||
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
|
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
|
||||||
* [nimlsp](https://github.com/PMunch/nimlsp)
|
* [nimlsp](https://github.com/PMunch/nimlsp)
|
||||||
|
|
|
@ -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(''))
|
Loading…
Reference in New Issue