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' ],
|
||||
'VimspectorBP',
|
||||
sign,
|
||||
9,
|
||||
file_name,
|
||||
bp[ 'line' ] )
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,6 @@ class CodeView( object ):
|
|||
signs.PlaceSign( self._signs[ 'vimspectorPC' ],
|
||||
'VimspectorCode',
|
||||
'vimspectorPC',
|
||||
20,
|
||||
frame[ 'source' ][ 'path' ],
|
||||
frame[ 'line' ] )
|
||||
except vim.error as e:
|
||||
|
|
@ -184,7 +183,6 @@ class CodeView( object ):
|
|||
'VimspectorCode',
|
||||
'vimspectorBP' if breakpoint[ 'verified' ]
|
||||
else 'vimspectorBPDisabled',
|
||||
9,
|
||||
file_name,
|
||||
breakpoint[ 'line' ] )
|
||||
|
||||
|
|
@ -248,9 +246,9 @@ class CodeView( object ):
|
|||
if term_options[ 'vertical' ] and not term_options.get( 'curwin', 0 ):
|
||||
term_options[ 'term_cols' ] = max(
|
||||
min ( int( vim.eval( 'winwidth( 0 )' ) )
|
||||
- settings.Int( 'code_minwidth', 82 ),
|
||||
settings.Int( 'terminal_maxwidth', 80 ) ),
|
||||
settings.Int( 'terminal_minwidth' , 10 )
|
||||
- settings.Int( 'code_minwidth' ),
|
||||
settings.Int( 'terminal_maxwidth' ) ),
|
||||
settings.Int( 'terminal_minwidth' )
|
||||
)
|
||||
|
||||
buffer_number = int(
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ class DebugSession( object ):
|
|||
|
||||
# TODO: The UI code is too scattered. Re-organise into a UI class that
|
||||
# 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
|
||||
self._logView = output.OutputView( win, self._api_prefix )
|
||||
self._logView.AddLogFileView()
|
||||
|
|
@ -525,7 +525,7 @@ class DebugSession( object ):
|
|||
# and poking into each View class to check its window is valid also feels
|
||||
# wrong.
|
||||
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 )
|
||||
vim.vars[ 'vimspector_session_windows' ][ 'output' ] = utils.WindowID(
|
||||
vim.current.window,
|
||||
|
|
@ -568,7 +568,7 @@ class DebugSession( object ):
|
|||
|
||||
# Call stack
|
||||
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
|
||||
one_third = int( vim.eval( 'winheight( 0 )' ) ) / 3
|
||||
self._stackTraceView = stack_trace.StackTraceView( self,
|
||||
|
|
@ -594,7 +594,7 @@ class DebugSession( object ):
|
|||
|
||||
# Output/logging
|
||||
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
|
||||
self._outputView = output.DAPOutputView( output_window,
|
||||
self._api_prefix )
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def RunInstaller( api_prefix, leave_open, *args, **kwargs ):
|
|||
_ResetInstaller()
|
||||
|
||||
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
|
||||
OUTPUT_VIEW = output.OutputView( win, api_prefix )
|
||||
|
||||
|
|
|
|||
|
|
@ -18,22 +18,58 @@ import vim
|
|||
import builtins
|
||||
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 ):
|
||||
return cls( utils.GetVimValue( vim.vars,
|
||||
f'vimspector_{ option }',
|
||||
default ) )
|
||||
DEFAULTS.get( option, cls() ) ) )
|
||||
|
||||
|
||||
def Int( option: str, default=0 ):
|
||||
return Get( option, default=default, cls=builtins.int )
|
||||
def Int( option: str ):
|
||||
return Get( option, cls=builtins.int )
|
||||
|
||||
|
||||
def List( option: str, default=[] ):
|
||||
return utils.GetVimList( vim.vars, f'vimspector_{ option }', default )
|
||||
def List( option: str ):
|
||||
return utils.GetVimList( vim.vars,
|
||||
f'vimspector_{ option }',
|
||||
DEFAULTS.get( option, [] ) )
|
||||
|
||||
|
||||
def Dict( option: str, default={} ):
|
||||
return utils.GetVimValue( vim.vars,
|
||||
f'vimspector_{ option }',
|
||||
default )
|
||||
# FIXME:
|
||||
# In Vim, we must use vim.Dictionary because this sorts out the annoying
|
||||
# keys-as-bytes discrepancy, making things awkward. That said, we still have the
|
||||
# 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 }' )
|
||||
|
||||
|
||||
def PlaceSign( sign_id, group, name, priority, file, line ):
|
||||
priority = settings.Dict( 'sign_priority' ).get( name, priority )
|
||||
def PlaceSign( sign_id, group, name, file, line ):
|
||||
priority = settings.Dict( 'sign_priority' )[ name ]
|
||||
|
||||
cmd = ( f'sign place { sign_id } '
|
||||
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 ]
|
||||
|
||||
|
||||
|
||||
def GetVimspectorBase():
|
||||
return GetVimValue( vim.vars,
|
||||
'vimspector_base_dir',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue