diff options
| author | Mitermayer Reis <mitermayer.reis@gmail.com> | 2017-06-06 12:27:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-06 12:27:50 -0700 |
| commit | c28004d9c616a3599e8d0622c87fa071aa2342e8 (patch) | |
| tree | fb0924bf23922badf6f025b1e645189a75977d1c /autoload/prettier.vim | |
| parent | b394b4c23622fe3aae78333d7830bc5dabf11e50 (diff) | |
| parent | a3df2e771010f9c70e74fadda32dd81a28b88f4f (diff) | |
| download | vim-prettier-0.0.5.tar.xz | |
Merge pull request #11 from mitermayer/feature/adding-support-for-new-parsers-bump-prettier0.0.5
Bumping support to latest prettier ^1.4.X, enabling support for css,scss,less,typescript formatting and allowing user configuration to enable async as the default for configuration for `:Prettier` command
Diffstat (limited to 'autoload/prettier.vim')
| -rw-r--r-- | autoload/prettier.vim | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/autoload/prettier.vim b/autoload/prettier.vim index 249ffb1..66166f4 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -3,13 +3,10 @@ let s:root_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h') function! prettier#Prettier(...) abort let l:execCmd = s:Get_Prettier_Exec() let l:async = a:0 > 0 ? a:1 : 0 - - if &ft !~ 'javascript' - return - endif + let l:config = getbufvar(bufnr('%'), 'prettier_ft_default_args', {}) if l:execCmd != -1 - let l:cmd = l:execCmd . s:Get_Prettier_Exec_Args() + let l:cmd = l:execCmd . s:Get_Prettier_Exec_Args(l:config) " close quickfix call setqflist([]) @@ -124,25 +121,27 @@ endfunction " By default we will default to our internal " configuration settings for prettier -function! s:Get_Prettier_Exec_Args() abort +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 let l:cmd = ' --print-width ' . - \ g:prettier#config#print_width . + \ get(a:config, 'printWidth', g:prettier#config#print_width) . \ ' --tab-width ' . - \ g:prettier#config#tab_width . + \ get(a:config, 'tabWidth', g:prettier#config#tab_width) . \ ' --use-tabs ' . - \ g:prettier#config#use_tabs . + \ get(a:config, 'useTabs', g:prettier#config#use_tabs) . \ ' --semi ' . - \ g:prettier#config#semi . + \ get(a:config, 'semi', g:prettier#config#semi) . \ ' --single-quote ' . - \ g:prettier#config#single_quote . + \ get(a:config, 'singleQuote', g:prettier#config#single_quote) . \ ' --bracket-spacing ' . - \ g:prettier#config#bracket_spacing . + \ get(a:config, 'bracketSpacing', g:prettier#config#bracket_spacing) . \ ' --jsx-bracket-same-line ' . - \ g:prettier#config#jsx_bracket_same_line . + \ get(a:config, 'jsxBracketSameLine', g:prettier#config#jsx_bracket_same_line) . \ ' --trailing-comma ' . - \ g:prettier#config#trailing_comma . + \ get(a:config, 'trailingComma', g:prettier#config#trailing_comma) . \ ' --parser ' . - \ g:prettier#config#parser . + \ get(a:config, 'parser', g:prettier#config#parser) . \ ' --stdin ' return cmd endfunction |
