You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Sereinme -- just wanted to share an update on MATLAB support. I had started to work on this, but ended up using regex to solve my limited issue. But wanted to share what I learned / fixed. I do NOT plan to revisit this to integrate, but this might help you.
SPM Resolution Fix
The tree-sitter-matlab package had an SPM resolution bug that prevented it from being added as a dependency. I filed an issue and PR upstream:
However, there's a significant challenge: both MATLAB and Objective-C use the .m extension. This will require content-based heuristics to disambiguate between them.
Tie-breaker: If both scores are 0, default to Objective-C (more common on macOS).
This would require extending the language detection logic in CodeLanguage+DetectLanguage.swift to handle this case, similar to how the codebase already handles shebang and modeline detection.
Activity
kkilchrist commentedon Dec 30, 2025
@Sereinme -- just wanted to share an update on MATLAB support. I had started to work on this, but ended up using regex to solve my limited issue. But wanted to share what I learned / fixed. I do NOT plan to revisit this to integrate, but this might help you.
SPM Resolution Fix
The
tree-sitter-matlabpackage had an SPM resolution bug that prevented it from being added as a dependency. I filed an issue and PR upstream:So the SPM blocker is now resolved!
.mExtension ConflictHowever, there's a significant challenge: both MATLAB and Objective-C use the
.mextension. This will require content-based heuristics to disambiguate between them.Here's a scoring approach we sketched out:
Objective-C Indicators
Definitive (50 points each):
#import/#includepreprocessor directives@interface,@implementation,@protocol,@endStrong (10-20 points):
@property,@synthesize,@dynamic(20)- (or+ ((20)[[...]]for message sending (15)@selector,@autoreleasepool,@synchronized,@try,@catch(15)@"..."(10)@YES,@NO,@[],@{}(10)^{or^((10)//(5)MATLAB Indicators
Definitive (50 points):
function result = name(args)at line startclassdef ClassNameat line startStrong (3-15 points):
%comments (8)elseif,parfor,spmd,persistent,global,arguments(15)@(args)(15).*,./,.^,.'(10)@functionName(8)[1 2; 3 4](8)~=or~(5)endkeyword (5)1:10(3){a, b}(3)Tie-breaker: If both scores are 0, default to Objective-C (more common on macOS).
This would require extending the language detection logic in
CodeLanguage+DetectLanguage.swiftto handle this case, similar to how the codebase already handles shebang and modeline detection.