teal-language / tl

The compiler for Teal, a typed dialect of Lua
MIT License
2.11k stars 108 forks source link

Feature request: Ability to rename the compiled files using regex #763

Closed elMuso closed 1 month ago

elMuso commented 1 month ago

Request

Some custom lua implementations use filetypes other than .lua, like Defold which has it's own .script extension to differenciate a lua module from a lua game script. However both are just lua scripts.

The Teal lsp works wonderfullly on vscode, you just need to associate .script to .lua. However the tl build command only outputs .lua files. A rename parameter should be added to tlconfig that accepts an input regex and output string. And replace the regex input with a string output to allow for custom file extensions.

Now, this is just an idea. In my use case i only needed to add this code to the tl lua binary below the write out function

local function write_out(tlconfig, result, output_file)
   if string.find(output_file,".script.") then
      output_file = string.gsub(output_file,".lua","")
   end

the binary is in C:\Users\{USER}\AppData\Roaming\luarocks\lib\luarocks\rocks-5.4\tl\0.15.3-1\bin

So i'm making this "Feature Request" to start a discussion and at the same time offer a solution for those who can't wait

Feel free to close this

lenscas commented 1 month ago

I think that this is better suited for the cyan project. Considering that this sounds more like a build thing and that cyan will become the build tool.

elMuso commented 1 month ago

Ok