Skip to content

Commit

Permalink
Merge pull request #802 from puremourning/disable-hover-option
Browse files Browse the repository at this point in the history
Add feature option to disable auto hovering
  • Loading branch information
mergify[bot] authored Nov 26, 2023
2 parents 66617ad + 0f93928 commit 2203e7d
Show file tree
Hide file tree
Showing 22 changed files with 374 additions and 156 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,16 @@ jobs:
brew update-reset
brew doctor || true
brew cleanup || true
for p in vim go tcl-tk llvm lua luajit love neovim; do
for p in vim go tcl-tk llvm lua luajit love neovim coreutils; do
brew install $p || brew outdated $p || brew upgrade $p
done
brew reinstall icu4c
brew link --overwrite python
brew link --overwrite vim
brew link --overwrite go
pip3 install --user neovim
# latest neovim doesn't work on python 3.12
# https://github.com/neovim/pynvim/issues/538
pip3 install --user 'pynvim @ git+https://github.com/neovim/pynvim'
name: 'Install vim and deps'
- name: 'Install requirements'
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ When contributing pull requests, I ask that:

### Running the tests locally

Requirements for running the tests:

* Linux or macOS
* Supported Vim or Neovim version (ideally both)
* acsiinema instaled (`pip3 install --user asciinema`)
* `timeout` installed (on macOS: `brew install coreutils`)
* various other dependencies for the individual debuggers.

The simplest way to run the tests is using the container image, as all
dependencies are there for you. If you decide not to, then the best way to work
out what's required is to look at either the `Dockerfile` (for Linux) or the
`.github/workflows/build.yaml` (for macOS).

There are 2 ways:

1. In the docker container. The CI tests for linux run in a container, so as to
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ The following sections expand on the above brief overview.
Vimspector requires:

* One of:
* Vim 8.2 Huge build compiled with Python 3.10 or later
* Neovim 0.8 with Python 3.10 or later (experimental)
* Vim 8.2.4797 or later "huge" build compiled with Python 3.10 or later
* Neovim 0.8 with Python 3.10 or later
* One of the following operating systems:
* Linux
* macOS Mojave or later
Expand Down Expand Up @@ -1266,6 +1266,10 @@ All rules for `Variables and scopes` apply plus the following:

![variable eval hover](https://puremourning.github.io/vimspector-web/img/vimspector-variable-eval-hover.png)

You can disable automatic hovering popup by settings
`g:vimspector_enable_auto_hover=0` before starting the debug session. You can
then map something to `<Plug>VimspectorBalloonEval` and trigger it manually.

## Watches

The watch window is used to inspect variables and expressions. Expressions are
Expand Down Expand Up @@ -1294,6 +1298,10 @@ value are displayed, with other data available from hovering the mouse or
triggering `<Plug>VimspectorBalloonEval` on the line containing the value in the
variables (or watches) window.

You can disable automatic hovering popup by settings
`g:vimspector_enable_auto_hover=0` before starting the debug session. You can
then map something to `<Plug>VimspectorBalloonEval` and trigger it manually.

### Watch autocompletion

The watch prompt buffer has its `omnifunc` set to a function that will
Expand Down
3 changes: 3 additions & 0 deletions autoload/vimspector/internal/channel.vim
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function! vimspector#internal#channel#Send( session_id, msg ) abort
catch /E631/
" Channel is closed
return 0
catch /E906/
" Channel is closed
return 0
endtry
endfunction

Expand Down
2 changes: 2 additions & 0 deletions autoload/vimspector/internal/job.vim
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ function! vimspector#internal#job#Send( session_id, msg ) abort
return 1
catch /E631/
return 0
catch /E906/
return 0
endtry
endfunction

Expand Down
138 changes: 74 additions & 64 deletions python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,29 @@ def OnChannelClosed( self ):
self._connection = None


def _StopNextSession( self, terminateDebuggee, then ):
if self.child_sessions:
c = self.child_sessions.pop()
c._StopNextSession( terminateDebuggee,
then = lambda: self._StopNextSession(
terminateDebuggee,
then ) )
elif self._connection:
self._StopDebugAdapter( terminateDebuggee, callback = then )
elif then:
then()

def StopAllSessions( self, interactive = False, then = None ):
def Next():
if self.child_sessions:
c = self.child_sessions.pop()
c.StopAllSessions( interactive = interactive, then = Next )
elif self._connection:
self._StopDebugAdapter( interactive = interactive, callback = then )
else:
then()
Next()
if not interactive:
self._StopNextSession( None, then )
elif not self._server_capabilities.get( 'supportTerminateDebuggee' ):
self._StopNextSession( None, then )
elif not self._stackTraceView.AnyThreadsRunning():
self._StopNextSession( None, then )
else:
self._ConfirmTerminateDebugee(
lambda terminateDebuggee: self._StopNextSession( terminateDebuggee,
then ) )

@ParentOnly()
@IfConnected()
Expand Down Expand Up @@ -1490,65 +1503,62 @@ def _StartDebugAdapter( self ):
self._logger.info( 'Debug Adapter Started' )
return True

def _StopDebugAdapter( self, interactive = False, callback = None ):
def _StopDebugAdapter( self, terminateDebuggee, callback ):
arguments = {}

def disconnect():
self._splash_screen = utils.DisplaySplash(
self._api_prefix,
self._splash_screen,
f"Shutting down debug adapter for session {self.DisplayName()}..." )

def handler( *args ):
self._splash_screen = utils.HideSplash( self._api_prefix,
self._splash_screen )

if callback:
self._logger.debug( "Setting server exit handler before disconnect" )
assert not self._run_on_server_exit
self._run_on_server_exit = callback

vim.eval( 'vimspector#internal#{}#StopDebugSession( {} )'.format(
self._connection_type,
self.session_id ) )

self._connection.DoRequest(
handler,
{
'command': 'disconnect',
'arguments': arguments,
},
failure_handler = handler,
timeout = self._connection.sync_timeout )
if terminateDebuggee is not None:
arguments[ 'terminateDebuggee' ] = terminateDebuggee

if not interactive:
disconnect()
elif not self._server_capabilities.get( 'supportTerminateDebuggee' ):
disconnect()
elif not self._stackTraceView.AnyThreadsRunning():
disconnect()
else:
def handle_choice( choice ):
if choice == 1:
# yes
arguments[ 'terminateDebuggee' ] = True
elif choice == 2:
# no
arguments[ 'terminateDebuggee' ] = False
elif choice <= 0:
# Abort
return
# Else, use server default

disconnect()

utils.Confirm( self._api_prefix,
"Terminate debuggee?",
handle_choice,
default_value = 3,
options = [ '(Y)es', '(N)o', '(D)efault' ],
keys = [ 'y', 'n', 'd' ] )
self._splash_screen = utils.DisplaySplash(
self._api_prefix,
self._splash_screen,
f"Shutting down debug adapter for session {self.DisplayName()}..." )

def handler( *args ):
self._splash_screen = utils.HideSplash( self._api_prefix,
self._splash_screen )

if callback:
self._logger.debug( "Setting server exit handler before disconnect" )
assert not self._run_on_server_exit
self._run_on_server_exit = callback

vim.eval( 'vimspector#internal#{}#StopDebugSession( {} )'.format(
self._connection_type,
self.session_id ) )

self._connection.DoRequest(
handler,
{
'command': 'disconnect',
'arguments': arguments,
},
failure_handler = handler,
timeout = self._connection.sync_timeout )


def _ConfirmTerminateDebugee( self, then ):
def handle_choice( choice ):
terminateDebuggee = None
if choice == 1:
# yes
terminateDebuggee = True
elif choice == 2:
# no
terminateDebuggee = False
elif choice <= 0:
# Abort
return
# Else, use server default

then( terminateDebuggee )

utils.Confirm( self._api_prefix,
"Terminate debuggee?",
handle_choice,
default_value = 3,
options = [ '(Y)es', '(N)o', '(D)efault' ],
keys = [ 'y', 'n', 'd' ] )

def _PrepareAttach( self, adapter_config, launch_config ):
attach_config = adapter_config.get( 'attach' )
Expand Down
3 changes: 2 additions & 1 deletion python3/vimspector/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
'terminal_maxheight': 15,
'terminal_minheight': 5,

# WinBar
# Features
'enable_winbar': True,
'enable_auto_hover': True,

# Session files
'session_file_name': '.vimspector.session',
Expand Down
37 changes: 19 additions & 18 deletions python3/vimspector/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,28 +282,29 @@ def __init__( self, session_id, variables_win, watches_win ):
)

# Set the (global!) balloon expr if supported
has_balloon = int( vim.eval( "has( 'balloon_eval' )" ) )
has_balloon_term = int( vim.eval( "has( 'balloon_eval_term' )" ) )

self._oldoptions = {}
if has_balloon or has_balloon_term:
self._oldoptions = {
'balloonexpr': vim.options[ 'balloonexpr' ],
'balloondelay': vim.options[ 'balloondelay' ],
}
vim.options[ 'balloonexpr' ] = (
"vimspector#internal#balloon#HoverEvalTooltip()"
)
if settings.Bool( 'enable_auto_hover' ):
has_balloon = int( vim.eval( "has( 'balloon_eval' )" ) )
has_balloon_term = int( vim.eval( "has( 'balloon_eval_term' )" ) )

if has_balloon or has_balloon_term:
self._oldoptions = {
'balloonexpr': vim.options[ 'balloonexpr' ],
'balloondelay': vim.options[ 'balloondelay' ],
}
vim.options[ 'balloonexpr' ] = (
"vimspector#internal#balloon#HoverEvalTooltip()"
)

vim.options[ 'balloondelay' ] = 250
vim.options[ 'balloondelay' ] = 250

if has_balloon:
self._oldoptions[ 'ballooneval' ] = vim.options[ 'ballooneval' ]
vim.options[ 'ballooneval' ] = True
if has_balloon:
self._oldoptions[ 'ballooneval' ] = vim.options[ 'ballooneval' ]
vim.options[ 'ballooneval' ] = True

if has_balloon_term:
self._oldoptions[ 'balloonevalterm' ] = vim.options[ 'balloonevalterm' ]
vim.options[ 'balloonevalterm' ] = True
if has_balloon_term:
self._oldoptions[ 'balloonevalterm' ] = vim.options[ 'balloonevalterm' ]
vim.options[ 'balloonevalterm' ] = True


def Clear( self ):
Expand Down
2 changes: 1 addition & 1 deletion python3/vimspector/vendor/json_minify.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# Vimspector modification: strip_space defaults to False; we don't actually want
# to minify - we just want to strip comments.
def minify(string, strip_space=False):
tokenizer = re.compile('"|(/\*)|(\*/)|(//)|\n|\r')
tokenizer = re.compile(r'"|(/\*)|(\*/)|(//)|\n|\r')
end_slashes_re = re.compile(r'(\\)*$')

in_string = False
Expand Down
19 changes: 17 additions & 2 deletions run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,25 @@ VERSION_OPTIONS=$([ "$IS_NVIM" -ne 0 ] && echo '--headless' || echo '--not-a-ter

RUN_VIM="${VIM_EXE} -N --clean ${VERSION_OPTIONS}"

if which timeout >/dev/null 2>&1; then
TIMEOUT_SCRIPT="timeout --verbose --foreground --kill-after 7m 5m"
else
TIMEOUT_SCRIPT=""
echo "WARNING: No timeout found, not using timeout"
fi

# Check that vim's python support actual works, else we can't run tests
if ! ${TIMEOUT_SCRIPT} ${RUN_VIM} --cmd "py3 import vim; vim.command( 'qa!' )" --cmd "cquit!"; then
echo "Vim's python support doesn't work. Cannot run tests" >&2
exit 1
else
echo "Vim's python support works. Let's go..."
fi

# There seems to be a race condition with the way asciinema sets the pty size.
# It does fork() then if is_child: execvpe(...) else: set_pty_size(). This means
# the child might read the pty size before it's set. So we use a 1s sleepy.
RUN_TEST="sleep 1 && ${RUN_VIM} -S lib/run_test.vim"
RUN_TEST="sleep 1 && ${TIMEOUT_SCRIPT} ${RUN_VIM} -S lib/run_test.vim"

# We use fd 3 for vim's output. Send it to stdout if not already redirected
# Note: can't use ${out_fd} in a redirect because redirects happen before
Expand All @@ -143,7 +158,7 @@ fi

# Basic pre-flight check that vim and python work
# ffs neovim https://github.com/neovim/neovim/issues/14438
if ${RUN_VIM} -u support/test_python3.vim .fail; then
if ${TIMEOUT_SCRIPT} ${RUN_VIM} -u support/test_python3.vim .fail; then
rm -f .fail
echo "$VIM_EXE appears to have working python3 support. Let's go..."
else
Expand Down
Loading

0 comments on commit 2203e7d

Please sign in to comment.