reddit / emacs

I finally got full auto-competion in Swift with emacs, here is how:

konrad1977 · 2022-02-08 06:54
**\*Update\*** *This only work for* ***xcodeprojects*** *and* ***not*** *workspaces. Bummer.* \***Update 2\*** Got workspace configured project to work too. In Complete.swift in SourceKittenDaemon comment out `preprocessorFlags` and `-c` argument. (line 139 and 140). So 7-8 weeks of struggling with Swift and Emacs and I got it finally to work. A lot of people seems to have alot of problems with Swift and Emacs, lsp package stop working as soon as Apples LSP returns an error, but Eglot handle this much better but there are problems with LSP. First of all Apple doesnt want you to use LSP for Xcode projects, they officially stated this in their forums. It will not work with XCode projects, only swift packages. But most of us who works professionally uses XCode (.xcodeproj or a workspace). I tried several options but today I tried `company-sourcekit` and after about of one hour of struggeling to get it work it started working. So here is a short guide: *This will only work on macOS. Sourcekitten doesnt fully work on Linux yet.* **Get SourceKittenDaemon** So here is step by step guide: 1. clone and compile [https://github.com/terhechte/SourceKittenDaemon](https://github.com/terhechte/SourceKittenDaemon). Its a swift package so just double click package.swift and let Xcode do its job one final time. Xcode needs to resolve 5-6 depency packages so it will take sometime before you can build. Have patience. 2. Locate the binary in the build folder: Xcode -> Preferences -> Location -> Derived Data. Open the folder and locate "SourceKittenDaemon" (Build/Products/Debug/sourcekittend) 3. Copy it to `/usr/local/bin` 4. Add it to you PATH (dont know if its needed or not) **Emacs/your init.el file.** `(use-package company-sourcekit` `:config (setq company-sourcekit-verbose nil s` `ourcekit-verbose nil` `sourcekit-sourcekittendaemon-executable "/usr/local/bin/sourcekittend")` `(add-to-list 'company-backends 'company-sourcekit))` Turn off **Eglot** and **LSP** if you already have configured them. Launch a terminal/vterm and `cd` to your project. `$ sourcekittend start --port 8081 --project yourproject.xcodeproj` Locate the project in Emacs and enjoy auto-completion that hopefully works. [Full auto-compete on nested types](https://preview.redd.it/1cit0h6l3kg81.png?width=3584&format=png&auto=webp&s=17a34d6a110aa4245b6ade8017ed3147e85da410)
xenodium · 2022-02-15 08:09
Hey, thanks for the write-up. Just saying hello. Nice to know there are more of us out there (writing Swift on our beloved lispy editor). I’ve written the odd Emacs/Swift posts here and there: - https://xenodium.com/previewing-swiftui-layouts-in-emacs-revisited - https://xenodium.com/swift-package-code-coverage/
konrad1977 · 2022-02-17 07:47
Thanks. Have you configured multiple fly checkers for swift? Like SwiftLint and Xcode and swiftx? I don't know how to do that. I tried "Tabnine" yesterday with swift and it works good with swift.
xenodium · 2022-02-17 08:25
I have swiftlint and swift-format https://github.com/xenodium/dotsies/blob/main/emacs/features/fe-swift.el
konrad1977 · 2022-02-17 09:14
But is your swift-format added as checker? It seems to be on save-hook?
xenodium · 2022-02-17 12:00
Correct. Save hook.
mr__paradox · 2022-11-08 11:34
Which theme is used in the screenshot?
konrad1977 · 2022-11-11 06:17
My port of Kanagawa. Its in my repo: [https://github.com/konrad1977/emacs](https://github.com/konrad1977/emacs) ../themes/kanagawa.el
mr__paradox · 2022-11-11 07:48
Do you still use this for iOS dev? I find this very limited and slow at times