Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | book/src/generated/lang-support.md | 1 | ||||
| -rw-r--r-- | languages.toml | 20 | ||||
| -rw-r--r-- | runtime/queries/luau/highlights.scm | 792 | ||||
| -rw-r--r-- | runtime/queries/luau/indents.scm | 126 | ||||
| -rw-r--r-- | runtime/queries/luau/injections.scm | 2 | ||||
| -rw-r--r-- | runtime/queries/luau/locals.scm | 25 | ||||
| -rw-r--r-- | runtime/queries/luau/textobjects.scm | 18 |
7 files changed, 984 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 360e1a62..ab5af300 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -139,6 +139,7 @@ | log | ✓ | | | | | lpf | ✓ | | | | | lua | ✓ | ✓ | ✓ | `lua-language-server` | +| luau | ✓ | ✓ | ✓ | `luau-lsp` | | mail | ✓ | ✓ | | | | make | ✓ | | ✓ | | | markdoc | ✓ | | | `markdoc-ls` | diff --git a/languages.toml b/languages.toml index 8488ed77..d08c1581 100644 --- a/languages.toml +++ b/languages.toml @@ -143,6 +143,7 @@ ember-language-server = { command = "ember-language-server", args = ["--stdio"] teal-language-server = { command = "teal-language-server" } wasm-language-tools = { command = "wat_server" } sourcepawn-studio = { command = "sourcepawn-studio" } +luau = { command = "luau-lsp", args = ["lsp"] } [language-server.ansible-language-server] command = "ansible-language-server" @@ -4403,3 +4404,22 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "alloy" source = { git = "https://github.com/mattsre/tree-sitter-alloy", rev = "3e18eb4e97f06c57a3925f3d20bef6329a6eaef3" } + +[[language]] +name = "luau" +scope = "source.luau" +injection-regex = "^luau$" +file-types = ["luau"] +comment-tokens = ["--", "---"] +block-comment-tokens = [ + {start = "--[[", end = "]]"}, + {start = "--[=[", end = "]=]"}, + {start = "--[==[", end = "]==]"} +] +indent = { tab-width = 2, unit = " "} +roots = [ "aftman.toml", "default.project.json", "wally.toml", "rokit.toml", "selene.toml", ".darklua.json", "foreman.toml", ".luaurc" ] +language-servers = [ "luau" ] + +[[grammar]] +name = "luau" +source = { git = "https://github.com/polychromatist/tree-sitter-luau", rev = "ec187cafba510cddac265329ca7831ec6f3b9955" } diff --git a/runtime/queries/luau/highlights.scm b/runtime/queries/luau/highlights.scm new file mode 100644 index 00000000..0bbc3549 --- /dev/null +++ b/runtime/queries/luau/highlights.scm @@ -0,0 +1,792 @@ +"return" @keyword.control.return + +"local" @keyword.storage.modifier + +"type" @keyword.storage.type + +"function" @keyword.function + +(break_stmt) @keyword.control +(continue_stmt) @keyword.control +(readwrite) @keyword.storage.modifier + +[ + "do" + "end" +] @keyword + +[ + "while" + "repeat" + "until" + "for" +] @keyword.control.repeat + +[ + "if" + "elseif" + "else" + "then" +] @keyword.control.conditional + +[ + "in" + "and" + "or" + "not" +] @keyword.operator + +(ifexp +[ + "if" + "then" + "elseif" + "else" +] @keyword.operator) + +(type_stmt "export" @keyword.control.import) + +(_ + operator: [ + "+" "-" "*" "/" "//" "%" + "^" "#" "==" "~=" "<=" ">=" + "<" ">" "&" "|" "->" "::" + ".." + ] @operator +) + +(_ + assign_symbol: [ + "=" "+=" "-=" "*=" "/=" "//=" + "%=" "^=" "..=" + ] @operator +) + +[ + ";" + ":" + "," + "." +] @punctuation.delimiter + +(string) @string + +(_ + variable_name: (name) @variable +) + +(_ + parameter_name: (name) @variable.parameter +) + +(_ + method_name: (name) @function.method +) + +(_ + function_name: (name) @function +) + +(_ + table_name: (name) @namespace +) + +(_ + field_name: (name) @variable.other.member +) + +(table +[ + "{" + "}" +] @constructor) + +; special comment directives +(chunk + . + (comment)* + . + (comment) @keyword.directive + (#match? @keyword.directive "^--!(strict|native)[\r]?$") +) + +(comment) @comment + +(number) @constant.numeric + +(unicode_escape + "{" @punctuation.special + "codepoint" @constant.numeric.integer + "}" @punctuation.special +) +(unicode_escape) @constant.character.escape +(dec_byte_escape) @constant.character.escape +(hex_byte_escape) @constant.character.escape +(simple_escape) @constant.character.escape + +(interp_start) @punctuation.special +(interp_content) @string +(interp_brace_open) @punctuation.special +(interp_brace_close) @punctuation.special +(interp_end) @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +(_ + type_name: (name) @type +) + +(type_stmt + left: (name) @type +) + +(_ + attribute_name: (name) @attribute +) + +(exp + (vararg) @constant +) + +(nil) @constant.builtin + +(boolean) @constant.builtin.boolean + +(_ + generic_type_name: (name) @type.parameter +) + +(_ + generic_typepack_name: (name) @type.parameter +) + +(dyntype + "typeof" @keyword.directive +) + +(_ + module_namespace: (name) @namespace +) + +; if the value of the field is a function, then +; color the name of a field assignment as a method +(field + field_name: (name) @function.method + value: (anon_fn) +) + +; if a call statement is an invocation on a variable, +; color the last name in a name sequence as a function +(call_stmt + invoked: (var + variable_name: (name) @function + ) +) + +(call_stmt + invoked: (var + table_name: (name) @namespace + (key + field_name: (name) @function + ) + . + ) +) + +(call_stmt + invoked: (_ + (key + field_name: (name) @function + ) + . + ) +) + +(fn_stmt + (key + field_name: (name) @function.method + ) + . + (paramlist)? +) + +(_ + type_name: (name) @type.builtin + (#any-of? @type.builtin + "number" "string" "any" + "never" "unknown" "boolean" + "thread" "userdata" "Accessory" + "Accoutrement" "Actor" "AdGui" + "AdPortal" "AdService" "AdvancedDragger" + "AirController" "AlignOrientation" "AlignPosition" + "AnalysticsSettings" "AnalyticsService" "AngularVelocity" + "Animation" "AnimationClip" "AnimationClipProvider" + "AnimationController" "AnimationFromVideoCreatorService" "AnimationFromVideoCreatorStudioService" + "AnimationRigData" "AnimationStreamTrack" "AnimationTrack" + "Animator" "AppStorageService" "AppUpdateService" + "ArcHandles" "AssetCounterService" "AssetDeliveryProxy" + "AssetImportService" "AssetImportSession" "AssetManagerService" + "AssetService" "AssetSoundEffect" "Atmosphere" + "Attachment" "AvatarEditorService" "AvatarImportService" + "Axes" "Backpack" "BackpackItem" + "BadgeService" "BallSocketConstraint" "BasePart" + "BasePlayerGui" "BaseScript" "BaseWrap" + "Beam" "BillboardGui" "BinaryStringValue" + "BindableEvent" "BindableFunction" "BloomEffect" + "BlurEffect" "BodyAngularVelocity" "BodyColors" + "BodyForce" "BodyGyro" "BodyMover" + "BodyPosition" "BodyThrust" "BodyVelocity" + "Bone" "BoolValue" "BoxHandleAdornment" + "Breakpoint" "BrickColor" "BrickColorValue" + "BrowserService" "BubbleChatConfiguration" "BulkImportService" + "CFrame" "CFrameValue" "CSGDictionaryService" + "CacheableContentProvider" "CalloutService" "Camera" + "CanvasGroup" "CatalogPages" "CatalogSearchParams" + "ChangeHistoryService" "ChannelSelectorSoundEffect" "CharacterAppearance" + "CharacterMesh" "Chat" "ChatInputBarConfiguration" + "ChatWindowConfiguration" "ChorusSoundEffect" "ClickDetector" + "ClientReplicator" "ClimbController" "Clothing" + "CloudLocalizationTable" "Clouds" "ClusterPacketCache" + "CollectionService" "Color3" "ColorCorrectionEffect" + "ColorSequence" "ColorSequenceKeypoint" "CommandInstance" + "CommandService" "CompressorSoundEffect" "ConeHandleAdornment" + "Configuration" "ConfigureServerService" "Constraint" + "Content" "ContentProvider" "ContextActionService" + "Controller" "ControllerBase" "ControllerManager" + "ControllerService" "CookiesService" "CoreGui" + "CorePackages" "CoreScript" "CoreScriptSyncService" + "CornerWedgePart" "CrossDMScriptChangeListener" "CurveAnimation" + "CustomSoundEffect" "CylinderHandleAdornment" "CylindricalConstraint" + "DataModel" "DataModelMesh" "DataModelPatchService" + "DataModelSession" "DataStore" "DataStoreIncrementOptions" + "DataStoreInfo" "DataStoreKey" "DataStoreKeyInfo" + "DataStoreKeyPages" "DataStoreListingPages" "DataStoreObjectVersionInfo" + "DataStoreOptions" "DataStorePages" "DataStoreService" + "DataStoreSetOptions" "DataStoreVersionPages" "DateTime" + "Debris" "DebugSettings" "DebuggablePluginWatcher" + "DebuggerBreakpoint" "DebuggerConnection" "DebuggerConnectionManager" + "DebuggerLuaResponse" "DebuggerManager" "DebuggerUIService" + "DebuggerVariable" "DebuggerWatch" "Decal" + "DepthOfFieldEffect" "DeviceIdService" "Dialog" + "DialogChoice" "DistortionSoundEffect" "DockWidgetPluginGui" + "DockWidgetPluginGuiInfo" "DraftsService" "Dragger" + "DraggerService" "DynamicRotate" "EchoSoundEffect" + "EditableImage" "EditableMesh" "EmotesPages" + "Enum" "EnumItem" "Enums" + "EqualizerSoundEffect" "EulerRotationCurve" "EventIngestService" + "ExperienceInviteOptions" "Explosion" "FaceAnimatorService" + "FaceControls" "FaceInstance" "Faces" + "FacialAnimationRecordingService" "FacialAnimationStreamingService" "Feature" + "File" "FileMesh" "Fire" + "FlagStandService" "FlangeSoundEffect" "FloatCurve" + "FlyweightService" "Folder" "Font" + "ForceField" "FormFactorPart" "Frame" + "FriendPages" "FriendService" "GamePassService" + "GameSettings" "GamepadService" "GenericSettings" + "Geometry" "GetTextBoundsParams" "GlobalDataStore" + "GlobalSettings" "GoogleAnalyticsConfiguration" "GroundController" + "GroupService" "GuiBase" "GuiButton" + "GuiLabel" "GuiObject" "GuiService" + "GuidRegistryService" "HSRDataContentProvider" "HandleAdornment" + "Handles" "HandlesBase" "HapticService" + "HeightmapImporterService" "HiddenSurfaceRemovalAsset" "Highlight" + "HingeConstraint" "HttpRbxApiService" "HttpRequest" + "HttpService" "Humanoid" "HumanoidController" + "HumanoidDescription" "IKControl" "ILegacyStudioBridge" + "IXPService" "ImageButton" "ImageHandleAdornment" + "ImageLabel" "ImporterAnimationSettings" "ImporterBaseSettings" + "ImporterFacsSettings" "ImporterGroupSettings" "ImporterJointSettings" + "ImporterMaterialSettings" "ImporterMeshSettings" "ImporterRootSettings" + "IncrementalPatchBuilder" "InputObject" "InsertService" + "Instance" "InstanceAdornment" "IntValue" + "InventoryPages" "JointInstance" "KeyboardService" + "Keyframe" "KeyframeMarker" "KeyframeSequence" + "KeyframeSequenceProvider" "LSPFileSyncService" "LanguageService" + "LayerCollector" "LegacyStudioBridge" "Light" + "Lighting" "LineForce" "LineHandleAdornment" + "LinearVelocity" "LocalDebuggerConnection" "LocalScript" + "LocalStorageService" "LocalizationService" "LocalizationTable" + "LodDataEntity" "LodDataService" "LogService" + "LoginService" "LuaSettings" "LuaSourceContainer" + "LuaWebService" "LuauScriptAnalyzerService" "MarkerCurve" + "MarketplaceService" "MaterialService" "MaterialVariant" + "MemStorageConnection" "MemStorageService" "MemoryStoreQueue" + "MemoryStoreService" "MemoryStoreSortedMap" "MeshContentProvider" + "MeshPart" "MessageBusConnection" "MessageBusService" + "MessagingService" "MetaBreakpoint" "MetaBreakpointContext" + "MetaBreakpointManager" "Model" "ModuleScript" + "Motor" "Mouse" "MouseService" + "MultipleDocumentInterfaceInstance" "NegateOperation" "NetworkClient" + "NetworkMarker" "NetworkPeer" "NetworkReplicator" + "NetworkServer" "NetworkSettings" "NoCollisionConstraint" + "NonReplicatedCSGDictionaryService" "NotificationService" "NumberPose" + "NumberRange" "NumberSequence" "NumberSequenceKeypoint" + "NumberValue" "Object" "ObjectValue" + "OrderedDataStore" "OutfitPages" "OverlapParams" + "PVAdornment" "PVInstance" "PackageLink" + "PackageService" "PackageUIService" "Pages" + "Pants" "ParabolaAdornment" "Part" + "PartAdornment" "PartOperation" "PartOperationAsset" + "ParticleEmitter" "PatchMapping" "Path" + "PathWaypoint" "PathfindingLink" "PathfindingModifier" + "PathfindingService" "PausedState" "PausedStateBreakpoint" + "PausedStateException" "PermissionsService" "PhysicalProperties" + "PhysicsService" "PhysicsSettings" "PitchShiftSoundEffect" + "PlaneConstraint" "Platform" "Player" + "PlayerEmulatorService" "PlayerGui" "PlayerMouse" + "PlayerScripts" "Players" "Plugin" + "PluginAction" "PluginDebugService" "PluginDragEvent" + "PluginGui" "PluginGuiService" "PluginManagementService" + "PluginManager" "PluginManagerInterface" "PluginMenu" + "PluginMouse" "PluginPolicyService" "PluginToolbar" + "PluginToolbarButton" "PointLight" "PolicyService" + "Pose" "PoseBase" "PostEffect" + "PrismaticConstraint" "ProcessInstancePhysicsService" "ProximityPrompt" + "ProximityPromptService" "PublishService" "QWidgetPluginGui" + "RBXScriptConnection" "Random" "Ray" + "RayValue" "RaycastParams" "RaycastResult" + "RbxAnalyticsService" "Rect" "ReflectionMetadata" + "ReflectionMetadataCallbacks" "ReflectionMetadataClass" "ReflectionMetadataClasses" + "ReflectionMetadataEnum" "ReflectionMetadataEnumItem" "ReflectionMetadataEnums" + "ReflectionMetadataEvents" "ReflectionMetadataFunctions" "ReflectionMetadataItem" + "ReflectionMetadataMember" "ReflectionMetadataProperties" "ReflectionMetadataYieldFunctions" + "Region3" "Region3int16" "RemoteDebuggerServer" + "RemoteEvent" "RemoteFunction" "RenderSettings" + "RenderingTest" "ReplicatedFirst" "ReplicatedStorage" + "ReverbSoundEffect" "RigidConstraint" "RobloxPluginGuiService" + "RobloxReplicatedStorage" "RodConstraint" "RopeConstraint" + "RotationCurve" "RtMessagingService" "RunService" + "RunningAverageItemDouble" "RunningAverageItemInt" "RunningAverageTimeIntervalItem" + "RuntimeScriptService" "ScreenGui" "ScreenshotHud" + "Script" "ScriptChangeService" "ScriptCloneWatcher" + "ScriptCloneWatcherHelper" "ScriptContext" "ScriptDebugger" + "ScriptDocument" "ScriptEditorService" "ScriptRegistrationService" + "ScriptService" "ScrollingFrame" "Seat" + "Selection" "SelectionBox" "SelectionLasso" + "SelectionSphere" "ServerReplicator" "ServerScriptService" + "ServerStorage" "ServiceProvider" "SessionService" + "Shirt" "ShirtGraphic" "SkateboardController" + "Sky" "SlidingBallConstraint" "Smoke" + "SnippetService" "SocialService" "SolidModelContentProvider" + "Sound" "SoundEffect" "SoundGroup" + "SoundService" "Sparkles" "SpawnLocation" + "SpawnerService" "SpecialMesh" "SphereHandleAdornment" + "SpotLight" "SpringConstraint" "StackFrame" + "StandalonePluginScripts" "StandardPages" "StarterCharacterScripts" + "StarterGear" "StarterGui" "StarterPack" + "StarterPlayer" "StarterPlayerScripts" "Stats" + "StatsItem" "StopWatchReporter" "StringValue" + "Studio" "StudioAssetService" "StudioData" + "StudioDeviceEmulatorService" "StudioHighDpiService" "StudioPublishService" + "StudioScriptDebugEventListener" "StudioService" "StudioTheme" + "SunRaysEffect" "SurfaceAppearance" "SurfaceGui" + "SurfaceGuiBase" "SurfaceLight" "SurfaceSelection" + "SwimController" "TaskScheduler" "Team" + "TeamCreateService" "Teams" "TeleportAsyncResult" + "TeleportOptions" "TeleportService" "TemporaryCageMeshProvider" + "TemporaryScriptService" "Terrain" "TerrainDetail" + "TerrainRegion" "TestService" "TextBox" + "TextBoxService" "TextButton" "TextChannel" + "TextChatCommand" "TextChatConfigurations" "TextChatMessage" + "TextChatMessageProperties" "TextChatService" "TextFilterResult" + "TextLabel" "TextService" "TextSource" + "Texture" "ThirdPartyUserService" "ThreadState" + "TimerService" "ToastNotificationService" "Tool" + "Torque" "TorsionSpringConstraint" "TotalCountTimeIntervalItem" + "TouchInputService" "TouchTransmitter" "TracerService" + "TrackerLodController" "TrackerStreamAnimation" "Trail" + "Translator" "TremoloSoundEffect" "TriangleMeshPart" + "TrussPart" "Tween" "TweenBase" + "TweenInfo" "TweenService" "UDim" + "UGCValidationService" "UIAspectRatioConstraint" "UIBase" + "UIComponent" "UIConstraint" "UICorner" + "UIGradient" "UIGridLayout" "UIGridStyleLayout" + "UILayout" "UIListLayout" "UIPadding" + "UIPageLayout" "UIScale" "UISizeConstraint" + "UIStroke" "UITableLayout" "UITextSizeConstraint" + "UnionOperation" "UniversalConstraint" "UnreliableRemoteEvent" + "UnvalidatedAssetService" "UserGameSettings" "UserInputService" + "UserService" "UserSettings" "UserStorageService" + "VRService" "ValueBase" "Vector2" + "Vector2int16" "Vector3" "Vector3int16" + "VectorForce" "VehicleController" "VehicleSeat" + "VelocityMotor" "VersionControlService" "VideoCaptureService" + "VideoFrame" "ViewportFrame" "VirtualInputManager" + "VirtualUser" "VisibilityService" "Visit" + "VoiceChannel" "VoiceChatInternal" "VoiceChatService" + "WedgePart" "Weld" "WeldConstraint" + "WireframeHandleAdornment" "Workspace" "WorldModel" + "WorldRoot" "WrapLayer" "WrapTarget" + ) +) + +(var + variable_name: (name) @function.builtin + (#any-of? @function.builtin + "assert" "collectgarbage" "elapsedTime" + "error" "gcinfo" "getfenv" + "getmetatable" "ipairs" "loadstring" + "next" "newproxy" "pairs" + "pcall" "PluginManager" "print" + "printidentity" "rawequal" "rawget" + "rawlen" "rawset" "require" + "select" "setfenv" "setmetatable" + "spawn" "tick" "time" + "tonumber" "tostring" "type" + "typeof" "unpack" "UserSettings" + "version" "warn" "workspace" + "xpcall") +) + +(var + . + (name) @variable.builtin + (#any-of? @variable.builtin + "_G" "_VERSION" "bit32" + "coroutine" "debug" "game" + "math" "os" "plugin" + "script" "string" "table" + "task" "utf8" "workspace" + ) +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "bit32") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "arshift" "lrotate" "lshift" "replace" + "rrotate" "rshift" "btest" "bxor" + "band" "bnot" "bor" "countlz" + "countrz" "extract" "byteswap" + ) + )? +) + +(_ table_name: + (name) @variable.builtin + (#eq? @variable.builtin "coroutine") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "close" "create" "isyieldable" + "resume" "running" "status" + "wrap" "yield" + ) + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "debug") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "info" "traceback" "profilebegin" + "profileend" "resetmemorycategory" "setmemorycategory" + "dumpcodesize" + ) + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "math") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "abs" "acos" "asin" + "atan" "atan2" "ceil" + "clamp" "cos" "cosh" + "deg" "exp" "floor" + "fmod" "frexp" "ldexp" + "log" "log10" "max" + "min" "modf" "noise" + "pow" "rad" "random" + "randomseed" "round" "sign" + "sin" "sinh" "sqrt" + "tan" "tanh" + ) + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "math") + . + (key + field_name: (name) @constant.builtin + ; (#match? @constant.builtin "^(huge|pi)$") + (#any-of? @constant.builtin "huge" "pi") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "os") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "clock" "date" "difftime" + "time") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "string") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "byte" "char" "find" + "format" "gmatch" "gsub" + "len" "lower" "match" + "pack" "packsize" "rep" + "reverse" "split" "sub" + "unpack" "upper") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "table") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "create" "clear" "clone" + "concat" "foreach" "foreachi" + "find" "freeze" "getn" + "insert" "isfrozen" "maxn" + "move" "pack" "remove" + "sort" "unpack") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "task") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "cancel" "defer" "delay" + "synchronize" "desynchronize" "spawn" + "wait") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "utf8") + . + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "char" "codepoint" "codes" + "graphemes" "len" "offset" + "nfcnormalize" "nfdnormalize") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "utf8") + . + (key + field_name: (name) @constant.builtin + (#eq? @constant.builtin "charpattern") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "buffer") + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "create" "fromstring" "tostring" + "len" "copy" "fill" + "readi8" "readu8" "readi16" + "readu16" "readi32" "readu32" + "readf32" "readf64" "writei8" + "writeu8" "writei16" "writeu16" + "writei32" "writeu32" "writef32" + "writef64" "readstring" "writestring") + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "vector") + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "create" "magnitude" "normalize" + "cross" "dot" "angle" + "floor" "ceil" "abs" + "sign" "clamp" "max" + "min" + ) + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "vector") + (key + field_name: (name) @constant.builtin + (#any-of? @constant.builtin + "zero" "one" + ) + )? +) + +(_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "Content") + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "fromUri" "fromAssetId" "fromObject" + ) + )? +) + +(type_fn_stmt + body: (_ + [ + (_ + variable_name: (name) @variable.builtin + (#eq? @variable.builtin "types") + ) + (_ + table_name: (name) @variable.builtin + (#eq? @variable.builtin "types") + (key + field_name: (name) @function.builtin + (#any-of? @function.builtin + "" + ) + ) + ) + ] + ) +) + +(call_stmt + method_table: (var + (name) @variable.builtin + (#eq? @variable.builtin "game") + ) + method_name: (name) @function.builtin + (#eq? @function.builtin "GetService") + (arglist + . + (string)? @string.special + (#any-of? @string.special + "\"AccountService\"" "\"AchievementService\"" "\"AdService\"" + "\"AnalyticsService\"" "\"AnimationClipProvider\"" "\"AnimationFromVideoCreatorService\"" + "\"AnimationFromVideoCreatorStudioService\"" "\"AnnotationsService\"" "\"AppLifecycleObserverService\"" + "\"AppUpdateService\"" "\"AssetCounterService\"" "\"AssetDeliveryProxy\"" + "\"AssetImportService\"" "\"AssetManagerService\"" "\"AssetService\"" + "\"AudioFocusService\"" "\"AvatarChatService\"" "\"AvatarCreationService\"" + "\"AvatarEditorService\"" "\"AvatarImportService\"" "\"BadgeService\"" + "\"CoreGui\"" "\"StarterGui\"" "\"BrowserService\"" + "\"BulkImportService\"" "\"CacheableContentProvider\"" "\"HSRDataContentProvider\"" + "\"MeshContentProvider\"" "\"SolidModelContentProvider\"" "\"CalloutService\"" + "\"CaptureService\"" "\"ChangeHistoryService\"" "\"Chat\"" + "\"ChatbotUIService\"" "\"CloudCRUDService\"" "\"ClusterPacketCache\"" + "\"CollaboratorsService\"" "\"CollectionService\"" "\"CommandService\"" + "\"CommerceService\"" "\"ConfigureServerService\"" "\"ConnectivityService\"" + "\"ContentProvider\"" "\"ContextActionService\"" "\"ControllerService\"" + "\"ConversationalAIAcceptanceService\"" "\"CookiesService\"" "\"CorePackages\"" + "\"CoreScriptDebuggingManagerHelper\"" "\"CoreScriptSyncService\"" "\"CreationDBService\"" + "\"CreatorStoreService\"" "\"CrossDMScriptChangeListener\"" "\"DataModelPatchService\"" + "\"DataStoreService\"" "\"Debris\"" "\"DebuggablePluginWatcher\"" + "\"DebuggerConnectionManager\"" "\"DebuggerManager\"" "\"DebuggerUIService\"" + "\"DeviceIdService\"" "\"DraftsService\"" "\"DraggerService\"" + "\"EditableService\"" "\"EventIngestService\"" "\"ExampleService\"" + "\"ExperienceAuthService\"" "\"ExperienceNotificationService\"" "\"ExperienceService\"" + "\"ExperienceStateCaptureService\"" "\"FaceAnimatorService\"" "\"FacialAnimationRecordingService\"" + "\"FacialAnimationStreamingServiceV2\"" "\"FlagStandService\"" "\"FlyweightService\"" + "\"CSGDictionaryService\"" "\"NonReplicatedCSGDictionaryService\"" "\"FriendService\"" + "\"GamePassService\"" "\"GamepadService\"" "\"GenericChallengeService\"" + "\"Geometry\"" "\"GeometryService\"" "\"GoogleAnalyticsConfiguration\"" + "\"GroupService\"" "\"GuiService\"" "\"GuidRegistryService\"" + "\"HapticService\"" "\"HeatmapService\"" "\"HeightmapImporterService\"" + "\"Hopper\"" "\"HttpRbxApiService\"" "\"HttpService\"" + "\"ILegacyStudioBridge\"" "\"LegacyStudioBridge\"" "\"IXPService\"" + "\"IncrementalPatchBuilder\"" "\"InsertService\"" "\"InternalSyncService\"" + "\"JointsService\"" "\"KeyboardService\"" "\"KeyframeSequenceProvider\"" + "\"LSPFileSyncService\"" "\"LanguageService\"" "\"Lighting\"" + "\"LinkingService\"" "\"LiveScriptingService\"" "\"LocalStorageService\"" + "\"AppStorageService\"" "\"UserStorageService\"" "\"LocalizationService\"" + "\"LodDataService\"" "\"LogReporterService\"" "\"LogService\"" + "\"LoginService\"" "\"LuaWebService\"" "\"LuauScriptAnalyzerService\"" + "\"MarketplaceService\"" "\"MaterialGenerationService\"" "\"MaterialService\"" + "\"MemStorageService\"" "\"MemoryStoreService\"" "\"MessageBusService\"" + "\"MessagingService\"" "\"MetaBreakpointManager\"" "\"MouseService\"" + "\"NetworkClient\"" "\"NetworkServer\"" "\"NetworkSettings\"" + "\"NotificationService\"" "\"OmniRecommendationsService\"" "\"OpenCloudService\"" + "\"Workspace\"" "\"PackageService\"" "\"PackageUIService\"" + "\"PatchBundlerFileWatch\"" "\"PathfindingService\"" "\"PermissionsService\"" + "\"PhysicsService\"" "\"PlaceStatsService\"" "\"PlacesService\"" + "\"PlatformCloudStorageService\"" "\"PlatformFriendsService\"" "\"PlayerEmulatorService\"" + "\"PlayerHydrationService\"" "\"PlayerViewService\"" "\"Players\"" + "\"PluginDebugService\"" "\"PluginGuiService\"" "\"PluginManagementService\"" + "\"PluginPolicyService\"" "\"PointsService\"" "\"PolicyService\"" + "\"ProcessInstancePhysicsService\"" "\"ProximityPromptService\"" "\"PublishService\"" + "\"RbxAnalyticsService\"" "\"ReflectionService\"" "\"RemoteCursorService\"" + "\"RemoteDebuggerServer\"" "\"RenderSettings\"" "\"ReplicatedFirst\"" + "\"ReplicatedStorage\"" "\"RibbonNotificationService\"" "\"RobloxPluginGuiService\"" + "\"RobloxReplicatedStorage\"" "\"RobloxServerStorage\"" "\"RomarkRbxAnalyticsService\"" + "\"RomarkService\"" "\"RtMessagingService\"" "\"RunService\"" + "\"RuntimeScriptService\"" "\"SafetyService\"" "\"ScriptChangeService\"" + "\"ScriptCloneWatcher\"" "\"ScriptCloneWatcherHelper\"" "\"ScriptCommitService\"" + "\"ScriptContext\"" "\"ScriptEditorService\"" "\"ScriptProfilerService\"" + "\"ScriptRegistrationService\"" "\"ScriptService\"" "\"Selection\"" + "\"SelectionHighlightManager\"" "\"ServerScriptService\"" "\"ServerStorage\"" + "\"ServiceVisibilityService\"" "\"SessionService\"" "\"SharedTableRegistry\"" + "\"ShorelineUpgraderService\"" "\"SmoothVoxelsUpgraderService\"" "\"SnippetService\"" + "\"SocialService\"" "\"SoundService\"" "\"SpawnerService\"" + "\"StartPageService\"" "\"StarterPack\"" "\"StarterPlayer\"" + "\"StartupMessageService\"" "\"Stats\"" "\"StopWatchReporter\"" + "\"StreamingService\"" "\"Studio\"" "\"StudioAssetService\"" + "\"StudioData\"" "\"StudioDeviceEmulatorService\"" "\"StudioPublishService\"" + "\"StudioScriptDebugEventListener\"" "\"StudioSdkService\"" "\"StudioService\"" + "\"StudioUserService\"" "\"StudioWidgetsService\"" "\"StylingService\"" + "\"TaskScheduler\"" "\"TeamCreateData\"" "\"TeamCreatePublishService\"" + "\"TeamCreateService\"" "\"Teams\"" "\"TeleportService\"" + "\"TemporaryCageMeshProvider\"" "\"TemporaryScriptService\"" "\"TestService\"" + "\"TextBoxService\"" "\"TextChatService\"" "\"TextService\"" + "\"TextureGenerationService\"" "\"ThirdPartyUserService\"" "\"TimerService\"" + "\"ToastNotificationService\"" "\"TouchInputService\"" "\"TracerService\"" + "\"TutorialService\"" "\"TweenService\"" "\"UGCAvatarService\"" + "\"UGCValidationService\"" "\"UIDragDetectorService\"" "\"UnvalidatedAssetService\"" + "\"UserInputService\"" "\"UserService\"" "\"VRService\"" + "\"VRStatusService\"" "\"VersionControlService\"" "\"VideoCaptureService\"" + "\"VideoService\"" "\"VirtualInputManager\"" "\"VirtualUser\"" + "\"VisibilityCheckDispatcher\"" "\"Visit\"" "\"VisualizationModeService\"" + "\"VoiceChatInternal\"" "\"VoiceChatService\"" "\"WebViewService\"" + ) + . + ) +) + diff --git a/runtime/queries/luau/indents.scm b/runtime/queries/luau/indents.scm new file mode 100644 index 00000000..06414742 --- /dev/null +++ b/runtime/queries/luau/indents.scm @@ -0,0 +1,126 @@ +[ + (repeat_stmt) + (for_in_stmt) + (for_range_stmt) + (do_stmt) + (while_stmt) + (if_stmt) + ; (else_clause) + ; (elseif_clause) + (fn_stmt) + (local_fn_stmt) + (anon_fn) + (bindinglist) + (varlist) + (paramlist) + (paramtypelist) + (table) + (cast) + (tbtype) + (dyntype) + (bintype) + (wraptype) + (typepack) + (attribute) + (parattr) + (littable) +] @indent + +( + [ + (arglist) + ] @indent + (#set! "scope" "all") +) + +( + [ + (explist) + (interp_exp) + ] @indent.always + (#set! "scope" "all") +) + +[ + "until" + "end" + ")" + "}" + "]" +] @outdent + +[ + (interp_brace_close) +] @outdent.always + +(ret_stmt + "return" @expr-start + . + (_) @indent + (#not-same-line? @indent @expr-start) + (#set! "scope" "all") +) + +(field + "[" @expr-start + . + field_indexer: (_) @indent + (#not-same-line? @expr-start @indent) + (#set! "scope" "all") +) + +(_ + (_) @expr-start + . + assign_symbol: _ @indent + . + (_) @expr-end + (#not-same-line? @indent @expr-start) + (#same-line? @expr-end @indent) + (#set! "scope" "all") +) + +(_ + (_) @expr-start + . + assign_symbol: _ @assign-sym + . + (_) @indent + (#same-line? @expr-start @assign-sym) + (#not-same-line? @assign-sym @indent) + (#set! "scope" "all") +) + +(ifexp + [ + "if" + "then" + "elseif" + "else" + ] @expr-start + . + (_) @indent.always + (#set! "scope" "all") + (#not-same-line? @indent.always @expr-start) +) + +(fntype + (paramtypelist) @expr-start + return_type: (_) @indent + (#not-same-line? @expr-start @indent) + (#set! "scope" "all") +) + +(exp_wrap + (_) @expr-content + (#not-same-line? @indent @expr-content) + (#not-kind-eq? @expr-content "ifexp") +) @indent + +(else_clause + "else" @outdent +) + +(elseif_clause + "elseif" @outdent +) diff --git a/runtime/queries/luau/injections.scm b/runtime/queries/luau/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/luau/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/luau/locals.scm b/runtime/queries/luau/locals.scm new file mode 100644 index 00000000..484d824d --- /dev/null +++ b/runtime/queries/luau/locals.scm @@ -0,0 +1,25 @@ +[ + (block) + (fn_stmt) + (local_fn_stmt) + (anon_fn) + (for_range_stmt) + (for_in_stmt) +] @local.scope + +(_ + parameter_name: (name) @local.definition.variable.parameter +) + +(binding + variable_name: (name) @local.definition.variable +) + +(var + variable_name: (name) @local.reference +) + +; (call_stmt +; . +; method_table: (name) @local.reference +; ) diff --git a/runtime/queries/luau/textobjects.scm b/runtime/queries/luau/textobjects.scm new file mode 100644 index 00000000..c270facc --- /dev/null +++ b/runtime/queries/luau/textobjects.scm @@ -0,0 +1,18 @@ +(fn_stmt + body: (_)? @function.inside) @function.around + +(local_fn_stmt + body: (_)? @function.inside) @function.around + +(anon_fn + body: (_)? @function.inside) @function.around + +(param + ((name) @parameter.inside . ","? @parameter.around) @parameter.around) + +(arglist + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(comment) @comment.inside + +(comment)+ @comment.around |