forked from puremourning/vimspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_ui_vimrc
174 lines (138 loc) · 4.79 KB
/
custom_ui_vimrc
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
" setup boilerplate to make this file usable with vim -Nu <tihs file> {{{
scriptencoding utf-8
execute 'source' expand( '<sfile>:p:h' ) . '/minimal_vimrc'
set noequalalways
let mapleader = ','
let maplocalleader = "\<Space>"
" }}}
" Custom Layout {{{
function! s:CustomiseUI()
let wins = g:vimspector_session_windows
" Close the Variables window
if has( 'nvim' )
" No win_execute in neovim
call win_gotoid( wins.variables )
quit
else
call win_execute( wins.variables, 'q' )
endif
" Put the stack trace at the top of the "left bar" (rotate)
call win_gotoid( wins.stack_trace )
wincmd r
" Make the left column at least 70 chars
70wincmd |
" Make the code window at least 80 chars
call win_gotoid( wins.code )
80wincmd |
" Make the output window 10 lines high and right at the top of the screen
call win_gotoid( wins.output )
10wincmd _
wincmd K
" Enable keyboard-hover for vars and watches
call win_gotoid( g:vimspector_session_windows.variables )
nmap <silent> <buffer> <LocalLeader>di <Plug>VimspectorBalloonEval
call win_gotoid( g:vimspector_session_windows.watches )
nmap <silent> <buffer> <LocalLeader>di <Plug>VimspectorBalloonEval
endfunction
function s:SetUpTerminal()
if !has_key( g:vimspector_session_windows, 'terminal' )
" There's a neovim bug which means that this doesn't work in neovim
return
endif
let terminal_win = g:vimspector_session_windows.terminal
" Make the terminal window at most 80 columns wide, ensuring there is enough
" sapce for our code window (80 columns) and the left bar (70 columns)
" Padding is 2 for the 2 vertical split markers and 2 for the sign column in
" the code window.
let left_bar = 70
let code = 80
let padding = 4
let cols = max( [ min( [ &columns - left_bar - code - padding, 80 ] ), 10 ] )
call win_gotoid( terminal_win )
execute string(cols) . 'wincmd |'
endfunction
function! s:CustomiseWinBar()
call win_gotoid( g:vimspector_session_windows.code)
aunmenu WinBar
nnoremenu WinBar.▷\ ᶠ⁵ :call vimspector#Continue()<CR>
nnoremenu WinBar.↷\ ᶠ¹⁰ :call vimspector#StepOver()<CR>
nnoremenu WinBar.↓\ ᶠ¹¹ :call vimspector#StepInto()<CR>
nnoremenu WinBar.↑\ ˢᶠ¹¹ :call vimspector#StepOut()<CR>
nnoremenu WinBar.❘❘\ ᶠ⁶ :call vimspector#Pause()<CR>
nnoremenu WinBar.□\ ˢᶠ⁵ :call vimspector#Stop()<CR>
nnoremenu WinBar.⟲\ ᶜˢᶠ⁵ :call vimspector#Restart()<CR>
nnoremenu WinBar.✕\ ᶠ⁸ :call vimspector#Reset()<CR>
endfunction
augroup TestUICustomistaion
autocmd!
autocmd User VimspectorUICreated call s:CustomiseUI()
autocmd User VimspectorTerminalOpened call s:SetUpTerminal()
autocmd User VimspectorUICreated call s:CustomiseWinBar()
augroup END
" }}}
" Custom sign priority {{{
let g:vimspector_sign_priority = {
\ 'vimspectorBP': 3,
\ 'vimspectorBPCond': 2,
\ 'vimspectorBPDisabled': 1,
\ 'vimspectorPC': 999,
\ }
" }}}
" Custom mappings while debuggins {{{
let s:mapped = {}
function! s:OnJumpToFrame() abort
if has_key( s:mapped, string( bufnr() ) )
return
endif
nmap <silent> <buffer> <LocalLeader>dn <Plug>VimspectorStepOver
nmap <silent> <buffer> <LocalLeader>ds <Plug>VimspectorStepInto
nmap <silent> <buffer> <LocalLeader>df <Plug>VimspectorStepOut
nmap <silent> <buffer> <LocalLeader>dc <Plug>VimspectorContinue
nmap <silent> <buffer> <LocalLeader>di <Plug>VimspectorBalloonEval
xmap <silent> <buffer> <LocalLeader>di <Plug>VimspectorBalloonEval
let s:mapped[ string( bufnr() ) ] = { 'modifiable': &modifiable }
setlocal nomodifiable
endfunction
function! s:OnDebugEnd() abort
let original_buf = bufnr()
let hidden = &hidden
augroup VimspectorSwapExists
au!
autocmd SwapExists * let v:swapchoice='o'
augroup END
try
set hidden
for bufnr in keys( s:mapped )
try
execute 'buffer' bufnr
silent! nunmap <buffer> <LocalLeader>dn
silent! nunmap <buffer> <LocalLeader>ds
silent! nunmap <buffer> <LocalLeader>df
silent! nunmap <buffer> <LocalLeader>dc
silent! nunmap <buffer> <LocalLeader>di
silent! xunmap <buffer> <LocalLeader>di
let &l:modifiable = s:mapped[ bufnr ][ 'modifiable' ]
endtry
endfor
finally
execute 'noautocmd buffer' original_buf
let &hidden = hidden
endtry
au! VimspectorSwapExists
let s:mapped = {}
endfunction
augroup TestCustomMappings
au!
autocmd User VimspectorJumpedToFrame call s:OnJumpToFrame()
autocmd User VimspectorDebugEnded ++nested call s:OnDebugEnd()
augroup END
" }}}
" Custom mappings for special buffers {{{
let g:vimspector_mappings = {
\ 'stack_trace': {},
\ 'variables': {
\ 'set_value': [ '<Tab>', '<C-CR>', 'C' ],
\ }
\ }
" }}}
" vim: foldmethod=marker