Skip to content

Commit aabf57a

Browse files
committed
Import SourceKit-LSP sources
0 parents  commit aabf57a

File tree

104 files changed

+14081
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+14081
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
default.profraw
3+
Package.resolved
4+
/.build
5+
/Packages
6+
/*.xcodeproj
7+
/*.sublime-project
8+
/*.sublime-workspace

CODEOWNERS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file is a list of the people responsible for ensuring that patches for a
2+
# particular part of SourceKit-LSP are reviewed, either by themselves or by
3+
# someone else. They are also the gatekeepers for their part of Swift, with the
4+
# final word on what goes in or not.
5+
6+
# Lines starting with '#' are comments.
7+
# Each line is a file pattern followed by one or more owners.
8+
# Order is important. The last matching pattern has the most precedence.
9+
10+
# Owner of anything in SourceKit-LSP not owned by anyone else.
11+
# N: Ben Langmuir
12+
13+
* @benlangmuir

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
By submitting a pull request, you represent that you have the right to license
2+
your contribution to Apple and the community, and agree by submitting the patch
3+
that your contributions are licensed under the [Swift
4+
license](https://swift.org/LICENSE.txt).
5+
6+
---
7+
8+
Before submitting the pull request, please make sure you have [tested your
9+
changes](https://github.com/apple/swift/blob/master/docs/ContinuousIntegration.md)
10+
and that they follow the Swift project [guidelines for contributing
11+
code](https://swift.org/contributing/#contributing-code).

Editors/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Editor Integration
2+
3+
This document contains information about how to configure an editor to use SourceKit-LSP. If your editor is not listed below, but it supports the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) (LSP), see [Other Editors](#other-editors).
4+
5+
## Visual Studio Code
6+
7+
To use SourceKit-LSP with Visual Studio Code, you will need the [SourceKit-LSP
8+
Visual Studio Code extension](vscode). Documentation for [Building and Installing](vscode/README.md#building-and-installing-the-extension) is in the extension's README. There is also information about [Configuration](vscode/README.md#configuration). The most common settings are listed below.
9+
10+
After installing the extension, settings for SourceKit-LSP can be found in `Preferences > Settings` under
11+
`Extensions > SourceKit-LSP` or by searching for the setting prefix
12+
`sourcekit-lsp.`.
13+
14+
* `sourcekit-lsp.serverPath`: The path to sourcekit-lsp executable
15+
* `sourcekit-lsp.toolchainPath`: The path to the swift toolchain (sets `SOURCEKIT_TOOLCHAIN_PATH`)
16+
17+
## Sublime Text
18+
19+
Before using SourceKit-LSP with Sublime Text, you will need to install the LSP package from Package Control. To configure SourceKit-LSP, open the LSP package's settings. The following snippet should be enough to get started with Swift.
20+
21+
You will need the path to the `sourcekit-lsp` executable and the Swift toolchain for the "command" and "env" sections.
22+
23+
```json
24+
{
25+
"clients":
26+
{
27+
"SourceKit-LSP":
28+
{
29+
"enabled": true,
30+
"command": [
31+
"<path to sourcekit-lsp>"
32+
],
33+
"env": {
34+
"SOURCEKIT_TOOLCHAIN_PATH": "<path to toolchain>",
35+
},
36+
"languages": [
37+
{
38+
"scopes": ["source.swift"],
39+
"syntaxes": [
40+
"Packages/Swift/Syntaxes/Swift.tmLanguage",
41+
],
42+
"languageId": "swift"
43+
},
44+
{
45+
"scopes": ["source.c"],
46+
"syntaxes": ["Packages/C++/C.sublime-syntax"],
47+
"languageId": "c"
48+
},
49+
{
50+
"scopes": ["source.c++"],
51+
"syntaxes": ["Packages/C++/C++.sublime-syntax"],
52+
"languageId": "cpp"
53+
},
54+
{
55+
"scopes": ["source.objc"],
56+
"syntaxes": ["Packages/Objective-C/Objective-C.sublime-syntax"],
57+
"languageId": "objective-c"
58+
},
59+
{
60+
"scopes": ["source.objc++"],
61+
"syntaxes": ["Packages/Objective-C/Objective-C++.sublime-syntax"],
62+
"languageId": "objective-cpp"
63+
},
64+
]
65+
}
66+
}
67+
}
68+
```
69+
70+
## Other Editors
71+
72+
SourceKit-LSP should work with any editor that supports the Language Server Protocol](https://microsoft.github.io/language-server-protocol/)
73+
(LSP). Each editor has its own mechanism for configuring an LSP server, so consult your editor's
74+
documentation for the specifics. In general, you can configure your editor to use SourceKit-LSP for
75+
Swift, C, C++, Objective-C and Objective-C++ files; the editor will need to be configured to find
76+
the `sourcekit-lsp` executable (see the top-level [README](https://github.com/apple/sourcekit-lsp) for build instructions), which
77+
expects to communicate with the editor over `stdin` and `stdout`.

Editors/vscode/.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Set default behavior to automatically normalize line endings.
2+
* text=auto
3+

Editors/vscode/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
out
2+
node_modules
3+
.vscode-test/
4+
*.vsix

Editors/vscode/.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"runtimeExecutable": "${execPath}",
13+
"args": [
14+
"--extensionDevelopmentPath=${workspaceFolder}"
15+
],
16+
"outFiles": [
17+
"${workspaceFolder}/out/**/*.js"
18+
],
19+
"preLaunchTask": "npm: watch"
20+
},
21+
{
22+
"name": "Extension Tests",
23+
"type": "extensionHost",
24+
"request": "launch",
25+
"runtimeExecutable": "${execPath}",
26+
"args": [
27+
"--extensionDevelopmentPath=${workspaceFolder}",
28+
"--extensionTestsPath=${workspaceFolder}/out/test"
29+
],
30+
"outFiles": [
31+
"${workspaceFolder}/out/test/**/*.js"
32+
],
33+
"preLaunchTask": "npm: watch"
34+
}
35+
]
36+
}

Editors/vscode/.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": false // set this to true to hide the "out" folder with the compiled JS files
5+
},
6+
"search.exclude": {
7+
"out": true // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off"
11+
}

Editors/vscode/.vscode/tasks.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
}
19+
]
20+
}

Editors/vscode/.vscodeignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.vscode/**
2+
.vscode-test/**
3+
out/test/**
4+
out/**/*.map
5+
src/**
6+
.gitignore
7+
tsconfig.json
8+
vsc-extension-quickstart.md
9+
tslint.json

Editors/vscode/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SourceKit-LSP for Visual Studio Code
2+
3+
This extension adds support to Visual Studio Code for using SourceKit-LSP, a
4+
language server for Swift and C/C++/Objective-C languages.
5+
6+
**Note**: SourceKit-LSP is under heavy development and this should be considered
7+
a preview. Users will need to separately provide the `sourcekit-lsp` executable
8+
as well as a Swift toolchain.
9+
10+
## Building and Installing the Extension
11+
12+
Currently, the way to get the extension is to build and install it from source.
13+
You will also need the `sourcekit-lsp` language server executable and a Swift
14+
toolchain. For more information about sourcekit-lsp, see [here](https://github.com/apple/sourcekit-lsp).
15+
16+
**Prerequisite**: To build the extension, you will need Node.js and npm: https://www.npmjs.com/get-npm.
17+
18+
The following commands build the extension and creates a `.vsix` package in the `out` directory.
19+
20+
```
21+
$ cd Editors/vscode
22+
$ npm run createDevPackage
23+
```
24+
25+
You can install the package from the command-line if you have the `code` executable on your `PATH`:
26+
27+
```
28+
code --install-extension out/sourcekit-lsp-vscode-dev.vsix
29+
```
30+
31+
Or you can install from within the application using the `Extensions > Install from VSIX...` command from the command palette.
32+
33+
### Developing the Extension in Visual Studio Code
34+
35+
As an alternative, you can open the extension directory from Visual Studio Code and build it from within the application.
36+
37+
1. Run `npm install` inside the extension directory to install dependencies.
38+
2. Open the extension directory in Visual Studio Code.
39+
3. Hit `F5` to build the extension and launch an editor window that uses it.
40+
41+
This will start debugging a special instance of Visual Studio Code that will have "[Extension Development Host]" in the window title and use the new extension.
42+
43+
There is extensive documentation for developing extensions from within Visual Studio Code at https://code.visualstudio.com/docs/extensions/overview.
44+
45+
## Configuration
46+
47+
Settings for SourceKit-LSP can be found in `Preferences > Settings` under
48+
`Extensions > SourceKit-LSP` or by searching for the setting prefix
49+
`sourcekit-lsp.`.
50+
51+
* Server Path: The path of the sourcekit-lsp executable
52+
* Toolchain Path: The path of the swift toolchain (sets `SOURCEKIT_TOOLCHAIN_PATH`)
53+
54+
The extension will find the `sourcekit-lsp` executable automatically if it is in
55+
`PATH`, or it can be provided manually using this setting.

0 commit comments

Comments
 (0)