emacs-lsp / lsp-sourcekit

lsp-mode :heart: Apple's sourcekit
https://emacs-lsp.github.io/lsp-sourcekit
GNU General Public License v3.0
103 stars 13 forks source link

ask xcrun(1) for the sourcekit-lsp server path #16

Closed slippycheeze closed 3 years ago

slippycheeze commented 3 years ago

Recent XCode ships with the sourcekit-lsp server, but it is a "developer tool" and so not on the normal path.

This updates the logic for discovering the executable to:

  1. use a lsp-dependency to specify the executable, and
  2. try xcrun --find if the executable is not on the path.

This makes the platform-supplied server work for me, and is generally how apple treat these development tools.

Additionally, the server is registered with lsp-mode automatically, through an autoload, so the package will just work™ after installation.

danielmartin commented 3 years ago

Thanks for your contribution!

zzak commented 3 years ago

Hello! @danielmartin @slippycheeze this commit broke my setup so I had to revert it, here is my configuration if that helps:

(add-to-list 'auto-mode-alist '("\\.swift\\'" . swift-mode))

(eval-after-load 'lsp-mode
  (progn
    (require 'lsp-sourcekit)
    (setq lsp-sourcekit-executable "/Library/Developer/CommandLineTools/usr/bin/sourcekit-lsp")))

(defun setup-swift-mode ()
  (interactive)
  (lsp)
  (flycheck-mode +1)
  (flycheck-swift-setup)
  (setq flycheck-check-syntax-automatically '(save mode-enabled)))

(add-hook 'swift-mode-hook #'setup-swift-mode)