onivim / oni2

Native, lightweight modal code editor
https://v2.onivim.io
MIT License
7.83k stars 282 forks source link

Swift Language Extension Support #3434

Open PierreCapo opened 3 years ago

PierreCapo commented 3 years ago

Hello, I have tried to use Onivim 2 for developing stuff in Swift. The Swift integration on VSCode is already not an easy path. Need to follow :

At the end I'm able to make it work more or less. However on Onivim 2, this process doesn't work. I think the extension for VSCode mentioned in the link doesn't work on Onivim. Do you know if there is something planned to work on Swift support on Onivim 2?

It shouldn't be too urgent because most developers are using XCode for Swift development, but at some point since Swift is one of the most popular language, it would be cool to support it. By the way, congratulations for all the nice work and improvements, Onivim 2 looks better every day 👏

bryphe commented 3 years ago

Hi @PierreCapo ,

Thanks for logging the issue and testing this extension out!

However on Onivim 2, this process doesn't work.

Interesting - did you see an error message or just nothing happened when you opened a Swift file?

I tried out the steps, and the extension was at least giving me some basic language services:

2021-04-23 14 32 24

(I did see a couple of issues with diagnostics - they would show in the pane, but not in the UI, and some snippets provided by completion were failing to expand - looking into those separately)

In my setup, I did the following:

1) Installed the extension: - I followed the instructions here - https://github.com/apple/sourcekit-lsp/tree/main/Editors/vscode#building-and-installing-the-extension - except I used oni2 --install-extension /Users/bryphe/sourcekit-lsp/Editors/vscode/out/sourcekit-lsp-vscode-dev.vsix

If that's successful - we should at least see SourceKit-LSP in the extensions pane: image

2) Set the sourcekit-lsp.serverPath setting: - I used xcrun toolchain --find sourcekit-lsp to get the executable:

➜  hello-swift xcrun --toolchain swift --find sourcekit-lsp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp

And then, in Onivim's configuration, I set the sourcekit-lsp.serverPath setting:

  "sourcekit-lsp.serverPath":
    "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"

3) Finally, with that all set up, I started Onivim in a swift project directory (that was already initialized, built - I used swift package init --type=executable to create a fresh project, and also tried it out in sourcekit-lsp - both seemed to give me language services).

Let me know if these steps don't work for you -

It shouldn't be too urgent because most developers are using XCode for Swift development, but at some point since Swift is one of the most popular language, it would be cool to support it.

For sure! Ultimately my goal is to be compatible with VSCode extensions - so Onivim should be compatible with the VSCode sourcekit-lsp plugin

By the way, congratulations for all the nice work and improvements, Onivim 2 looks better every day 👏

Thanks, really appreciate it 😄