Coder Social home page Coder Social logo

company-sourcekit's People

Contributors

basil-conto avatar galeo avatar jojojames avatar nathankot avatar syohex avatar terhechte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

company-sourcekit's Issues

xcodebuild

[sourcekit] process message: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance[sourcekit] process message: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

how can i fix this? bros.

Serious perfomance problem

Sorry,

but how could I achieve the code completion speed the gif demo showed? It is so slow as to be pretty much unusable.

The sourcekit-output-buffer has been kept on filling with too much JSON output (tens of thousands of lines), the completion work is endured endless waiting.

Getting same completions with different prefixes

Getting same offsets (and same completions) while adding extra characters to the prefix.

Added a dropbox video.

https://dl.dropboxusercontent.com/u/11400324/Untitled.mov

import UIKit

class SentBottlesController: UIViewController {

override func loadView() {
    self.view = SentBottlesView.init()
    self.[view] <-- every letter in view returns the same completions (incorrect candidates)
}

override func viewDidLoad() {
    super.viewDidLoad()
    self.title = "Sent"
}

}

Project-specific completion

Will need to derive and send the correct flags to sourcekitten. It's best that this happens automatically simply by inspecting the .xcodeproj or .xcworkspace.

Here is what XCode sends to sourcekit when doing completion in a project:

I don't think everything is required but we should try to emulate the important bits:

  key.compilerargs: [
    "-module-name",
    "Rumuki",
    "-O",
    "-DAPI_NATHAN",
    "-DDEBUG",
    "-sdk",
    "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk",
    "-target",
    "x86_64-apple-ios8.0",
    "-g",
    "-module-cache-path",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/ModuleCache",
    "-Xfrontend",
    "-serialize-debugging-options",
    "-I",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Products/Nathan-iphonesimulator",
    "-F",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Products/Nathan-iphonesimulator",
    "-F",
    "/Users/nathan/Development/Apps/rumuki/ios/Carthage/Build/iOS",
    "-c",
    "-j4",
    "/Users/nathan/Development/Apps/rumuki/ios/Rumuki/Cryptography/CryptHelpers.swift",
    "/Users/nathan/Development/Apps/rumuki/ios/Rumuki/HTTP/Api.swift",
    "/Users/nathan/Development/Apps/rumuki/ios/Rumuki/UserInterface/Components/RecordingListEmptyBackgroundComponent.swift",
    "/Users/nathan/Development/Apps/rumuki/ios/Rumuki/AudioVideo/Library/AVCNALHelpers.swift",
   "/* ... long list of source files */",
    "-emit-module",
    "-emit-module-path",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/Objects-normal/x86_64/Rumuki.swiftmodule",
    "-Xcc",
    "-I/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/swift-overrides.hmap",
    "-Xcc",
    "-iquote",
    "-Xcc",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/Rumuki-generated-files.hmap",
    "-Xcc",
    "-I/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/Rumuki-own-target-headers.hmap",
    "-Xcc",
    "-I/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/Rumuki-all-non-framework-target-headers.hmap",
    "-Xcc",
    "-ivfsoverlay",
    "-Xcc",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/all-product-headers.yaml",
    "-Xcc",
    "-iquote",
    "-Xcc",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/Rumuki-project-headers.hmap",
    "-Xcc",
    "-I/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Products/Nathan-iphonesimulator/include",
    "-Xcc",
    "-I/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/DerivedSources/x86_64",
    "-Xcc",
    "-I/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/DerivedSources",
    "-Xcc",
    "-DDEBUG=1",
    "-Xcc",
    "-DDEBUG=1",
    "-emit-objc-header",
    "-emit-objc-header-path",
    "/Users/nathan/Library/Developer/Xcode/DerivedData/Rumuki-famrqdkrtmqhvkawkbxggtwiipsp/Build/Intermediates/Rumuki.build/Nathan-iphonesimulator/Rumuki.build/Objects-normal/x86_64/Rumuki-Swift.h",
    "-import-objc-header",
    "/Users/nathan/Development/Apps/rumuki/ios/Rumuki/BridgingHeader.h",
    "-Xcc",
    "-working-directory/Users/nathan/Development/Apps/rumuki/ios"
  ]

[Request] - Step by step on how to make this work

Hey guys.
I'm supper new to emacs and I don't know how to make this package work.
I've installed SourceKitten, SourceKittenDaemon and the company-sourcekit package, but I don't know to to make it work.

Is there any possibility to provide a step by step o how to configure it properly?
I would really appreciate that because I really would like to use emacs as an iOS development IDE.

Thanks.

Completing middle of word

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
   NSOBjec
    return true
}

Typing NSObject doesn't trigger completion until NSObject<---

Anything before NSObjec <-- won't show completion but will show that there was a file written too.

Question: How to make company-sourcekit turn on automatically?

Company mode not being automatically enable company-sourcekitten, instead it turn on some kind of "general" mode, when it's trying to complete me based not on sourcekitten.

When I type a few chars, I got:

And only when I run company-sourcekit, the real completion is showing up:

Could you please point me at what I am doing wrong?

How to setup with other backends?

I havent successfully configured company-sourcekit to work with other backends. It will always swallow their result. If I set company-sourcekit at the end of my list it wont start.

Any example how to get this working with either :separate or :with
https://company-mode.github.io/manual/Backends.html

I want to use company-keywords, company-debbrev-code company-tabnine and company-sourcekit.

Inspect symbol's type

Is it possible to implement inspecting symbol's type just like we do in Xcode with โŒฅ-click ?

Why not silent the message when writing to the tmp file?

Hi, @nathankot

I've seen the latest two commits (6c0c783 and 0c3ccf9) by you trying to silent the writing message and then reverted. Maybe the code (write-region (point-min) (point-max) tmpfile 'silent) in 6c0c783 was wrong:

The arguments for write-region:

(write-region START END FILENAME &optional APPEND VISIT LOCKNAME MUSTBENEW)

The optional fourth argument APPEND should be set to nil. The right code should be:
(write-region (point-min) (point-max) tmpfile nil 'silent) .

Could we turn off the writing message which is really annoying?

Thanks and happy new year :)

Can't complete in workspace

I import ZipZap in my workspace
If i type
entry.
can't complete.

import Foundation
import ZipZap

let filename = "test.zip"
if (FileManager.default.fileExists(atPath: filename)) {

    var url = URL(fileURLWithPath: filename)

    do
    {
        var archive = try ZZArchive(url: url)
        for entry in archive.entries
        {
            let fileName = entry.fileName
            entry. // error here, Can't complete
            print(fileName)
        }
    }
    catch
    {
        debugPrint("Error")
    }
}

Improve the performance and accuracy

I don't know if the development of this package is stopped. The last commit date on master branch was 7 months ago (Jun 5, 2016). Is there a change to improve the performance and accuracy?

There is a NeoVim plugin called Autocomplete-swift, which just uses SourceKitten as its back-end. When I tried to code with company-sourcekit(latest) in emacs(25.1.1) like the gif screenshot in its README, it went to totally mass.

screen shot 2017-01-06 at 10 01 44 pm
As the above picture shows, when type var|, the completion list appeared, then type SPACE, it got completed like this:
screen shot 2017-01-06 at 10 05 54 pm

Going on, type String|,
screen shot 2017-01-06 at 10 06 32 pm
then type SPACE, got this
screen shot 2017-01-06 at 10 06 54 pm

... ...

I use the latest SourceKittenDaemon code compiled with Sourcekitten 0.15.0 and Xcode 8.2 a few days ago.


It seems that SourceKittenDaemon is not actively developed either, will it improve the performance and accuracy by just using SourceKitten as the back-end?

Or could we port Autocomplete-swift into emacs?

Thanks.

Roadmap for working release

@terhechte as per #1, here's a list of things I think need to be done. Feel free to edit at will.

  • Clean up useless -project and -workspace flags, via #3
  • Ensure vanilla completion is working without project support, via #3
  • Ensure completion function is async (currently not), via #3
  • Annotations and type information when displaying candidates, via #3
  • Typing after completion candidates are built should instantly narrow down results, via #5
  • Add project support via --compilerargs, see #4
  • Write readme!
  • Keep XPC running? Might be nice if sourcekitten can run as daemon, see https://github.com/terhechte/SourceKittenDaemon

For project support we can simply check for common cocoapods/carthage framework paths and add them with -F. -sdk and -target detection might be more involving...

compan-sourcekit slow or I am missing something?

Hello, I have set up company-sorcekit and now if I type "CGRect(" after a fraction of second it appears a list of suggestion, as in your demo video.

soft question: is it possible to make that fraction of second smaller? For instance with company I use
(setq company-idle-delay 0.01)
(setq company-dabbrev-downcase 0.01)
in order to cut the time that I have to wait before seeing the suggestions, but this does not seem to affect company-sourcekit.

But the real problem is the following: If I type (inside a method of a class) "self.", the suggestions are showed after 5 seconds! It is an eternity!
This happen also with various other variables.

Is this the default behaviour, is it a known bug or maybe I am not using company-sourcekit correctly?
I would like to cut down that time or to bind a key, for instance S-TAB, to the function that shows the suggestions. In other word I would like that typing "self." (or maybe typing "self." S-TAB) emacs would show me the suggestions immediately.
Is it possible?

Thank you in advance!
Luca.

company-keywoards

We can improve company integration by adding swift keywords:

(eval-after-load 'company-keywords
    '(add-to-list 'company-keywords-alist
                  '(swift-mode "true" "false" "nil" "available" "column" "elseif" "else" "endif" "file" "function" "if" "line" "selector" "associatedtype" "class" "deinit" "enum" "extension" "fileprivate" "func" "import" "init" "inout" "internal" "let" "open" "operator" "private" "protocol" "public" "static" "struct" "subscript" "typealias" "var" "break" "case" "continue" "default" "defer" "do" "else" "fallthrough" "for" "guard" "if" "in" "repeat" "return" "switch" "where" "while" "as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws" "throw" "try" "Protocol" "Type" "and" "assignment" "associativity" "convenience" "didSet" "dynamic" "final" "get" "higherThan" "indirect" "infix" "lazy" "left" "lowerThan" "mutating" "none" "nonmutating" "optional" "override" "postfix" "precedence" "precedencegroup" "prefix" "required" "right" "set" "unowned" "weak" "willSet")))

Surely, will be better to get that list from swift-mode, but currently there's no plain list of keywords there.

Please, prompt the right upstream, where it should be added: here, in company-mode or in swift-mode?

yasnippet compatible?

I have

(setq company-backends
      '(company-files
        company-keywords
        company-capf
        company-yasnippet
        company-abbrev
        company-dabbrev
        company-dabbrev-code))

and

(defun company-sourcekit-init ()
  "Enable sourcekit backend for company."
  (eval-after-load 'company
    '(add-to-list
      (make-local-variable 'company-backends)
      'company-sourcekit)))

(add-hook 'swift-mode-hook 'company-sourcekit-init)

so, company-sourcekit mostly works for now. But company-yasnippet work only when I manually call M-x company-yasnippet. General company-complete or show sourcekit variants only, or do just nothing at all.

Disabling 'Wrote ...'

Wrote /var/folders/k2/y7hdq90906d_5pgbt3_pt9jw0000gn/T/sourcekitten37241uWD [11 times]
Saving file /Users//messagebottle/AppDelegate.swift...
Wrote /Users/
/AppDelegate.swift
Wrote /var/folders/k2/y7hdq90906d_5pgbt3_pt9jw0000gn/T/sourcekitten37241uWD [15 times]
Saving file /Users//AppDelegate.swift...
Wrote /Users/
/AppDelegate.swift
Wrote /var/folders/k2/y7hdq90906d_5pgbt3_pt9jw0000gn/T/sourcekitten37241uWD [18 times]

(setq company-sourcekit-verbose nil)
(setq sourcekit-verbose nil)

are nil.

Seems to be writing to a file after every (single) character is typed.

Completion of symbols in current module

import Foundation

let x = "Hello"

func test(x: String) -> String {
    return x + " World"
}

let y = te // Completion doesn't work

But if we write

let y = Temp.te // Completion works perfectly

where Temp is module name

Offset seems off by 3

I'm hitting an odd error with the offset being off by the beginning of the word. For instance,

import AVFoundation|
                   ^

is reported as

[company-sourcekit] prefix: `AVFoundation`, file: /var/folders/8b/5vz4t2yd5x7116mq280krw4r0000gn/T/sourcekitten56925ebh, offset: 7

It seems that it is subtracting the prefix? I wrote a tiny lisp function to test this:

(defun foo-bar (&optional prefix)
  (interactive)
  (message "FOOBAR: %d" (- (point) (length prefix) (point-min))))

And it reports the position as FOOBAR: 19. This causes problems for things such as:

let r = GCR|
           ^

because this will sent the X-Offset as 29 (as my other issue shows) causing a 400k+ buffer to fill up with JSON.

Should the length of the prefix be added to current offset (or rather not subtracted as is currently)?

Support for documentation

Should be able to access documentation by using company-mode's doc-buffer. sourcekitten complete doesn't actual return documentation information so maybe sourcekitten doc?

No completion in workspaces

Hey,

First of all I really appreciate the work you're doing on this. Would love to be able to use Emacs for all my Swift dev :)

Just had a quick question about compatibility inside workspaces. The autocompletion works for me inside simple projects but as soon as I'm in a project relying on a workspace I get no completion at all, even for built-in types. Just wondering if that's normal or is my configuration broken somewhere?

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.