Allow moving the gadget/configuration dirs to arbitrary location

This commit is contained in:
Ben Jackson 2020-05-09 15:22:42 +01:00
commit 5837135fee
6 changed files with 106 additions and 14 deletions

View file

@ -32,9 +32,8 @@ from vimspector import ( breakpoints,
variables )
from vimspector.vendor.json_minify import minify
VIMSPECTOR_HOME = os.path.abspath( os.path.join( os.path.dirname( __file__ ),
'..',
'..' ) )
# We cache this once, and don't allow it to change (FIXME?)
VIMSPECTOR_HOME = utils.GetVimspectorBase()
# cache of what the user entered for any option we ask them
USER_CHOICES = {}
@ -1007,7 +1006,7 @@ def PathsToAllGadgetConfigs( vimspector_base, current_file ):
def PathsToAllConfigFiles( vimspector_base, current_file, filetypes ):
for ft in filetypes:
for ft in filetypes + [ '_all' ]:
for p in sorted( glob.glob(
os.path.join( install.GetConfigDirForFiletype( vimspector_base, ft ),
'*.json' ) ) ):

View file

@ -26,6 +26,18 @@ def GetOS():
return 'linux'
def mkdirs( p ):
try:
os.makedirs( p )
except FileExistsError:
pass
def MakeInstallDirs( vimspector_base ):
mkdirs( GetGadgetConfigDir( vimspector_base ) )
mkdirs( GetConfigDirForFiletype( vimspector_base, '_all' ) )
def GetGadgetDir( vimspector_base, OS ):
return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', OS )

View file

@ -563,3 +563,12 @@ def HideSplash( api_prefix, splash ):
Call( f'vimspector#internal#{api_prefix}popup#HideSplash', splash )
return None
def GetVimspectorBase():
try:
return vim.vars[ 'vimspector_base_dir' ].decode( 'utf-8' )
except KeyError:
return os.path.abspath( os.path.join( os.path.dirname( __file__ ),
'..',
'..' ) )