replacing function calls with plug command

This commit is contained in:
dsych 2021-02-19 23:39:54 -05:00 committed by Ben Jackson
commit 51d551fe52
5 changed files with 58 additions and 35 deletions

View file

@ -539,6 +539,25 @@ class DebugSession( object ):
self._variablesView.DeleteWatch()
@IfConnected()
def ShowEvalBalloon( self, winnr, expression, is_hover ):
frame = self._stackTraceView.GetCurrentFrame()
# Check if RIP is in a frame
if frame is None:
self._logger.debug( 'Tooltip: Not in a stack frame' )
return ''
# Check if cursor in code window
if winnr != int( self._codeView._window.number ):
self._logger.debug( 'Winnr %s is not the code window %s',
winnr,
self._codeView._window.number )
return ''
# Return variable aware function
return self._variablesView.VariableEval( frame, expression, is_hover )
@IfConnected()
def ShowTooltip( self, winnr, expression, is_hover ):
"""Proxy: ballonexpr -> variables.ShowTooltip"""

View file

@ -34,6 +34,12 @@ _log_handler = logging.FileHandler( LOG_FILE, mode = 'w' )
_log_handler.setFormatter(
logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' ) )
# this is the "large number" that vim returns for col num, when getting '> mark
# with getpos() for line wise visual selection(V)
# see https://github.com/vim/vim/blob/eed9d46293f0842aad0d50ff3a526f9a48b12421/src/evalfunc.c#L4077
# and https://github.com/vim/vim/blob/064095012c0b8e4e43e75834b337115950898fbf/src/vim.h#L1699
MAX_COL = 2147483647
def SetUpLogging( logger ):
logger.setLevel( logging.DEBUG )
@ -642,7 +648,7 @@ def DisplayBalloon( is_term, display, is_hover = False ):
rc = int( vim.eval(
"vimspector#internal#balloon#CreateTooltip({}, {})".format(
is_hover, json.dumps( display )
int( is_hover ), json.dumps( display )
)
) )
@ -725,6 +731,21 @@ def GetBufferFiletypes( buf ):
return ft.split( '.' )
def GetVisualSelection( bufnr ):
start_line, start_col = vim.current.buffer.mark( "<" )
end_line, end_col = vim.current.buffer.mark( ">" )
# lines are 1 based, but columns are 0 based
# don't as me why...
lines = vim.buffers[ bufnr ][ start_line - 1 : end_line ]
lines[ 0 ] = lines[ 0 ][ start_col : ]
# only trim the end if we are not in line-wise select mode
if( end_col < MAX_COL ):
lines[ -1 ] = lines[ -1 ][ : end_col + 1 ]
return lines
def DisplaySplash( api_prefix, splash, text ):
if splash:
return Call( f'vimspector#internal#{api_prefix}popup#UpdateSplash',