Swift support? #910
-
Hi i couldnt find support for swift. It's this something that is planned or easily added? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Hi! In most cases it should be trivial to add to
If you could tell us the mode and the command to start the language server, it would be trivial to add it. Some language servers are worse than others though, and might need particular support code (e.g. Java). I don't know if Swift is one of them. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I got it working. But it doesnt complete-at-point. Nor does lsp-sourcekit maybe something is wrong with apples lsp server? According to Apple it has a lot of things supported that doesnt work. Like rename https://github.com/apple/sourcekit-lsp There is a command to find lsp-sourcekit on mac. Let me know if I can be of any assistance. |
Beta Was this translation helpful? Give feedback.
-
Did a comparison with VSCode and SDE (Swift Development) and they seem to work the same. Its probably lsp-sourcekit that doesn't work correctly. I don't get completion of inner variables of structs/classes. Only current file. |
Beta Was this translation helpful? Give feedback.
-
I don't follow this discussion closely, but there's seems to be a misunderstanding. lsp-sourcekit requires lsp-mode and not Eglot. However, if the problem turns out to be in Eglot, filling out a proper bug report will greatly help the developers of Eglot to work on the issue. Also, @konrad1977 said he "got it working", but for others to benefit, we need the exact settings of eglot-server-programs. |
Beta Was this translation helpful? Give feedback.
-
I am new to lsp/eglot and emacs in general. But I thought you could got get full syntax-highlighting and code-completion. But maybe that's not the case? I meant that the bugs are in https://github.com/apple/sourcekit-lsp and not in lsp-sourcekit (which is now a part of lsp-mode). This is how I load swift support for eglot. I take no credibility (found it on GitHub)
I don't think you need any options ("--sync") |
Beta Was this translation helpful? Give feedback.
-
There's some unfortunate naming confusion here. If you are using Eglot, you do not need In some cases you might also want to pass some compiler flags. For example, when doing iOS development you might want to pass the iOS SDK. You can see one possible way to do this in my Emacs config. (Please feel free to use/adapt that code if you wish.) As for the completion behavior, Apple's LSP server does not recognize Xcode-based projects. In order to get project-wide completion it is pretty much required to have a Package.swift manifest. The |
Beta Was this translation helpful? Give feedback.
-
Nice explanation . Going to try to convert this into a discussion and mark your post the answer. |
Beta Was this translation helpful? Give feedback.
There's some unfortunate naming confusion here.
sourcekit-lsp
is Apple's implementation of an LSP server, based on its SourceKit tool.lsp-sourcekit
is an Emacs package that plugs the Apple LSP server intolsp-mode
(another Emacs package).If you are using Eglot, you do not need
lsp-sourcekit
. You just need to tell Eglot where thesourcekit-lsp
binary is on your system. That's what your snippet does.In some cases you might also want to pass some compiler flags. For example, when doing iOS development you might want to pass the iOS SDK. You can see one possible way to do this in my Emacs config. (Please feel free to use/adapt that code if you wish.)
As for the completion behavior, Apple's…