mirror of
https://github.com/dense-analysis/ale
synced 2024-12-26 16:12:40 +00:00
add nimpretty fixer
This commit is contained in:
parent
db6b1b5ecc
commit
abad8e474b
@ -54,6 +54,11 @@ let s:default_registry = {
|
||||
\ 'description': 'Apply elm-format to a file.',
|
||||
\ 'aliases': ['format'],
|
||||
\ },
|
||||
\ 'nimpretty': {
|
||||
\ 'function': 'ale#fixers#nimpretty#Fix',
|
||||
\ 'suggested_filetypes': ['nim'],
|
||||
\ 'description': 'Apply nimpretty to a file.',
|
||||
\ },
|
||||
\ 'eslint': {
|
||||
\ 'function': 'ale#fixers#eslint#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
||||
|
21
autoload/ale/fixers/nimpretty.vim
Normal file
21
autoload/ale/fixers/nimpretty.vim
Normal file
@ -0,0 +1,21 @@
|
||||
" Author: Nhan <hi@imnhan.com>
|
||||
" Description: Integration of nimpretty with ALE.
|
||||
|
||||
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:options = ale#Var(a:buffer, 'nim_nimpretty_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(ale#fixers#nimpretty#GetExecutable(a:buffer))
|
||||
\ . ' %t'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
27
test/fixers/test_nimpretty_fixer_callback.vader
Normal file
27
test/fixers/test_nimpretty_fixer_callback.vader
Normal file
@ -0,0 +1,27 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('nim', 'nimpretty')
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
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'
|
||||
\ },
|
||||
\ ale#fixers#nimpretty#Fix(bufnr(''))
|
||||
|
||||
Execute(The nimpretty callback should include any additional options):
|
||||
let g:ale_nim_nimpretty_options = '--some-option'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(g:ale_nim_nimpretty_executable)
|
||||
\ . ' %t'
|
||||
\ . ' --some-option',
|
||||
\ },
|
||||
\ ale#fixers#nimpretty#Fix(bufnr(''))
|
Loading…
Reference in New Issue
Block a user