Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

company backend #87

Open
gozes opened this issue Mar 6, 2015 · 5 comments
Open

company backend #87

gozes opened this issue Mar 6, 2015 · 5 comments

Comments

@gozes
Copy link

gozes commented Mar 6, 2015

It be great if lua-mode came with a company backend.

@immerrr
Copy link
Owner

immerrr commented Oct 23, 2015

There's https://github.com/ptrv/company-lua for builtin stuff. As for dynamic completions, I don't think it will come soon.

@immerrr
Copy link
Owner

immerrr commented Oct 23, 2015

That is if you wait it from me :) But, of course, PRs are welcome.

@technomancy
Copy link

I have some code here for loading completions dynamically from a subprocess: http://p.hagelb.org/pnh-lua-completion.el.html It uses Emacs's built-in completion-at-point instead of any 3rd-party completion libs. If you like I could clean it up for inclusion in lua-mode.

There are a few shortcomings; first that it uses a tempfile to communicate candidates back to Emacs. I believe this is the only way since lua-mode only seems to support one-way Emacs->Lua communication, but this is kind of tacky. Secondly it only supports completing from _G; I would like to support completing from the current lexical context, but Lua makes this difficult because loadstring ignores lexical context.

@technomancy
Copy link

I have a new version that works with top-level lexical scope; however the means by which it accomplishes it is somewhat questionable: http://p.hagelb.org/pnh-lua-complete.el.html

Basically it greps the file for "local x = require y" matches and then during the point of calculating the completions, it creates a clone of _G, stuffs each lib that was required into that table under the name of the local. Then it uses this table as a context in which to look up completions.

Anyway, this seems a lot more useful than completing based on _G alone, but I'm not so sure about the way we match against loaded libs using a regex. Thoughts?

@jdtsmith
Copy link

jdtsmith commented May 24, 2019

I've taken technomancy's PR and fixed various issues that made CI testing fail, and made some significant improvements. These include using comint-redirect to avoid writing an external file, traversing the globals tree in a limited breadth-first search, caching completion results for speed, and more. Very usable at this point, including with company mode; see the discussion in the PR's: #147, #148 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants