Sublime Forum

Projectwide features config file

#1

Idea from the navigation panel ( for bookmarks, snippets, todo comments, functions in current file and so on to be displayed on the right side in categories or nested categories ) which has a file you can place in projects ( or the language definition folder ) to have the panel load the options in a language-wide or project wide method…

Project-wide features could include:

  • Rename all files with the following extensions to all-lowercase on save ( and re-open if changed ) - or instead of lower, can do uppercase, etc… option to use regex

  • Use specific language for syntax highlighting, snippets, etc… ( If you have Lua and GMod Lua languages defined / installed, then only 1 will load and it will typically be Lua for .lua files even though GMod Lua is Lua with C style operators allowed which also uses .lua file-extension… being able to define which one will be used is helpful ) for certain file extensions…

  • Git username, password, path, etc…

  • On Save or on file-close, add commit ( but do not push ) for git - then add option for pushing changes in menu somewhere…

  • Etc… project-wide file should be integrated with mods so mods can define options and functionality to add ( such as git? )

All rules can be invoked more than once if default behavior is to be replaced - ie use lang on extension would let you define each file extension to use a certain language for, ie .lua for GModLua instead of standard Lua highlighting, snippets, etc…

0 Likes

#2

Project wide settings are possible already by adding a "settings": { } object to your project file. Whether plugins make use of it or define their own settings trees within a project if they intend to support project wide settings at all is up to the plugin developers.

Snippets are basically filtered by scopes not by (project) settings.

The functions to perform on files on certain events (save, close, …) is up to plugins, too.

Assigning certain syntax to extensions might be handled by a plugin, too. It could use a map placed in a project file to assign a desired syntax after opening files.

But honestly: Adding files to git on save or close? Really?! Sounds very special.

0 Likes

#3

Thanks - But now that I’ve moved on I’m having major issues with load_settings… For some reason the file isn’t discovered at all…

I’m adding settings to User/CodeMap ( an addon by oleg-shiro - my addon: https://bitbucket.org/Acecool/acecooldev_sublimetext3 - greatly extends the functionality of that mapper )… I’m now trying to load per mapper configuration so python, Lua, etc… languages have their own configuration file…


##
##  Class Callbacks - This is an extension to XCodeMapper which only houses the Callback functions which are meant to be manipulated / edited for each language, or implementation...
##
class XCodeMapper_Python( XCodeMapperBase ):
	##
	## Important Declarations
	##

	## Class Name
	__name__ = 'XCodeMapper_Python'


	##
	##
	##
	def DeveloperFunc( self ):
		## Load the mapper configuration - dynamically would be to read the loaded file and get the extension then use ext_config.sublime-settings...
		XCM_MAPPER_SETTINGS	= sublime.load_settings( 'py_xcodemapper_config.sublime-settings' )

		## For some reason the file isn't detected... This hould return True, True, "Python", "Alphabetically" - Instead the defaults are being returned and this is a problem!!!
		print( str( XCM_MAPPER_SETTINGS.get( 'DeveloperMode', False ) ) )
		print( str( XCM_MAPPER_SETTINGS.get( 'DebugMode', False ) ) )
		print( str( XCM_MAPPER_SETTINGS.get( 'LanguageName', False ) ) )
		print( str( XCM_MAPPER_SETTINGS.get( 'OutputSortMethod', 'A-Z' ) ) )

That’s the testing code I’m using - obviously with a lot more code not shown…

XCodeMapperBase contains a lot of callbacks for mapping syntax and adding earmarks of data to show in the Code - Map Panel… See the bottom of the post for the entire output of the Python language mapper with several basic rules in place ( New rule system will allow scope-mapping easily for other languages now that I finished working on the algorithm )… Basically XCodeMapper is to show as much useful information with as little as possible and to make it as easy as possible to map new languages, provide useful output in a concise manner… repeating, I know… But basically self.AddSyntax( CategoryToShowFindingsIn, SearchMethod_StartsEndsWith_RegEx_Contains_adding_others_too, ‘search for this’, ‘and this’, ‘and keep repeating for as many patterns for this category and search methpod’ )… and they’re organized as shown below… many different view methods - 2 shown below where classes are shown in nested categories, and similar to Lua with full class / nested output ( or just parent output ) with more views being added…

Mapping: py.py containing: 1019 lines and 54 entries!

☼ Task List = 'Entries containing internal code comments / notes specifying alterations to be made, new features to integrate, and':
    ## Task: Add System to check for multi-line declarations #:340
    ## Task: Combine XCodeMapper Category Output functions and add additional sort methods, etc... #:345
    ## Task: Create self.AddSyntaxRule( SYNTAX_ERROR, IF_STATEMENTS, CONTAINS, "!", WHEN_NOT "!=" ) - ie extend search detection methods #:466
    ## Task: Create self.AddSyntaxRule( SYNTAX_ERROR, IF_STATEMENTS, CONTAINS, "&&", "WHEN_NOT_IN_QUOTES, "||", "WHEN_NOT_IN_QUOTES ) - ie extend search detection methods #:472
    ## Task: Detect type of indentation used and use tabs to spaces engine and spaces to tabs to ensure 4 depth doesn't mean 4 tabs when 4 spaces are used... #':343
    ## Task: Look into Sublime text and their GC for Python. If these aren't properly collected that this can cause issues after days or weeks running non-stop. Unlikely as it may be, if it is an issue that can arise, I don't want it in my code... I prefer to release quality instead of hacks. #:514
    ## TODO: Add basic rule system so different languages can take advantage of this ( for languages that don't use a prefix - Lua uses function x.func( ) or x.func = function where x acts as the object, library of functions without object or cloning properties, meta-table, etc.. -- PHP for example could benefit from this output but it requires optional { }s to look for scope and it requires looking at more info so a simple rule system to plug into this system would be fantastic - depth isn't always defined by indentation so depth has to be defined other ways ) #:519
    ## TODO: Create Depth system - as depth isn't defined by indent-level in all languages ( python being the exception ), depth needs to be defined using other methods... But depth doesn't always mean what we have it mean here so we need to target specifically what we want to trigger depth and add a new IndentLevel accessor-func for visual output and let Depth be used for logical / scope depth.. #:520

☼ Notes = 'Entries designed as internal comments / notation..':
    ## Note: Commented out for now so all nested line up... Now that we don't put classes and functions in the same category ( they're category and nested entries meaning they can be sorted without the headers being moved ) the depth-mod already modifies the output depth so 0 is category_depth + 1 #:657
    ## Note: functions using : have their name defined as Meta-Table <Name> or Object <Name> for the CATEGORY_CLASS_FUNCTION Header... [ self is also to the output ( in some cases ) -- NEXT UPDATE - option to choose it ] #:283
    ## Note: I recommend trying it as True - And trying as False to see which you prefer... THIS OPTION IS ONLY ACTIVE IF THE ABOVE VALUE IS True... #:289
    ## Note: I've left functions and categories to use depth so they'll show you their level of indentation ( useful to know in Python ) while the rest is at 0 so you don't end up with a ton of tabs for other bits of info... If you don't like the depths being shown all over the place for categories and normal functions simply comment it out and the return 0 will be used... #:652
    ## Note: This has been added temporarily as a stand-alone function until it is converted into a Syntax Rule... or Rule Set... I will be renaming some of the helper functions to better fit what it is I'm actually doing... Expect that update soon.. Converting things, and coding, is easier when you design your code to be a series of building blocks.. #':491

☼ Class Headers = 'For Class declarations..':
    class XCodeMapper_Python( XCodeMapperBase )::380
    class XCodeMapper_Python_Acecool_XCM( XCodeMapper_Python )::771
    class XCodeMapper_Python_User( XCodeMapper_Python )::897

☼ Class Functions - Children = 'For Class Function declarations..':
    ☼ class XCodeMapper_Python( XCodeMapperBase )::380
        ƒ DeveloperFunc( <This> )::392
        ƒ OnCalcDepth( <This>, _category, _line_number, _code, _depth, _mode, _pattern )::650
        ƒ OnProcessLine( <This>, _line_number, _code, _depth, _in_comment, _in_comment_block )::452
        ƒ OnRunDeveloperFunc( <This> )::408
        ƒ OnSetupArgDataType( <This> )::668
        ƒ OnSetupConfig( <This> )::685
        ƒ OnSetupSyntax( <This> )::415
        ƒ PreOnAddEntry( <This>, _category, _line_number, _code, _depth, _mode, _pattern, _category_original )::575
        ƒ ResetActiveClass( <This> )::506
        ƒ StripAllExceptClassName( <This>, _code )::738
        ƒ SyntaxRuleFunctionClassScopeDepthTracker( <This>, _line_number, _code, _depth, _in_comment, _in_comment_block )::493

    ☼ class XCodeMapper_Python_Acecool_XCM( XCodeMapper_Python )::771
        ƒ OnAccessorFuncExpansion( <This>, _mode, _category, _pattern, _line_number, _code, _depth, _args, _args_count )::829
        ƒ OnSetupSyntax( <This> )::783

    ☼ class XCodeMapper_Python_User( XCodeMapper_Python )::897
        ƒ OnAccessorFuncExpansion( <This>, _mode, _category, _pattern, _line_number, _code, _depth, _args, _args_count )::952
        ƒ OnSetupAccessorFuncs( <This> )::975
        ƒ OnSetupCategoryOutputOrder( <This> )::909
        ƒ OnSetupConfig( <This> )::995
        ƒ OnSetupSyntax( <This> )::923

☼ function = 'For function declarations..':
    ƒ generate( _file )::331

Same file - using full-class name / method of calling similar to Lua tables output:

Mapping: py.py containing: 1017 lines and 54 entries!

☼ Task List = 'Entries containing internal code comments / notes specifying alterations to be made, new features to integrate, and':
    ## Task: Add System to check for multi-line declarations #:340
    ## Task: Combine XCodeMapper Category Output functions and add additional sort methods, etc... #:345
    ## Task: Create self.AddSyntaxRule( SYNTAX_ERROR, IF_STATEMENTS, CONTAINS, "!", WHEN_NOT "!=" ) - ie extend search detection methods #:464
    ## Task: Create self.AddSyntaxRule( SYNTAX_ERROR, IF_STATEMENTS, CONTAINS, "&&", "WHEN_NOT_IN_QUOTES, "||", "WHEN_NOT_IN_QUOTES ) - ie extend search detection methods #:470
    ## Task: Detect type of indentation used and use tabs to spaces engine and spaces to tabs to ensure 4 depth doesn't mean 4 tabs when 4 spaces are used... #':343
    ## Task: Look into Sublime text and their GC for Python. If these aren't properly collected that this can cause issues after days or weeks running non-stop. Unlikely as it may be, if it is an issue that can arise, I don't want it in my code... I prefer to release quality instead of hacks. #:512
    ## TODO: Add basic rule system so different languages can take advantage of this ( for languages that don't use a prefix - Lua uses function x.func( ) or x.func = function where x acts as the object, library of functions without object or cloning properties, meta-table, etc.. -- PHP for example could benefit from this output but it requires optional { }s to look for scope and it requires looking at more info so a simple rule system to plug into this system would be fantastic - depth isn't always defined by indentation so depth has to be defined other ways ) #:517
    ## TODO: Create Depth system - as depth isn't defined by indent-level in all languages ( python being the exception ), depth needs to be defined using other methods... But depth doesn't always mean what we have it mean here so we need to target specifically what we want to trigger depth and add a new IndentLevel accessor-func for visual output and let Depth be used for logical / scope depth.. #:518

☼ Notes = 'Entries designed as internal comments / notation..':
    ## Note: Commented out for now so all nested line up... Now that we don't put classes and functions in the same category ( they're category and nested entries meaning they can be sorted without the headers being moved ) the depth-mod already modifies the output depth so 0 is category_depth + 1 #:655
    ## Note: functions using : have their name defined as Meta-Table <Name> or Object <Name> for the CATEGORY_CLASS_FUNCTION Header... [ self is also to the output ( in some cases ) -- NEXT UPDATE - option to choose it ] #:283
    ## Note: I recommend trying it as True - And trying as False to see which you prefer... THIS OPTION IS ONLY ACTIVE IF THE ABOVE VALUE IS True... #:289
    ## Note: I've left functions and categories to use depth so they'll show you their level of indentation ( useful to know in Python ) while the rest is at 0 so you don't end up with a ton of tabs for other bits of info... If you don't like the depths being shown all over the place for categories and normal functions simply comment it out and the return 0 will be used... #:650
    ## Note: This has been added temporarily as a stand-alone function until it is converted into a Syntax Rule... or Rule Set... I will be renaming some of the helper functions to better fit what it is I'm actually doing... Expect that update soon.. Converting things, and coding, is easier when you design your code to be a series of building blocks.. #':489

☼ Class Headers = 'For Class declarations..':
    class XCodeMapper_Python( XCodeMapperBase )::380
    class XCodeMapper_Python_Acecool_XCM( XCodeMapper_Python )::769
    class XCodeMapper_Python_User( XCodeMapper_Python )::895

☼ Class Functions = 'For Class Function declarations..':
    ƒ XCodeMapper_Python.DeveloperFunc( <This> )::392
    ƒ XCodeMapper_Python.OnCalcDepth( <This>, _category, _line_number, _code, _depth, _mode, _pattern )::648
    ƒ XCodeMapper_Python.OnProcessLine( <This>, _line_number, _code, _depth, _in_comment, _in_comment_block )::450
    ƒ XCodeMapper_Python.OnRunDeveloperFunc( <This> )::406
    ƒ XCodeMapper_Python.OnSetupArgDataType( <This> )::666
    ƒ XCodeMapper_Python.OnSetupConfig( <This> )::683
    ƒ XCodeMapper_Python.OnSetupSyntax( <This> )::413
    ƒ XCodeMapper_Python.PreOnAddEntry( <This>, _category, _line_number, _code, _depth, _mode, _pattern, _category_original )::573
    ƒ XCodeMapper_Python.ResetActiveClass( <This> )::504
    ƒ XCodeMapper_Python.StripAllExceptClassName( <This>, _code )::736
    ƒ XCodeMapper_Python.SyntaxRuleFunctionClassScopeDepthTracker( <This>, _line_number, _code, _depth, _in_comment, _in_comment_block )::491
    ƒ XCodeMapper_Python_Acecool_XCM.OnAccessorFuncExpansion( <This>, _mode, _category, _pattern, _line_number, _code, _depth, _args, _args_count )::827
    ƒ XCodeMapper_Python_Acecool_XCM.OnSetupSyntax( <This> )::781
    ƒ XCodeMapper_Python_User.OnAccessorFuncExpansion( <This>, _mode, _category, _pattern, _line_number, _code, _depth, _args, _args_count )::950
    ƒ XCodeMapper_Python_User.OnSetupAccessorFuncs( <This> )::973
    ƒ XCodeMapper_Python_User.OnSetupCategoryOutputOrder( <This> )::907
    ƒ XCodeMapper_Python_User.OnSetupConfig( <This> )::993
    ƒ XCodeMapper_Python_User.OnSetupSyntax( <This> )::921

☼ function = 'For function declarations..':
    ƒ generate( _file )::331

☼ Active XCodeMapper Features = 'Specific Features the current mapper has..':
    - Language: Python using XCodeMapper_Python_User
    Added new feature: Jan 11 2018 - CFG_DISPLAY_FUNCTIONS_ALTERNATIVELY / CFG_DISPLAY_FUNCTIONS_ALTERNATIVE_FULL_DEPTH - These lets you choose to show functions within classes in the nested-category layout, or similar to LuaTable.FunctionName( _args ) style with the second Cfg allowing you to show more than just the direct-parent ( which.will.follow.the.shallowest.class.to.our.FunctionName( _args ) - This can save space, it can cost space... It is a unique way to display the data and it sorts... For those worried about too little vertical room - you may want to try this! )
    Basic Syntax-Error Detection for Class and Function Definitions - if : doesn't exist then [ ERROR ] is added to the output line, if applicable, and a Syntax Error Entry is added!
    Class Headers. Child Functions sorted into nested categories and global / local to the scope functions in their own category..
    Detection for comments, functions, classes and print statements for debugging / optimization...


Another option can be used to show only DirectParent.FuncName( args ) but these aren’t nested deeper than 1 so the output would be no different…

So, my problem is despite py_xcodemapper_config.sublime-settings file existing with these contents:

//
// Python Language XCodeMapper Configuration File...
//
{
	//
	// Developer / Debugging Commands
	//

	// Developer Mode: When developer mode is set to true, all base files ( XCodeMapper.py, AcecoolST3_Library.py, and XCodeMapper_Definitions.py ) are reloaded to allow edits to occur without needing to restart ST3...
	"DeveloperMode": true,


	// Debug Mode: This determines how much debugging information from self.print( "Category", "Output" ) is displayed. If set to true, then all of it is shown. If false, none of it is shown. If set to a string which matches "Category" then only that data is shown. Useful for debugging certain aspects..
	"DebugMode": true,


	//
	// Mapper Language Information
	//

	// Language Name: Plain-Text identifier used for your benefit. This is what is output into the ST3 console: [ XCodeMapper > LanguageName > generate ] ----
	"LanguageName": "Python",


	//
	// Sorting of Output..
	//

	// OutputSortMethod: Determines how entries within categories are sorted when output... Alphabetical, Descending Alphabetical, By Line-Number ( DEFAULT ), or Reverse Line-Number...
	// Accepted Values: "A-Z" [ for alphabetically ], "Z-A" [ for  reverse alphabetically ], "0-9" or "default" [ for output by line-number Ascending ie by order found, first in first out.. ], "9-0" [ for first found last out, last found first out, reverse line-numbering ]
	// Accepted Values: "Alphabetically" / "Line"
	"OutputSortMethod": "A-Z",
	"OutputSortMethod": "Alphabetically",

	// Output Sort Direction: Ascending or Descending... Ascending is 0-9 or A-Z and Descending is Z-A or 9-0...
	// Accepted Values: "Asc" [ for ascending ] / "Desc" [ for descending ]
	"OutputSortDirection": "Asc",


	//
	// Configuration regarding displaying information about the file being mapped...
	//

	// Display File Entries Info: If enabled, the first line of the Code - Map Panel will be "Mapping <FILENAME>.<EXT> containing: <LINE_COUNT> lines and <ENTRY_COUNT> entries!"
	"OutputFileEntriesInfo": true,

	// Output File Entries Info New Lines: Determines how many new lines are added after the above line is added.. Default is 2 to allow an empty line to appear between it, and the first category containing entries...
	"OutputFileEntriesInfoNewLines": 2,


	//
	// New Line Character( s ) Settings...
	//

	// Output New Line Char: This is the character used at the end of each line... Sublime Text properly parses \n on Windows machines so it's best to use it unless you want to copy / paste the output into a text-editor which doesn't support *nix new-lines by itself..
	// New-Line preferred for reading Files and for outputting to the Code - Map Panel
	// Options: CONST_NEW_LINE_WINDOWS [ \r\n ] / CONST_NEW_LINE_UNIX [ \n ] / CONST_NEW_LINE_MAC_OS_9 [ \n ]
	"OutputNewLineChar": "CONST_NEW_LINE_UNIX",

	// File New Line Delimiter: This character( s ) is used to convert the file we're parsing into a table with each line being a separate key / index in the array.. Each line is also stripped so \r is removed if you are parsing a Windows plain-text file or a file created by Microsoft products.
	// New-Line character used to delimit the active-file.. The new-line type will appear under TOP_MENU > View > Line Endings > [ Windows / Unix / Mac OS 9 ]
	"FileNewLineDelimiter": "CONST_NEW_LINE_UNIX",


	//
	// Indentation Options
	//

	// Characters used for indentation - Can be anything from a tab-character to multiple spaces to ascii-art..
	// "IndentChars": "\t",
	"IndentChars": "    ",

	// Set this to -1 to disable the column sizing feature ( meaning line :1234 shows up right at the side of the code output to CodeMap Panel ). Set it to 1 to truncate values meaning the column will be max of that plus the line-size. Set it to 0 to try to force it to that column, but don't truncate. If it goes over, use -1 behavior on that line... This way the line numbers line up nicely most of the time..
	// Options: ENUM_INDENT_CODE_COLUMN_MODE_DEFAULT / ENUM_INDENT_CODE_COLUMN_MODE_TRUNCATE / ENUM_INDENT_CODE_COLUMN_MODE_ORGANIZED
	"IndentCodeColumnWidthMode": "ENUM_INDENT_CODE_COLUMN_MODE_DEFAULT",

	// Configure the maximum width code should take up in the output before being truncated... Then the line column comes... Note, there will be an additional callback so you can define this on the fly for specific categories so if you want notes / tasks to have no limit, no worries... If you want to disable this feature set it to -1 also note that the line one will be turned off too.. Also, you can set this to a large value, just remember that spaces are used!! I'd recommend keeping it under 255 or so chars per line which is about 1080px wide if viewing on a 4k monitor with a few ticks up in font-size... But at that width you'll unlikely see the line number... keep that in mind...
	// Options: Numerical 0 through n - Only Active if CFG_INDENT_CODE_COLUMN_WIDTH_MODE is something other than _DEFAULT
	"IndentCodeColumnWidth": 125,

	// Should we limit the Category Name / Description Length? If so, use CFG_INDENT_CODE_COLUMN_WIDTH + 5 for file with 9999 max lines, or 6 with 99,999 for good measure so they'll be lined up properly...
	// Options: Numerical 0 through n - Its' best to keep this on paar with CFG_INDENT_CODE_COLUMN_WIDTH
	"IndentCodeLimitCategoryColumnWidth": "CFG_INDENT_CODE_COLUMN_WIDTH + 6",


	//
	//
	//
	"": "",

	//
	//
	//
	"": "",

	//
	//
	//
	"": "",

	//
	//
	//
	"": "",


	//
	// Category Output Order: This list determines the output order of categories. If a category isn't included, then it is hidden - although it's best to keep all categories in this list in the preferred order and use HiddenCategories to hide the ones you don't want...
	//
	"CategoryDisplayOrder": [

	],

	//
	// Hidden Categories: This list determines which categories are hidden for the Python Mappers..
	//
	"HiddenCategories": [

	],

	//
	//
	//
	"": ""
}



// ##
// ## Task / Todo Line Hack to prevent the entire file from turning green, or whichever color strings are, when a ' or " appears...
// ##

// ## If you want to comment out Task / TODO lines, set this to the language comment
// ## Options: Any String
// CFG_TASK_LINE_PREFIX							= ''

// ## This suffix is used to ensure the rest of the Code - Map Panel doesn't show up as a single-color.. Simply use a block-comment or comment with a single and double-quote to ensure the syntax highlighter catche sit...
// ## Options: Any String
// CFG_TASK_LINE_SUFFIX							= ' #"\''


// ##
// ## Category Output Configuration For the Code - Map Panel
// ##

// ## Should we display the Category Description?
// ## Options: True / False
// CFG_CATEGORY_LINE_SHOW_DESC						= True

// ## The Prefix to be used separating the Category Name from the Description - I'd recommend something similar to ' - ', maybe with tabs, etc... You can also use Acecool.string.FormatColumn( 25, ' - ' ) to add 22 spaces after ' - '... Later I may add support for the category output to use this function so all category names / descriptions line up in the output...
// ## Options: Any String
// CFG_CATEGORY_LINE_PREFIX						= ' = \''

// ## If we show the Category Description, I highly recommend you set this to use a comment for the language along with ' and " - or simply use CFG_TASK_LINE_SUFFIX - to prevent the highlighter from messing up and coloring everything one color..
// ## Options: Any String
// CFG_CATEGORY_LINE_SUFFIX						= '\':'


// ##
// ## Function / Class For-Each Argument Callback Configuration
// ##

// ## This is what separates the function or class from the arguments passed through - Example: func<OPENING_DELIMITER> x, y, z )
// ## Options: Any String
// CFG_OBJECT_ARGUMENT_OPENING_DELIMITER			= '('

// ## This is what separates the arguments from the end function / class call or declaration - Example: func( x, y, z <ENDING_DELIMITER>
// ## Options: Any String
// CFG_OBJECT_ARGUMENT_ENDING_DELIMITER			= ')'

// ## This is the character used to delimit or split arguments - It isn't recommended to use more than 1 char otherwise other coding-standards may not be properly read...
// ## Options: Any String
// CFG_OBJECT_ARGUMENT_SPLIT_DELIMITER				= ','

// ## This is to split a default value from an argument... ie func ( x, y, z = true ) in some languages means z, if unset, is set to true...
// ## Options: Any String
// CFG_OBJECT_ARGUMENT_DEFAULT_SPLIT_DELIMITER		= '='

// ## This is the string used to re-join the list of modified arguments back into a string - A comma and space here provide an Airy output: func( x<JOIN_DELIMITER>y<JOIN_DELIMITER>z )
// ## Options: Any String
// CFG_OBJECT_ARGUMENT_JOIN_DELIMITER				= ', '

// ## These are what comes between the arguments on either side of the rejoined args string, and the opening / ending delimiter - Spaces here provide an Airy output: func(<PREFIX>x, y, z<SUFFIX>)
// ## Options: Any String
// CFG_CLASSFUNC_ARG_REASSEMBLE_PREFIX				= ' '
// CFG_CLASSFUNC_ARG_REASSEMBLE_SUFFIX				= ' '


// ##
// ## If CFG_FUNC_FIND_TEXT_REPLACEMENT is set then we look for CFG_FUNC_FIND_TEXT and replace it with CFG_FUNC_FIND_TEXT_REPLACEMENT... so def can become function, or function can become fund or f... Space-savings!
// ##

// ## If CFG_FUNC_TEXT above is not '' then set this to what you are looking to replace... Add the space in both, or neither
// ## Options: Any String
// CFG_FUNC_NAME_SEARCH							= ''

// ## Internal helper for GLua - This defines the text to be used for function declarations as function in Callback.PreOnAddEntry is replaced to save space as some of the function / object declarations in Lua and GLua are quite long...
// ## Options: Any String
// CFG_FUNC_NAME_REPLACE							= ''


// ##
// ## Data-Type Options for Function / Class Arguments...
// ##
// ##	<DataType>		==		ENUM_DISPLAY_DATA_TYPE_ONLY		|	<DataType> _arg		==		ENUM_DISPLAY_DATA_TYPE_BOTH		|	_arg	==		ENUM_DISPLAY_DATA_TYPE_DEFAULT
// ##

// ## Determine how the Data-Type system should apply data... ENUM_DISPLAY_DATA_TYPE_DEFAULT == Leaves the argument as is / _TYPE_BOTH == displays <DataType> _arg - assumes ' ', '<', '>' cfg / _TYPE_ONLY == <DataType> only
// ## Options: ENUM_DISPLAY_DATA_TYPE_DEFAULT == _arg / ENUM_DISPLAY_DATA_TYPE_ONLY == <DataType> / ENUM_DISPLAY_DATA_TYPE_BOTH == <DataType> _arg
// CFG_DISPLAY_ARG_DATA_TYPE						= ENUM_DISPLAY_DATA_TYPE_ONLY

// ## How data-types appear - for when they are added to, or replacing, function args... ie if the following 3 are: ' ' '-' 'x' they'd appear: ( -Playerx _p, -Weaponx _w ) or ' ' '<' '>' they'd appear: ( <Player> _p, <Weapon> _w )
// ## Options: Any String
// CFG_DISPLAY_ARG_DATA_TYPE_SPACER_CHARS			= ' '
// CFG_DISPLAY_ARG_DATA_TYPE_PREFIX				= '<'
// CFG_DISPLAY_ARG_DATA_TYPE_SUFFIX				= '>'


// ##
// ## Personal Information
// ##

// ## Display my personal story?
// ## Options: True / False
// CFG_DISPLAY_PERSONAL_STORY						= False


// ##
// ## Custom Additions ( for Callback class ) Config - ie things you've added - I'd highly recommend using this area instead of hard-coding values in case you decide to share your Callback class for Language <X> with anyone else...
// ##



// ##
// ## Mapper Configuration --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// ##


// ##
// ## Which Mapping Variant would you like to use? Each option going downward gives you everything of the level above and itself except for the USER which is for you to customize how you want.
// ##
// ## ENUM																	Class Name								Base Class				ClassDescription
// ## ENUM_LANG_XCODEMAPPERDEV						= SetupLangVariantMap( 'XCodeMapperBase',						'XCodeMapper_Python',	'XCodeMapper Development platform to test updates in real-time instead of restarting gmod. This is used to test major updates to the XCodeMapperBase Class!' )
// ENUM_LANG_PYTHON_VANILLA						= SetupLangVariantMap( 'XCodeMapper_Python',					'XCodeMapperBase', 		'Python - Standard Edition - This maps the following: ' )
// ENUM_LANG_PYTHON_ACECOOL_XCODEMAPPER			= SetupLangVariantMap( 'XCodeMapper_Python_Acecool_XCM',		'XCodeMapper_Python',	'Python - With the additional mappings to navigate through these scripts easily!' )
// ENUM_LANG_PYTHON_USER							= SetupLangVariantMap( 'XCodeMapper_Python_User',				'XCodeMapper_Python',	'Python - Everything you need to create your own extension - I added it to the end to make copying / pasting easier, for when this script updates. On Updates of this script, copy the relevent segments ( This, the config element below, and the class... That is it.. )!' )


// ## This option is the default and will add mappings for the Vanilla Language / Variant.
// CFG_XCODEMAPPER_MAPPER_VARIANT					= ENUM_LANG_PYTHON_VANILLA

// ## This mapper is specifically used to read XCodeMapper XCodeMapper Base, Definitions, Acecool ST3 Library, and code_map.<ext>.py files by creating mappings to show much more information.
// CFG_XCODEMAPPER_MAPPER_VARIANT					= ENUM_LANG_PYTHON_ACECOOL_XCODEMAPPER

// ## This option is for Greatly altering XCodeMapperBase
// ## CFG_XCODEMAPPER_MAPPER_VARIANT					= ENUM_LANG_XCODEMAPPERDEV

// ## This option is a blank Class usable as a template to create mappings for your own project. It is left at the end of the file to allow for easier processing of updates - when a new updates comes out, copy and paste the object to the new file..
// CFG_XCODEMAPPER_MAPPER_VARIANT					= ENUM_LANG_PYTHON_USER

only the default values are being output… Despite the py_xcodemapper_config.sublime-settings file being in the root directory ( easy to find ) in User/CodeMap/ under Packages… It does not load… And apparently I can’t use the exact path because that’s bad…

So how do I load it if I can’t use the exact path, and sublime text can’t find a uniquely named file in a root directory of an addon where user-files should exist?

Filename in code: py_xcodemapper_config.sublime-settings
Filename in explo:py_xcodemapper_config.sublime-settings

Identical…

	## For some reason the file isn't detected... This hould return True, True, "Python", "Alphabetically" - Instead the defaults are being returned and this is a problem!!!
	print( str( XCM_MAPPER_SETTINGS.get( 'DeveloperMode', False ) ) )
	print( str( XCM_MAPPER_SETTINGS.get( 'DebugMode', False ) ) )
	print( str( XCM_MAPPER_SETTINGS.get( 'LanguageName', False ) ) )
	print( str( XCM_MAPPER_SETTINGS.get( 'OutputSortMethod', 'A-Z' ) ) )

should print: True, True, “Python”, “Alphabetically” but prints False, False, False, “A-Z”…

Basically, I need project wide settings for many different languages… I currently support these languages and projects: Python, Python with XCodeMapper mappings, Lua, Garry’s Mod Lua / GMod Lua, GMod Lua with AcecoolDev_Framework mappings, AutoHotkey, JavaScript, JavaScript with AcecoolWeb_Framework mappings, Markdown, PHP ( infancy - still working on the settings so that I can add support for fallback languages - ie PHP files need to support PHP inside of php tags, HTML outside, JavaScript in Script tables, CSS in Style tags, and SQL in php tags in sql functions… Asp needs the same support ), TypeScript - All languages include a _User class to allow users to add their projects with a semi-easy way to ensure updates don’t mean they have to re-edit tons of files…

The problem is without the ability to add a settings file per language, I’m stuck with all of the classes per language stuck in one file ( otherwise I end up with circular imports or an ugly way to manage configuration )… By having a way to load configuration I have a way to specify the class so I can keep XCodeMapper an addon to CodeMap without editing their core files, so I can support multilingual files, and more…

0 Likes

#4

sublime.load_settings('file.sublime-settings') loads the file by finding all of the settings files with that name from within all packages and combining them all together in package load order into a single settings object.

When you call sublime.save_settings('file.sublime-settings'), the settings file that’s saved is always placed in the root of the User package.

Although the file can be anywhere you want in most packages, when it comes to the User package it has to be in the root of the package to be loaded, since that’s where it will get saved.

Hence, your code will work if you move the settings file to the root of the User package. If you want to be to stored in a CodeMap folder of a package, store it in a package other than User.

If you’re married to having the settings file in Packages/User/CodeMap/file.sublime-settings, you can manually load it:

>>> sublime.find_resources('py_xcodemapper_config.sublime-settings')
['Packages/User/CodeMap/py_xcodemapper_config.sublime-settings']
>>> data = sublime.load_resource('Packages/User/CodeMap/py_xcodemapper_config.sublime-settings')
>>> XCM_MAPPER_SETTINGS = sublime.decode_value(data)
>>> print( str( XCM_MAPPER_SETTINGS.get( 'DeveloperMode', False ) ) )
True
>>> print( str( XCM_MAPPER_SETTINGS.get( 'DebugMode', False ) ) )
True
>>> print( str( XCM_MAPPER_SETTINGS.get( 'LanguageName', False ) ) )
Python
>>> print( str( XCM_MAPPER_SETTINGS.get( 'OutputSortMethod', 'A-Z' ) ) )
Alphabetically

Note that if you do this and you want it to work like regular settings (i.e. to load all files by that name and merge them), then you will need to manually load all of the files that find_resources returns and merge them together yourself.

0 Likes

#5

Thanks… Yeah, I was hoping to keep it in the nested folder and not in the root folder… The problem with it being in the root directory is so many files would end up there and it wouldn’t be organized…

I want the option to read all of the data too to traverse it - since I am going to automatically create AccessorFuncs ( ideally ) using the settings - although if that isn’t possible, I doubt they’d make it impossible, then I can always make a list of string = string where index is the name and value is the setting tied to the default value ( when the function set is initializes )

Cheers - this does help :slight_smile:

I may end up putting the entire config into 1 file… then the default can be in the root and a nested table for each language can be added - where only the config which is changed from default needs to be edited for each language ( which was the plan anyway if I made multiple files with the non-changed data commented out ) …

0 Likes