-
Notifications
You must be signed in to change notification settings - Fork 47
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 with company-mode #5
Comments
You'll need subprocess integration first. The completion part is trivial afterwards. |
Just wanted to mention that I was able to get completions from |
@chrisbarrett You should consider making @ap4y a project collaborator. His work so far has been outstanding! |
Absolutely agreed. @ap4y, you have the power. |
Thanks guys, I'll do my best. :) |
Is it possible to use |
I've been trying to achieve this using sourcekitten which acts as a sane interface to SourceKit. |
looks interesting! Glad that sourcekitten added support for code completion |
I forked @nathankot's code and have a working version of Swift completion in Emacs now. You can try it out here: |
Nice! I'm gonna try it when I get home, I've been dabbling with mine but admittedly haven't gotten anywhere Nathan Kot
|
Looks good, like yasnippet integration. I have a question: does sourcekitten support something like clang compilation database or there is another way of defining args for the compiler? |
I played a bit around with it, and it still has a lot of rough edges. Initializers don't work too well, the return type isn't listed yet, and much more. However, I'm hopeful that most of that can be implemented easily. @ap4y I may be wrong here, but sourcekitten uses the same XPC service (SourceKitD) as Xcode for code completion. However, Xcode has the service running in the background all the time, so I suppose that SourceKitD does internal caching. company-sourcekit currently runs sourcekitten for every completion call. It'd probably be better to keep the XPC service running. Technically that seems to be possible as sourcekitten also provides a framework which can be integrated in an app. Then, one would need to run a daemon that keeps the XPC running and emacs/company-sourcekit could connect to it and do completions. That's probably a lot more work though. |
Things might have changed, but when I played with sourcekit xpc you had to provide compilation args, maybe sourcekitten handles this internally. I think as a first cut non-daemon solution is good enough, but I like daemon idea a lot. I had a bit crazy (for OSX devs) idea of allowing remote calls for such daemon. I like emacs on linux (and tiling vms) a bit more, so I usually run linux VM on macbook or OSX VM on Linux machine, so being able to call some sort of remote api from Linux will help me a lot. |
Since I had to fix a bug in Sourcekitten in order to get this to work, I had a brief look at how it works, and those are the args that are send to the XPC for completion:
Compilerargs look like this: |
Interesting, thanks for the info! |
I got this working too with |
@nicklanasa by parameter completion do you mean parameter placeholders? Because it should already work if you have yasnippet installed ;) And you should get type annotations below the mode line, will look into getting some documentation that xcode normally displays available as well |
@nathankot I do have yasnippet installed but no parameter placeholders. How would I go about setting this up? or is there some fancy keyboard macro I'm missing? |
@nathankot I've cloned your fork of |
@nicklanasa yasnippet integration should work automatically by detecting whether or not you have yasnippet installed. To move between parameters you call Hmmm how did you add it to
(add-to-list 'load-path "~/.emacs.d/vendor")
(require 'company-sourcekit) |
@nicklanasa if you |
@nathankot Ok, so I got Here's a screenshot and I've pushed my emacs config to my repo: https://github.com/nicklanasa/emacs/blob/master/init.el#L116 Thanks for your help so far! |
So right now company-sourcekit really only supports completion after typing nathankot/company-sourcekit#5 will also involve On Sat, Nov 14, 2015 at 4:06 PM, Nickolas Lanasa [email protected]
|
@nathankot Nothing shows up when I type |
@nicklanasa try checking out master and building from source. I also first installed source kitten via homebrew, but that crashed with a Dylib error |
@terhechte Got it working when I build sourekitten from source on the master branch. Thanks everybody. |
Hey guys just want to announce that @terhechte and I have spent a good amount of time getting emacs to do completion for swift and now it works! Please try out company-sourcekit and let us know how it goes 😁 |
Is it possible to get completion on Linux? |
@nathankot Does it only work for Objective C Classes? Not seeing |
It should do (see screenshot). To debug you can Note however that just like when using xcode there are situations where completion won't work if the file or project you're working on isn't compiling |
@stardiviner The daemon (SourceKittenDaemon) just runs a webserver but currently requires OS X. If you run the SourceKittenDaemon on an OSX machine, you can connect to it from anywhere on your network (Linux, FreeBSD, etc) and get completions. So if OSX is your host, and Linux is your guest, you need to forward the webserver port from OSX into Linux, and then you could get completions. Similarly the other way around (OSX Guest, Linux Host). Although right now, I believe, the SourceKittenDaemon webserver starts by default on "localhost" instead of "0.0.0.0", so I'm unsure whether it will be reachable from outside the machine, but that would be an easy fix. |
@nathankot That works but if I wanted to use |
@terhechte Thanks for your help. |
@nicklanasa We haven't gotten around to supporting workspaces yet. But since workspaces simply link multiple .xcodeproj's together, it should still work as long as you compile all the frameworks/dependencies in the workspace first (correct me if I'm wrong) Let's continue this discussion @ nathankot/company-sourcekit#13 and nathankot/company-sourcekit#12 |
Closing. |
Find a way to get code-completion working with completion-at-point to enable auto-completion using company-mode.
The text was updated successfully, but these errors were encountered: