vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

luau.in (1570B)


      1 -- vim: set ft=luau sw=2 noet:
      2 
      3 -- START_INDENT
      4 @native
      5 function compute<T>(values: {T}): number
      6 local total: number = 0
      7 for _, value: T in values do
      8 if value then
      9 continue
     10 else
     11 total += 1
     12 end
     13 end
     14 return total
     15 end
     16 
     17 local function typed(
     18 name: string,
     19 count: number
     20 ): boolean
     21 return count > 0
     22 end
     23 
     24 function singletonReturn(): "end"
     25 print("string singleton return")
     26 end
     27 
     28 if ready then -- end in a comment
     29 print("comment closer ignored")
     30 end
     31 
     32 local oneline = function() end
     33 local afterOneline = oneline
     34 
     35 declare function PluginManager(): PluginManager
     36 local afterDeclareFunction = true
     37 
     38 declare function WithArgs(
     39 arg: string
     40 ): boolean
     41 local afterDeclareFunctionArgs = true
     42 
     43 local text = `function(`
     44 local afterText = text
     45 
     46 -- function(
     47 local afterLineComment = text
     48 
     49 class = makeClass()
     50 local afterClassIdentifier = class
     51 
     52 export type Box<T> = {
     53 read value: T,
     54 write name: string,
     55 callback: (T) -> (),
     56 }
     57 
     58 const function makeBox<T>(value: T): Box<T>
     59 return {
     60 value = value,
     61 name = `box {tostring(value)}`,
     62 callback = function(item: T)
     63 print(item)
     64 end,
     65 }
     66 end
     67 
     68 declare extern type Vector with
     69 x: number
     70 y: number
     71 z: number
     72 end
     73 
     74 declare class EnumItem extends Enum
     75 @deprecated
     76 function IsA(self, enumName: string): boolean
     77 Name: string
     78 end
     79 
     80 type function Optionalize(t)
     81 return types.optional(t)
     82 end
     83 
     84 local choice = if 2 == 3 then 4 else 5
     85 local raw = [=[
     86 if true then
     87 ]=]
     88 local afterRaw = choice
     89 
     90 --[=[
     91 function ignored()
     92 ]=]
     93 local afterComment = raw
     94 
     95 class Widget
     96 public Name: string
     97 public function Describe(self): string
     98 return `Widget {self.Name}`
     99 end
    100 end
    101 -- END_INDENT