1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
" TypeScript vim settings
setlocal commentstring=//\ %s
setlocal suffixesadd+=.ts
let b:undo_ftplugin = ''
nnoremap <silent> <buffer> gf
\ :<C-u>call <SID>FindFile(v:count1, expand('<cfile>'), 'find', 'gf')<CR>
nnoremap <buffer> <C-w>f
\ :<C-u>call <SID>FindFile(v:count1, expand('<cfile>'), 'sfind', '<C-v><C-w>f')<CR>
nnoremap <silent> <buffer> <C-w><C-f>
\ :<C-u>call <SID>FindFile(v:count1, expand('<cfile>'), 'sfind', '<C-v><C-w><C-v><C-f>')<CR>
nnoremap <silent> <buffer> <C-w>gf
\ :<C-u>call <SID>FindFile(v:count1, expand('<cfile>'), 'tabfind', '<C-v><C-w>gf')<CR>
" Debugging
nnoremap <buffer> Zd odebugger;<Esc>
nnoremap <buffer> ZD Odebugger;<Esc>
nnoremap <buffer> Zc :make<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> Zd'
let b:undo_ftplugin .= '| nunmap <buffer> ZD'
let b:undo_ftplugin .= '| nunmap <buffer> Zc'
let b:undo_ftplugin .= '| nunmap <buffer> 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
|