Enable embedded vim python debugging

This allows us to use vimspector to debug vimspector. The idea is that
in Vim you call 'py3 from vimspector.developer import SetUpDebugpy;
SetUpDebugpy()' and then just attach to localhost:5678 using the new
multi-session mode support. Oof.
This commit is contained in:
Ben Jackson 2020-05-17 19:15:39 +01:00
commit 6a1c9a6b52
2 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,42 @@
# 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 sys
import os
from vimspector import install, utils
def SetUpDebugpy( wait=False, port=5678 ):
sys.path.insert(
1,
os.path.join( install.GetGadgetDir( utils.GetVimspectorBase(),
install.GetOS() ),
'debugpy',
'build',
'lib' ) )
import debugpy
exe = sys.executable
try:
# debugpy uses sys.executable (which is `vim`, so we hack it)
sys.executable = 'python3'
debugpy.listen( port )
finally:
sys.executable = exe
if wait:
debugpy.wait_for_client()