Merge pull request #244 from puremourning/sign-pri
Highlight the current line using linehl=CursorLine
This commit is contained in:
commit
e81be848a1
10 changed files with 177 additions and 35 deletions
|
|
@ -1370,7 +1370,7 @@ define them in your `vimrc`.
|
||||||
| `vimspectorBP` | Line breakpoint | 9 |
|
| `vimspectorBP` | Line breakpoint | 9 |
|
||||||
| `vimspectorBPCond` | Conditional line breakpiont | 9 |
|
| `vimspectorBPCond` | Conditional line breakpiont | 9 |
|
||||||
| `vimspectorBPDisabled` | Disabled breakpoint | 9 |
|
| `vimspectorBPDisabled` | Disabled breakpoint | 9 |
|
||||||
| `vimspectorPC` | Program counter (i.e. current line) | 20 |
|
| `vimspectorPC` | Program counter (i.e. current line) | 200 |
|
||||||
|
|
||||||
The default symbols are the equivalent of something like the following:
|
The default symbols are the equivalent of something like the following:
|
||||||
|
|
||||||
|
|
@ -1378,7 +1378,7 @@ The default symbols are the equivalent of something like the following:
|
||||||
sign define vimspectorBP text=\ ● texthl=WarningMsg
|
sign define vimspectorBP text=\ ● texthl=WarningMsg
|
||||||
sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg
|
sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg
|
||||||
sign define vimspectorBPDisabled text=\ ● texthl=LineNr
|
sign define vimspectorBPDisabled text=\ ● texthl=LineNr
|
||||||
sign define vimspectorPC text=\ ▶ texthl=MatchParen
|
sign define vimspectorPC text=\ ▶ texthl=MatchParen linehl=CursorLine
|
||||||
```
|
```
|
||||||
|
|
||||||
If the signs don't display properly, your font probably doesn't contain these
|
If the signs don't display properly, your font probably doesn't contain these
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,6 @@ class ProjectBreakpoints( object ):
|
||||||
signs.PlaceSign( bp[ 'sign_id' ],
|
signs.PlaceSign( bp[ 'sign_id' ],
|
||||||
'VimspectorBP',
|
'VimspectorBP',
|
||||||
sign,
|
sign,
|
||||||
9,
|
|
||||||
file_name,
|
file_name,
|
||||||
bp[ 'line' ] )
|
bp[ 'line' ] )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ class CodeView( object ):
|
||||||
if not signs.SignDefined( 'vimspectorPC' ):
|
if not signs.SignDefined( 'vimspectorPC' ):
|
||||||
signs.DefineSign( 'vimspectorPC',
|
signs.DefineSign( 'vimspectorPC',
|
||||||
text = '▶',
|
text = '▶',
|
||||||
texthl = 'MatchParen' )
|
texthl = 'MatchParen',
|
||||||
|
linehl = 'CursorLine' )
|
||||||
|
|
||||||
|
|
||||||
def SetCurrentFrame( self, frame ):
|
def SetCurrentFrame( self, frame ):
|
||||||
|
|
@ -78,7 +79,6 @@ class CodeView( object ):
|
||||||
signs.PlaceSign( self._signs[ 'vimspectorPC' ],
|
signs.PlaceSign( self._signs[ 'vimspectorPC' ],
|
||||||
'VimspectorCode',
|
'VimspectorCode',
|
||||||
'vimspectorPC',
|
'vimspectorPC',
|
||||||
20,
|
|
||||||
frame[ 'source' ][ 'path' ],
|
frame[ 'source' ][ 'path' ],
|
||||||
frame[ 'line' ] )
|
frame[ 'line' ] )
|
||||||
except vim.error as e:
|
except vim.error as e:
|
||||||
|
|
@ -184,7 +184,6 @@ class CodeView( object ):
|
||||||
'VimspectorCode',
|
'VimspectorCode',
|
||||||
'vimspectorBP' if breakpoint[ 'verified' ]
|
'vimspectorBP' if breakpoint[ 'verified' ]
|
||||||
else 'vimspectorBPDisabled',
|
else 'vimspectorBPDisabled',
|
||||||
9,
|
|
||||||
file_name,
|
file_name,
|
||||||
breakpoint[ 'line' ] )
|
breakpoint[ 'line' ] )
|
||||||
|
|
||||||
|
|
@ -248,9 +247,9 @@ class CodeView( object ):
|
||||||
if term_options[ 'vertical' ] and not term_options.get( 'curwin', 0 ):
|
if term_options[ 'vertical' ] and not term_options.get( 'curwin', 0 ):
|
||||||
term_options[ 'term_cols' ] = max(
|
term_options[ 'term_cols' ] = max(
|
||||||
min ( int( vim.eval( 'winwidth( 0 )' ) )
|
min ( int( vim.eval( 'winwidth( 0 )' ) )
|
||||||
- settings.Int( 'code_minwidth', 82 ),
|
- settings.Int( 'code_minwidth' ),
|
||||||
settings.Int( 'terminal_maxwidth', 80 ) ),
|
settings.Int( 'terminal_maxwidth' ) ),
|
||||||
settings.Int( 'terminal_minwidth' , 10 )
|
settings.Int( 'terminal_minwidth' )
|
||||||
)
|
)
|
||||||
|
|
||||||
buffer_number = int(
|
buffer_number = int(
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ class DebugSession( object ):
|
||||||
|
|
||||||
# TODO: The UI code is too scattered. Re-organise into a UI class that
|
# TODO: The UI code is too scattered. Re-organise into a UI class that
|
||||||
# just deals with these thigns like window layout and custmisattion.
|
# just deals with these thigns like window layout and custmisattion.
|
||||||
vim.command( f'botright { settings.Int( "bottombar_height", 10 ) }new' )
|
vim.command( f'botright { settings.Int( "bottombar_height" ) }new' )
|
||||||
win = vim.current.window
|
win = vim.current.window
|
||||||
self._logView = output.OutputView( win, self._api_prefix )
|
self._logView = output.OutputView( win, self._api_prefix )
|
||||||
self._logView.AddLogFileView()
|
self._logView.AddLogFileView()
|
||||||
|
|
@ -525,7 +525,7 @@ class DebugSession( object ):
|
||||||
# and poking into each View class to check its window is valid also feels
|
# and poking into each View class to check its window is valid also feels
|
||||||
# wrong.
|
# wrong.
|
||||||
with utils.LetCurrentTabpage( self._uiTab ):
|
with utils.LetCurrentTabpage( self._uiTab ):
|
||||||
vim.command( f'botright { settings.Int( "bottombar_height", 10 ) }new' )
|
vim.command( f'botright { settings.Int( "bottombar_height" ) }new' )
|
||||||
self._outputView.UseWindow( vim.current.window )
|
self._outputView.UseWindow( vim.current.window )
|
||||||
vim.vars[ 'vimspector_session_windows' ][ 'output' ] = utils.WindowID(
|
vim.vars[ 'vimspector_session_windows' ][ 'output' ] = utils.WindowID(
|
||||||
vim.current.window,
|
vim.current.window,
|
||||||
|
|
@ -568,7 +568,7 @@ class DebugSession( object ):
|
||||||
|
|
||||||
# Call stack
|
# Call stack
|
||||||
vim.command(
|
vim.command(
|
||||||
f'topleft vertical { settings.Int( "sidebar_width", 50 ) }new' )
|
f'topleft vertical { settings.Int( "sidebar_width" ) }new' )
|
||||||
stack_trace_window = vim.current.window
|
stack_trace_window = vim.current.window
|
||||||
one_third = int( vim.eval( 'winheight( 0 )' ) ) / 3
|
one_third = int( vim.eval( 'winheight( 0 )' ) ) / 3
|
||||||
self._stackTraceView = stack_trace.StackTraceView( self,
|
self._stackTraceView = stack_trace.StackTraceView( self,
|
||||||
|
|
@ -594,7 +594,7 @@ class DebugSession( object ):
|
||||||
|
|
||||||
# Output/logging
|
# Output/logging
|
||||||
vim.current.window = code_window
|
vim.current.window = code_window
|
||||||
vim.command( f'rightbelow { settings.Int( "bottombar_height", 10 ) }new' )
|
vim.command( f'rightbelow { settings.Int( "bottombar_height" ) }new' )
|
||||||
output_window = vim.current.window
|
output_window = vim.current.window
|
||||||
self._outputView = output.DAPOutputView( output_window,
|
self._outputView = output.DAPOutputView( output_window,
|
||||||
self._api_prefix )
|
self._api_prefix )
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ def RunInstaller( api_prefix, leave_open, *args, **kwargs ):
|
||||||
_ResetInstaller()
|
_ResetInstaller()
|
||||||
|
|
||||||
with utils.RestoreCurrentWindow():
|
with utils.RestoreCurrentWindow():
|
||||||
vim.command( f'botright { settings.Int( "bottombar_height", 10 ) }new' )
|
vim.command( f'botright { settings.Int( "bottombar_height" ) }new' )
|
||||||
win = vim.current.window
|
win = vim.current.window
|
||||||
OUTPUT_VIEW = output.OutputView( win, api_prefix )
|
OUTPUT_VIEW = output.OutputView( win, api_prefix )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,58 @@ import vim
|
||||||
import builtins
|
import builtins
|
||||||
from vimspector import utils
|
from vimspector import utils
|
||||||
|
|
||||||
|
DEFAULTS = {
|
||||||
|
# UI
|
||||||
|
'bottombar_height': 10,
|
||||||
|
'sidebar_width': 50,
|
||||||
|
'code_minwidth': 82,
|
||||||
|
'terminal_maxwidth': 80,
|
||||||
|
'terminal_minwidth': 10,
|
||||||
|
|
||||||
|
# Signs
|
||||||
|
'sign_priority': {
|
||||||
|
'vimspectorPC': 200,
|
||||||
|
'vimspectorBP': 9,
|
||||||
|
'vimspectorBPCond': 9,
|
||||||
|
'vimspectorBPDisabled': 9,
|
||||||
|
},
|
||||||
|
|
||||||
|
# Installer
|
||||||
|
'install_gadgets': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def Get( option: str, default=None, cls=str ):
|
def Get( option: str, default=None, cls=str ):
|
||||||
return cls( utils.GetVimValue( vim.vars,
|
return cls( utils.GetVimValue( vim.vars,
|
||||||
f'vimspector_{ option }',
|
f'vimspector_{ option }',
|
||||||
default ) )
|
DEFAULTS.get( option, cls() ) ) )
|
||||||
|
|
||||||
|
|
||||||
def Int( option: str, default=0 ):
|
def Int( option: str ):
|
||||||
return Get( option, default=default, cls=builtins.int )
|
return Get( option, cls=builtins.int )
|
||||||
|
|
||||||
|
|
||||||
def List( option: str, default=[] ):
|
def List( option: str ):
|
||||||
return utils.GetVimList( vim.vars, f'vimspector_{ option }', default )
|
return utils.GetVimList( vim.vars,
|
||||||
|
f'vimspector_{ option }',
|
||||||
|
DEFAULTS.get( option, [] ) )
|
||||||
|
|
||||||
|
|
||||||
def Dict( option: str, default={} ):
|
# FIXME:
|
||||||
return utils.GetVimValue( vim.vars,
|
# In Vim, we must use vim.Dictionary because this sorts out the annoying
|
||||||
f'vimspector_{ option }',
|
# keys-as-bytes discrepancy, making things awkward. That said, we still have the
|
||||||
default )
|
# problem where the _values_ are potentially bytes. It's very tempting to just
|
||||||
|
# make a deep copy to antive str type here.
|
||||||
|
# Of course in neovim, it's totally different and you actually get a dict type
|
||||||
|
# back (though for once, neovim is making life somewhat easier for a change).
|
||||||
|
DICT_TYPE = dict
|
||||||
|
if hasattr( vim, 'Dictionary' ):
|
||||||
|
DICT_TYPE = vim.Dictionary
|
||||||
|
|
||||||
|
|
||||||
|
def Dict( option: str ):
|
||||||
|
d = DICT_TYPE( DEFAULTS.get( option, {} ) )
|
||||||
|
d.update( utils.GetVimValue( vim.vars,
|
||||||
|
f'vimspector_{ option }',
|
||||||
|
{} ) )
|
||||||
|
return d
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,22 @@ def SignDefined( name ):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def DefineSign( name, text, texthl, col = 'right' ):
|
def DefineSign( name, text, texthl, col = 'right', **kwargs ):
|
||||||
if col == 'right':
|
if col == 'right':
|
||||||
if int( utils.Call( 'strdisplaywidth', text ) ) < 2:
|
if int( utils.Call( 'strdisplaywidth', text ) ) < 2:
|
||||||
text = ' ' + text
|
text = ' ' + text
|
||||||
|
|
||||||
text = text.replace( ' ', r'\ ' )
|
text = text.replace( ' ', r'\ ' )
|
||||||
|
|
||||||
vim.command( f'sign define { name } text={ text } texthl={ texthl }' )
|
cmd = f'sign define { name } text={ text } texthl={ texthl }'
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
cmd += f' { key }={ value }'
|
||||||
|
|
||||||
|
vim.command( cmd )
|
||||||
|
|
||||||
|
|
||||||
def PlaceSign( sign_id, group, name, priority, file, line ):
|
def PlaceSign( sign_id, group, name, file, line ):
|
||||||
priority = settings.Dict( 'sign_priority' ).get( name, priority )
|
priority = settings.Dict( 'sign_priority' )[ name ]
|
||||||
|
|
||||||
cmd = ( f'sign place { sign_id } '
|
cmd = ( f'sign place { sign_id } '
|
||||||
f'group={ group } '
|
f'group={ group } '
|
||||||
|
|
|
||||||
|
|
@ -749,7 +749,6 @@ def GetVimList( vim_dict, name, default=None ):
|
||||||
return [ i.decode( 'utf-8' ) if isinstance( i, bytes ) else i for i in value ]
|
return [ i.decode( 'utf-8' ) if isinstance( i, bytes ) else i for i in value ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def GetVimspectorBase():
|
def GetVimspectorBase():
|
||||||
return GetVimValue( vim.vars,
|
return GetVimValue( vim.vars,
|
||||||
'vimspector_base_dir',
|
'vimspector_base_dir',
|
||||||
|
|
|
||||||
|
|
@ -631,8 +631,92 @@ function! Test_Custom_Breakpoint_Priority()
|
||||||
call vimspector#test#setup#Reset()
|
call vimspector#test#setup#Reset()
|
||||||
lcd -
|
lcd -
|
||||||
%bwipeout!
|
%bwipeout!
|
||||||
endfunction
|
unlet! g:vimspector_sign_priority
|
||||||
|
endfunction
|
||||||
function! TearDown_Test_Custom_Breakpoint_Priority()
|
|
||||||
|
function! Test_Custom_Breakpoint_Priority_Partial()
|
||||||
|
let g:vimspector_sign_priority = {
|
||||||
|
\ 'vimspectorBP': 2,
|
||||||
|
\ 'vimspectorBPCond': 3,
|
||||||
|
\ 'vimspectorBPDisabled': 4
|
||||||
|
\ }
|
||||||
|
|
||||||
|
" While not debugging
|
||||||
|
lcd testdata/cpp/simple
|
||||||
|
edit simple.cpp
|
||||||
|
|
||||||
|
call setpos( '.', [ 0, 15, 1 ] )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call setpos( '.', [ 0, 16, 1 ] )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
|
||||||
|
\ 'VimspectorBP',
|
||||||
|
\ 16,
|
||||||
|
\ 'vimspectorBPDisabled',
|
||||||
|
\ 4 )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
|
||||||
|
|
||||||
|
call setpos( '.', [ 0, 17, 1 ] )
|
||||||
|
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
|
||||||
|
\ 'VimspectorBP',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorBPCond',
|
||||||
|
\ 3 )
|
||||||
|
|
||||||
|
" While debugging
|
||||||
|
call vimspector#Launch()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 )
|
||||||
|
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 15 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorPC',
|
||||||
|
\ 200 )
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorCode',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
|
||||||
|
call vimspector#StepOver()
|
||||||
|
" No sign as disabled
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 16, 1 )
|
||||||
|
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 16 )
|
||||||
|
|
||||||
|
call vimspector#StepOver()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 17, 1 )
|
||||||
|
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 17 )
|
||||||
|
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorPC',
|
||||||
|
\ 200 )
|
||||||
|
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
lcd -
|
||||||
|
%bwipeout!
|
||||||
unlet! g:vimspector_sign_priority
|
unlet! g:vimspector_sign_priority
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,12 @@ function! Test_All_Buffers_Deleted_NoHidden()
|
||||||
|
|
||||||
let buffers_after = getbufinfo( opts )
|
let buffers_after = getbufinfo( opts )
|
||||||
|
|
||||||
call assert_equal( len( buffers_before ), len( buffers_after ) )
|
if assert_equal( len( buffers_before ), len( buffers_after ) )
|
||||||
|
call assert_report( 'Expected '
|
||||||
|
\ . string( buffers_before )
|
||||||
|
\ . ' but found '
|
||||||
|
\ . string( buffers_after ) )
|
||||||
|
endif
|
||||||
|
|
||||||
set hidden&
|
set hidden&
|
||||||
lcd -
|
lcd -
|
||||||
|
|
@ -101,7 +106,12 @@ function! Test_All_Buffers_Deleted_Hidden()
|
||||||
|
|
||||||
let buffers_after = getbufinfo( opts )
|
let buffers_after = getbufinfo( opts )
|
||||||
|
|
||||||
call assert_equal( len( buffers_before ), len( buffers_after ) )
|
if assert_equal( len( buffers_before ), len( buffers_after ) )
|
||||||
|
call assert_report( 'Expected '
|
||||||
|
\ . string( buffers_before )
|
||||||
|
\ . ' but found '
|
||||||
|
\ . string( buffers_after ) )
|
||||||
|
endif
|
||||||
|
|
||||||
set hidden&
|
set hidden&
|
||||||
lcd -
|
lcd -
|
||||||
|
|
@ -115,7 +125,13 @@ function! Test_All_Buffers_Deleted_ToggleLog()
|
||||||
VimspectorToggleLog
|
VimspectorToggleLog
|
||||||
VimspectorToggleLog
|
VimspectorToggleLog
|
||||||
let buffers_after = getbufinfo( #{ buflisted: 1 } )
|
let buffers_after = getbufinfo( #{ buflisted: 1 } )
|
||||||
call assert_equal( len( buffers_before ), len( buffers_after ) )
|
|
||||||
|
if assert_equal( len( buffers_before ), len( buffers_after ) )
|
||||||
|
call assert_report( 'Expected '
|
||||||
|
\ . string( buffers_before )
|
||||||
|
\ . ' but found '
|
||||||
|
\ . string( buffers_after ) )
|
||||||
|
endif
|
||||||
|
|
||||||
call vimspector#test#setup#Reset()
|
call vimspector#test#setup#Reset()
|
||||||
set hidden&
|
set hidden&
|
||||||
|
|
@ -142,7 +158,12 @@ function! Test_All_Buffers_Deleted_Installer()
|
||||||
\ 120000 )
|
\ 120000 )
|
||||||
|
|
||||||
let buffers_after = getbufinfo( #{ buflisted: 1 } )
|
let buffers_after = getbufinfo( #{ buflisted: 1 } )
|
||||||
call assert_equal( len( buffers_before ), len( buffers_after ) )
|
if assert_equal( len( buffers_before ), len( buffers_after ) )
|
||||||
|
call assert_report( 'Expected '
|
||||||
|
\ . string( buffers_before )
|
||||||
|
\ . ' but found '
|
||||||
|
\ . string( buffers_after ) )
|
||||||
|
endif
|
||||||
|
|
||||||
call vimspector#test#setup#Reset()
|
call vimspector#test#setup#Reset()
|
||||||
set hidden&
|
set hidden&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue