diff options
| -rw-r--r-- | README.md | 25 | ||||
| -rw-r--r-- | autoload/prettier/utils/buffer.vim | 2 | ||||
| -rw-r--r-- | doc/prettier.txt | 19 |
3 files changed, 44 insertions, 2 deletions
@@ -79,6 +79,22 @@ If your are on vim 8+ you can also trigger async formatting by: :PrettierAsync ``` +You can send to prettier your entire buffer but ensure that it formats only your selection. + +**note: ** differs from `:PrettierFragment` by sending the entire buffer to prettier, allowing identation level to be preserved, but it requires the whole file to be valid. + +```vim +:PrettierPartial +``` + +You can send to prettier your current selection as a fragment of same type as the file being edited. + +**note: ** differs from `:PrettierFragment` by sending only the current selection to prettier, this allows for faster formatting but wont preserve indentation. + +````vim +:PrettierFragment +``` + You can check what is the `vim-prettier` plugin version by: ```vim @@ -135,6 +151,13 @@ By default parsing errors will open the quickfix but can also be disabled let g:prettier#quickfix_enabled = 0 ``` +By default selection formatting will be running `:PrettierFragment` but we can set +`:PrettierPartial` as the default selection formatting by: + +```vim +let g:prettier#partial_format=1 +``` + By default we auto focus on the quickfix when there are errors but can also be disabled ```vim @@ -205,3 +228,5 @@ let g:prettier#config#prose_wrap = 'preserve' ### REQUIREMENT(S) If prettier installation can't be found no code formatting will happen +``` +```` diff --git a/autoload/prettier/utils/buffer.vim b/autoload/prettier/utils/buffer.vim index 0b3c619..258c615 100644 --- a/autoload/prettier/utils/buffer.vim +++ b/autoload/prettier/utils/buffer.vim @@ -35,7 +35,7 @@ function! prettier#utils#buffer#createBufferFromUpdatedLines(lines, start, end) endfunction " Adapted from https://github.com/farazdagi/vim-go-ide -function! s:getCharPosition(line, col) +function! s:getCharPosition(line, col) abort if &encoding !=# 'utf-8' " On utf-8 enconding we can't just use bytes so we need to make sure we can count the " characters, we do that by adding the text into a temporary buffer and counting the chars diff --git a/doc/prettier.txt b/doc/prettier.txt index 632c1d8..208cf22 100644 --- a/doc/prettier.txt +++ b/doc/prettier.txt @@ -89,7 +89,24 @@ You can check what is the resolved `prettier` cli path by: You can check what is the resolved `prettier` cli version by: > :PrettierCliVersion -< + +You can send to prettier your entire buffer but ensure that it +formats only your selection. + +**note: ** differs from `:PrettierFragment` by sending the entire buffer +to prettier, allowing identation level to be preserved, but it requires +the whole file to be valid. +> + :PrettierPartial + +You can send to prettier your current selection as a fragment of same type as +the file being edited. + +**note: ** differs from `:PrettierPartial` by sending only the current selection +to prettier, this allows for faster formatting but wont preserve indentation. +> + :PrettierFragment + ============================================================================== CONFIGURATION *vim-prettier-configuration* |
