-
Notifications
You must be signed in to change notification settings - Fork 75
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
Completion: Fixed #147
Completion: Fixed #147
Conversation
Completion on an expression at the beginning of a buffer now works.
This allows it to work in the *lua-repl* buffer.
Helps it work with certain less-intelligent repls.
…input. Good grief, `last' returns a list, not a list element?
Great stuff. Travis still fails for some reason, do you know why? I'll try to have a closer look at the changes over the weekend. |
I am now "debugging" Travis on a separate branch, since all buttercup tests succeed on my machine. It is almost certainly due to the need for asynchronous process communication (i.e. "wait for the prompt before doing anything else"), which right now is not being implemented. That leads to platform/machine/lua-version/test-specific brokenness. Sigh. I'll probably have to bite the bullet and implement a simple |
I am not a big fan of dropping compatibility unnecessarily, as I myself had quite a bit of pain resolving dependencies for some packages while living on few-years-old Ubuntu LTS releases. But seeing that Debian Stable/Ubuntu 14.04 both have emacs=24.5, I guess dropping 24.3 and older should probably be fine. |
Hmm, I'm seeing the same error when trying to run the tests locally, let me have a closer look... |
Welp, so much for the debugging opportunity. Now the tests are working, and I didn't even do anything 🤷♂️ |
Yeah it's all related to the fact that the completion framework has no asynchronous mode or callback, so we always need to block and check for the prompt before proceeding. Sometimes you get lucky timing-wise, other times not. Spent way too much time digging into this this week. I have substantially rewritten much of the completion code to avoid the use an external file, using |
I am not entirely sure it's related to timing, could be some sort of misconfiguration. I wonder if the tests could be improved by checking the output of Let me try that... |
I wouldn't suggest putting too much effort into the current version on this branch as I've made some substantial changes and don't want to have conflicts. In fact let me just organize and commit my current changes so you can play as well. |
That sounds very simple and easy to implement. I agree a future PR might be the right place for this simple change. |
If you want to check that the require library scanning works without a process that's fine, but all the |
Per-lua-buffer unique is what I mean. When setting to buffer-local variables, it wasn't enough to just |
Agreed. I actually implemented a draft version of "return the list of everything below here", in e.g. That would require writing our own version of a
Sounds good. Take a closer look and ideally play with completion in your own environment. The commit tree on this PR branch got a bit trampled by having to retool to sort out CI issues, so I agree we probably shouldn't expose all that to master. I suppose PR branches get kept around for posterity, in case anyone wants to recreate the two-steps-forward-one-step-back progress? |
One other small improvement I should probably port onto this version. Some embedded Lua's don't implement |
I do like this. I felt like coordinating all the relevant variables which are process-centric with
Good points. I'd definitely be annoyed to have per-buffer processes by default, so I don't think that's a good option. But I see your point; in a separate commit, I changed Have a look. |
with smth like
|
Agreed, the buffers should be shared by default by the normal sharing of global variables between buffers. If we come across a more sophisticated inferior process sharing that makes the variable buffer local and then sets the buffer-local values applying some domain knowledge to figure out which processes must be kept separate, but the default behaviour should be to share anyway.
Looks good, but probably a better fit would be the |
That's effectively what I'm doing, but using buffer name to disambiguate. Maybe that's not the right choice, if we want something like "these 3 buffers share one lua process, the rest share another" or similar, i.e. for these process managers you allude to. One more issue: if you re-call |
Right. Though it does seem that these process sharing managers will need a way to affect the process buffer names.
I see, so they are always buffer-local. OK, you convinced me. See the latest commit. I removed the local variable setup code entirely, favoring One way to "manage" process buffer-locality would then be to add a file local variable, ala: --*- lua-process-buffer: nil -*- This isn't as grok'able as --*- lua-process-buffer-is-buffer-local: t -*- But it works. And if we accept any pre-set --*- lua-process-buffer: "*lua*<MyProject>" -*- constituting a poor-man's form of process management. |
Alright, I think I'm converging on a stable PR here. I made a number of small changes in the last commit batch. I try to avoid gratuitous Also, I did go ahead and switch to I am considering whether to put effort into making completion work in the shell here, or in a later PR. It's a trivial addition, but the biggest issue is the process buffer doesn't know its own name. I could make the process buffer know |
Not sure if you are still digging around in this PR. I have another branch which picks up on this work and implements some new functionality, but didn't want to distract you if you were in the midst of review: see my branch completion-with-cache. In my new branch (which just builds on this PR branch), I've implemented completion as a queue-based breadth-first search of the lua global tree, returning all possible completions below the point, independent of depth. So e.g. This required fully rewriting the lua code My testing showed that the completion framework calls back 6 or more times per completion action. Originally, each and every time, we'd hit lua up for the same completion list. So I also implemented a custom This replaces I'm pretty well done modulo any issues you spot (I'm going to leave the shell alone for now). Options for this:
I favor option 1, since the new branch is just far more usable, never bogs down with company mode, etc. Let me know how you want to proceed. PS: One other oddity I found that explains much of the failing-travis stuff: in clean interactive emacs sessions (like |
To make it simpler for you to review, I condensed history into many fewer commits and opened a new PR: #148. That PR supersedes this one. If you agree, feel free to close this one. |
I fixed the issues with PR #119:
require
tests didn't have the library name correct, and in any caseLUA_PATH
needed to be set sorequire
could find the library to begin with.So e.g.:
couldn't correctly complete.
I also switched
sed
toperl
in the Makefile sincesed
command switches aren't portable.Longer term, switching to
comint-simple-send
withcomint-preoutput-filter-functions
to hide the back channel completion communication with the lua process would be preferable to the current temp file write/read. That's pretty easy to implement so I may have a go at that.It also seems very inefficient to clone the full nested
_G
var each and every time completion occurs. Probably better to serialize the full completion tree into Elisp as needed, and then provide a user command to update it on demand. That said, performance was fine for me (using a small embedded Lua inside of Hammerspoon). Large package sets and more active completes likecompany-mode
could start to impact performance.Recognizing a few more cases of library load, and local aliasing, e.g.:
would also be useful.