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

Allow for IJulia auto-completion #38

Open
cbecker opened this issue Mar 1, 2014 · 12 comments
Open

Allow for IJulia auto-completion #38

cbecker opened this issue Mar 1, 2014 · 12 comments

Comments

@cbecker
Copy link
Contributor

cbecker commented Mar 1, 2014

(Apologies if this is already implemented but I just cannot find the way to trigger it)
Is it possible to have auto-completion working within Sublime-IJulia, like plain IJulia or julia repl? This is extremely useful in many cases when debugging or trying to find functions/symbols. More specifically, I mean for example to type

str + <equivalent to tab> and get

julia> str
strchr      stringmime  string      strides     stride      strftime    strerror    strwidth    strip       strptime

I know there is base function auto-completion from sublime, but I wonder if something can be done to support the 'intrinsic' auto-completion of IJulia.

@quinnj
Copy link
Owner

quinnj commented Mar 2, 2014

Definitely possible, I just don't have time to really get around to it. To me, doing a quick parsing of the standard library was fairly painless and didn't involve any dealing with the kernel, plus the fact that you get the auto-completion in julia source files instead of just the console (though now that I think about it, there's not really a reason you couldn't set it up to work in julia source as well).

@cbecker
Copy link
Contributor Author

cbecker commented Mar 2, 2014

Thanks. I managed to get it to work, after reading the ipython docs.
Before filing a pull request, a question: Kernel.queue is the command queue, so I guess that we need to add another queue for auto-completion requests, does this make sense? Right now I can call self.complete(code), in the same way as one does to execute code with self.execute(code).

@cbecker
Copy link
Contributor Author

cbecker commented Mar 2, 2014

Also, I wonder how to keep track of auto-completion, especially when in the middle of a command, for example if the cursor is in the middle of the code written in the sublime window, so that if the user accepts the completion, it should be updated properly.

This would require keeping track of the input and updating it properly, and also some what to know where the cursor is at when the auto-complete command is called.

@quinnj
Copy link
Owner

quinnj commented Mar 3, 2014

I'd have to look at your code to help further, so a PR may be best at this point. How are you planning on displaying the auto-completion list? Are you using a similar facility to Sublime's own autocompletion?

@cbecker
Copy link
Contributor Author

cbecker commented Mar 7, 2014

I am not sure how to display the auto-completion list. For now it could be just showing the possible completions, returned by IJulia.

You can check my test here https://github.com/cbecker/Sublime-IJulia/tree/autocompletiontest
Basically it will display the auto-completion list when the string to be run contains str.
See my comments at cbecker@9bc99e9

I am not sure how to merge everything together, seems like the best solution requires quite a bit of coding to integrate it properly in sublime

@quinnj
Copy link
Owner

quinnj commented Aug 30, 2014

Working on this now. @one-more-minute, how do you do auto-completion in LightTable? I notice in particular that you are able to do completions for packages. Is that all through the Base REPLCompletions machinery, or do you have your own magic you're using?

@MikeInnes
Copy link

Take a look at Jewel.jl's completions.jl, all the logic is in there. I've tried not to make it too Light Table specific, so you should be able to call allcompletions with the code and a cursor position, feed the resulting data back to Sublime and have it work without too much hassle. I'm happy to work with you if changes are needed, though – just let me know if you want any more info.

@quinnj
Copy link
Owner

quinnj commented Aug 30, 2014

I'm not sure I understand the inputs to allcompletions. Do I want to pass in the entire file text as code and the cursor position as cursor? Seems like that might be prohibitive for large files? Or am I missing something?

@MikeInnes
Copy link

That's right, the idea is to pick up on the right context. You can only determine what module the user is in by parsing the whole file.

allcompletions returns a regex for pulling out the current token alongside the relevant hints. That way the frontend can react to input on its own without having to update the hints on every keypress. It definitely could be more efficient, but in practice it works quite well already.

OTOH if you're not worried about supporting modules other than Main, you could always just pass a single line in, e.g.

Jewel.allcompletions("  Pkg.", LNR.cursor(1, 7))

@quinnj
Copy link
Owner

quinnj commented Aug 30, 2014

Ah, I see. So if I pass the whole file, then the module parsing is done in the completions.jl code?

@MikeInnes
Copy link

Currently this call actually does the parsing, but really allcompletions should call that itself, that's just an oversight on my part. (So in principle, yes.)

@malmaud
Copy link

malmaud commented Jul 17, 2015

Any activity on this?

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

No branches or pull requests

4 participants