From b16bb29156bd5c50c8565a4512abe21e49097684 Mon Sep 17 00:00:00 2001 From: James Vaughan Date: Mon, 13 Apr 2020 22:44:35 -0700 Subject: Autoformat .rb files --- ftplugin/ruby.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index f93997d..53d13cf 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -4,5 +4,5 @@ let b:prettier_ft_default_args = { augroup Prettier autocmd! - autocmd BufWritePre *.ruby call prettier#Autoformat() + autocmd BufWritePre *.rb,*.ruby call prettier#Autoformat() augroup end -- cgit v1.3 From b351226a0ea4aded1755284b189d1cd608e810bc Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Wed, 6 May 2020 17:45:14 -0500 Subject: Fix string concatenation typo --- plugin/prettier.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/prettier.vim b/plugin/prettier.vim index f7818dc..595f50d 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -33,7 +33,7 @@ let g:prettier#autoformat_config_files = get(g:, 'prettier#autoformat_config_fil \'.prettierrc.yaml', \'.prettierrc.js', \'.prettierrc.config.js', - \'.prettierrc.json' + \'.prettierrc.json', \'.prettierrc.toml']) " path to prettier cli -- cgit v1.3 From 27fadfd62040fa90b86c23dbc1736a335374a7c7 Mon Sep 17 00:00:00 2001 From: Marco Comes Date: Sun, 24 May 2020 17:58:14 +0200 Subject: Add missing ".yml" in autocmd --- ftplugin/yaml.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/yaml.vim b/ftplugin/yaml.vim index 2d0564d..60f669b 100644 --- a/ftplugin/yaml.vim +++ b/ftplugin/yaml.vim @@ -4,5 +4,5 @@ let b:prettier_ft_default_args = { augroup Prettier autocmd! - autocmd BufWritePre *.yaml call prettier#Autoformat() + autocmd BufWritePre *.yml,*.yaml call prettier#Autoformat() augroup end -- cgit v1.3 From 29449e7a155b858085ddfe3cab1f770464a68cdf Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Thu, 16 Jul 2020 10:27:12 +0200 Subject: Fix error when quitting Neovim with :wq This fixes #215 by implementing the fix I've suggested in [my comment][0]. After [the suggestion to open a PR][1], here we are :) [0]: https://github.com/prettier/vim-prettier/issues/215#issuecomment-629681399 [1]: https://github.com/prettier/vim-prettier/issues/215#issuecomment-648657236 --- autoload/prettier/job/async/neovim.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/prettier/job/async/neovim.vim b/autoload/prettier/job/async/neovim.vim index 7f69f4e..35e5f82 100644 --- a/autoload/prettier/job/async/neovim.vim +++ b/autoload/prettier/job/async/neovim.vim @@ -42,6 +42,8 @@ endfunction " " note that somehow we exectuing both async and sync on nvim when using the autoformat function! s:onExit(status, info, out, err) abort + if len(a:out) == 0 | return | endif + let l:currentBufferNumber = bufnr('%') let l:isInsideAnotherBuffer = a:info.buf_nr != l:currentBufferNumber ? 1 : 0 let l:last = a:out[len(a:out) - 1] -- cgit v1.3 From ef2977397babd7d6c204124e885b467f07b54381 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Jul 2020 11:32:21 +0000 Subject: Bump lodash from 4.17.15 to 4.17.19 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1bf61f4..6b0974a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2131,9 +2131,9 @@ lodash.sortby@^4.7.0: integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== loose-envify@^1.0.0: version "1.4.0" -- cgit v1.3 From 184f6232605a1296d0d1d48b5608efeeadafde24 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2020 07:37:08 +0000 Subject: Bump acorn from 5.7.3 to 5.7.4 Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4. - [Release notes](https://github.com/acornjs/acorn/releases) - [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6b0974a..65dd6e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -75,9 +75,9 @@ acorn-walk@^6.0.1: integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA== acorn@^5.5.3: - version "5.7.3" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279" - integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw== + version "5.7.4" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e" + integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg== acorn@^6.0.1: version "6.4.0" -- cgit v1.3 From 7dc91ade28b0b89309e7c6b332ea6ccbd1c8f823 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Tue, 4 Aug 2020 12:58:28 -0400 Subject: Add support for buffer-level prettier_exec_cmd, for prettier-stylelint for instance --- README.md | 14 ++++++++++++++ autoload/prettier/resolver/executable.vim | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a6a192..4c32d4d 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,20 @@ vim-prettier executable resolution: 3. Look for a global prettier installation 4. Use locally installed vim-prettier prettier executable +### Prettier Stylelint + +To use an alternative command, like +[`prettier-stylelint`](https://github.com/hugomrdias/prettier-stylelint), set +this at the buffer level, e.g.: + +```vim +au FileType css,scss,scss.css let b:prettier_exec_cmd = "prettier-stylelint" +``` + +vim-prettier will look for the executable in the same places it looks for +`prettier`, and will fall back to `prettier` if it can't find +`b:prettier_exec_cmd` + ### USAGE Prettier by default will run on auto save but can also be manually triggered by: diff --git a/autoload/prettier/resolver/executable.vim b/autoload/prettier/resolver/executable.vim index 8d233ab..0cb0b02 100644 --- a/autoload/prettier/resolver/executable.vim +++ b/autoload/prettier/resolver/executable.vim @@ -33,7 +33,12 @@ endfunction function! s:GetExecPath(...) abort let l:rootDir = a:0 > 0 ? a:1 : -1 let l:dir = l:rootDir != -1 ? l:rootDir . '/.bin/' : '' - return l:dir . 'prettier' + let l:path = l:dir . get(b:, 'prettier_exec_cmd', 'prettier') + if executable(l:path) + return l:path + else + return l:dir . 'prettier' + endif endfunction " Searches for the existence of a directory accross -- cgit v1.3 From 1033199e52a6a6b32a14c4d5cc9ae1fba6386f69 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Tue, 4 Aug 2020 17:52:01 -0400 Subject: Simplify example autocmd for prettier-stylelint --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c32d4d..773fa6a 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ To use an alternative command, like this at the buffer level, e.g.: ```vim -au FileType css,scss,scss.css let b:prettier_exec_cmd = "prettier-stylelint" +au FileType css,scss let b:prettier_exec_cmd = "prettier-stylelint" ``` vim-prettier will look for the executable in the same places it looks for -- cgit v1.3 From 0241700d62814a1ddafc0227e0c66e9a8e3fae87 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Thu, 6 Aug 2020 08:27:32 -0400 Subject: Add buffer-level prettier exec command to doc --- doc/prettier.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/prettier.txt b/doc/prettier.txt index b56f6e1..e9cf496 100644 --- a/doc/prettier.txt +++ b/doc/prettier.txt @@ -158,6 +158,17 @@ Running before saving, changing text or leaving insert mode: let g:prettier#quickfix_enabled = 0 autocmd BufWritePre,TextChanged,InsertLeave *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync < +Buffer-level custom commands + +To use an alternative command, like `prettier-stylelint`, set this at the +buffer level with `b:prettier_exec_cmd`, e.g.: +> + au FileType css,scss let b:prettier_exec_cmd = "prettier-stylelint" +< +vim-prettier will look for the executable in the same places it looks for +`prettier`, and will fall back to `prettier` if it can't find +`b:prettier_exec_cmd` + Overwrite default prettier configuration **Note:** vim-prettier default settings differ from prettier intentionally. -- cgit v1.3 From 349999cc6eb3f11280ae1b1ed00f4975c4d84053 Mon Sep 17 00:00:00 2001 From: Ethan Nguyen Date: Thu, 13 Aug 2020 13:23:53 +0100 Subject: Uses default configs from Prettier CLI document --- plugin/prettier.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/prettier.vim b/plugin/prettier.vim index 595f50d..fde0df5 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -105,13 +105,13 @@ let g:prettier#config#jsx_bracket_same_line = get(g:,'prettier#config#jsx_bracke " avoid wrapping a single arrow function param in parens " avoid|always -" default: 'avoid' -let g:prettier#config#arrow_parens = get(g:,'prettier#config#arrow_parens', 'avoid') +" default: 'always' +let g:prettier#config#arrow_parens = get(g:,'prettier#config#arrow_parens', 'always') " Print trailing commas wherever possible when multi-line. " none|es5|all -" default: 'none' -let g:prettier#config#trailing_comma = get(g:,'prettier#config#trailing_comma', 'none') +" default: 'es5' +let g:prettier#config#trailing_comma = get(g:,'prettier#config#trailing_comma', 'es5') " restrict itself to only format files that contain a special comment @prettier or @format let g:prettier#config#require_pragma= get(g:, 'prettier#config#require_pragma', 'false') -- cgit v1.3 From 5d5bde20964b0b55e05516f7f7784bd90d92aeb8 Mon Sep 17 00:00:00 2001 From: Ethan Nguyen Date: Thu, 13 Aug 2020 13:24:46 +0100 Subject: Adds Prettier CLI document references --- plugin/prettier.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugin/prettier.vim b/plugin/prettier.vim index fde0df5..944e38d 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -59,61 +59,75 @@ let g:prettier#preset#config = get(g:,'prettier#preset#config', 'default') " Max line length that prettier will wrap on: a number or 'auto' (use " textwidth). " default: 'auto' +" See more: https://prettier.io/docs/en/options.html#print-width let g:prettier#config#print_width = get(g:, 'prettier#config#print_width', 'auto') " number of spaces per indentation level: a number or 'auto' (use " softtabstop) " default: 'auto' +" See more: https://prettier.io/docs/en/options.html#tab-width let g:prettier#config#tab_width = get(g:,'prettier#config#tab_width', 'auto') " use tabs instead of spaces: true, false, or auto (use the expandtab setting). " default: 'auto' +" See more: https://prettier.io/docs/en/options.html#tabs let g:prettier#config#use_tabs = get(g:,'prettier#config#use_tabs', 'auto') " flow|babylon|typescript|css|less|scss|json|graphql|markdown or empty string " (let prettier choose). " default: '' +" See more: https://prettier.io/docs/en/options.html#parser let g:prettier#config#parser = get(g:,'prettier#config#parser', '') " cli-override|file-override|prefer-file " default: 'file-override' +" See more: https://prettier.io/docs/en/cli.html#--config-precedence let g:prettier#config#config_precedence = get(g:, 'prettier#config#config_precedence', 'file-override') " always|never|preserve " default: 'preserve' +" See more: https://prettier.io/docs/en/options.html#prose-wrap let g:prettier#config#prose_wrap = get(g:, 'prettier#config#prose_wrap', 'preserve') " css|strict|ignore " default: 'css' +" See more: https://prettier.io/docs/en/options.html#html-whitespace-sensitivity let g:prettier#config#html_whitespace_sensitivity = get(g:, 'prettier#config#html_whitespace_sensitivity', 'css') " print semicolons " default: 'true' +" See more: https://prettier.io/docs/en/options.html#semicolons let g:prettier#config#semi = get(g:,'prettier#config#semi', 'true') " Use single quotes instead of double quotes. " default: 'false' +" See more: https://prettier.io/docs/en/options.html#quotes let g:prettier#config#single_quote = get(g:,'prettier#config#single_quote', 'false') " print spaces between brackets " default: 'true' +" See more: https://prettier.io/docs/en/options.html#bracket-spacing let g:prettier#config#bracket_spacing = get(g:,'prettier#config#bracket_spacing', 'true') " put > on the last line instead of new line " default: 'false' +" See more: https://prettier.io/docs/en/options.html#jsx-brackets let g:prettier#config#jsx_bracket_same_line = get(g:,'prettier#config#jsx_bracket_same_line', 'false') " avoid wrapping a single arrow function param in parens " avoid|always " default: 'always' +" See more: https://prettier.io/docs/en/options.html#arrow-function-parentheses let g:prettier#config#arrow_parens = get(g:,'prettier#config#arrow_parens', 'always') " Print trailing commas wherever possible when multi-line. " none|es5|all " default: 'es5' +" See more: https://prettier.io/docs/en/options.html#trailing-commas let g:prettier#config#trailing_comma = get(g:,'prettier#config#trailing_comma', 'es5') " restrict itself to only format files that contain a special comment @prettier or @format +" See more: https://prettier.io/docs/en/options.html#require-pragma let g:prettier#config#require_pragma= get(g:, 'prettier#config#require_pragma', 'false') " synchronous by default -- cgit v1.3