lua.code-snippets 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {
  2. // Place your snippets for lua here. Each snippet is defined under a snippet name and has a prefix, body and
  3. // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  4. // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
  5. // same ids are connected.
  6. // Example:
  7. // "Print to console": {
  8. // "prefix": "log",
  9. // "body": [
  10. // "console.log('$1');",
  11. // "$2"
  12. // ],
  13. // "description": "Log output to console"
  14. // }
  15. "Create a path variable": {
  16. "prefix": "p",
  17. "body": [
  18. "local ${1:pathname} = ${2:basepath}.${1}"
  19. ]
  20. },
  21. "Require a library from a variable": {
  22. "prefix": "rv",
  23. "body": [
  24. "local ${1:ModuleName} = require(${2:variable})"
  25. ]
  26. },
  27. "Require a library from a path": {
  28. "prefix": "r",
  29. "body": [
  30. "local ${1:ModuleName} = require(${2:path}.${1})"
  31. ]
  32. },
  33. "Globals used by most scripts": {
  34. "prefix": "g",
  35. "body": [
  36. "local ReplicatedStorage = game:GetService(\"ReplicatedStorage\")",
  37. "",
  38. "local common = ReplicatedStorage.common",
  39. "local lib = ReplicatedStorage.lib",
  40. "",
  41. ]
  42. },
  43. "Players service": {
  44. "prefix": "ps",
  45. "body": [
  46. "local Players = game:GetService(\"Players\")",
  47. "",
  48. ]
  49. },
  50. "LocalPlayer": {
  51. "prefix": "lp",
  52. "body": [
  53. "local LocalPlayer = Players.LocalPlayer",
  54. "",
  55. ]
  56. },
  57. ":WaitForChild(...)": {
  58. "prefix": "wfc",
  59. "body": [
  60. ":WaitForChild(\"${1:child}\")"
  61. ]
  62. },
  63. ":FindFirstChild(...)": {
  64. "prefix": "ffc",
  65. "body": [
  66. ":FindFirstChild(\"${1:child}\")"
  67. ]
  68. },
  69. "Create a new instance variable with :WaitForChild": {
  70. "prefix": "iwfc",
  71. "body": [
  72. "local ${1:identifier} = ${2:basepath}:WaitForChild(\"${3:child}\")"
  73. ]
  74. },
  75. "Create a new instance variable with :FindFirstChild": {
  76. "prefix": "iffc",
  77. "body": [
  78. "local ${1:identifier} = ${2:basepath}:FindFirstChild(\"${3:child}\")"
  79. ]
  80. },
  81. "Require Roact": {
  82. "prefix": "rct",
  83. "body": [
  84. "local Roact = require(lib.Roact)",
  85. "",
  86. ]
  87. },
  88. "Require Rodux": {
  89. "prefix": "rdx",
  90. "body": [
  91. "local Rodux = require(lib.Rodux)",
  92. "",
  93. ]
  94. },
  95. "Require RoactRodux": {
  96. "prefix": "rctrdx",
  97. "body": [
  98. "local RoactRodux = require(lib.RoactRodux)",
  99. "",
  100. ]
  101. },
  102. "Create stateful component": {
  103. "prefix": "rcc",
  104. "body": [
  105. "local ${1:MyComponent} = Roact.Component:extend(\"${1}\")",
  106. "",
  107. "function ${1}:init()",
  108. "end",
  109. "",
  110. "function ${1}:didMount()",
  111. "end",
  112. "",
  113. "function ${1}:render()",
  114. "\t$0",
  115. "end",
  116. "",
  117. "return ${1}"
  118. ]
  119. },
  120. }