dapetcu21 / atom-autocomplete-lua

Extensible autocomplete+ provider for Lua
35 stars 6 forks source link

Get Project root directory instead of cwd? #16

Closed Nexela closed 6 years ago

Nexela commented 7 years ago

I currently use a setup like this

/main.lua |--Lib/libfile.lua |--Script/scriptfile.lua

In scriptfile.lua if I require("lib/libfile") I don't get the autocompletes from the require. If I do it from main.lua I get them just fine.

My lua_path has ./?.lua

The only way I have found to get them to work correctly is to add a .luacompleterc file in the project root with the hardcoded path to the project.

{
  "luaVersion": "5.2",
  "cwd": "E:/devel/mods/modname"
}

I would like to avoid a.) hardcoing the path and b.) having to use a the .luacompleterc file period if I don't have too

Am I missing something or is this currently not possible?

pablomayobre commented 7 years ago

I second this, Autocomplete-Lua should search for the project directory or a directory where .luacheckrc exists.

This should be doable: https://discuss.atom.io/t/project-folder-path-of-opened-file/24846/14

Note that it needs to check if the file is not unsaved, and if there is actually a project it belongs to. If the file doesn't belong to a project, but is a saved file, the CWD should be the path where the file resides.

dapetcu21 commented 7 years ago

This sounds like a good idea. I'll have time for this project again soon and I'll also make this change.

dapetcu21 commented 6 years ago

Implemented in b6c45dc