Centralise the default settings
This commit is contained in:
parent
7a6fea120b
commit
b2456b587f
7 changed files with 55 additions and 23 deletions
|
|
@ -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' ] )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,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 +183,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 +246,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': 20,
|
||||||
|
'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
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ def DefineSign( name, text, texthl, col = 'right' ):
|
||||||
vim.command( f'sign define { name } text={ text } texthl={ texthl }' )
|
vim.command( f'sign define { name } text={ text } texthl={ texthl }' )
|
||||||
|
|
||||||
|
|
||||||
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',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue