diff options
Diffstat (limited to 'autoload/prettier.vim')
| -rw-r--r-- | autoload/prettier.vim | 75 |
1 files changed, 1 insertions, 74 deletions
diff --git a/autoload/prettier.vim b/autoload/prettier.vim index d7c4338..c1aa35b 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -44,7 +44,7 @@ function! prettier#Prettier(...) abort let l:config = getbufvar(bufnr('%'), 'prettier_ft_default_args', {}) if l:execCmd != -1 - let l:cmd = l:execCmd . s:Get_Prettier_Exec_Args(l:config) + let l:cmd = l:execCmd . prettier#resolver#config#buildCliArgs(l:config) " close quickfix if it is opened if s:prettier_quickfix_open @@ -259,79 +259,6 @@ function! s:Apply_Prettier_Format(lines, startSelection, endSelection) abort call winrestview(l:winview) endfunction -" Returns either '--use-tabs' or an empty string. -function! s:Flag_use_tabs(config) abort - let l:value = get(a:config, 'useTabs', g:prettier#config#use_tabs) - if (l:value ==# 'auto') - let l:value = &expandtab ? 'false' : 'true' - endif - - if ( l:value ==# 'true' ) - return '--use-tabs' - else - return '' - endif -endfunction - -" Returns '--tab-width=NN' -function! s:Flag_tab_width(config) abort - let l:value = get(a:config, 'tabWidth', g:prettier#config#tab_width) - - if (l:value ==# 'auto') - let l:value = prettier#utils#shim#shiftwidth() - endif - - return '--tab-width=' . l:value -endfunction - -" Returns '--print-width=NN' or '' -function! s:Flag_print_width(config) abort - let l:value = get(a:config, 'printWidth', g:prettier#config#print_width) - - if (l:value ==# 'auto') - let l:value = &textwidth - endif - - if (l:value > 0) - return '--print-width=' . l:value - else - return '' - endif -endfunction - -" Returns '--parser=PARSER' or '' -function! s:Flag_parser(config) abort - let l:value = get(a:config, 'parser', g:prettier#config#parser) - - if (l:value !=# '') - return '--parser=' . l:value - else - return '' - endif -endfunction - -" By default we will default to our internal -" configuration settings for prettier -function! s:Get_Prettier_Exec_Args(config) abort - " Allow params to be passed as json format - " convert bellow usage of globals to a get function o the params defaulting to global - " TODO: Use a list, filter() and join() to get a nicer list of args. - let l:cmd = s:Flag_use_tabs(a:config) . ' ' . - \ s:Flag_tab_width(a:config) . ' ' . - \ s:Flag_print_width(a:config) . ' ' . - \ s:Flag_parser(a:config) . ' ' . - \ ' --config-precedence=' . - \ get(a:config, 'configPrecedence', g:prettier#config#config_precedence) . - \ ' --prose-wrap=' . - \ get(a:config, 'proseWrap', g:prettier#config#prose_wrap) . - \ ' --stdin-filepath=' . - \ simplify(expand('%:p')) . - \ ' --no-editorconfig '. - \ ' --loglevel error '. - \ ' --stdin ' - return l:cmd -endfunction - function! s:Prettier_Parse_Error(errors) abort call prettier#logging#error#log('PARSING_ERROR') if g:prettier#quickfix_enabled && prettier#bridge#parser#onError(a:errors) |
