LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.33k stars 314 forks source link

[Enhancement/Bug] Add global require paths #453

Closed sewbacca closed 3 years ago

sewbacca commented 3 years ago

Describe the bug For some projects i have outsourced documentation to a static location on my disk drive. For autocompletion it works fine, since i can use the Lua.workspace.library config, however, if I try to set a require path in Lua.runtime.path, then it doesn't recognize global paths. /global/path/to/modules/?.lua fails. Maybe this is a bug, since i don't know if Windows users can use global paths with C:\global\path\?.lua.

To Reproduce Steps to reproduce the behavior:

  1. Create a project
  2. Create a modules folder with a module file somewhere else on disk
  3. Add that folder path to Lua.runtime.path
  4. See no autocompletion for require inside the project.

Environment (please complete the following information):

sumneko commented 3 years ago

Currently runtime.path does not support absolute paths, you need to fill in a relative path with library

sewbacca commented 3 years ago

Okay so i misunderstood workspace.library. I added the modules folder to library and used a relative path to Lua.workspace.library in Lua.runtime.path and got my autocompletion. Thank you :)

sumneko commented 3 years ago

I think supports absolute path in runtime.path is necessary. The current usage is very unintuitive.

I will keep this issue open until supporting absolute path in runtime.path.

sewbacca commented 3 years ago

Currently runtime.path does not support absolute paths, you need to fill in a relative path with library

Hopefully you won't remove this feature, since in my case a relative path makes perfectly sense. My environment uses a virtual fs where the relative path to the modules folder is equivalent to the relative path inside my library.

sewbacca commented 3 years ago

I have problems using the global require paths feature. I try to include this file:

$ ls ~/.luarocks/share/lua/5.4/soop/init.lua 
/home/sewbacca/.luarocks/share/lua/5.4/soop/init.lua

Even though those paths are added globally and in the local settings.json, I cannot get autocompletion. Log here