aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-10-06 19:56:46 +0200
committerTeddy Wing2023-11-06 20:54:14 +0100
commit79aff1844f1defbe73801efa6dd176b64baba917 (patch)
treeebfe7948671052e187d7b08d6226b9b434a35f50
parentd54d9140ed15465d1b1e8569d11c580c95ec69e5 (diff)
downloaddotvim-79aff1844f1defbe73801efa6dd176b64baba917.tar.bz2
ftplugin/typescript.vim: Add 'prettier' formatting
Set up formatting for the current buffer using 'prettier'.
-rw-r--r--ftplugin/typescript.vim5
1 files changed, 5 insertions, 0 deletions
diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim
index 94b9c9e..fb9fc46 100644
--- a/ftplugin/typescript.vim
+++ b/ftplugin/typescript.vim
@@ -16,10 +16,15 @@ nnoremap <silent> <buffer> <C-w><C-f>
nnoremap <silent> <buffer> <C-w>gf
\ :<C-u>call <SID>FindFile(v:count1, expand('<cfile>'), 'tabfind', '<C-v><C-w>gf')<CR>
+nnoremap <buffer> Zf
+ \ :<C-u>execute 'silent !prettier --write ' . shellescape(expand('%'))
+ \ <Bar> redraw!<CR>
+
let b:undo_ftplugin .= 'nunmap <buffer> gf'
let b:undo_ftplugin .= '| nunmap <buffer> <C-w>f'
let b:undo_ftplugin .= '| nunmap <buffer> <C-w><C-f>'
let b:undo_ftplugin .= '| nunmap <buffer> <C-w>gf'
+let b:undo_ftplugin .= '| nunmap <buffer> Zf'
if exists('*s:FindFile')