fix: renamed command builder function, remove disable flag
moved Win32 check inside command builder
This commit is contained in:
parent
9e645c483d
commit
db4a01e197
@ -162,10 +162,6 @@ Here is a list of formatprograms that are supported by default, and thus will be
|
|||||||
It can be installed by running `npm install eslint`. The linter is then installed locally at ```node_modules/.bin/eslint```
|
It can be installed by running `npm install eslint`. The linter is then installed locally at ```node_modules/.bin/eslint```
|
||||||
When running formatter vim will walk up from the current file to search for such local installation and a
|
When running formatter vim will walk up from the current file to search for such local installation and a
|
||||||
ESLint configuration file (either .eslintrc or eslintrc.json). When both are found eslint is executed with the --fix argument.
|
ESLint configuration file (either .eslintrc or eslintrc.json). When both are found eslint is executed with the --fix argument.
|
||||||
This linter can be disabled using global setting
|
|
||||||
```vim
|
|
||||||
let g:formatters_javascript_eslint_local = 0
|
|
||||||
```
|
|
||||||
Currently only working on *nix like OS (Linux, MacOS etc.) requires OS to provide sh like shell syntax
|
Currently only working on *nix like OS (Linux, MacOS etc.) requires OS to provide sh like shell syntax
|
||||||
|
|
||||||
* `xo` for __Javascript__.
|
* `xo` for __Javascript__.
|
||||||
|
@ -163,15 +163,12 @@ endif
|
|||||||
" Setup ESLint local. Setup is done on formatter execution if ESLint and
|
" Setup ESLint local. Setup is done on formatter execution if ESLint and
|
||||||
" corresponding config is found they are used, otherwiese the formatter fails.
|
" corresponding config is found they are used, otherwiese the formatter fails.
|
||||||
" No windows support at the moment.
|
" No windows support at the moment.
|
||||||
if !exists('g:formatdef_eslint_local') && !has('win32')
|
if !exists('g:formatdef_eslint_local')
|
||||||
" set disable flag when not defined already
|
function! g:BuildESLintLocalCmd()
|
||||||
let g:formatters_javascript_eslint_local = exists('g:formatters_javascript_eslint_local') ? g:formatters_javascript_eslint_local : 1
|
|
||||||
|
|
||||||
function! g:SetupESLintLocalCmd()
|
|
||||||
let l:path = fnamemodify(expand('%'), ':p')
|
let l:path = fnamemodify(expand('%'), ':p')
|
||||||
let verbose = &verbose || g:autoformat_verbosemode == 1
|
let verbose = &verbose || g:autoformat_verbosemode == 1
|
||||||
if g:formatters_javascript_eslint_local == 0
|
if has('win32')
|
||||||
return "(>&2 echo 'ESLint local is disbaled')"
|
return "(>&2 echo 'ESLint Local not supported on win32')"
|
||||||
endif
|
endif
|
||||||
" find formatter & config file
|
" find formatter & config file
|
||||||
let l:prog = findfile('node_modules/.bin/eslint', l:path.";")
|
let l:prog = findfile('node_modules/.bin/eslint', l:path.";")
|
||||||
@ -193,7 +190,7 @@ if !exists('g:formatdef_eslint_local') && !has('win32')
|
|||||||
\ .l:prog." -c ".l:cfg." --fix ".l:eslint_js_tmp_file." 1> /dev/null; exit_code=$?
|
\ .l:prog." -c ".l:cfg." --fix ".l:eslint_js_tmp_file." 1> /dev/null; exit_code=$?
|
||||||
\ cat ".l:eslint_js_tmp_file."; rm -f ".l:eslint_js_tmp_file."; exit $exit_code"
|
\ cat ".l:eslint_js_tmp_file."; rm -f ".l:eslint_js_tmp_file."; exit $exit_code"
|
||||||
endfunction
|
endfunction
|
||||||
let g:formatdef_eslint_local = "g:SetupESLintLocalCmd()"
|
let g:formatdef_eslint_local = "g:BuildESLintLocalCmd()"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('g:formatters_javascript')
|
if !exists('g:formatters_javascript')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user