Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emacs-lsp/lsp-sourcekit
lsp-mode :heart: Apple's sourcekit
https://github.com/emacs-lsp/lsp-sourcekit
apple emacs emacs-lsp language-server-protocol lsp-sourcekit sourcekit sourcekit-lsp swift swift-toolchain
Last synced: 3 days ago
JSON representation
lsp-mode :heart: Apple's sourcekit
- Host: GitHub
- URL: https://github.com/emacs-lsp/lsp-sourcekit
- Owner: emacs-lsp
- License: gpl-3.0
- Created: 2018-11-22T08:14:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-27T22:36:40.000Z (7 months ago)
- Last Synced: 2024-04-13T20:52:28.920Z (7 months ago)
- Topics: apple, emacs, emacs-lsp, language-server-protocol, lsp-sourcekit, sourcekit, sourcekit-lsp, swift, swift-toolchain
- Language: Emacs Lisp
- Homepage: https://emacs-lsp.github.io/lsp-sourcekit
- Size: 2 MB
- Stars: 102
- Watchers: 8
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://github.com/emacs-lsp/lsp-sourcekit/workflows/CI/badge.svg?branch=master)](https://github.com/emacs-lsp/lsp-sourcekit/actions)
[![MELPA](https://melpa.org/packages/lsp-sourcekit-badge.svg)](https://melpa.org/#/lsp-sourcekit)# lsp-sourcekit
lsp-sourcekit is a client for [SourceKit-lsp](https://github.com/apple/sourcekit-lsp), a Swift/C/C++/Objective-C language server created by Apple.
Uses [lsp-mode](https://github.com/emacs-lsp/lsp-mode), but it's also open to be extended with additions outside of the LSP protocol, like semantic highlighting, if the server supports that.
## Screenshot
![alt text](https://github.com/emacs-lsp/lsp-sourcekit/raw/master/images/main_screenshot.png "Screenshot of SourceKit-lsp in Emacs")
## Quickstart
The SourceKit-LSP language server is included by default in Xcode 11.4+, so the simplest way to get started is the following:
- Download and install Xcode 11.4+ from the Mac App Store or from [the Apple developer portal](https://developer.apple.com).
- In Emacs, install `lsp-sourcekit`: `M-x package-install lsp-sourcekit RET`.
- Then you need to configure the package to point to the `sourcekit-lsp` executable:If you use `use-package`:
```elisp
(use-package lsp-sourcekit
:after lsp-mode
:config
(setq lsp-sourcekit-executable "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"))
```If you don't use `use-package`:
```elisp
(eval-after-load 'lsp-mode
(progn
(require 'lsp-sourcekit)
(setq lsp-sourcekit-executable
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp")))
```On macOS, you can get the path to the SourceKit-LSP executable by running `xcrun --find sourcekit-lsp` in Terminal. This also works to populate the path, if your emacs shell is configured correctly:
```elisp
(setq lsp-sourcekit-executable (string-trim (shell-command-to-string "xcrun --find sourcekit-lsp")))
```- Finally, if you want to enable `lsp` automatically whenever you visit a `.swift` file:
```elisp
(use-package swift-mode
:hook (swift-mode . (lambda () (lsp))))
```If you don't use `use-package`:
```elisp
(add-hook 'swift-mode-hook (lambda () (lsp)))
```## Advanced Setup
If you are using a custom Swift toolchain, a toolchain you compiled from source, or simply want to run SourceKit-LSP on a platform different from macOS, the above steps are almost the same, but you may need to set a different value for `lsp-sourcekit-executable`, or set a special environment variable to search for the corresponding toolchain. You can get further details in the [SourceKit-LSP](https://github.com/apple/sourcekit-lsp) repository.