diff --git a/python3/vimspector/code.py b/python3/vimspector/code.py index 29eaa0b..a4f2514 100644 --- a/python3/vimspector/code.py +++ b/python3/vimspector/code.py @@ -18,7 +18,7 @@ import logging import json from collections import defaultdict -from vimspector import utils +from vimspector import utils, settings class CodeView( object ): @@ -218,7 +218,7 @@ class CodeView( object ): args = params[ 'args' ] env = params.get( 'env', {} ) - options = { + term_options = { 'vertical': 1, 'norestore': 1, 'cwd': cwd, @@ -238,9 +238,9 @@ class CodeView( object ): and int( utils.Call( 'vimspector#internal#{}term#IsFinished'.format( self._api_prefix ), self._terminal_buffer_number ) ) ): - options[ 'curwin' ] = 1 + term_options[ 'curwin' ] = 1 else: - options[ 'vertical' ] = 0 + term_options[ 'vertical' ] = 0 buffer_number = None terminal_window = None @@ -248,17 +248,19 @@ class CodeView( object ): # If we're making a vertical split from the code window, make it no more # than 80 columns and no fewer than 10. Also try and keep the code window # at least 82 columns - if options[ 'vertical' ] and not options.get( 'curwin', 0 ): - options[ 'term_cols' ] = max( - min ( int( vim.eval( 'winwidth( 0 ) - 82' ) ), 80 ), - 10 + 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 ) ) buffer_number = int( utils.Call( 'vimspector#internal#{}term#Start'.format( self._api_prefix ), args, - options ) ) + term_options ) ) terminal_window = vim.current.window if buffer_number is None or buffer_number <= 0: diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 640a92e..f553850 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -29,7 +29,8 @@ from vimspector import ( breakpoints, output, stack_trace, utils, - variables ) + variables, + settings ) from vimspector.vendor.json_minify import minify # We cache this once, and don't allow it to change (FIXME?) @@ -487,7 +488,8 @@ class DebugSession( object ): self._codeView = code.CodeView( code_window, self._api_prefix ) # Call stack - vim.command( 'topleft vertical 50new' ) + vim.command( + f'topleft vertical { settings.Int( "sidebar_width", 50 ) }new' ) stack_trace_window = vim.current.window one_third = int( vim.eval( 'winheight( 0 )' ) ) / 3 self._stackTraceView = stack_trace.StackTraceView( self, @@ -515,7 +517,7 @@ class DebugSession( object ): # Output/logging vim.current.window = code_window - vim.command( 'rightbelow 10new' ) + vim.command( f'rightbelow { settings.Int( "bottombar_height", 10 ) }new' ) output_window = vim.current.window self._outputView = output.OutputView( self._connection, output_window, diff --git a/python3/vimspector/settings.py b/python3/vimspector/settings.py new file mode 100644 index 0000000..c365499 --- /dev/null +++ b/python3/vimspector/settings.py @@ -0,0 +1,26 @@ +# vimspector - A multi-language debugging system for Vim +# Copyright 2020 Ben Jackson +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import vim +import builtins + + +def Get( option: str, default=None, cls=str ): + return cls( vim.vars.get( f'vimspector_{ option }', default ) ) + + +def Int( option: str, default=0 ): + return Get( option, default=default, cls=builtins.int )