" TypeScript vim settings setlocal commentstring=//\ %s setlocal suffixesadd+=.ts let b:undo_ftplugin = '' nnoremap gf \ :call FindFile(v:count1, expand(''), 'find', 'gf') nnoremap f \ :call FindFile(v:count1, expand(''), 'sfind', 'f') nnoremap \ :call FindFile(v:count1, expand(''), 'sfind', '') nnoremap gf \ :call FindFile(v:count1, expand(''), 'tabfind', 'gf') " Debugging nnoremap Zd odebugger; nnoremap ZD Odebugger; nnoremap Zc :make nnoremap Zf \ :execute 'silent !prettier --write ' . shellescape(expand('%')) \ redraw! let b:undo_ftplugin .= 'nunmap gf' let b:undo_ftplugin .= '| nunmap f' let b:undo_ftplugin .= '| nunmap ' let b:undo_ftplugin .= '| nunmap gf' let b:undo_ftplugin .= '| nunmap Zd' let b:undo_ftplugin .= '| nunmap ZD' let b:undo_ftplugin .= '| nunmap Zc' let b:undo_ftplugin .= '| nunmap Zf' if exists('*s:FindFile') finish endif " If `fname` is a directory, open fname/index.ts using `command`. Otherwise, " run `map` with `count`. function! s:FindFile(count, fname, command, map) let relative_file = expand('%:h') . '/' . a:fname if isdirectory(relative_file) execute a:command . ' ' . relative_file . '/index.ts' return endif execute 'normal! ' . a:count . a:map endfunction