Allow gadget config in .gadgets.d to override the installed config
This commit is contained in:
parent
5586d9e694
commit
0057094179
2 changed files with 24 additions and 8 deletions
|
|
@ -13,13 +13,14 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import logging
|
import glob
|
||||||
import vim
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import shlex
|
import shlex
|
||||||
|
import subprocess
|
||||||
import traceback
|
import traceback
|
||||||
|
import vim
|
||||||
|
|
||||||
from vimspector import ( breakpoints,
|
from vimspector import ( breakpoints,
|
||||||
code,
|
code,
|
||||||
|
|
@ -90,8 +91,10 @@ class DebugSession( object ):
|
||||||
configurations = database.get( 'configurations' )
|
configurations = database.get( 'configurations' )
|
||||||
adapters = {}
|
adapters = {}
|
||||||
|
|
||||||
for gadget_config_file in [ install.GetGadgetConfigFile( VIMSPECTOR_HOME ),
|
glob.glob( install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ) )
|
||||||
utils.PathToConfigFile( '.gadgets.json' ) ]:
|
for gadget_config_file in PathsToAllGadgetConfigs( VIMSPECTOR_HOME,
|
||||||
|
current_file ):
|
||||||
|
self._logger.debug( f'Reading gadget config: {gadget_config_file}' )
|
||||||
if gadget_config_file and os.path.exists( gadget_config_file ):
|
if gadget_config_file and os.path.exists( gadget_config_file ):
|
||||||
with open( gadget_config_file, 'r' ) as f:
|
with open( gadget_config_file, 'r' ) as f:
|
||||||
adapters.update( json.load( f ).get( 'adapters' ) or {} )
|
adapters.update( json.load( f ).get( 'adapters' ) or {} )
|
||||||
|
|
@ -196,9 +199,6 @@ class DebugSession( object ):
|
||||||
|
|
||||||
def _StartWithConfiguration( self, configuration, adapter ):
|
def _StartWithConfiguration( self, configuration, adapter ):
|
||||||
def start():
|
def start():
|
||||||
self._logger.debug( "Starting debugger from stack context: %s",
|
|
||||||
traceback.format_stack() )
|
|
||||||
|
|
||||||
self._configuration = configuration
|
self._configuration = configuration
|
||||||
self._adapter = adapter
|
self._adapter = adapter
|
||||||
|
|
||||||
|
|
@ -860,3 +860,14 @@ class DebugSession( object ):
|
||||||
|
|
||||||
def AddFunctionBreakpoint( self, function ):
|
def AddFunctionBreakpoint( self, function ):
|
||||||
return self._breakpoints.AddFunctionBreakpoint( function )
|
return self._breakpoints.AddFunctionBreakpoint( function )
|
||||||
|
|
||||||
|
|
||||||
|
def PathsToAllGadgetConfigs( vimspector_base, current_file ):
|
||||||
|
yield install.GetGadgetConfigFile( vimspector_base )
|
||||||
|
for p in sorted( glob.glob(
|
||||||
|
os.path.join( install.GetGadgetConfigDir( vimspector_base ),
|
||||||
|
'*.json' ) ) ):
|
||||||
|
yield p
|
||||||
|
|
||||||
|
yield utils.PathToConfigFile( '.gadgets.json',
|
||||||
|
os.path.dirname( current_file ) )
|
||||||
|
|
|
||||||
|
|
@ -33,3 +33,8 @@ def GetGadgetDir( vimspector_base, OS ):
|
||||||
def GetGadgetConfigFile( vimspector_base ):
|
def GetGadgetConfigFile( vimspector_base ):
|
||||||
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ),
|
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ),
|
||||||
'.gadgets.json' )
|
'.gadgets.json' )
|
||||||
|
|
||||||
|
|
||||||
|
def GetGadgetConfigDir( vimspector_base ):
|
||||||
|
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ),
|
||||||
|
'.gadgets.d' )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue