mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
Merge 51327677ac79241919d0ca367cfadc7a6df25e93 into a494ce1c64a2637719a5c1339abf19ec7c48089c
This commit is contained in:
commit
e54500bf62
@ -794,6 +794,13 @@ To enable the recognition of Markdown comments each time after removing
|
||||
re-source "javaformat.vim" for Vim versions greater than `8.2.1397`: >
|
||||
runtime autoload/javaformat.vim
|
||||
<
|
||||
JAVASCRIPT *ft-javascript-plugin*
|
||||
|
||||
To enable prettier formatting of JavaScript files, set the following variable
|
||||
in your vimrc: >
|
||||
|
||||
let g:javascript_formatter = 'prettier'
|
||||
|
||||
JSON-FORMAT *ft-json-plugin*
|
||||
|
||||
JSON filetype can be extended to use 'formatexpr' and "json.FormatExpr()"
|
||||
|
@ -7452,6 +7452,7 @@ ft-inform-syntax syntax.txt /*ft-inform-syntax*
|
||||
ft-java-plugin filetype.txt /*ft-java-plugin*
|
||||
ft-java-syntax syntax.txt /*ft-java-syntax*
|
||||
ft-javascript-omni insert.txt /*ft-javascript-omni*
|
||||
ft-javascript-plugin filetype.txt /*ft-javascript-plugin*
|
||||
ft-jq-syntax syntax.txt /*ft-jq-syntax*
|
||||
ft-json-plugin filetype.txt /*ft-json-plugin*
|
||||
ft-json-syntax syntax.txt /*ft-json-syntax*
|
||||
|
@ -70,8 +70,23 @@ let &l:define =
|
||||
\ .. '\|^\s*\(export\s\+\|export\s\+default\s\+\)*\(var\|let\|const\|function\|class\)'
|
||||
\ .. '\|\<as\>'
|
||||
|
||||
if !empty(get(g:,'javascript_formatprg', ''))
|
||||
augroup formatprgsJavaScript
|
||||
autocmd! * <buffer>
|
||||
autocmd ShellFilterPost <buffer> if v:shell_error | execute 'echom "shell filter returned error " . v:shell_error . ", undoing changes"' | undo | endif
|
||||
if g:javascript_formatprg ==# 'prettier'
|
||||
autocmd BufWinEnter <buffer> ++once let &l:formatprg =
|
||||
\ executable('prettier') ? 'prettier' : 'npx prettier' .
|
||||
\ ' --stdin-filepath=%:S --parser=javascript ' .
|
||||
\ (&textwidth > 0 ? '--print-width=' . &textwidth : '') .
|
||||
\ ' --tab-width=' . &l:shiftwidth . (&expandtab ? '' : '--use-tabs') . ' --'
|
||||
endif
|
||||
augroup END
|
||||
endif
|
||||
|
||||
let b:undo_ftplugin =
|
||||
\ "setl fo< ofu< com< cms< sua< su< def< pa<"
|
||||
\ .. !empty(g:javascript_formatprg) ? " fp<" : ""
|
||||
\ .. "| unlet! b:browsefilter b:match_ignorecase b:match_words"
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
|
Loading…
x
Reference in New Issue
Block a user