spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

[Feature Request] [Layer] [swift] Add LSP support for swift

Open fiveNinePlusR opened this issue 6 years ago • 21 comments

there is a recent LSP server for the swift language here

It would be nice to have swift support for this.

fiveNinePlusR avatar Nov 15 '18 21:11 fiveNinePlusR

I think you need to ask someone from https://github.com/emacs-lsp to implement a package for swift, after which we can integrate it.

sdwolfz avatar Nov 15 '18 23:11 sdwolfz

alright, reported upstream https://github.com/emacs-lsp/lsp-mode/issues/472

fiveNinePlusR avatar Nov 15 '18 23:11 fiveNinePlusR

As potential work around in the meantime you may be able to investigate using eglot with a custom server command and swift-mode ex.

(add-to-list 'eglot-server-programs
             `(swift-mode . ("sourcekit-lsp" "--args")))

jamartin9 avatar Nov 16 '18 02:11 jamartin9

Thanks for that. i'll see if that works in the meantime.

fiveNinePlusR avatar Nov 16 '18 21:11 fiveNinePlusR

they have something working here: https://github.com/danielmartin/emacs-sourcekit-lsp

not sure what the final plan is for it but it's up and running there.

fiveNinePlusR avatar Nov 21 '18 19:11 fiveNinePlusR

We might be able to use that when it's in MELPA.

sdwolfz avatar Nov 21 '18 21:11 sdwolfz

seems like they are moving it to a different repository and hopefully will be up on melpa shortly.

edit: the link https://github.com/emacs-lsp/lsp-sourcekit

fiveNinePlusR avatar Nov 22 '18 21:11 fiveNinePlusR

Yaay for @yyoncho.

sdwolfz avatar Nov 22 '18 23:11 sdwolfz

I asked @danielmartin to move it under emacs-lsp - https://github.com/emacs-lsp/lsp-mode/issues/472#issuecomment-440949055 . If user @danielmartin agrees I could do that and do the onboarding melpa request.

yyoncho avatar Nov 23 '18 06:11 yyoncho

I just want to note that thanks to @danielmartin there is debugger support for swift in dap-mode. Here it is screenshot: swift

yyoncho avatar Jan 02 '19 19:01 yyoncho

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

github-actions[bot] avatar Feb 28 '20 03:02 github-actions[bot]

Could this be reopened, please? lsp-sourcekit is now available on melpa. (Many thanks to all involved.)

dato avatar Aug 25 '20 08:08 dato

Do we have any updates on this? Trying to get things working by manually configuring but no luck so far. I'm on Linux btw.

johalun avatar Aug 10 '21 18:08 johalun

@johalun what is your issue when you do M-x lsp in swift mode file?

yyoncho avatar Aug 10 '21 18:08 yyoncho

@johalun what is your issue when you do M-x lsp in swift mode file?

Got LSP[Disconnected] in status bar.

Have this in user-config

  (eval-after-load 'lsp-mode
    (progn
     (require 'lsp-sourcekit)
      (setq lsp-sourcekit-executable
            "/home/johalun/swift/swift/usr/bin/sourcekit-lsp")))

  (add-hook 'swift-mode-hook (lambda () (lsp)))

and lsp-sourcekit installed via package-install.

johalun avatar Aug 10 '21 18:08 johalun

I got it working! I think what was missing was load-path to lsp-sourcekit folder.

johalun avatar Aug 10 '21 18:08 johalun

@johalaun would you mind posting all the code you used to get it working? Is you .spacemacs online by any chance? I'm trying to do this right now and having trouble.

adudenamedruby avatar Sep 12 '21 03:09 adudenamedruby

@electricRGB https://emacs-lsp.github.io/lsp-sourcekit/

lebensterben avatar Sep 12 '21 05:09 lebensterben

@electricRGB I installed the emacs part of sourcekit from elpa and added this to user-config. Make sure you use the correct path for your installs.

  (add-to-list 'load-path "/home/johalun/.emacs.d/elpa/27.1/develop/lsp-sourcekit-20210404.1624")

  (eval-after-load 'lsp-mode
    (progn
      (require 'lsp-sourcekit)
      (setq lsp-sourcekit-executable
            "/home/johalun/swift/swift/usr/bin/sourcekit-lsp")))

  (add-hook 'swift-mode-hook (lambda () (lsp)))

johalun avatar Sep 12 '21 16:09 johalun

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

github-actions[bot] avatar Dec 10 '22 05:12 github-actions[bot]

Any updates here? It's been a couple years - maybe things have progressed?

schell avatar Aug 26 '23 21:08 schell