summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorRuben Paz <me@ruben.io>2017-03-21 12:30:32 +0000
committerw0rp <w0rp@users.noreply.github.com>2017-03-21 12:30:32 +0000
commit5122dc498d4cc6a4fe17c66dcedd2d8ff04ed8c3 (patch)
tree0cb444d724d68fbbbde4dd1f82f3351abb87ba13 /ale_linters
parent51729346bfb469a03c4ddcf1cbf8c4d2588efb8c (diff)
downloadale-5122dc498d4cc6a4fe17c66dcedd2d8ff04ed8c3.zip
tslint parameterized executable and config path (#400)
* Allow modifying the location of the tsling executable * Allow definition of config file path * fnameescape configuration file
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/typescript/tslint.vim31
1 files changed, 27 insertions, 4 deletions
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index 2f4d235e..8eeb98d7 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -1,6 +1,20 @@
" Author: Prashanth Chandra https://github.com/prashcr
" Description: tslint for TypeScript files
+let g:ale_typescript_tslint_executable =
+\ get(g:, 'ale_typescript_tslint_executable', 'tslint')
+
+let g:ale_typescript_tslint_config_path =
+\ get(g:, 'ale_typescript_tslint_config_path', '')
+
+function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
+ return ale#util#ResolveLocalPath(
+ \ a:buffer,
+ \ 'node_modules/.bin/tslint',
+ \ g:ale_typescript_tslint_executable
+ \)
+endfunction
+
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
" Matches patterns like the following:
"
@@ -37,15 +51,24 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
endfunction
function! ale_linters#typescript#tslint#BuildLintCommand(buffer) abort
- let l:tsconfig_path = ale#util#FindNearestFile(a:buffer, 'tslint.json')
- let l:tslint_options = empty(l:tsconfig_path) ? '' : '-c ' . l:tsconfig_path
+ let g:ale_typescript_tslint_config_path =
+ \ empty(g:ale_typescript_tslint_config_path) ?
+ \ ale#util#FindNearestFile(a:buffer, 'tslint.json')
+ \ : g:ale_typescript_tslint_config_path
+
+ let l:tslint_options =
+ \ empty(g:ale_typescript_tslint_config_path) ?
+ \ ''
+ \ : '-c ' . fnameescape(g:ale_typescript_tslint_config_path)
- return 'tslint ' . l:tslint_options . ' %t'
+ return ale_linters#typescript#tslint#GetExecutable(a:buffer)
+ \ . ' ' . l:tslint_options
+ \ . ' %t'
endfunction
call ale#linter#Define('typescript', {
\ 'name': 'tslint',
-\ 'executable': 'tslint',
+\ 'executable_callback': 'ale_linters#typescript#tslint#GetExecutable',
\ 'command_callback': 'ale_linters#typescript#tslint#BuildLintCommand',
\ 'callback': 'ale_linters#typescript#tslint#Handle',
\})