summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-11-14 14:50:16 +0000
committerw0rp <devw0rp@gmail.com>2019-11-14 14:50:21 +0000
commit9005a62dc2080327a0f2164d765f837e90e963dc (patch)
tree21b3704d4987e50a2e43958ff53a79e05cf8b4f3
parent7665559d0e6102c9eccf39a119afd9c7a1a0af82 (diff)
downloadale-9005a62dc2080327a0f2164d765f837e90e963dc.zip
Clean up the nimpretty code
-rw-r--r--autoload/ale/fixers/nimpretty.vim10
-rw-r--r--doc/ale-nim.txt20
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/fixers/test_nimpretty_fixer_callback.vader10
6 files changed, 28 insertions, 15 deletions
diff --git a/autoload/ale/fixers/nimpretty.vim b/autoload/ale/fixers/nimpretty.vim
index be6df470..fe2e7136 100644
--- a/autoload/ale/fixers/nimpretty.vim
+++ b/autoload/ale/fixers/nimpretty.vim
@@ -3,19 +3,13 @@
call ale#Set('nim_nimpretty_executable', 'nimpretty')
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
+ let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable')
let l:options = ale#Var(a:buffer, 'nim_nimpretty_options')
return {
- \ 'command': ale#Escape(ale#fixers#nimpretty#GetExecutable(a:buffer))
- \ . ' %t'
- \ . (empty(l:options) ? '' : ' ' . l:options),
+ \ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options),
\ 'read_temporary_file': 1,
\}
endfunction
diff --git a/doc/ale-nim.txt b/doc/ale-nim.txt
index ad7aa686..8985aeb8 100644
--- a/doc/ale-nim.txt
+++ b/doc/ale-nim.txt
@@ -22,4 +22,24 @@ g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources*
===============================================================================
+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:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index de1be1a2..29dabab7 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -284,6 +284,7 @@ Notes:
* Nim
* `nim check`!!
* `nimlsp`
+ * `nimpretty`
* nix
* `nix-instantiate`
* `nixpkgs-fmt`
diff --git a/doc/ale.txt b/doc/ale.txt
index 515c5f2c..593aae11 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2361,6 +2361,7 @@ documented in additional help files.
nim.....................................|ale-nim-options|
nimcheck..............................|ale-nim-nimcheck|
nimlsp................................|ale-nim-nimlsp|
+ nimpretty.............................|ale-nim-nimpretty|
nix.....................................|ale-nix-options|
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
nroff...................................|ale-nroff-options|
diff --git a/supported-tools.md b/supported-tools.md
index 5a3376d4..0abc6b75 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -293,6 +293,7 @@ formatting.
* Nim
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
* [nimlsp](https://github.com/PMunch/nimlsp)
+ * nimpretty
* nix
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
diff --git a/test/fixers/test_nimpretty_fixer_callback.vader b/test/fixers/test_nimpretty_fixer_callback.vader
index b05139f0..a26f649a 100644
--- a/test/fixers/test_nimpretty_fixer_callback.vader
+++ b/test/fixers/test_nimpretty_fixer_callback.vader
@@ -2,15 +2,13 @@ Before:
call ale#assert#SetUpFixerTest('nim', 'nimpretty')
After:
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownFixerTest()
Execute(The nimpretty callback should return the correct default values):
-
AssertEqual
\ {
\ 'read_temporary_file': 1,
- \ 'command': ale#Escape(g:ale_nim_nimpretty_executable)
- \ . ' %t --maxLineLen:80'
+ \ 'command': ale#Escape('nimpretty') . ' %t --maxLineLen:80'
\ },
\ ale#fixers#nimpretty#Fix(bufnr(''))
@@ -20,8 +18,6 @@ Execute(The nimpretty callback should include any additional options):
AssertEqual
\ {
\ 'read_temporary_file': 1,
- \ 'command': ale#Escape(g:ale_nim_nimpretty_executable)
- \ . ' %t'
- \ . ' --some-option',
+ \ 'command': ale#Escape('nimpretty') . ' %t --some-option'
\ },
\ ale#fixers#nimpretty#Fix(bufnr(''))