Clean up the nimpretty code
This commit is contained in:
parent
7665559d0e
commit
9005a62dc2
6 changed files with 28 additions and 15 deletions
|
@ -3,19 +3,13 @@
|
||||||
|
|
||||||
call ale#Set('nim_nimpretty_executable', 'nimpretty')
|
call ale#Set('nim_nimpretty_executable', 'nimpretty')
|
||||||
call ale#Set('nim_nimpretty_options', '--maxLineLen:80')
|
call ale#Set('nim_nimpretty_options', '--maxLineLen:80')
|
||||||
call ale#Set('nim_nimpretty_use_global', get(g:, 'ale_use_global_executables', 0))
|
|
||||||
|
|
||||||
function! ale#fixers#nimpretty#GetExecutable(buffer) abort
|
|
||||||
return ale#node#FindExecutable(a:buffer, 'nim_nimpretty', ['nimpretty'])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ale#fixers#nimpretty#Fix(buffer) abort
|
function! ale#fixers#nimpretty#Fix(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable')
|
||||||
let l:options = ale#Var(a:buffer, 'nim_nimpretty_options')
|
let l:options = ale#Var(a:buffer, 'nim_nimpretty_options')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#Escape(ale#fixers#nimpretty#GetExecutable(a:buffer))
|
\ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options),
|
||||||
\ . ' %t'
|
|
||||||
\ . (empty(l:options) ? '' : ' ' . l:options),
|
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -21,5 +21,25 @@ g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources*
|
||||||
command.
|
command.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
nimpretty *ale-nim-nimpretty*
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_nim_nimpretty_executable *g:ale_nim_nimpretty_executable*
|
||||||
|
*b:ale_nim_nimpretty_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'nimpretty'`
|
||||||
|
|
||||||
|
This variable can be changed to use a different executable for nimpretty.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_nim_nimpretty_options *g:ale_nim_nimpretty_options*
|
||||||
|
*b:ale_nim_nimpretty_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'--maxLineLen:80'`
|
||||||
|
|
||||||
|
This variable can be changed to modify flags given to nimpretty.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -284,6 +284,7 @@ Notes:
|
||||||
* Nim
|
* Nim
|
||||||
* `nim check`!!
|
* `nim check`!!
|
||||||
* `nimlsp`
|
* `nimlsp`
|
||||||
|
* `nimpretty`
|
||||||
* nix
|
* nix
|
||||||
* `nix-instantiate`
|
* `nix-instantiate`
|
||||||
* `nixpkgs-fmt`
|
* `nixpkgs-fmt`
|
||||||
|
|
|
@ -2361,6 +2361,7 @@ documented in additional help files.
|
||||||
nim.....................................|ale-nim-options|
|
nim.....................................|ale-nim-options|
|
||||||
nimcheck..............................|ale-nim-nimcheck|
|
nimcheck..............................|ale-nim-nimcheck|
|
||||||
nimlsp................................|ale-nim-nimlsp|
|
nimlsp................................|ale-nim-nimlsp|
|
||||||
|
nimpretty.............................|ale-nim-nimpretty|
|
||||||
nix.....................................|ale-nix-options|
|
nix.....................................|ale-nix-options|
|
||||||
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
|
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
|
||||||
nroff...................................|ale-nroff-options|
|
nroff...................................|ale-nroff-options|
|
||||||
|
|
|
@ -293,6 +293,7 @@ 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)
|
||||||
|
* nimpretty
|
||||||
* nix
|
* nix
|
||||||
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
|
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
|
||||||
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
|
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
|
||||||
|
|
|
@ -2,15 +2,13 @@ Before:
|
||||||
call ale#assert#SetUpFixerTest('nim', 'nimpretty')
|
call ale#assert#SetUpFixerTest('nim', 'nimpretty')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
call ale#test#RestoreDirectory()
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
Execute(The nimpretty callback should return the correct default values):
|
Execute(The nimpretty callback should return the correct default values):
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\ 'command': ale#Escape(g:ale_nim_nimpretty_executable)
|
\ 'command': ale#Escape('nimpretty') . ' %t --maxLineLen:80'
|
||||||
\ . ' %t --maxLineLen:80'
|
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#nimpretty#Fix(bufnr(''))
|
\ ale#fixers#nimpretty#Fix(bufnr(''))
|
||||||
|
|
||||||
|
@ -20,8 +18,6 @@ Execute(The nimpretty callback should include any additional options):
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\ 'command': ale#Escape(g:ale_nim_nimpretty_executable)
|
\ 'command': ale#Escape('nimpretty') . ' %t --some-option'
|
||||||
\ . ' %t'
|
|
||||||
\ . ' --some-option',
|
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#nimpretty#Fix(bufnr(''))
|
\ ale#fixers#nimpretty#Fix(bufnr(''))
|
||||||
|
|
Reference in a new issue