lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

[Question / Feature Request] Disable global variable

Open sewbacca opened this issue 3 years ago • 3 comments

I have a problem when concerning the lpeg library. The re module has a conditional if that defines re globally if and only if the version is Lua 5.1. However since it is global, the automated add require path won't trigger (e.g. on version 5.3). My first idea was to disable the global variable. This doesn't seem possible. Any suggestions?

sewbacca avatar Mar 16 '22 22:03 sewbacca

I just delete this line: https://github.com/sumneko/lua-language-server/blob/20d4be8bc74d6a78372f50112288fb6c4406b841/script/parser/relabel.lua#L351-L361

sumneko avatar Mar 18 '22 08:03 sumneko

I was hoping for a more generalized answer, since I would consider it bad practice to go, e.g. into the luarocks directory (which is how I installed lpeg) and edit stuff there. However if that is the only option, then I will go with that.

sewbacca avatar Mar 19 '22 17:03 sewbacca

Since Lua can implement a sandbox, I can consider adding a setting "Don't load global variables from the following files". Currently, you can preprocessing this file through plugin.

sumneko avatar Mar 21 '22 09:03 sumneko