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
format_lua("function deepcopy(orig)
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at wrapSafe (node:internal/modules/cjs/loader:1024:16)
at Module._compile (node:internal/modules/cjs/loader:1072:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
@suchipi: thanks for your help. It actually works great with 1.19.1.
I figured out why it wasn't working. I had used "" for quotes instead of backticks. So the loader was spitting out this wrapSafe error:
SyntaxError: Invalid or unexpected token
at wrapSafe (node:internal/modules/cjs/loader:1024:16)
at Module._compile (node:internal/modules/cjs/loader:1072:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
changing the source to backticks works fine:
format_lua(`function deepcopy(orig) local orig_type = type(orig) local copy if orig_type == 'table' then; copy = {} for orig_key, orig_value in next, orig, nil do copy[deepcopy(orig_key)] = deepcopy(orig_value) end setmetatable( copy, deepcopy( getmetatable(orig))) else copy = orig end return copy end`)
Unfortunately, it's not supported with prettier v2.*. running the example, I get:
Activity
suchipi commentedon Jan 25, 2021
try it with prettier 1.x
hoebat commentedon Jan 26, 2021
@suchipi: which version?
I've done a simple example here: https://github.com/zcaudate/tool.prettier-plugin-lua/blob/master/src/main.js
using prettier v1.19.1 gives:
suchipi commentedon Jan 26, 2021
try 1.13.7; it's been a long time since I've worked on this plugin
hoebat commentedon Jan 27, 2021
@suchipi: thanks for your help. It actually works great with 1.19.1.
I figured out why it wasn't working. I had used
""for quotes instead of backticks. So the loader was spitting out thiswrapSafeerror:changing the source to backticks works fine:
Unfortunately, it's not supported with prettier v2.*. running the example, I get:
suchipi commentedon Apr 17, 2023
Thanks to fixes in #17, it should work with prettier 2.x now (you'll need to use @prettier/plugin-lua 0.0.2)